“dzb”
2022-10-11 387e8b0743240de72425e5b5c5709d629ace9aa4
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>
@@ -59,7 +60,7 @@
            </div>
        </el-form>
        <div class="map">
            <MyMap></MyMap>
            <!-- <MyMap></MyMap> -->
        </div>
        <div class="footer">
            <el-button type="primary" @click="handleDispatch">确定</el-button>
@@ -73,9 +74,11 @@
    components: {
        MyMap
    },
    props: ['id','changeDialog','refresh'],
    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) => {
@@ -102,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) => {
@@ -156,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 }
                ],
@@ -180,14 +173,6 @@
                },
            ],
            departOptions: [
                {
                    label: '部门一',
                    value: 1,
                },
                {
                    label: '部门二',
                    value: 2,
                },
            ],
            carOptions: [
                {
@@ -200,24 +185,9 @@
                },
            ],
            squadronOptions: [
                {
                    label: '中队一',
                    value: 1,
                },
                {
                    label: '中队二',
                    value: 2,
                },
            ],
            personOptions: [
                {
                    label: '人员一',
                    value: 1,
                },
                {
                    label: '人员二',
                    value: 2,
                },
            ],
        }
    },
@@ -228,32 +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',{flag:false});
                        this.refresh();
                    })
                } else {
                    return false;
                }
            })
        },
        // 取消调度
        handleBack(){
            this.$emit('changeDialog',{flag: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);
                })
        },
        // 获取渣土车辆
        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;
        }
    }
}
@@ -261,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;
@@ -282,7 +346,8 @@
        height: 388px;
        width: 100%;
    }
    .footer{
    .footer {
        display: flex;
        justify-content: flex-end;
        padding: 10px 20px;