“dzb”
2022-10-17 0d7d6fc9a5c40ccc90190b0f24039ec1362f120f
src/components/dispatch/index.vue
@@ -22,8 +22,8 @@
            <!-- 选择人员 -->
            <div class="form-person">
                <!-- 部门 -->
                <el-form-item label="选择人员:" prop="dispatchOpinion">
                    <el-select v-model="dispatch.dispatchOpinion" placeholder="请选择部门" @change="handleTopChange">
                <el-form-item label="选择人员:" prop="createUser">
                    <el-select v-model="dispatch.createUser" placeholder="请选择部门" @change="handleTopChange">
                        <el-option v-for="item in departOptions" :key="item.id" :label="item.departName"
                            :value="item.id">
                        </el-option>
@@ -32,7 +32,7 @@
                <!-- 中队 -->
                <el-form-item prop="enforcementTeam" class="person-item">
                    <el-select v-model="dispatch.enforcementTeam" placeholder="选择中队"
                        :disabled="squadronOptions.length!==0?false:true" @change="handleMidChange">
                        :disabled="squadronOptions.length!==0 && squadronOptions?false:true" @change="handleMidChange">
                        <el-option v-for="item in squadronOptions" :key="item.id" :label="item.departName"
                            :value="item.id">
                        </el-option>
@@ -41,7 +41,7 @@
                <el-form-item prop='lawEnforcer' class="person-item">
                    <!-- 人员 -->
                    <el-select v-model="dispatch.lawEnforcer" placeholder="请选择人员"
                        :disabled="personOptions.length !== 0 ? false:true" @change="handlePerChange">
                        :disabled="personOptions.length !== 0 && personOptions? false:true" @change="handlePerChange">
                        <el-option v-for="item in personOptions" :key="item.id" :label="item.username" :value="item.id">
                        </el-option>
                    </el-select>
@@ -50,13 +50,22 @@
            <div class="form-footer">
                <!-- 执法人员编号 -->
                <el-form-item label="执法人员编号:" prop="lawEnforcerName">
                    <el-input v-model="dispatch.lawEnforcerName"></el-input>
                    <el-input v-model="dispatch.lawEnforcerName" disabled></el-input>
                </el-form-item>
                <!-- 执法人员联系方式 -->
                <el-form-item label="联系方式:" prop="contactWay">
                    <el-input v-model="dispatch.contactWay"></el-input>
                    <el-input v-model="dispatch.contactWay" disabled></el-input>
                </el-form-item>
                <el-button type="primary">发送短信</el-button>
            </div>
            <div class="form-time">
                <el-form-item label="派遣意见" prop="dispatchOpinion">
                    <el-input v-model="dispatch.dispatchOpinion" placeholder="请输入派遣意见"></el-input>
                </el-form-item>
                <el-form-item label="处置日期" prop="disposeDate">
                    <el-date-picker v-model="dispatch.disposeDate" type="datetime" placeholder="选择日期时间">
                    </el-date-picker>
                </el-form-item>
            </div>
        </el-form>
        <div class="map">
@@ -74,7 +83,7 @@
    components: {
        MyMap
    },
    props: ['id', 'changeDialog', 'refresh', 'mytype'],
    props: ['id', 'changeDialog', 'refresh', 'mytype'],
    created() {
        // 判断车辆类型
        this.mytype === 1 ? this.getLawCarList() : this.getSoilCarList();
@@ -90,14 +99,14 @@
                    callback();
                }
            } else {
                callback(new Error('联系方式不能为空'))
                callback()
            }
        }
        const checkOpinion = (rule, value, callback) => {
            if (value) {
                callback();
            } else {
                callback(new Error('部门不能为空'))
                callback(new Error('派遣意见不能为空'))
            }
        }
        const checkDistance = (rule, value, callback) => {
@@ -111,7 +120,7 @@
            if (value) {
                callback();
            } else {
                callback(new Error('中队不能为空'))
                callback(new Error('处置日期不能为空'))
            }
        }
        const checkPerson = (rule, value, callback) => {
@@ -128,19 +137,32 @@
                callback()
            }
        }
        const checkDepart = (rule, value, callback) => {
            if (value) {
                callback();
            } else {
                callback(new Error('请选择部门'))
            }
        }
        return {
            dispatch: {
                baseCaseId: 0,//案件id
                contactWay: "",//联系方式
                dispatchOpinion: "",//部门
                dispatchOpinion: "",//处置意见
                disposeDate: "",//处置日期
                distance: 0,//距离
                enforcementCar: '',//执法车
                enforcementTeam: "",//执法中队
                lawEnforcer: '',//执法人员
                lawEnforcerName: ""//执法编号
                lawEnforcerName: "",//执法编号,
                createUser: null,
            },
            rules: {
                createUser: [
                    {
                        required: true, trigger: 'change', validator: checkDepart
                    }
                ],
                contactWay: [
                    {
                        required: false, trigger: 'blur', validator: checkPhone
@@ -161,6 +183,11 @@
                lawEnforcerName: [
                    { required: false, trigger: 'change', validator: checkNumber }
                ],
                disposeDate: [
                    {
                        required: true, trigger: 'false', validator: checkTeam
                    }
                ]
            },
            carOptions: [
                {
@@ -233,7 +260,7 @@
            })
                .then(res => {
                    this.carOptions = res.data.records;
                    console.log(res,this.carOptions);
                    console.log(res, this.carOptions);
                })
        },
        // 获取渣土车辆
@@ -259,6 +286,7 @@
        },
        // 获取中队
        async getTeamList(id) {
            console.log(id);
            await this.$axios({
                method: 'get',
                url: `sccg/depart/query_father_children?fatherId=${id}`
@@ -272,52 +300,83 @@
        },
        // 获取部门下的用户
        async getDepartUserList(id) {
            console.log(id);
            await this.$axios({
                method: 'get',
                url: `sccg/admin/getDepartUser/${id}`,
            })
                .then(res => {
                    this.personOptions = res.data;
                    console.log(res);
                    if (res.code === 200) {
                        this.personOptions = res.data;
                    } else {
                        this.personOptions = [];
                    }
                    if(this.personOptions.length === 0){
                        this.$message({
                            type: 'warning',
                            message: '该中队下没有人员'
                        })
                    }
                })
                .catch(err => {
                    this.$message({
                    type: 'error',
                    message: '该部门人员不足,请换个部门'
                })
                        type: 'error',
                        message: '该部门人员不足,请换个部门'
                    })
                })
        },
        // 部门更改
        async handleTopChange(id) {
            this.dispatch.lawEnforcer = '';
            this.dispatch.enforcementTeam = '';
            this.dispatch.contactWay = '';
            this.dispatch.lawEnforcerName = '';
            await this.getTeamList(id);
            if(this.squadronOptions.length===0){
                await this.getDepartUserList(id);
            }
            // if (this.squadronOptions.length === 0) {
            //     await this.getDepartUserList(id);
            // }
        },
        // 中队更改
        async handleMidChange(id) {
            this.dispatch.lawEnforcer = '';
            this.dispatch.contactWay = '';
            this.dispatch.lawEnforcerName = '';
            await this.getDepartUserList(id);
        },
        // 人员更改
        async handlePerChange(id){
            let obj =  await this.getLawUser(id);
        async handlePerChange(id) {
            let obj = await this.getLawUser(id);
            this.dispatch.lawEnforcerName = obj.nickName;
            this.dispatch.contactWay = obj.mobile;
        },
        // 获取执法人员信息
        async getLawUser(id){
        async getLawUser(id) {
            let obj = {}
            await this.$axios({
                method:'get',
                url:`sccg/admin/${id}`
                method: 'get',
                url: `sccg/admin/${id}`
            })
            .then(res=>{
                obj = res.data;
            })
                .then(res => {
                    obj = res.data;
                })
            return obj;
        }
    },
    watch: {
        'squadronOptions.length': {
            handler(newval, oldval) {
                console.log(newval);
                if (newval === 0) {
                    console.log(1);
                    this.$message({
                        type: 'warning',
                        message: '该部门下没有中队'
                    })
                }
            },
            deep: true
        },
    }
}
</script>