浏览代码

省市区下拉

yuedefeng 6 年之前
父节点
当前提交
4ab3908607

+ 4 - 0
src/dashoo.cn/backend/api/controllers/oilsupplier/supplier.go

@@ -2,6 +2,7 @@ package oilsupplier
 
 import (
 	"dashoo.cn/backend/api/business/workflow"
+	"dashoo.cn/business2/areajson"
 	"dashoo.cn/business2/items"
 	"encoding/json"
 	"strconv"
@@ -966,11 +967,14 @@ func (this *OilSupplierController) GetDictList() {
 	dictList := make(map[string]interface{})
 	dictSvc := items.GetItemsService(utils.DBE)
 	userSvc := baseUser.GetBaseUserService(utils.DBE)
+	areaJsonSvc := areajson.GetAreaJsonService(utils.DBE)
 	//customerSvc := svccustomer.GetCustomerService(utils.DBE)
 	dictList["UnitRelation"] = dictSvc.GetKeyValueItems("UnitRelation")
 	var userEntity userRole.Base_User
 	userSvc.GetEntityById(this.User.Id, &userEntity)
 	dictList["Supervisers"] = userSvc.GetUserListByDepartmentId(this.User.AccCode, userEntity.Departmentid)
+	dictList["GaodeMapChinaAreas"] = areaJsonSvc.GetGaodeMapChinaAreas()
+
 
 	//var dictCustomer []svccustomer.Customer
 	//customerSvc.GetEntitysByWhere(this.User.AccCode + CustomerName, "", &dictCustomer)

+ 13 - 10
src/dashoo.cn/frontend_web/src/pages/oilsupplier/supplier/_opera/techedit.vue

@@ -98,7 +98,7 @@
                   <el-form-item label="注册地址" required>
                     <el-row>
                       <el-col :span="8">
-                        <el-cascader :options="countryoptions" placeholder="省市区" v-model="CityAry" style="width: 100%">
+                        <el-cascader :options="countryoptions" :props="countryprops" placeholder="省市区" v-model="CityAry" style="width: 100%">
                         </el-cascader>
                       </el-col>
                       <el-col :span="16">
@@ -117,7 +117,7 @@
                   <el-form-item label="通信地址" required>
                     <el-row>
                       <el-col :span="8">
-                        <el-cascader :options="countryoptions" placeholder="省市区" v-model="CityAry" style="width: 100%">
+                        <el-cascader :options="countryoptions" :props="countryprops" placeholder="省市区" v-model="CityAry" style="width: 100%">
                         </el-cascader>
                       </el-col>
                       <el-col :span="16">
@@ -538,6 +538,11 @@
         UnitRelationOptions: [],
         UnitRelationAry: [],
         countryoptions: [],
+        countryprops: {
+          value: 'adcode',
+          label: 'name',
+          children: 'districts'
+        },
         CityAry: [],
         serviceId: '',
         certId: '',
@@ -693,20 +698,18 @@
       },
 
       getDictOptions () {
-        this.getCityList()
         api.getDictList(this.$axios).then(res => {
           this.UnitRelationOptions = res.data.items['UnitRelation']
+          this.getCityList(res.data.items['GaodeMapChinaAreas'])
         }).catch(err => {
           console.error(err)
         })
       },
-      getCityList () {
-        this.$axios.get('http://restapi.amap.com/v3/config/district?key=13f54664eb5a883195604db09d3fba5c&subdistrict=3')
-          .then((res) => {
-            let countstr = JSON.stringify(res.data.districts[0].districts)
-            countstr = countstr.replace(/\,\"districts\"\:\[\]/g,'')
-            this.countryoptions = JSON.parse(countstr)
-          })
+      getCityList (areaJson) {
+        let resData = JSON.parse(areaJson)
+        let countstr = JSON.stringify(resData.districts[0].districts)
+        countstr = countstr.replace(/\,\"districts\"\:\[\]/g,'')
+        this.countryoptions = JSON.parse(countstr)
       },
 
       //保存信息