From c569fe2027abbcb85c1f7c817456ecf31301f36a Mon Sep 17 00:00:00 2001 From: zhanghua <314079846@qq.com> Date: 星期二, 25 十月 2022 14:04:09 +0800 Subject: [PATCH] 车辆管理bug --- src/views/operate/car/myIndex/create/law/index.vue | 574 +++++++++++++++++++++++++++++--------------------------- 1 files changed, 298 insertions(+), 276 deletions(-) diff --git a/src/views/operate/car/myIndex/create/law/index.vue b/src/views/operate/car/myIndex/create/law/index.vue index 4994bfc..7f0ca0b 100644 --- a/src/views/operate/car/myIndex/create/law/index.vue +++ b/src/views/operate/car/myIndex/create/law/index.vue @@ -1,303 +1,325 @@ <template> - <div class="createUser"> - <main> - <div class="mainContent"> - <el-form ref="user" label-width="140px" :rules="createCarRules" autoComplete="on" :model="car" - label-position="right"> - <!-- 杞︾墝鍙� --> - <el-form-item class="optionItem" label="杞︾墝鍙�:" prop="carNumber"> - <el-input v-model="car.carNumber" placeholder="璇峰~鍐欒溅鐗屽彿"></el-input> - </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.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="optionItem" label="杞︿富濮撳悕:" prop="ownerName"> - <el-input v-model="car.ownerName" placeholder="璇疯緭鍏ヨ溅涓诲鍚�"></el-input> - </el-form-item> - <!-- 杞﹁締浣跨敤浜哄憳 --> - <el-form-item class="optionItem" label="杞﹁締浣跨敤浜哄憳:" prop="vehicleUser"> + <div class="createUser"> + <main> + <div class="mainContent"> + <el-form + ref="user" + label-width="140px" + :rules="createCarRules" + autoComplete="on" + :model="car" + label-position="right" + > + <!-- 杞︾墝鍙� --> + <el-form-item class="optionItem" label="杞︾墝鍙�:" prop="carNumber"> + <el-input + v-model="car.carNumber" + placeholder="璇峰~鍐欒溅鐗屽彿" + ></el-input> + </el-form-item> + <!-- 鎵�灞為儴闂� --> + <el-form-item class="optionItems" label="鎵�灞為儴闂�:" prop="departId"> + <!-- <el-input v-model="car.depart" placeholder="璇峰~鍐欐墍灞為儴闂�"></el-input> --> + <el-select v-model="car.departName" 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="optionItem" label="杞︿富濮撳悕:" prop="ownerName"> + <el-input + v-model="car.ownerName" + placeholder="璇疯緭鍏ヨ溅涓诲鍚�" + ></el-input> + </el-form-item> + <!-- 杞﹁締浣跨敤浜哄憳 --> + <!-- <el-form-item class="optionItem" label="杞﹁締浣跨敤浜哄憳:" prop="vehicleUser"> <el-input v-model="car.vehicleUser" placeholder="璇疯緭鍏ヨ溅杈嗕娇鐢ㄤ汉鍛�"></el-input> - </el-form-item> - <!-- 鑱旂郴鏂瑰紡 --> - <el-form-item class="optionItem" label="鑱旂郴鏂瑰紡:" prop="contact"> - <el-input v-model="car.contact" placeholder="璇疯緭鍏ヨ溅涓绘墜鏈哄彿鐮�"></el-input> - </el-form-item> - <el-form-item> - <div class="optionBtn"> - <el-button type="primary" class="btn submit" @click.native.prevent="handleCar">纭 - </el-button> - <el-button class="btn cancel" @click.native.prevent="handleStop"> - 鍙栨秷 - </el-button> - </div> - </el-form-item> - </el-form> - + </el-form-item> --> + <!-- 鑱旂郴鏂瑰紡 --> + <el-form-item class="optionItem" label="鑱旂郴鏂瑰紡:" prop="contact"> + <el-input + v-model="car.contact" + placeholder="璇疯緭鍏ヨ溅涓绘墜鏈哄彿鐮�" + ></el-input> + </el-form-item> + <el-form-item> + <div class="optionBtn"> + <el-button + type="primary" + class="btn submit" + @click.native.prevent="handleCar" + >纭 + </el-button> + <el-button class="btn cancel" @click.native.prevent="handleStop"> + 鍙栨秷 + </el-button> </div> - </main> - </div> + </el-form-item> + </el-form> + </div> + </main> + </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)) { - callback() - } else { - callback(new Error('璇疯緭鍏ユ纭殑杞︾墝鍙�')); - } - } else { - callback(new Error('杞︾墝鍙蜂笉鑳戒负绌�')); - } + data() { + const checkCarNum = (rule, value, callback) => { + if (value) { + if (validateCarNum(value)) { + callback(); + } else { + callback(new Error("璇疯緭鍏ユ纭殑杞︾墝鍙�")); } - const checkName = (rule, value, callback) => { - if (value) { - if (validateName(value)) { - callback() - } else { - callback(new Error('璇锋纭緭鍏ヨ溅涓诲鍚�')); - } - } else { - callback(new Error('杞︿富濮撳悕涓嶈兘涓虹┖')); - } + } else { + callback(new Error("杞︾墝鍙蜂笉鑳戒负绌�")); + } + }; + const checkName = (rule, value, callback) => { + if (value) { + if (validateName(value)) { + callback(); + } else { + callback(new Error("璇锋纭緭鍏ヨ溅涓诲鍚�")); } - const checkUser = (rule, value, callback) => { - if (value) { - if (validateName(value)) { - callback() - } else { - callback(new Error('璇锋纭緭鍏ヨ溅杈嗕娇鐢ㄤ汉鍛�')); - } - } else { - callback(new Error('杞﹁締浣跨敤浜哄憳涓嶈兘涓虹┖')); - } + } else { + callback(new Error("杞︿富濮撳悕涓嶈兘涓虹┖")); + } + }; + const checkDepartId = (rule, value, callback) => { + if (value) { + callback(); + } else { + callback(new Error("杞﹁締浣跨敤鐨勯儴闂ㄤ笉鑳戒负绌�")); + } + }; + const checkPhone = (rule, value, callback) => { + if (value) { + if (validatePhone(value)) { + callback(); + } else { + callback(new Error("璇疯緭鍏ユ纭殑鎵嬫満鍙�")); } - const checkPhone = (rule, value, callback) => { - if (value) { - if (validatePhone(value)) { - callback() - } else { - callback(new Error('璇疯緭鍏ユ纭殑鎵嬫満鍙�')); - } - } else { - callback(new Error('鎵嬫満鍙风爜涓嶈兘涓虹┖')); - } - } - return { - car: { - carNumber: "", - contact: "", - belong: "", - // id: 0, - ownerName: "", - trajectory: "", - vehicleUser: "", - depart: '', - }, - createCarRules: { - carNumber: [ - { - required: true, trigger: 'blur', validator: checkCarNum - } - ], - contact: [ - { - required: true, trigger: 'blur', validator: checkPhone - } - ], - // id: 0, - ownerName: [ - { - required: true, trigger: 'blur', validator: checkName - } - ], - vehicleUser: [ - { - required: true, trigger: 'blur', validator: checkUser - } - ] - }, - teamList: [ - { - label: '澶ч槦涓�', - value: 1, - }, - { - 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: { - // 娣诲姞杞﹁締 - handleCar() { - console.log(this.car); - this.$refs.user.validate((valid) => { - if (valid) { - const { car } = this; - this.$axios({ - method: 'post', - url: 'sccg/car_Manage/addition_enforce', - data: { - carNumber: car.carNumber, - contact: car.contact, - belong: car.belong, - // id: 0, - ownerName: car.ownerName, - trajectory: car.trajectory, - vehicleUser: car.vehicleUser, - 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, - }) - } - }) - } else { - return false; - } - }) + } else { + callback(new Error("鎵嬫満鍙风爜涓嶈兘涓虹┖")); + } + }; + return { + car: { + carNumber: "", + contact: "", + ownerName: "", + trajectory: "", + vehicleUser: "", + departName: "", + departId: 0, + }, + createCarRules: { + departId: [ + { + required: true, + trigger: "blur", + validator: checkDepartId, + }, + ], + carNumber: [ + { + required: true, + trigger: "blur", + validator: checkCarNum, + }, + ], + contact: [ + { + required: true, + trigger: "blur", + validator: checkPhone, + }, + ], + // id: 0, + ownerName: [ + { + required: true, + trigger: "blur", + validator: checkName, + }, + ], + // vehicleUser: [ + // { + // required: true, trigger: 'blur', validator: checkUser + // } + // ] + }, + teamList: [ + { + label: "澶ч槦涓�", + value: 1, }, - handleStop() { - this.$emit('closeDialog', { flag: false, index: 0 }); + { + label: "澶ч槦浜�", + value: 2, }, - // 閮ㄩ棬淇敼 - 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 = '' + ], + selectOrg: { + orgsid: [], + }, + mylabel: "", + departList: [], + defaultProps: { + children: "children", + label: "departName", + }, + }; + }, + created() { + // 鑾峰彇鍏ㄩ儴閮ㄩ棬鍒楄〃 + this.$axios.get("/sccg/depart/tree").then((res) => { + this.departList = res.data; + }); + }, + methods: { + // 娣诲姞杞﹁締 + handleCar() { + this.$refs.user.validate((valid) => { + debugger; + if (valid) { + const { car } = this; + this.$axios({ + method: "post", + url: "sccg/car_Manage/addition_enforce", + data: car, + }).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; + } + }); }, - props: ['closeDialog'] -} + handleStop() { + this.$emit("closeDialog", { flag: false, index: 0 }); + }, + // 閮ㄩ棬淇敼 + handleCheck(data, checked) { + console.log(data); + // this.car.belong = data.departName + this.car.departId = data.id; + this.car.departName = data.departName; + // 鑾峰彇褰撳墠閫夋嫨鐨刬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.departName = ""; + } + }, + }, + props: ["closeDialog"], +}; </script> <style lang="scss" scoped> .createUser { - border-radius: 1px; + border-radius: 1px; + background-color: #09152f; + + main { + // border: 1px solid #fff; + text-align: left; + padding: 0 55px; background-color: #09152f; + padding-bottom: 50px; - main { - // border: 1px solid #fff; - text-align: left; - padding: 0 55px; - background-color: #09152f; - padding-bottom: 50px; + .mainContent { + display: flex; + justify-content: center; + padding-top: 50px; - .mainContent { - display: flex; - justify-content: center; - padding-top: 50px; + .el-form-item__content { + width: 400px; - .el-form-item__content { - width: 400px; - - .el-select { - width: 100%; - } - } - - .optionHandleSp { - display: flex; - - .areaNumber, - .moreNumber { - flex: 1; - } - - .telNumber { - flex: 2; - } - } - - .optionBtn { - display: flex; - margin-top: 20px; - - .btn { - padding: 12px 50px; - } - } - + .el-select { + width: 100%; } - } + } - &::v-deep .el-textarea__inner { - background-color: #09152f; - border: 1px solid #17324c; - } + .optionHandleSp { + display: flex; - ::v-deep .el-form-item__label { - color: #4b9bb7; - } + .areaNumber, + .moreNumber { + flex: 1; + } - ::v-deep .el-input__inner { - background-color: #09152f; - border: 1px solid #17324c; + .telNumber { + flex: 2; + } + } + + .optionBtn { + display: flex; + margin-top: 20px; + + .btn { + padding: 12px 50px; + } + } } + } + + &::v-deep .el-textarea__inner { + background-color: #09152f; + border: 1px solid #17324c; + } + + ::v-deep .el-form-item__label { + color: #4b9bb7; + } + + ::v-deep .el-input__inner { + background-color: #09152f; + border: 1px solid #17324c; + } } </style> \ No newline at end of file -- Gitblit v1.8.0