lct
Your Name
2022-08-20 52cdea9a329e0835fc30ef8c3ebb7263658cf38d
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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
<template>
    <div class="home-container">
        <div style="height: 100%">
        <el-form :model="form" label-width="150px" :rules="applyRules" ref="ruleFormRef">
            <div class="homeCard">
            <el-row>
                <el-col :span="12">
                    <el-form-item label="作业人" prop="operatorUids">
                        <el-select v-model="form.operatorUids" multiple>
                            <el-option
                                    v-for="item in workerList"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                            />
                        </el-select>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <el-form-item label="作业时间" prop="workTimeLine">
                        <el-date-picker
                                v-model="form.workTimeLine"
                                format="YYYY-MM-DD HH:mm"
                                value-format="YYYY-MM-DD HH:mm:00"
                                type="datetimerange"
                                range-separator="至"
                                start-placeholder="开始时间"
                                end-placeholder="结束时间"
                        />
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <el-form-item label="作业内容" prop="workContent">
                        <el-input
                                v-model="form.workContent"
                                autosize
                                type="textarea"
                                placeholder="请输入作业内容"
                        />
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="作业地址" prop="workLocation">
                        <el-input
                                v-model="form.workLocation"
                                autosize
                                type="textarea"
                                placeholder="请输入作业地址"
                        />
                    </el-form-item>
                </el-col>
            </el-row>
 
 
            <el-row>
                <el-col :span="12">
                    <el-form-item label="作业单位" prop="workDetail.operationDepId">
                        <el-select v-model="form.workDetail.operationDepId">
                            <el-option
                                    v-for="item in csDepList"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                            />
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="断路原因" prop="workDetail.bcReason">
                        <el-input
                                v-model="form.workDetail.bcReason"
                                autosize
                                type="textarea"
                                placeholder="请输入"
                        />
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <el-form-item label="断路地段说明" prop="workDetail.bcExplain">
                        <el-input
                                v-model="form.workDetail.bcExplain"
                                autosize
                                type="textarea"
                                placeholder="请输入"
                        />
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="涉及相关部门" prop="workDetail.involvedDepIds">
                        <el-select v-model="form.workDetail.involvedDepIds" multiple>
                            <el-option v-for="item in otherWorkList" :key="item.value" :label="item.label" :value="item.value" />
                        </el-select>
                    </el-form-item>
                </el-col>
            </el-row>
            </div>
        </el-form>
        <div class="applyBtn">
            <el-button type="primary" size="large" plain @click="submitForm(ruleFormRef)">发起申请</el-button>
        </div>
    </div>
    </div>
</template>
 
<script lang="ts">
    import { toRefs, reactive, defineComponent, ref, defineAsyncComponent } from 'vue';
    import { storeToRefs } from 'pinia';
    import { initBackEndControlRoutes } from '/@/router/backEnd';
    import {useUserInfo} from "/@/stores/userInfo";
    import { Session } from '/@/utils/storage';
    import { Search } from '@element-plus/icons-vue'
    import { ElMessage } from 'element-plus'
    import type { FormInstance, FormRules } from 'element-plus'
    import { workApplyApi } from '/@/api/specialWorkSystem/workApply';
 
 
    interface stateType {
        form: Object,
        workerList: Array<any>,
        csDepList: Array<any>,
        otherWorkList: Array<any>
    }
    export default defineComponent({
        name: 'brokenForm',
        components: {},
        setup() {
            const userInfo = useUserInfo()
            const { userInfos } = storeToRefs(userInfo);
            const state  = reactive<stateType>({
                form: {
                    operatorUids: [],
                    workType: 5,
                    workLevel: 0,
                    workContent: '',
                    workLocation: '',
                    workDetail:{
                        operationDepId: null,
                        bcReason: '',
                        bcExplain: '',
                        bcPath: '',
                        involvedDepIds: []
                    },
                    workTimeLine: [],
                    expStartTime: '',
                    expEndTime: ''
                },
                workerList:[
                    {
                        label: "张三",
                        value: 53
                    },
                    {
                        label: "李四",
                        value: 54
                    },
                    {
                        label: "测试一",
                        value: 55
                    },
                    {
                        label: "测试二",
                        value: 56
                    }
                ],
                csDepList: [
                    {
                        label: "单位一",
                        value: 1
                    },
                    {
                        label: "单位二",
                        value: 2
                    },
                    {
                        label: "单位三",
                        value: 3
                    },
                    {
                        label: "单位四",
                        value: 4
                    },
                    {
                        label: "单位五",
                        value: 5
                    },
                    {
                        label: "单位六",
                        value: 6
                    }
                ],
                otherWorkList: [
                    {
                        label: '部门一',
                        value: 1
                    },
                    {
                        label: '部门二',
                        value: 2
                    },
                    {
                        label: '部门三',
                        value: 3
                    },
                    {
                        label: '部门四',
                        value: 4
                    }
                ]
            });
            const ruleFormRef = ref<FormInstance>()
            const applyRules = reactive<FormRules>({
                operatorUids: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                workType: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                workContent: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                workLocation: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                workTimeLine: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                "workDetail.operationDepId": [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                "workDetail.bcReason": [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                "workDetail.bcExplain": [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                "workDetail.otherSpecialWork": [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                "workDetail.involvedDepIds": [{ required: true, message: '该内容不能为空', trigger: 'blur' }]
            });
            const submitForm = async (formEl: FormInstance | undefined) => {
                if (!formEl) return
                await formEl.validate(async (valid, fields) => {
                    if (valid) {
                        state.form.expStartTime = JSON.parse(JSON.stringify(state.form.workTimeLine))[0]
                        state.form.expEndTime = JSON.parse(JSON.stringify(state.form.workTimeLine))[1]
                        let { workTimeLine, ...data } = JSON.parse(JSON.stringify(state.form))
                        data.workDetail.involvedDepIds = data.workDetail.involvedDepIds.join(',')
                        console.log(data,'data')
                        const res = await workApplyApi().postBrokenApply(data)
                        if (res.data.code === '200') {
                                ElMessage({
                                    type: 'success',
                                    message: '提交成功!'
                                });
                                formEl.resetFields()
                        } else {
                            ElMessage({
                                type: 'warning',
                                message: res.data.msg
                            });
                        }
                    } else {
                        console.log('error submit!', fields)
                    }
                })
            }
            // 折线图
            const renderMenu = async (value: string) => {
                Session.set('projectId',value)
                userInfos.value.projectId = value
                await initBackEndControlRoutes();
            };
            return {
                renderMenu,
                Search,
                ruleFormRef,
                applyRules,
                submitForm,
                ...toRefs(state),
            };
        },
    });
</script>
 
<style scoped lang="scss">
    .home-container {
        height: 100%;
        overflow: hidden;
        position: relative;
        .homeCard{
            width: 100%;
            padding: 20px;
            box-sizing: border-box;
            background: #fff;
            border-radius: 4px;
            margin-bottom: 20px;
        }
        .applyBtn{
            width: 100%;
            background: #fff;
            height: 80px;
            z-index: 5;
            box-shadow: 0 -3px 8px rgba(150,150,150,.1);
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .el-row{
            margin-bottom: 20px;
        }
        .el-row:last-child {
            margin-bottom: 0;
        }
        .el-input{
            width: 100% !important;
        }
        .el-date-editor::v-deep{
            width: 100%;
        }
        .el-select{
            width: 100%;
        }
        .el-cascader{
            width: 100% !important;
        }
    }
</style>