Lou
2023-11-08 13cee53e7b48f4edb3dfdd0d19f0927a34b07082
subPackage/workbench/views/cscj.vue
@@ -1,666 +1,706 @@
<template>
   <view class="container">
      <u-form labelWidth="70" :model="form" :rules="rules" ref="form">
         <view class="box-title">
            <box-title title="基础信息"></box-title>
         </view>
         <view class="item">
            <u-form-item @click="showPicker = true" class="form-item" labelWidth="100" label="楼栋:"
            :required="isRequired" :disabled="isDisabled"
               prop="buildingCode">
               <u--input border="none" disabledColor="#ffffff" v-model="form.building" placeholder="请选择">
               </u--input>
               <u-icon slot="right" name="arrow-right"></u-icon>
            </u-form-item>
            <u-form-item class="form-item" labelWidth="100" label="场所名称:"
             :required="isRequiredPlace" :disabled="isDisabled" prop="placeName">
               <u--input border="none" v-model="form.placeName" placeholder="请输入">
               </u--input>
            </u-form-item>
            <u-form-item @click="popup" class="form-item" labelWidth="100" label="标签:"
            :required="isRequired" :disabled="isDisabled" prop="label">
               <u--input border="none" disabled disabledColor="#ffffff" placeholder="请选择">
               </u--input>
               <u-icon slot="right" name="arrow-right"></u-icon>
            </u-form-item>
            <view v-if="showLabelList.length>0" class="label">
               <view v-for="(item,index) in showLabelList" :key="index" class="activeLabel">
                  <u-tag closable :show="!item.isClose" size="mini" @close="delTag(item)"
                     :text="item.text"></u-tag>
               </view>
            </view>
            <u-form-item class="form-item" labelWidth="100" label="备注:" prop="remark">
               <u--input border="none" v-model="form.remark" placeholder="请输入">
               </u--input>
            </u-form-item>
            <u-form-item class="form-item" labelWidth="100" label="经纬度:" prop="location">
               <u--input border="none" disabled disabledColor="#ffffff" v-model="form.jwd" placeholder="请输入">
               </u--input>
            </u-form-item>
         </view>
         <view class="box-title">
            <box-title title="负责人信息"></box-title>
         </view>
         <view class="item">
            <u-form-item class="form-item" labelWidth="100" :required="isRequired" :disabled="isDisabled"
             label="场所负责人:" prop="username">
               <u--input border="none" v-model="form.username" placeholder="请输入">
               </u--input>
            </u-form-item>
            <u-form-item class="form-item" labelWidth="100" :required="isRequired" :disabled="isDisabled"
             label="手机号:" prop="phone">
               <u--input border="none" v-model="form.phone" placeholder="请输入">
               </u--input>
            </u-form-item>
         </view>
         <view class="box-title">
            <box-title title="场所照片"></box-title>
         </view>
         <view class="item pic">
            <u-upload :fileList="form.images" :previewFullImage="uploadConfig.previewFullImage"
               :accept="uploadConfig.acceptImg" :multiple="uploadConfig.multiple" :maxCount="uploadConfig.maxCount"
               :capture="uploadConfig.capture" @afterRead="afterReadImg" @delete="deletePic">
            </u-upload>
         </view>
      </u-form>
      <view class="box-title">
         <box-title title="综治网格">
            <template slot="titleMore">
               <view class="title-more">
                  <view class="red item"></view>
                  <view class="orange item">85.9</view>
                  <view class="green item"></view>
               </view>
            </template>
         </box-title>
      </view>
      <view class="item">
         <lineItem :dataInfo="comprehensiveData.basic">
         </lineItem>
         <lineItem :dataInfo="comprehensiveData.scene">
            <template v-slot:pic="{scope}">
               {{scope.value}}
            </template>
         </lineItem>
      </view>
      <view class="box-title">
         <box-title title="公安网格">
            <template slot="titleMore">
               <view class="title-more">
                  <view class="red item"></view>
                  <view class="orange item">85.9</view>
                  <view class="green item"></view>
               </view>
            </template>
         </box-title>
      </view>
      <view class="item">
         <lineItem :dataInfo="comprehensiveData.basic">
         </lineItem>
         <lineItem :dataInfo="comprehensiveData.scene">
            <template v-slot:pic="{scope}">
               {{scope.value}}
            </template>
         </lineItem>
      </view>
      <view class="bottom">
         <view class="btn">
            <u-button @click="submit" type="primary" text="提交"></u-button>
         </view>
      </view>
      <uni-popup class="citys_win popup_win" ref="uniPopup" type="bottom">
         <wyh-tree-select :items="labelList" title="标签选择" :showNav="true" defaultActiveColor="#4586fe"
            :activeIds="activeIds" @clickItem="labelClick" :showCancel="false" :showConfirm="false">
         </wyh-tree-select>
      </uni-popup>
      <u-picker :show="showPicker" :defaultIndex="defaultIndex" ref="uPicker" keyName="name" :loading="pickerLoading"
         :columns="pickColumns" @change="changeHandler" @confirm="confirmPicker"
         @cancel="showPicker = false"></u-picker>
   </view>
</template>
<script>
   import uploadMixin from "@/mixin/uploadMixin";
   import lineItem from "@/subPackage/workbench/components/lineItem.vue"
   import {
      getLabelList
   } from "@/api/label/categoryLabel.js";
   import {
      getDoorplateAddressDetail,
      getDoorplateAddressList
   } from "@/api/doorplateAddress/doorplateAddress";
   import {
      add
   } from "@/api/place/place";
   export default {
      mixins: [uploadMixin],
      components: {
         lineItem
      },
      data() {
         return {
            isRequired:false,
            isRequiredPlace:true,
            isDisabled:true,
            showPicker: false,
            pickerLoading: false,
            pickColumns: [],
            defaultIndex: [0, 0, 0, 0, 0],
            selectValue: [],
            form: {
               buildingCode: "",
               label: "",
               remark: "",
<template>
   <view class="container">
      <u-form labelWidth="70" :model="form" :rules="rules" ref="form">
         <view class="box-title">
            <box-title title="基础信息"></box-title>
         </view>
         <view class="item">
            <u-form-item @click="showPicker = true" class="form-item" labelWidth="100" label="楼栋:"
               :required="isRequired" :disabled="isDisabled" prop="buildingCode">
               <u--input border="none" disabledColor="#ffffff" v-model="form.building" placeholder="请选择">
               </u--input>
               <u-icon slot="right" name="arrow-right"></u-icon>
            </u-form-item>
            <u-form-item class="form-item" labelWidth="100" label="场所名称:" :required="isRequiredPlace"
               :disabled="isDisabled" prop="placeName">
               <u--input border="none" v-model="form.placeName" placeholder="请输入">
               </u--input>
            </u-form-item>
            <u-form-item @click="popup" class="form-item" labelWidth="100" label="标签:" :required="isRequired"
               :disabled="isDisabled" prop="label">
               <u--input border="none" disabled disabledColor="#ffffff" placeholder="请选择">
               </u--input>
               <u-icon slot="right" name="arrow-right"></u-icon>
            </u-form-item>
            <view v-if="showLabelList.length>0" class="label">
               <view v-for="(item,index) in showLabelList" :key="index" class="activeLabel">
                  <u-tag closable :show="!item.isClose" size="mini" @close="delTag(item)"
                     :text="item.text"></u-tag>
               </view>
            </view>
            <u-form-item class="form-item" labelWidth="100" label="备注:" prop="remark">
               <u--input border="none" v-model="form.remark" placeholder="请输入">
               </u--input>
            </u-form-item>
            <u-form-item class="form-item" labelWidth="100" label="经纬度:" prop="location">
               <u--input border="none" disabled disabledColor="#ffffff" v-model="form.jwd" placeholder="请输入">
               </u--input>
            </u-form-item>
         </view>
         <view class="box-title">
            <box-title title="负责人信息"></box-title>
         </view>
         <view class="item">
            <u-form-item class="form-item" labelWidth="100" :required="isRequired" :disabled="isDisabled"
               label="场所负责人:" prop="username">
               <u--input border="none" v-model="form.username" placeholder="请输入">
               </u--input>
            </u-form-item>
            <u-form-item class="form-item" labelWidth="100" :required="isRequired" :disabled="isDisabled"
               label="手机号:" prop="phone">
               <u--input border="none" v-model="form.phone" placeholder="请输入">
               </u--input>
            </u-form-item>
         </view>
         <view class="box-title">
            <box-title title="场所照片"></box-title>
         </view>
         <view class="item pic">
            <u-upload :fileList="form.images" :previewFullImage="uploadConfig.previewFullImage"
               :accept="uploadConfig.acceptImg" :multiple="uploadConfig.multiple" :maxCount="uploadConfig.maxCount"
               :capture="uploadConfig.capture" @afterRead="afterReadImg" @delete="deletePic">
            </u-upload>
         </view>
      </u-form>
      <view class="box-title">
         <box-title title="综治网格">
            <template slot="titleMore">
               <view class="title-more">
                  <view class="red item"></view>
                  <view class="orange item">85.9</view>
                  <view class="green item"></view>
               </view>
            </template>
         </box-title>
      </view>
      <view class="item">
         <lineItem :dataInfo="comprehensiveData.basic">
         </lineItem>
         <lineItem :dataInfo="comprehensiveData.scene">
            <template v-slot:pic="{scope}">
               <view class="image" v-if="scope.value !== ''">
                  <u--image @click="imgPreview(scope.value)" width="200rpx" height="200rpx" :src="scope.value"></u--image>
               </view>
            </template>
         </lineItem>
      </view>
      <view class="box-title">
         <box-title title="公安网格">
            <template slot="titleMore">
               <view class="title-more">
                  <view class="red item"></view>
                  <view class="orange item">85.9</view>
                  <view class="green item"></view>
               </view>
            </template>
         </box-title>
      </view>
      <view class="item">
         <lineItem :dataInfo="publicData.basic">
         </lineItem>
         <lineItem :dataInfo="publicData.scene">
            <template v-slot:pic="{scope}">
               {{scope.value}}
            </template>
         </lineItem>
      </view>
      <view class="bottom">
         <view class="btn">
            <u-button @click="submit" type="primary" text="提交"></u-button>
         </view>
      </view>
      <uni-popup class="citys_win popup_win" ref="uniPopup" type="bottom">
         <wyh-tree-select :items="labelList" title="标签选择" :showNav="true" defaultActiveColor="#4586fe"
            :activeIds="activeIds" @clickItem="labelClick" :showCancel="false" :showConfirm="false">
         </wyh-tree-select>
      </uni-popup>
      <u-picker :show="showPicker" :defaultIndex="defaultIndex" ref="uPicker" keyName="name" :loading="pickerLoading"
         :columns="pickColumns" @change="changeHandler" @confirm="confirmPicker"
         @cancel="showPicker = false"></u-picker>
   </view>
</template>
<script>
   import uploadMixin from "@/mixin/uploadMixin";
   import lineItem from "@/subPackage/workbench/components/lineItem.vue"
   import {
      getLabelList
   } from "@/api/label/categoryLabel.js";
   import {
      getDoorplateAddressDetail,
      getDoorplateAddressList
   } from "@/api/doorplateAddress/doorplateAddress";
   import {
      add
   } from "@/api/place/place";
   export default {
      mixins: [uploadMixin],
      components: {
         lineItem
      },
      data() {
         return {
            isRequired: false,
            isRequiredPlace: true,
            isDisabled: true,
            showPicker: false,
            pickerLoading: false,
            pickColumns: [],
            defaultIndex: [0, 0, 0, 0, 0],
            selectValue: [],
            form: {
               buildingCode: "",
               label: "",
               remark: "",
               imageUrls: "",
            },
            rules: {
               'buildingCode': {
                  type: 'string',
                  required: true,
                  message: '请选择楼栋',
                  trigger: ['blur', 'change']
               },
               'placeName': {
                  type: 'string',
                  required: true,
                  message: '请输入场所名称',
                  trigger: ['blur', 'change']
               },
               'label': {
                  type: 'string',
                  required: true,
                  message: '请选择标签',
                  trigger: ['blur', 'change'],
               },
               'username': {
                  type: 'string',
                  required: true,
                  message: '请输入场所负责人',
                  trigger: ['blur', 'change'],
               },
               'phone': {
                  type: 'string',
                  required: true,
                  message: '请输入手机号',
                  trigger: ['blur', 'change'],
               },
            },
            labelList: [{
               text: '全部标签',
               children: [],
               dot: false
            }, ],
            comprehensiveData: {
               basic: [{
                     label: "社区名称",
                     value: "暂无数据"
                  },
                  {
                     label: "网格名称",
                     value: "暂无数据"
                  },
                  {
                     label: "网格员",
                     value: "暂无数据"
                  },
                  {
                     label: "联系电话",
                     value: "暂无数据"
               placeName: ""
            },
            rules: {
               'buildingCode': {
                  type: 'string',
                  required: true,
                  message: '请选择楼栋',
                  trigger: ['blur', 'change']
               },
               'placeName': {
                  type: 'string',
                  required: true,
                  message: '请输入场所名称',
                  trigger: ['blur', 'change']
               },
               'label': {
                  type: 'string',
                  required: true,
                  message: '请选择标签',
                  trigger: ['blur', 'change'],
               },
               'username': {
                  type: 'string',
                  required: true,
                  message: '请输入场所负责人',
                  trigger: ['blur', 'change'],
               },
               'phone': {
                  type: 'string',
                  required: true,
                  message: '请输入手机号',
                  trigger: ['blur', 'change'],
               },
            },
            labelList: [{
               text: '全部标签',
               children: [],
               dot: false
            }, ],
            comprehensiveData: {
               basic: [{
                     label: "社区名称",
                     name: 'neiName',
                     value: "暂无数据"
                  },
                  {
                     label: "网格名称",
                     value: "暂无数据"
                  },
                  {
                     label: "网格员",
                     value: "暂无数据"
                  },
                  {
                     label: "联系电话",
                     value: "暂无数据"
                  }
               ],
               scene: [{
                     label: "场所照片",
                     name: 'imageUrls',
                     value: "",
                     useSlot: "pic",
                  },
                  {
                     label: "场所负责人",
                     name: 'username',
                     value: "未完善",
                  },
                  {
                     label: "采集人",
                     name: 'createUser',
                     value: "未完善"
                  },
                  {
                     label: "采集时间",
                     name: 'createTime',
                     value: "未完善"
                  },
                  {
                     label: "历史事件",
                     value: "未完善",
                  }
               ],
            },
            publicData: {
               basic: [{
                     label: "公安局",
                     name: 'branchName',
                     value: "暂无数据"
                  },
                  {
                     label: "派出所",
                     name: 'localPoliceStationName',
                     value: "暂无数据"
                  },
                  {
                     label: "辖区民警",
                     name: 'policeman',
                     value: "暂无数据"
                  },
                  {
                     label: "联系电话",
                     name: 'policemanPhone',
                     value: "暂无数据"
                  }
               ],
               scene: [{
                     label: "消防照片",
                     value: "",
                     useSlot: "pic",
                  },
                  {
                     label: "采集人",
                     value: "未完善"
                  },
                  {
                     label: "采集时间",
                     value: "未完善"
                  },
                  {
                     label: "消防负责人",
                     value: "未完善",
                  },
                  {
                     label: "采集人",
                     value: "未完善"
                  },
                  {
                     label: "采集时间",
                     value: "未完善",
                  },
                  {
                     label: "历史事件",
                     value: "未完善",
                  }
               ],
            },
            activeIds: [],
            showLabelList: [],
            stdId: "",
         }
      },
      watch: {
         activeIds: {
            handler(newVal) {
               this.form.label = newVal.join(",")
            }
         },
         "form.buildingCode": {
            handler(newVal) {
               console.log(newVal)
            }
         }
      },
      created() {
         this.buildColumn()
      },
      mounted() {
      },
      options: {
         styleIsolation: 'shared', // 解除样式隔离
      },
      onLoad(option) {
         this.stdId = option.stdId
         console.log(this.stdId, "----------")
         if (this.stdId) {
            this.getBuildingDetail()
         }
      },
      onShow() {
         this.getLabel()
         this.getLocation()
      },
      methods: {
         getBuildingDetail(params = {}) {
            getDoorplateAddressDetail(Object.assign(params, {
               stdId: this.stdId
            })).then(res => {
               let data = res.data
               this.form.buildingCode = data.buildingCode
               let buildingNameArr = [data.townStreetName, data.neiName, data.streetRuName, data.aoiName,
                  data.buildingName
               ]
               let arr = buildingNameArr.filter(e => {
                  return e != null || e != ''
               })
               // 赋值
               // this.form.placeName = data['placeName']
               Object.keys(this.form).forEach(key => {
                  if (!data[key]) {
                     this.form[key] = data.place[key]
                  } else {
                     this.form[key] = data[key]
                  }
               ],
               scene: [{
                     label: "场所照片",
                     value: "",
                     useSlot: "pic",
                  },
                  {
                     label: "采集人",
                     value: "未完善"
                  },
                  {
                     label: "采集时间",
                     value: "未完善"
                  },
                  {
                     label: "场所负责人",
                     value: "未完善",
                  },
                  {
                     label: "采集人",
                     value: "未完善"
                  },
                  {
                     label: "采集时间",
                     value: "未完善",
                  },
                  {
                     label: "历史事件",
                     value: "未完善",
                  }
               ],
            },
            publicData: {
               basic: [{
                     label: "公安局",
                     value: "暂无数据"
                  },
                  {
                     label: "派出所",
                     value: "暂无数据"
                  },
                  {
                     label: "辖区民警",
                     value: "暂无数据"
                  },
                  {
                     label: "联系电话",
                     value: "暂无数据"
                  }
               ],
               scene: [{
                     label: "消防照片",
                     value: "",
                     useSlot: "pic",
                  },
                  {
                     label: "采集人",
                     value: "未完善"
                  },
                  {
                     label: "采集时间",
                     value: "未完善"
                  },
                  {
                     label: "消防负责人",
                     value: "未完善",
                  },
                  {
                     label: "采集人",
                     value: "未完善"
                  },
                  {
                     label: "采集时间",
                     value: "未完善",
                  },
                  {
                     label: "历史事件",
                     value: "未完善",
                  }
               ],
            },
            activeIds: [],
            showLabelList: [],
            stdId: "",
         }
      },
      watch: {
         activeIds: {
            handler(newVal) {
               this.form.label = newVal.join(",")
            }
         },
         "form.buildingCode": {
            handler(newVal) {
               console.log(newVal)
            }
         }
      },
      created() {
         this.buildColumn()
      },
      mounted() {
      },
      options: {
         styleIsolation: 'shared', // 解除样式隔离
      },
      onLoad(option) {
         this.stdId = option.stdId
         console.log(this.stdId, "----------")
         if (this.stdId) {
            this.getBuildingDetail()
         }
      },
      onShow() {
         this.getLabel()
         this.getLocation()
      },
      methods: {
         getBuildingDetail(params = {}) {
            getDoorplateAddressDetail(Object.assign(params, {
               stdId: this.stdId
            })).then(res => {
               let data = res.data
               this.form.buildingCode = data.buildingCode
               let buildingNameArr = [data.townStreetName, data.neiName, data.streetRuName, data.aoiName,
                  data.buildingName
               ]
               let arr = buildingNameArr.filter(e => {
                  return e != null || e != ''
               })
               this.form.building = arr.join("")
            })
         },
         //表单提交
         submit() {
            const that = this
            this.$refs.form.validate().then(valid => {
               if (valid) {
                  if (this.form.images.length > 0) {
                     let urls = []
                     this.form.images.forEach(e => {
                        urls.push(e.name)
                     })
                     this.form.imageUrls = urls.join(",")
                  }
                  add(this.form).then(res => {
                     uni.showToast({
                        icon: 'success',
                        title: '提交成功',
                        success() {
                           setTimeout(() => {
                              that.$u.func.globalNavigator(
                                 "/pages/home/index", "switchTab")
                           }, 1000)
                        }
                     })
               Object.keys(this.comprehensiveData).forEach(key => {
                  this.comprehensiveData[key].forEach(item => {
                     if (!data[item.name]) {
                        item.value = data.place[item.name] || '未完善'
                     } else {
                        item.value = data[item.name] || '未完善'
                     }
                  })
               }
                  this.publicData[key].forEach(item => {
                     if (!data[item.name]) {
                        item.value = data.place[item.name] || '未完善'
                     } else {
                        item.value = data[item.name] || '未完善'
                     }
                  })
               })
            })
         },
         //表单提交
         submit() {
            const that = this
            this.$refs.form.validate().then(valid => {
               if (valid) {
                  if (this.form.images.length > 0) {
                     let urls = []
                     this.form.images.forEach(e => {
                        urls.push(e.name)
                     })
                     this.form.imageUrls = urls.join(",")
                  }
                  add(this.form).then(res => {
                     uni.showToast({
                        icon: 'success',
                        title: '提交成功',
                        success() {
                           setTimeout(() => {
                              that.$u.func.globalNavigator(
                                 "/pages/home/index", "switchTab")
                           }, 1000)
                        }
                     })
                  })
               }
            })
         },
         async buildColumn() {
            //设置街道
            const townStreet = await this.getDoorplateAddressList(null, "townStreet")
            this.setColumn(townStreet, 0)
            //设置社区
            const nei = await this.getDoorplateAddressList(townStreet[0].code, "nei")
            this.setColumn(nei, 1)
            //设置路
            const streetRu = await this.getDoorplateAddressList(nei[0].code, "streetRu")
            this.setColumn(streetRu, 2)
            //设置地区
            const district = await this.getDoorplateAddressList(streetRu[0].code, "district")
            this.setColumn(district, 3)
            //设置楼栋
            const building = await this.getDoorplateAddressList(district[0].code, "building")
            this.setColumn(building, 4)
         },
         setColumn(data, index) {
            this.$set(this.pickColumns, index, data)
         },
         getLocation() {
            const that = this
            uni.getLocation({
               type: 'wgs84', // 坐标系类型
               success: function(res) {
                  var latitude = res.latitude; // 维度
                  var longitude = res.longitude; // 经度
                  that.form.lng = longitude
                  that.form.lat = latitude
                  that.form.jwd = longitude + "," + latitude
               },
               fail: function(res) {
                  console.log('获取定位失败:' + res.errMsg);
               }
            });
         },
         async getDoorplateAddressList(code, type) {
            const res = await getDoorplateAddressList(code, type)
            return res.data
         },
         confirmPicker(e) {
            if (e.value[4]) {
               this.selectValue = e.value
               let arr = this.selectValue.map(e => e.name)
               this.form.building = arr.join("")
               this.form.buildingCode = e.value[4].code
            }
            this.showPicker = false
         },
         async changeHandler(e) {
            const {
               columnIndex,
               index,
               // 微信小程序无法将picker实例传出来,只能通过ref操作
               picker = this.$refs.uPicker
            } = e
            let item = e.values[columnIndex][index]
            //街道
            if (columnIndex === 0) {
               //获取社区列表
               const nei = await this.getDoorplateAddressList(item.code, "nei")
               picker.setColumnValues(1, nei)
               const streetRu = await this.getDoorplateAddressList(nei[0].code, "streetRu")
               picker.setColumnValues(2, streetRu)
               const district = await this.getDoorplateAddressList(streetRu[0].code, "district")
               picker.setColumnValues(3, district)
               const building = await this.getDoorplateAddressList(district[0].code, "building")
               picker.setColumnValues(4, building)
            }
            if (columnIndex === 1) {
               const streetRu = await this.getDoorplateAddressList(item.code, "streetRu")
               picker.setColumnValues(2, streetRu)
               const district = await this.getDoorplateAddressList(streetRu[0].code, "district")
               picker.setColumnValues(3, district)
               const building = await this.getDoorplateAddressList(district[0].code, "building")
               picker.setColumnValues(4, building)
            }
            if (columnIndex === 2) {
               const district = await this.getDoorplateAddressList(item.code, "district")
               picker.setColumnValues(3, district)
               const building = await this.getDoorplateAddressList(district[0].code, "building")
               picker.setColumnValues(4, building)
            }
            if (columnIndex === 3) {
               const building = await this.getDoorplateAddressList(item.code, "building")
               picker.setColumnValues(4, building)
            }
         },
         //弹出层打开
         popup() {
            this.$refs.uniPopup.open()
         },
         getLabel() {
            getLabelList({
               size: -1
            }).then(res => {
               let data = res.data.records
               data.sort((a, b) => a.sort - b.sort)
               data.forEach(label => {
                  this.labelList[0].children.push({
                     id: label.categoryNo,
                     text: label.categoryName
                  })
               })
            })
         },
         labelClick(item) {
            //判断label是否已在
            const label = this.showLabelList.find(e => e.id == item.id)
            if (label) {
               //在,去掉
               this.showLabelList = this.showLabelList.filter(e => e.id != label.id)
               this.activeIds = this.activeIds.filter(e => e != label.id)
            } else {
               //不在,添加
               item.isClose = false
               this.showLabelList.push(item)
               this.activeIds.push(item.id)
            }
            this.showLabelList.sort((a, b) => a.sort - b.sort)
         },
         delTag(label) {
            label.isClose = true
            this.showLabelList = this.showLabelList.filter(e => e.id != label.id)
            this.activeIds = this.activeIds.filter(e => e != label.id)
         },
         imgPreview(value) {
            uni.previewImage({
               urls: [value],
            })
         },
         async buildColumn() {
            //设置街道
            const townStreet = await this.getDoorplateAddressList(null, "townStreet")
            this.setColumn(townStreet, 0)
            //设置社区
            const nei = await this.getDoorplateAddressList(townStreet[0].code, "nei")
            this.setColumn(nei, 1)
            //设置路
            const streetRu = await this.getDoorplateAddressList(nei[0].code, "streetRu")
            this.setColumn(streetRu, 2)
            //设置地区
            const district = await this.getDoorplateAddressList(streetRu[0].code, "district")
            this.setColumn(district, 3)
            //设置楼栋
            const building = await this.getDoorplateAddressList(district[0].code, "building")
            this.setColumn(building, 4)
         },
         setColumn(data, index) {
            this.$set(this.pickColumns, index, data)
         },
         getLocation() {
            const that = this
            uni.getLocation({
               type: 'wgs84', // 坐标系类型
               success: function(res) {
                  var latitude = res.latitude; // 维度
                  var longitude = res.longitude; // 经度
                  that.form.lng = longitude
                  that.form.lat = latitude
                  that.form.jwd = longitude + "," + latitude
               },
               fail: function(res) {
                  console.log('获取定位失败:' + res.errMsg);
               }
            });
         },
         async getDoorplateAddressList(code, type) {
            const res = await getDoorplateAddressList(code, type)
            return res.data
         },
         confirmPicker(e) {
            if (e.value[4]) {
               this.selectValue = e.value
               let arr = this.selectValue.map(e => e.name)
               this.form.building = arr.join("")
               this.form.buildingCode = e.value[4].code
            }
            this.showPicker = false
         },
         async changeHandler(e) {
            const {
               columnIndex,
               index,
               // 微信小程序无法将picker实例传出来,只能通过ref操作
               picker = this.$refs.uPicker
            } = e
            let item = e.values[columnIndex][index]
            //街道
            if (columnIndex === 0) {
               //获取社区列表
               const nei = await this.getDoorplateAddressList(item.code, "nei")
               picker.setColumnValues(1, nei)
               const streetRu = await this.getDoorplateAddressList(nei[0].code, "streetRu")
               picker.setColumnValues(2, streetRu)
               const district = await this.getDoorplateAddressList(streetRu[0].code, "district")
               picker.setColumnValues(3, district)
               const building = await this.getDoorplateAddressList(district[0].code, "building")
               picker.setColumnValues(4, building)
            }
            if (columnIndex === 1) {
               const streetRu = await this.getDoorplateAddressList(item.code, "streetRu")
               picker.setColumnValues(2, streetRu)
               const district = await this.getDoorplateAddressList(streetRu[0].code, "district")
               picker.setColumnValues(3, district)
               const building = await this.getDoorplateAddressList(district[0].code, "building")
               picker.setColumnValues(4, building)
            }
            if (columnIndex === 2) {
               const district = await this.getDoorplateAddressList(item.code, "district")
               picker.setColumnValues(3, district)
               const building = await this.getDoorplateAddressList(district[0].code, "building")
               picker.setColumnValues(4, building)
            }
            if (columnIndex === 3) {
               const building = await this.getDoorplateAddressList(item.code, "building")
               picker.setColumnValues(4, building)
            }
         },
         //弹出层打开
         popup() {
            this.$refs.uniPopup.open()
         },
         getLabel() {
            getLabelList({
               size: -1
            }).then(res => {
               let data = res.data.records
               data.sort((a, b) => a.sort - b.sort)
               data.forEach(label => {
                  this.labelList[0].children.push({
                     id: label.categoryNo,
                     text: label.categoryName
                  })
               })
            })
         },
         labelClick(item) {
            //判断label是否已在
            const label = this.showLabelList.find(e => e.id == item.id)
            if (label) {
               //在,去掉
               this.showLabelList = this.showLabelList.filter(e => e.id != label.id)
               this.activeIds = this.activeIds.filter(e => e != label.id)
            } else {
               //不在,添加
               item.isClose = false
               this.showLabelList.push(item)
               this.activeIds.push(item.id)
            }
            this.showLabelList.sort((a, b) => a.sort - b.sort)
         },
         delTag(label) {
            label.isClose = true
            this.showLabelList = this.showLabelList.filter(e => e.id != label.id)
            this.activeIds = this.activeIds.filter(e => e != label.id)
         }
      }
   }
</script>
<style scoped lang="scss">
   .container {
      position: relative;
      width: 100%;
      // height: 100%;
      display: flex;
      flex-direction: column;
      background: #F9F9FA;
      .box-title {
         padding: 10px 0;
         .title-more {
            display: flex;
            align-items: center;
            height: 100%;
            .item {
               width: 50rpx;
               height: 40rpx;
               color: #ffffff;
               padding: 6rpx;
               font-size: 2rpx;
               text-align: center;
               line-height: 20px;
            }
         }
      }
      .item {
         .form-item {
            background-color: #ffffff;
            padding: 2rpx 10px;
            border-bottom: 0.1px solid #eff1f3;
         }
         .label {
            padding: 10rpx 30rpx;
            display: flex;
            background-color: #ffffff;
            flex-wrap: wrap;
            .activeLabel {
               // width: 80rpx;
               margin-left: 10rpx;
               margin-top: 10rpx
            }
         }
      }
      .pic {
         background-color: #ffffff;
         padding: 40rpx 30rpx;
      }
      .bottom {
         },
      }
   }
</script>
<style scoped lang="scss">
   .container {
      position: relative;
      width: 100%;
      // height: 100%;
      display: flex;
      flex-direction: column;
      background: #F9F9FA;
      .box-title {
         padding: 10px 0;
         .title-more {
            display: flex;
            align-items: center;
            height: 100%;
            .item {
               width: 50rpx;
               height: 40rpx;
               color: #ffffff;
               padding: 6rpx;
               font-size: 2rpx;
               text-align: center;
               line-height: 20px;
            }
         }
      }
      .item {
         .form-item {
            background-color: #ffffff;
            padding: 2rpx 10px;
            border-bottom: 0.1px solid #eff1f3;
         }
         .label {
            padding: 10rpx 30rpx;
            display: flex;
            background-color: #ffffff;
            flex-wrap: wrap;
            .activeLabel {
               // width: 80rpx;
               margin-left: 10rpx;
               margin-top: 10rpx
            }
         }
      }
      .pic {
         background-color: #ffffff;
         padding: 40rpx 30rpx;
      }
      .image {
         padding: 20rpx;
         background-color: #ffffff;
         display: flex;
         justify-content: center;
         align-items: center;
         .btn {
            width: calc(100% - 40rpx);
         }
      }
   }
   /deep/ .u-form-item {
      background-color: #ffffff;
      padding: 2rpx 10px;
      border-bottom: 1px solid #eff1f3;
   }
   .red {
      background-color: red;
      border-radius: 10rpx 0rpx 0rpx 10rpx;
   }
   .orange {
      background-color: orange;
   }
   .green {
      background-color: green;
      border-radius: 0rpx 10rpx 10rpx 0rpx;
   }
</style>
      .bottom {
         padding: 20rpx;
         background-color: #ffffff;
         display: flex;
         justify-content: center;
         align-items: center;
         .btn {
            width: calc(100% - 40rpx);
         }
      }
   }
   /deep/ .u-form-item {
      background-color: #ffffff;
      padding: 2rpx 10px;
      border-bottom: 1px solid #eff1f3;
   }
   .red {
      background-color: red;
      border-radius: 10rpx 0rpx 0rpx 10rpx;
   }
   .orange {
      background-color: orange;
   }
   .green {
      background-color: green;
      border-radius: 0rpx 10rpx 10rpx 0rpx;
   }
</style>