mapType.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <uni-popup class="picker-popup" ref="mapTypePopupRef" type="bottom" border-radius="10px 10px 0 0">
  3. <div class="picker-content">
  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. </style>