“dzb”
2022-10-10 676722551d0bc2f8caa0644961e60deef3f0d532
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,
                },
            ],
        }
    },
@@ -254,6 +224,93 @@
        // 取消调度
        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){
            await this.getLawUser(id);
        },
        // 获取执法人员信息
        async getLawUser(id){
            await this.$axios({
                method:'get',
                url:`sccg/admin/${id}`
            })
            .then(res=>{
                console.log(res);
            })
        }
    }
}
@@ -261,12 +318,15 @@
<style lang="scss" scoped>
.dispatch {
    padding: 50px 20px 10px;
    .form-person{
        display: flex;
        .person-item{
            margin-left: -100px;
        }
    }
    .form-footer {
        display: flex;
        align-items: center;
@@ -282,6 +342,7 @@
        height: 388px;
        width: 100%;
    }
    .footer{
        display: flex;
        justify-content: flex-end;