From 387e8b0743240de72425e5b5c5709d629ace9aa4 Mon Sep 17 00:00:00 2001
From: “dzb” <2632970487@qq.com>
Date: 星期二, 11 十月 2022 20:17:43 +0800
Subject: [PATCH] 新增消息界面、处理遗留问题

---
 src/components/dispatch/index.vue |  201 +++++++++++++++++++++++++++++++++++---------------
 1 files changed, 140 insertions(+), 61 deletions(-)

diff --git a/src/components/dispatch/index.vue b/src/components/dispatch/index.vue
index ebef391..c5aebf1 100644
--- a/src/components/dispatch/index.vue
+++ b/src/components/dispatch/index.vue
@@ -23,25 +23,26 @@
             <div class="form-person">
                 <!-- 閮ㄩ棬 -->
                 <el-form-item label="閫夋嫨浜哄憳:" prop="dispatchOpinion">
-                    <el-select v-model="dispatch.dispatchOpinion" placeholder="璇烽�夋嫨閮ㄩ棬">
-                        <el-option v-for="item in departOptions" :key="item.value" :label="item.label"
-                            :value="item.value">
+                    <el-select v-model="dispatch.dispatchOpinion" placeholder="璇烽�夋嫨閮ㄩ棬" @change="handleTopChange">
+                        <el-option v-for="item in departOptions" :key="item.id" :label="item.departName"
+                            :value="item.id">
                         </el-option>
                     </el-select>
                 </el-form-item>
                 <!-- 涓槦 -->
                 <el-form-item prop="enforcementTeam" class="person-item">
-                    <el-select v-model="dispatch.enforcementTeam" placeholder="閫夋嫨涓槦">
-                        <el-option v-for="item in squadronOptions" :key="item.value" :label="item.label"
-                            :value="item.value">
+                    <el-select v-model="dispatch.enforcementTeam" placeholder="閫夋嫨涓槦"
+                        :disabled="squadronOptions.length!==0?false:true" @change="handleMidChange">
+                        <el-option v-for="item in squadronOptions" :key="item.id" :label="item.departName"
+                            :value="item.id">
                         </el-option>
                     </el-select>
                 </el-form-item>
                 <el-form-item prop='lawEnforcer' class="person-item">
                     <!-- 浜哄憳 -->
-                    <el-select v-model="dispatch.lawEnforcer" placeholder="璇烽�夋嫨浜哄憳">
-                        <el-option v-for="item in personOptions" :key="item.value" :label="item.label"
-                            :value="item.value">
+                    <el-select v-model="dispatch.lawEnforcer" placeholder="璇烽�夋嫨浜哄憳"
+                        :disabled="personOptions.length !== 0 ? false:true" @change="handlePerChange">
+                        <el-option v-for="item in personOptions" :key="item.id" :label="item.username" :value="item.id">
                         </el-option>
                     </el-select>
                 </el-form-item>
@@ -55,11 +56,15 @@
                 <el-form-item label="鑱旂郴鏂瑰紡:" prop="contactWay">
                     <el-input v-model="dispatch.contactWay"></el-input>
                 </el-form-item>
-                <el-button type="primary" @click.native.prevent="handleDispatch">鍙戦�佺煭淇�</el-button>
+                <el-button type="primary">鍙戦�佺煭淇�</el-button>
             </div>
         </el-form>
         <div class="map">
             <!-- <MyMap></MyMap> -->
+        </div>
+        <div class="footer">
+            <el-button type="primary" @click="handleDispatch">纭畾</el-button>
+            <el-button @click="handleBack">杩斿洖</el-button>
         </div>
     </div>
 </template>
@@ -69,9 +74,11 @@
     components: {
         MyMap
     },
-    props: ['id','changeDialog'],
+    props: ['id', 'changeDialog', 'refresh', 'mytype'],
     created() {
-        console.log(this.id);
+        // 鍒ゆ柇杞﹁締绫诲瀷
+        this.mytype === 1 ? this.getLawCarList() : this.getSoilCarList();
+        this.getDepartList();
     },
     data() {
         const checkPhone = (rule, value, callback) => {
@@ -98,13 +105,6 @@
                 callback();
             } else {
                 callback(new Error('璺濈涓嶈兘涓虹┖'))
-            }
-        }
-        const checkCar = (rule, value, callback) => {
-            if (value) {
-                callback();
-            } else {
-                callback(new Error('鎵ф硶杞﹁締涓嶈兘涓虹┖'))
             }
         }
         const checkTeam = (rule, value, callback) => {
@@ -152,12 +152,9 @@
                 distance: [
                     { required: true, trigger: 'change', validator: checkDistance }
                 ],
-                enforcementCar: [
-                    { required: true, trigger: 'change', validator: checkCar }
-                ],
-                enforcementTeam: [
-                    { required: true, trigger: 'change', validator: checkTeam }
-                ],
+                // enforcementTeam: [
+                //     { required: true, trigger: 'change', validator: checkTeam }
+                // ],
                 lawEnforcer: [
                     { required: true, trigger: 'change', validator: checkPerson }
                 ],
@@ -176,14 +173,6 @@
                 },
             ],
             departOptions: [
-                {
-                    label: '閮ㄩ棬涓�',
-                    value: 1,
-                },
-                {
-                    label: '閮ㄩ棬浜�',
-                    value: 2,
-                },
             ],
             carOptions: [
                 {
@@ -196,24 +185,9 @@
                 },
             ],
             squadronOptions: [
-                {
-                    label: '涓槦涓�',
-                    value: 1,
-                },
-                {
-                    label: '涓槦浜�',
-                    value: 2,
-                },
             ],
             personOptions: [
-                {
-                    label: '浜哄憳涓�',
-                    value: 1,
-                },
-                {
-                    label: '浜哄憳浜�',
-                    value: 2,
-                },
+
             ],
         }
     },
@@ -224,27 +198,123 @@
             this.$refs.form.validate((valid) => {
                 console.log(valid);
                 if (valid) {
-                    const {dispatch,id} = this;
+                    const { dispatch, id } = this;
                     dispatch.disposeDate = new Date();
                     console.log(id);
                     dispatch.baseCaseId = id;
                     console.log(dispatch);
                     this.$axios({
-                        method:'post',
-                        url:`sccg/dispatch_handle/dispatch`,
-                        data:dispatch
+                        method: 'post',
+                        url: `sccg/dispatch_handle/dispatch`,
+                        data: dispatch
                     })
-                    .then(res=>{
-                        this.$message({
-                            type: res.code === 200 ? 'success':'error',
-                            message: res.code === 200 ? '璋冨害鎴愬姛':res.message,
+                        .then(res => {
+                            this.$message({
+                                type: res.code === 200 ? 'success' : 'error',
+                                message: res.code === 200 ? '璋冨害鎴愬姛' : res.message,
+                            })
+                            this.$emit('changeDialog', { flag: false });
+                            this.refresh();
                         })
-                        this.$emit('changeDialog',{dialogView:false});
-                    })
                 } else {
                     return false;
                 }
             })
+        },
+        // 鍙栨秷璋冨害
+        handleBack() {
+            this.$emit('changeDialog', { flag: false })
+        },
+        // 鑾峰彇鎵ф硶杞﹁締
+        getLawCarList() {
+            this.$axios({
+                method: 'get',
+                url: `sccg/car_Manage/query_enforce?current=1&size=1000`
+            })
+                .then(res => {
+                    this.carOptions = res.data.orders;
+                    console.log(res);
+                })
+        },
+        // 鑾峰彇娓e湡杞﹁締
+        getSoilCarList() {
+            this.$axios({
+                method: 'get',
+                url: `sccg/car_Manage/query_slag?current=1&size=1000`
+            })
+                .then(res => {
+                    this.carOptions = res.data.orders;
+                    console.log(res);
+                })
+        },
+        // 鑾峰彇椤剁骇閮ㄩ棬
+        getDepartList() {
+            this.$axios({
+                method: 'get',
+                url: `sccg/depart/query_father`,
+            })
+                .then(res => {
+                    this.departOptions = res.data;
+                })
+        },
+        // 鑾峰彇涓槦
+        async getTeamList(id) {
+            await this.$axios({
+                method: 'get',
+                url: `sccg/depart/query_father_children?fatherId=${id}`
+            })
+                .then(res => {
+                    this.squadronOptions = res.data;
+                })
+                .catch(err => {
+                    console.log(err);
+                })
+        },
+        // 鑾峰彇閮ㄩ棬涓嬬殑鐢ㄦ埛
+        async getDepartUserList(id) {
+            await this.$axios({
+                method: 'get',
+                url: `sccg/admin/getDepartUser/${id}`,
+            })
+                .then(res => {
+                    this.personOptions = res.data;
+                })
+                .catch(err => {
+                    this.$message({
+                    type: 'error',
+                    message: '璇ラ儴闂ㄤ汉鍛樹笉瓒筹紝璇锋崲涓儴闂�'
+                })
+                })
+        },
+        // 閮ㄩ棬鏇存敼
+        async handleTopChange(id) {
+            this.dispatch.lawEnforcer = '';
+            this.dispatch.enforcementTeam = '';
+            await this.getTeamList(id);
+            await this.getDepartUserList(id);
+        },
+        // 涓槦鏇存敼
+        async handleMidChange(id) {
+            this.dispatch.lawEnforcer = '';
+            await this.getDepartUserList(id);
+        },
+        // 浜哄憳鏇存敼
+        async handlePerChange(id){
+            let obj =  await this.getLawUser(id);
+            this.dispatch.lawEnforcerName = obj.nickName;
+            this.dispatch.contactWay = obj.mobile;
+        },
+        // 鑾峰彇鎵ф硶浜哄憳淇℃伅
+        async getLawUser(id){
+            let obj = {}
+            await this.$axios({
+                method:'get',
+                url:`sccg/admin/${id}`
+            })
+            .then(res=>{
+                obj = res.data;
+            })
+            return obj;
         }
     }
 }
@@ -252,12 +322,15 @@
 <style lang="scss" scoped>
 .dispatch {
     padding: 50px 20px 10px;
-    .form-person{
+
+    .form-person {
         display: flex;
-        .person-item{
+
+        .person-item {
             margin-left: -100px;
         }
     }
+
     .form-footer {
         display: flex;
         align-items: center;
@@ -273,5 +346,11 @@
         height: 388px;
         width: 100%;
     }
+
+    .footer {
+        display: flex;
+        justify-content: flex-end;
+        padding: 10px 20px;
+    }
 }
 </style>
\ No newline at end of file

--
Gitblit v1.8.0