From c46189c4f6749602c71eb7cb5bab89823fe9b1e1 Mon Sep 17 00:00:00 2001 From: “dzb” <2632970487@qq.com> Date: 星期五, 21 十月 2022 14:03:40 +0800 Subject: [PATCH] 修改车辆管理bug --- src/views/operate/car/myIndex/create/law/index.vue | 140 +++++++++++++++++++++++++++++----------------- 1 files changed, 87 insertions(+), 53 deletions(-) diff --git a/src/views/operate/car/myIndex/create/law/index.vue b/src/views/operate/car/myIndex/create/law/index.vue index 3519ff4..4994bfc 100644 --- a/src/views/operate/car/myIndex/create/law/index.vue +++ b/src/views/operate/car/myIndex/create/law/index.vue @@ -10,21 +10,14 @@ </el-form-item> <!-- 鎵�灞為儴闂� --> <el-form-item class="optionItems" label="鎵�灞為儴闂�:" prop="depart"> - <el-input v-model="car.depart" placeholder="璇峰~鍐欐墍灞為儴闂�"></el-input> - <!-- <el-select v-model="car.group" placeholder="璇烽�夋嫨鎵�灞炵被鍨�"> - <el-option v-for="item in teamList" :key="item.value" :label="item.label" - :value="item.value"> + <!-- <el-input v-model="car.depart" placeholder="璇峰~鍐欐墍灞為儴闂�"></el-input> --> + <el-select v-model="car.belong" placeholder="璇烽�夋嫨鎵�灞為儴闂�"> + <el-option value="1"> + <el-tree ref="tree" :check-strictly="true" :data="departList" :props="defaultProps" + show-checkbox @check-change="handleCheck" default-expand-all node-key="id"> + </el-tree> </el-option> - </el-select> --> - </el-form-item> - <!-- 鎵�灞炲ぇ闃� --> - <el-form-item class="optionItems" label="鎵�灞炲ぇ闃�:" prop="belong"> - <el-input v-model="car.belong" placeholder="璇峰~鍐欐墍灞炲ぇ闃�"></el-input> - <!-- <el-select v-model="car.group" placeholder="璇烽�夋嫨鎵�灞炵被鍨�"> - <el-option v-for="item in teamList" :key="item.value" :label="item.label" - :value="item.value"> - </el-option> - </el-select> --> + </el-select> </el-form-item> <!-- 杞︿富濮撳悕 --> <el-form-item class="optionItem" label="杞︿富濮撳悕:" prop="ownerName"> @@ -37,10 +30,6 @@ <!-- 鑱旂郴鏂瑰紡 --> <el-form-item class="optionItem" label="鑱旂郴鏂瑰紡:" prop="contact"> <el-input v-model="car.contact" placeholder="璇疯緭鍏ヨ溅涓绘墜鏈哄彿鐮�"></el-input> - </el-form-item> - <!-- 杞ㄨ抗 --> - <el-form-item class="optionItem" label="杞ㄨ抗:" prop="trajectory"> - <el-input type="textarea" :rows="2" v-model="car.trajectory" placeholder="璇疯緭鍏ヨ溅杈嗚建杩�"></el-input> </el-form-item> <el-form-item> <div class="optionBtn"> @@ -58,14 +47,14 @@ </div> </template> <script> -import {validateCarNum,validatePhone,validateName} from '@/utils/validate' +import { validateCarNum, validatePhone, validateName } from '@/utils/validate' export default { data() { const checkCarNum = (rule, value, callback) => { if (value) { - if(validateCarNum(value)){ + if (validateCarNum(value)) { callback() - }else{ + } else { callback(new Error('璇疯緭鍏ユ纭殑杞︾墝鍙�')); } } else { @@ -74,9 +63,9 @@ } const checkName = (rule, value, callback) => { if (value) { - if(validateName(value)){ + if (validateName(value)) { callback() - }else{ + } else { callback(new Error('璇锋纭緭鍏ヨ溅涓诲鍚�')); } } else { @@ -85,9 +74,9 @@ } const checkUser = (rule, value, callback) => { if (value) { - if(validateName(value)){ + if (validateName(value)) { callback() - }else{ + } else { callback(new Error('璇锋纭緭鍏ヨ溅杈嗕娇鐢ㄤ汉鍛�')); } } else { @@ -96,9 +85,9 @@ } const checkPhone = (rule, value, callback) => { if (value) { - if(validatePhone(value)){ + if (validatePhone(value)) { callback() - }else{ + } else { callback(new Error('璇疯緭鍏ユ纭殑鎵嬫満鍙�')); } } else { @@ -114,28 +103,28 @@ ownerName: "", trajectory: "", vehicleUser: "", - depart:'', + depart: '', }, createCarRules: { carNumber: [ { - required: true, trigger:'blur', validator: checkCarNum + required: true, trigger: 'blur', validator: checkCarNum } ], contact: [ { - required: true,trigger:'blur', validator: checkPhone + required: true, trigger: 'blur', validator: checkPhone } ], // id: 0, ownerName: [ { - required: true,trigger:'blur', validator: checkName + required: true, trigger: 'blur', validator: checkName } ], vehicleUser: [ { - required: true,trigger:'blur', validator: checkUser + required: true, trigger: 'blur', validator: checkUser } ] }, @@ -148,10 +137,23 @@ label: '澶ч槦浜�', value: 2, }, - ] + ], + selectOrg: { + orgsid: [], + }, + mylabel: '', + departList: [], + defaultProps: { + children: "children", + label: "departName", + }, } }, created() { + // 鑾峰彇鍏ㄩ儴閮ㄩ棬鍒楄〃 + this.$axios.get('/sccg/depart/tree').then(res => { + this.departList = res.data; + }) }, methods: { // 娣诲姞杞﹁締 @@ -159,7 +161,7 @@ console.log(this.car); this.$refs.user.validate((valid) => { if (valid) { - const {car} = this; + const { car } = this; this.$axios({ method: 'post', url: 'sccg/car_Manage/addition_enforce', @@ -171,32 +173,64 @@ ownerName: car.ownerName, trajectory: car.trajectory, vehicleUser: car.vehicleUser, - depart:car.depart, + depart: car.depart, } }) - .then(res=>{ - console.log(res); - if(res.code === 200){ - this.$message({ - type:'success', - message:'鏂板杞﹁締鎴愬姛', - }) - this.$emit('closeDialog',{flag:false,index:1}); - }else{ - this.$message({ - type:'error', - message:res.message, - }) - } - }) + .then(res => { + console.log(res); + if (res.code === 200) { + this.$message({ + type: 'success', + message: '鏂板杞﹁締鎴愬姛', + }) + this.$emit('closeDialog', { flag: false, index: 1 }); + } else { + this.$message({ + type: 'error', + message: res.message, + }) + } + }) } else { return false; } }) }, - handleStop(){ - this.$emit('closeDialog',{flag:false,index:0}); - } + handleStop() { + this.$emit('closeDialog', { flag: false, index: 0 }); + }, + // 閮ㄩ棬淇敼 + handleCheck(data, checked) { + console.log(data); + this.car.belong = data.departName + this.car.depart = data.id + // 鑾峰彇褰撳墠閫夋嫨鐨刬d鍦ㄦ暟缁勪腑鐨勭储寮� + const indexs = this.selectOrg.orgsid.indexOf(data.id); + // 濡傛灉涓嶅瓨鍦ㄦ暟缁勪腑锛屽苟涓旀暟缁勪腑宸茬粡鏈変竴涓猧d骞朵笖checked涓簍rue鐨勬椂鍊欙紝浠h〃涓嶈兘鍐嶆閫夋嫨銆� + if (indexs < 0 && this.selectOrg.orgsid.length === 1 && checked) { + this.$message({ + message: "鍙兘閫夋嫨涓�涓儴闂紒", + type: "warning", + showClose: true, + }); + // 璁剧疆宸查�夋嫨鐨勮妭鐐逛负false 寰堥噸瑕� + this.$refs.tree.setChecked(data, false); + } else if (this.selectOrg.orgsid.length === 0 && checked) { + // 鍙戠幇鏁扮粍涓虹┖ 骞朵笖鏄凡閫夋嫨 + // 闃叉鏁扮粍鏈夊�硷紝棣栧厛娓呯┖锛屽啀push + this.selectOrg.orgsid = []; + this.selectOrg.orgsid.push(data.id); + } else if ( + indexs >= 0 && + this.selectOrg.orgsid.length === 1 && + !checked + ) { + // 鍐嶆鐩存帴杩涜璧嬪�间负绌烘搷浣� + this.selectOrg.orgsid = []; + this.car.belong = '' + this.car.depart = '' + } + }, }, props: ['closeDialog'] -- Gitblit v1.8.0