liuhj 4 months ago
parent
commit
a1dd3b66ff
1 changed files with 74 additions and 7 deletions
  1. 74 7
      src/components/MCR/MarketCustomerResourcesOperation.vue

+ 74 - 7
src/components/MCR/MarketCustomerResourcesOperation.vue

@@ -87,7 +87,7 @@
                         <el-col :span="8">
                             <div class="grid-content bg-purple">
                                 <el-form-item label="职务:" prop="job">
-                                    <el-input v-model="requestData.job"></el-input>
+                                    <el-input placeholder="只填入职务即可" v-model="requestData.job"></el-input>
                                 </el-form-item>
                             </div>
                         </el-col>
@@ -112,7 +112,23 @@
                         <el-col :span="8">
                             <div class="grid-content bg-purple">
                                 <el-form-item label="所在城市:" prop="location">
-                                    <el-input v-model="requestData.location"></el-input>
+                                    <el-autocomplete
+                                    style="width: 100%;"
+                                    class="inline-input"
+                                    v-model="requestData.location"
+                                    :fetch-suggestions="querySearch"
+                                    placeholder="请输入内容"
+                                    @select="handleSelect"
+                                    ></el-autocomplete>
+                                    <!-- <el-cascader
+                                    show-all-levels="false"
+                                    filterable
+                                    size="large"
+                                    @input="cascaderinput"
+                                    :options="pcaTextArr"
+                                    v-model="selectedOptions">
+                                    </el-cascader> -->
+                                    <!-- <el-input v-model="requestData.location"></el-input> -->
                                 </el-form-item>
                             </div>
                         </el-col>
@@ -216,8 +232,7 @@
 </template>
 
 <script>
-
-
+import { pcaTextArr } from 'element-china-area-data'
 export default {
     data() {
         const validName = (rule, value, callback) => {
@@ -300,7 +315,7 @@ export default {
                 ],
                 contact: [
                     { required: true, message: '请输入联系人名称', trigger: 'blur' },
-                    // { validator: validName, trigger: 'blur' }
+                    { validator: validName, trigger: 'blur' }
                 ],
                 telephone: [
                     { required: true, message: '请输入联系人手机号', trigger: 'blur' },
@@ -312,17 +327,43 @@ export default {
                     { required: true, message: '请输入单位名称', trigger: 'blur' },
                 ],
                 location: [
-                    { required: true, message: '请输入所在城市', trigger: 'blur' },
+                    { required: true, message: '请输入所在城市', trigger: 'change' },
                 ],
                 address: [
                     { required: true, message: '请输入具体位置', trigger: 'blur' },
                 ],
-            }
+            },
+            pcaTextArr,
+            selectedOptions: [],
+            restaurants:[]
         }
     },
     methods: {
+        querySearch(queryString, cb) {
+            var restaurants = this.restaurants;
+            var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
+            // 调用 callback 返回建议列表的数据
+            cb(results);
+        },
+        createFilter(queryString) {
+            return (restaurant) => {
+                return restaurant.value.replace("  ", "").toLowerCase().match(queryString.toLowerCase());
+            };
+        },
         Getback() {
             this.$router.push('/home/MCR');
+        },
+        handleSelect(item) {
+            this.requestData.location=''
+            if (item.value.split(' ')[1]=='市辖区'||item.value.split(' ')[1]=='县') {
+                this.requestData.location=(item.value.split(' ')[0]).substring(0, (item.value.split(' ')[0]).length - 1)+' '+item.value.split(' ')[2];
+            }else{
+                this.requestData.location=(item.value.split(' ')[1]).substring(0, (item.value.split(' ')[1]).length - 1)+' '+item.value.split(' ')[2];
+            }
+            // console.log(item);
+            
+            
+          
         },
         QueryPageData() {
             var that = this;
@@ -371,6 +412,10 @@ export default {
                 }
             })
         },
+        cascaderinput(val){
+            console.log(pcaTextArr);
+            // this.selectedOptions=val[1]+val[2]+''
+        },
         save() {
             var that = this;
 
@@ -442,8 +487,27 @@ export default {
                 this.$message.error('网络异常!');
             })
         },
+        restaurantsfz(){
+            for(let i=0;i<pcaTextArr.length;i++){
+                for (let j = 0; j < pcaTextArr[i].children.length; j++) {
+                    for (let x = 0; x < pcaTextArr[i].children[j].children.length; x++) {
+                        this.restaurants.push({'value':pcaTextArr[i].value+' '+pcaTextArr[i].children[j].value+' '+pcaTextArr[i].children[j].children[x].value})
+                    }
+                }
+            }
+            console.log(this.restaurants);
+            
+        }
     },
     mounted() {
+        console.log(pcaTextArr);
+        this.restaurantsfz()
+        // this.restaurants=pcaTextArr.map((terminal) => {
+        //     pcaTextArr.children
+        //     // return {
+        //     //     value: terminal.contact +'   '+ terminal.client +'   '+terminal.telephone+'   '+terminal.wechat,
+        //     // };
+        // });
         this.token = JSON.parse(localStorage.getItem('userinif')).token;
         this.userId = JSON.parse(localStorage.getItem('userinif')).userInfo.userId;
         this.requestData.ascribedUser.push(this.userId);
@@ -490,6 +554,9 @@ body {
 .operationMCR-Box .el-select {
     width: 100%;
 }
+.operationMCR-Box .el-cascader{
+    width: 100%;
+}
 
 .operationMCRtitle {
     font-size: 17px;