mapType.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <uni-popup ref="mapTypePopupRef" type="bottom" border-radius="10px 10px 0 0">
  3. <div class="city-box">
  4. <div class="city-picker-btn">
  5. <text @click.stop="cancel()">取消</text>
  6. <text @click.stop="confirm()">确定</text>
  7. </div>
  8. <picker-view indicator-class="indicator-class" :value="value||[]" class="picker-view" @change="bindChange">
  9. <picker-view-column>
  10. <view class="item" v-for="(item,index) in mapTypeList" :key="index">{{item.typeName}}</view>
  11. </picker-view-column>
  12. </picker-view>
  13. </div>
  14. </uni-popup>
  15. </template>
  16. <script>
  17. import { getMaptypeList_Api } from "@/api/map.js";
  18. export default {
  19. name: "mapType",
  20. props: {
  21. mapTypeId: {
  22. type: String,
  23. default: null
  24. }
  25. },
  26. data() {
  27. return {
  28. value: [],
  29. defaultVal:[{
  30. mapTypeId:undefined,
  31. typeName:'全部'
  32. }],
  33. mapTypeList: []
  34. }
  35. },
  36. watch: {
  37. },
  38. created() {
  39. this.init()
  40. },
  41. mounted() {
  42. },
  43. methods: {
  44. init() {
  45. const parms = { typeStatus: 'ENABLE' }
  46. getMaptypeList_Api(parms).then(res => {
  47. this.mapTypeList = this.defaultVal.concat(res || []);
  48. })
  49. },
  50. open() {
  51. this.$refs.mapTypePopupRef.open()
  52. },
  53. bindChange(val) {
  54. const { value } = val.detail;
  55. this.value = value || [0]
  56. },
  57. confirm() {
  58. const in_ = this.value[0] || 0;
  59. const item = this.mapTypeList[in_];
  60. this.$emit("update:mapTypeId", item.mapTypeId);
  61. this.$emit("typeName", item.typeName);
  62. this.cancel();
  63. },
  64. cancel() {
  65. this.$refs.mapTypePopupRef.close()
  66. }
  67. }
  68. }
  69. </script>
  70. <style lang="scss" scoped>
  71. .uni-popup {
  72. z-index: 1002;
  73. .city-box {
  74. height: 55vh;
  75. background-color: #fff;
  76. border-radius: 30rpx 30rpx 0 0;
  77. .city-picker-btn {
  78. height: 100rpx;
  79. display: flex;
  80. justify-content: space-between;
  81. align-items: center;
  82. padding: 0 30rpx;
  83. }
  84. .picker-view {
  85. height: calc(100% - 100rpx);
  86. text-align: center;
  87. }
  88. }
  89. }
  90. /deep/ .indicator-class {
  91. height: 100rpx;
  92. }
  93. /deep/ .uni-picker-view-content {
  94. .item {
  95. text-align: center;
  96. line-height: 100rpx;
  97. }
  98. }
  99. </style>