lct
Your Name
2022-08-12 965f7a2479a2cf7c1c56fb298e7fbb855c89e212
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<template>
    <div class="system-add-menu-container">
        <el-dialog :title="title" v-model="isShowCheckDialog" width="600px" :close-on-click-modal="false">
            <el-form :model="checkForm" :rules="checkFormRules" ref="checkFormRef" size="default" label-width="120px">
                <el-row :gutter="35">
                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
                        <el-form-item label="验收意见" prop="checkInfo">
                            <el-input class="input-add" type="textarea" :rows="2" v-model.trim="checkForm.checkAcceptDesc" placeholder="请输入验收意见" clearable></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <template #footer>
                <span class="dialog-footer">
                    <el-button @click="isShowCheckDialog = !isShowCheckDialog" size="default">取 消</el-button>
                    <el-button type="primary" @click="submitCheck" v-throttle size="default">确 定</el-button>
                </span>
            </template>
        </el-dialog>
        <el-dialog :title="title" v-model="isShowCheckInfoDialog" width="600px" :close-on-click-modal="false">
            <el-form :model="checkInfoForm" ref="checkFormRef" size="default" label-width="120px">
                <el-row :gutter="35">
                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
                        <el-form-item label="验收意见" prop="rectifyDesc">
                            <el-input class="input-add" :disabled="true" type="textarea" :rows="2" v-model.trim="checkInfoForm.rectifyDesc" readonly></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
                        <el-form-item label="整改类型" prop="rectifyType">
                            <el-select class="input-add" :disabled="true" v-model="checkInfoForm.rectifyType" readonly>
                                <el-option v-for="item in rectifyTypeList" :key="item.id" :label="item.name" :value="item.id"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
                        <el-form-item label="整改部门" prop="rectifyDepId">
                            <el-cascader :disabled="true" :options="departmentList" :props="{ emitPath: false, checkStrictly: true, value: 'depId', label: 'depName' }" placeholder="请选择部门" clearable filterable class="input-add" v-model="checkInfoForm.rectifyDepId" readonly> </el-cascader>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
                        <el-form-item label="整改责任人" prop="liablePersonId">
                            <el-select class="input-add" :disabled="true" v-model="checkInfoForm.liablePersonId" clearable filterable readonly>
                                <el-option v-for="item in userList" :key="item.uid" :label="item.username" :value="item.uid"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
 
                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
                        <el-form-item label="整改资金" prop="dangerResult">
                            <el-input class="input-add" :disabled="true" type="number" v-model="checkInfoForm.cost" readonly> </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
                        <el-form-item label="验收人" prop="checkAcceptPerson">
                            <el-input class="input-add" :disabled="true" v-model="checkInfoForm.checkAcceptPerson" readonly />
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
        </el-dialog>
    </div>
</template>
 
<script lang="ts">
import { getUserByDepartment } from '/@/assets/methods';
 
interface stateType {
    isShowCheckDialog: Boolean;
    isShowCheckInfoDialog: Boolean;
    checkForm: {
        id: number | null;
        dangerManagerId: number | null;
        checkAcceptDesc: string | null;
    };
    departmentList: [];
    userList: [];
    rectifyTypeList: Array<rectifyType>;
    checkInfoForm: {
        rectifyDepId: number | null;
        liablePersonId: number | null;
    };
    title: string;
    checkTypeList: Array<checkTypeState>;
    checkFormRules: {};
}
interface checkTypeState {
    regionType: string;
    id: number;
}
 
interface rectifyType {
    id: number;
    name: string;
}
 
import { reactive, toRefs, ref } from 'vue';
import { ElMessage } from 'element-plus';
import { hiddenCheckApi } from '/@/api/doublePreventSystem/check';
export default {
    name: 'hiddenCheckDialog',
    setup(props: any, context: any) {
        const checkFormRef = ref();
        const state = reactive<stateType>({
            title: '',
            checkTypeList: [],
            rectifyTypeList: [
                { id: 1, name: '即查即改' },
                { id: 2, name: '限期整改' }
            ],
            departmentList: [],
            userList: [],
            isShowCheckDialog: false,
            isShowCheckInfoDialog: false,
            checkForm: {
                id: null,
                dangerManagerId: null,
                checkAcceptDesc: null
            },
            checkInfoForm: {
                rectifyDepId: null,
                liablePersonId: null
            },
            checkFormRules: {
                checkAcceptDesc: [{ required: true, message: '请填写整改说明', trigger: 'blur' }]
            }
        });
 
        //打开模态框
        const openCheckDialog = async (type: string, value: object, departmentList: []) => {
            state.departmentList = departmentList;
            if (type === '验收') {
                state.title = '验收';
                state.isShowCheckDialog = true;
                const checkForm = JSON.parse(JSON.stringify(value));
                state.checkForm.id = checkForm.id;
                state.checkForm.dangerManagerId = checkForm.dangerManagerId;
            } else {
                state.title = '查看';
                state.isShowCheckInfoDialog = true;
                state.checkInfoForm.rectifyDepId = JSON.parse(JSON.stringify(value)).rectifyDepId;
                await achieveUserList();
                state.checkInfoForm = JSON.parse(JSON.stringify(value));
            }
        };
 
        //提交整改
        const submitCheck = async () => {
            checkFormRef.value.validate(async (valid: Boolean) => {
                if (valid) {
                    let res = await hiddenCheckApi().submitHiddenCheck(state.checkForm);
                    if (res.data.code === '200') {
                        ElMessage({
                            type: 'success',
                            message: '整改提交成功',
                            duration: 2000
                        });
                        state.isShowCheckDialog = false;
                        context.emit('refreshCheck');
                    } else {
                        ElMessage({
                            type: 'warning',
                            message: res.data.msg
                        });
                    }
                } else {
                    ElMessage({
                        type: 'warning',
                        message: '请完善基本信息'
                    });
                }
            });
        };
 
        const achieveUserList = async () => {
            state.checkInfoForm.liablePersonId = null;
            const user: unknown = await getUserByDepartment(state.checkInfoForm.rectifyDepId);
            state.userList = user as [];
        };
 
        return {
            ...toRefs(state),
            checkFormRef,
            submitCheck,
            openCheckDialog
        };
    }
};
</script>
 
<style scoped>
:deep(.el-textarea.is-disabled .el-textarea__inner) {
    background-color: var(--el-card-bg-color);
    color: var(--el-input-text-color, var(--el-text-color-regular));
}
:deep(.el-input.is-disabled .el-input__inner) {
    color: var(--el-input-text-color, var(--el-text-color-regular));
}
:deep(.el-input.is-disabled .el-input__wrapper) {
    background-color: var(--el-card-bg-color);
}
</style>