Your Name
2022-08-03 6e1be6afed910d217199278bb3f89d8922dfc5af
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
<template>
    <div class="system-add-menu-container">
        <el-dialog :title="title" v-model="isShowRectifyDialog" width="600px">
            <el-form :model="rectifyForm" :rules="rectifyFormRules" ref="rectifyFormRef" 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="rectifyInfo">
                            <el-input class="input-add" type="textarea" :rows="2" v-model.trim="rectifyForm.rectifyInfo" placeholder="请输入整改说明" clearable></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="applyTime">
                            <el-date-picker type="datetime" value-format="YYYY-MM-DD HH:mm:ss" class="input-add" v-model="rectifyForm.applyTime" placeholder="请选择整改时间" clearable> </el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <template #footer>
                <span class="dialog-footer">
                    <el-button @click="isShowRectifyDialog = !isShowRectifyDialog" size="default">取 消</el-button>
                    <el-button type="primary" @click="submitRectify" v-throttle size="default">确 定</el-button>
                </span>
            </template>
        </el-dialog>
        <el-dialog :title="title" v-model="isShowDelayDialog" width="600px">
            <el-form :model="delayForm" :rules="delayFormRules" ref="rectifyFormRef" 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="timeOutDesc">
                            <el-input class="input-add" type="textarea" :rows="2" v-model.trim="delayForm.timeOutDesc" placeholder="请输入延期说明" clearable></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="rectifyTime">
                            <el-date-picker type="datetime" value-format="YYYY-MM-DD HH:mm:ss" class="input-add" v-model="delayForm.rectifyTime" placeholder="请选择整改期限" clearable> </el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <template #footer>
                <span class="dialog-footer" v-show="disabled">
                    <el-button @click="isShowDelayDialog = !isShowDelayDialog" size="default">取 消</el-button>
                    <el-button type="primary" @click="submitDelay" v-throttle size="default">确 定</el-button>
                </span>
            </template>
        </el-dialog>
        <el-dialog :title="title" v-model="isShowCheckInfoDialog" width="600px">
            <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" 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" 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 @change="achieveUserList" :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" 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" type="number" v-model="checkInfoForm.cost" readonly> </el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
        </el-dialog>
    </div>
</template>
 
<script lang="ts">
import { getUserByDepartment } from '/@/assets/methods';
 
interface stateType {
    disabled: Boolean;
    isShowRectifyDialog: Boolean;
    isShowDelayDialog: Boolean;
    isShowCheckInfoDialog: Boolean;
    rectifyForm: {
        id: number | null;
        dangerManagerId: number | null;
        rectifyInfo: string | null;
        applyTime: string | null;
    };
    delayForm: {
        id: number | null;
        dangerManagerId: number | null;
        rectifyTime: string | null;
        timeOutDesc: string | null;
    };
    title: string;
    departmentList: [];
    userList: [];
    rectifyTypeList: Array<rectifyTypeState>;
    rectifyFormRules: {};
    delayFormRules: {};
    checkInfoForm: {
        rectifyDepId: number | null;
        liablePersonId: number | null;
    };
}
interface rectifyTypeState {
    regionType: string;
    id: number;
}
 
import { reactive, toRefs, ref } from 'vue';
import { ElMessage } from 'element-plus';
import { hiddenRectifyApi } from '/@/api/doublePreventSystem/rectify';
export default {
    name: 'rectifyDialog',
    setup(props: any, context: any) {
        const rectifyFormRef = ref();
        const state = reactive<stateType>({
            title: '',
            disabled: false,
            rectifyTypeList: [],
            departmentList: [],
            userList: [],
            isShowCheckInfoDialog: false,
            checkInfoForm: {
                rectifyDepId: null,
                liablePersonId: null
            },
            isShowDelayDialog: false,
            isShowRectifyDialog: false,
            rectifyForm: {
                id: null,
                dangerManagerId: null,
                rectifyInfo: null,
                applyTime: null
            },
            delayForm: {
                id: null,
                dangerManagerId: null,
                rectifyTime: null,
                timeOutDesc: null
            },
            rectifyFormRules: {
                rectifyInfo: [{ required: true, message: '请填写整改说明', trigger: 'blur' }],
                applyTime: [{ required: true, message: '请选择整改时间', trigger: 'change' }]
            },
            delayFormRules: {
                timeOutDesc: [{ required: true, message: '请填写延期说明', trigger: 'blur' }],
                rectifyTime: [{ required: true, message: '请选择整改期限', trigger: 'change' }]
            }
        });
 
        //打开模态框
        const openRectifyDialog = async (type: string, value: object, departmentList: []) => {
            state.departmentList = departmentList;
            if (type === '延期') {
                state.title = '延期';
                state.disabled = true;
                state.isShowDelayDialog = true;
                const delayForm = JSON.parse(JSON.stringify(value));
                state.delayForm.id = delayForm.id;
                state.delayForm.dangerManagerId = delayForm.dangerManagerId;
                state.delayForm.timeOutDesc = null;
                state.delayForm.rectifyTime = null;
            } else if (type === '查看') {
                state.title = '查看';
                state.isShowCheckInfoDialog = true;
                state.checkInfoForm.rectifyDepId = JSON.parse(JSON.stringify(value)).rectifyDepId;
                await achieveUserList();
                state.checkInfoForm = JSON.parse(JSON.stringify(value));
            } else {
                state.disabled = true;
                state.title = '整改';
                state.isShowRectifyDialog = true;
                const rectifyForm = JSON.parse(JSON.stringify(value));
                state.rectifyForm.id = rectifyForm.id;
                state.rectifyForm.dangerManagerId = rectifyForm.dangerManagerId;
                state.rectifyForm.rectifyInfo = null;
                state.rectifyForm.applyTime = null;
            }
        };
 
        //提交整改
        const submitRectify = async () => {
            rectifyFormRef.value.validate(async (valid: Boolean) => {
                if (valid) {
                    let res = await hiddenRectifyApi().submitHiddenRectify(state.rectifyForm);
                    if (res.data.code === '200') {
                        ElMessage({
                            type: 'success',
                            message: '整改提交成功',
                            duration: 2000
                        });
                        state.isShowRectifyDialog = false;
                        context.emit('refreshRectify');
                    } else {
                        ElMessage({
                            type: 'warning',
                            message: res.data.msg
                        });
                    }
                } else {
                    ElMessage({
                        type: 'warning',
                        message: '请完善基本信息'
                    });
                }
            });
        };
 
        //提交延期
        const submitDelay = async () => {
            rectifyFormRef.value.validate(async (valid: Boolean) => {
                if (valid) {
                    let res = await hiddenRectifyApi().delayHiddenRectifyTime(state.delayForm);
                    if (res.data.code === '200') {
                        ElMessage({
                            type: 'success',
                            message: '隐患延期成功',
                            duration: 2000
                        });
                        state.isShowDelayDialog = false;
                        context.emit('refreshRectify');
                    } 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),
            rectifyFormRef,
            submitDelay,
            achieveUserList,
            submitRectify,
            openRectifyDialog
        };
    }
};
</script>
 
<style scoped></style>