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/edit/law/index.vue |  562 ++++++++++++++++++++++++++++++--------------------------
 1 files changed, 302 insertions(+), 260 deletions(-)

diff --git a/src/views/operate/car/myIndex/edit/law/index.vue b/src/views/operate/car/myIndex/edit/law/index.vue
index 52d7620..610a012 100644
--- a/src/views/operate/car/myIndex/edit/law/index.vue
+++ b/src/views/operate/car/myIndex/edit/law/index.vue
@@ -1,289 +1,331 @@
 <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="handleUpdateLawCar">纭
-                            </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="handleUpdateLawCar"
+                >纭
+              </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 checkUser = (rule, value, callback) => {
+      if (value) {
+        if (validateName(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('鎵嬫満鍙风爜涓嶈兘涓虹┖'));
-            }
+      } else {
+        callback(new Error("杞﹁締浣跨敤浜哄憳涓嶈兘涓虹┖"));
+      }
+    };
+    const checkPhone = (rule, value, callback) => {
+      if (value) {
+        if (validatePhone(value)) {
+          callback();
+        } else {
+          callback(new Error("璇疯緭鍏ユ纭殑鎵嬫満鍙�"));
         }
-        return {
-            car: {
-                carNumber: "",
-                contact: "",
-                belong: "",
-                // id: 0,
-                ownerName: "",
-                trajectory: "",
-                vehicleUser: "",
-                depart: '',
+      } 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
+        //     }
+        // ]
+      },
+      selectOrg: {
+        orgsid: [],
+      },
+      mylabel: "",
+      departList: [],
+      defaultProps: {
+        children: "children",
+        label: "departName",
+      },
+    };
+  },
+  created() {
+    console.log(this.info);
+    const { getDepartTree } = this;
+    // 鍒濆鍖栭儴闂ㄦ爲
+    getDepartTree();
+    // 鍒濆鍖栨暟鎹�
+    this.car = JSON.parse(JSON.stringify(this.info));
+    if (!this.car.departName) {
+      this.car.departName = this.car.pdepartName;
+    }
+  },
+  methods: {
+    // 淇敼鎵ф硶杞�
+    handleUpdateLawCar() {
+      this.$refs.user.validate((valid) => {
+        if (valid) {
+          const { car } = this;
+          this.$axios({
+            method: "put",
+            url: "sccg/car_Manage/modification_enforce",
+            data: {
+              ...car,
             },
-            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
-                    }
-                ]
-            },
-            selectOrg: {
-                orgsid: [],
-            },
-            mylabel: '',
-            departList: [],
-            defaultProps: {
-                children: "children",
-                label: "departName",
-            },
+          }).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;
         }
+      });
     },
-    created() {
-        console.log(this.info);
-        const {getDepartTree} = this
-        // 鍒濆鍖栭儴闂ㄦ爲
-        getDepartTree();
-        // 鍒濆鍖栨暟鎹�
-        this.car = JSON.parse(JSON.stringify(this.info));
-
+    // 閮ㄩ棬淇敼
+    handleCheck(data, checked) {
+      console.log(data);
+      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 = "";
+      }
     },
-    methods: {
-        // 淇敼鎵ф硶杞�
-        handleUpdateLawCar() {
-            this.$refs.user.validate((valid) => {
-                if (valid) {
-                    const { car } = this;
-                    this.$axios({
-                        method: 'put',
-                        url: 'sccg/car_Manage/modification_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;
-                }
-            })
-        },
-        // 閮ㄩ棬淇敼
-        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 = ''
-            }
-        },
-        // 鑾峰彇閮ㄩ棬鏍�
-        getDepartTree() { 
-            this.$axios.get('/sccg/depart/tree').then(res => {
-                this.departList = res.data;
-            })
-        }
-
-
+    // 鑾峰彇閮ㄩ棬鏍�
+    getDepartTree() {
+      this.$axios.get("/sccg/depart/tree").then((res) => {
+        this.departList = res.data;
+      });
     },
-    props: ['info','closeDialog']
-}
+  },
+  props: ["info", "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