|
@@ -7,12 +7,20 @@
|
7
|
7
|
<Input title="隐患名称" :verify="true" v-model="addForm.dangerName" />
|
8
|
8
|
<Input title="隐患描述" :verify="false" v-model="dangerDesc" />
|
9
|
9
|
<Select
|
|
10
|
+ :disable="dangerType"
|
10
|
11
|
:verify="true"
|
11
|
12
|
title="所在区域"
|
12
|
13
|
:options="getAreaTree"
|
13
|
14
|
v-model="addForm.areaId"
|
14
|
15
|
/>
|
15
|
16
|
<Select
|
|
17
|
+ :disable="dangerType"
|
|
18
|
+ :verify="true"
|
|
19
|
+ title="分析对象名称"
|
|
20
|
+ :options="getAreaTree1"
|
|
21
|
+ v-model="addForm.hazardId"
|
|
22
|
+ />
|
|
23
|
+ <Select
|
16
|
24
|
:verify="true"
|
17
|
25
|
title="隐患来源"
|
18
|
26
|
:options="dangerSrcList"
|
|
@@ -75,7 +83,8 @@ import {
|
75
|
83
|
upload,
|
76
|
84
|
getDangerItem,
|
77
|
85
|
editDanger,
|
78
|
|
- convertImageToBase64Str
|
|
86
|
+ convertImageToBase64Str,
|
|
87
|
+ getHazardList
|
79
|
88
|
} from '@/api/danger'
|
80
|
89
|
export default {
|
81
|
90
|
name: 'Vueh5CbsAddDanger',
|
|
@@ -100,8 +109,24 @@ export default {
|
100
|
109
|
return new Date(2010, 0, 1)
|
101
|
110
|
}
|
102
|
111
|
},
|
|
112
|
+ watch: {
|
|
113
|
+ addForm: {
|
|
114
|
+ handler (val) {
|
|
115
|
+ if (val.areaId && (val.areaId !== this.areaIdOld)) {
|
|
116
|
+ console.log('进来了', val.areaId, this.areaIdOld)
|
|
117
|
+ this.getHazardList(val.areaId)
|
|
118
|
+ this.areaIdOld = val.areaId
|
|
119
|
+ }
|
|
120
|
+ },
|
|
121
|
+ deep: true,
|
|
122
|
+ immediate: true
|
|
123
|
+ }
|
|
124
|
+ },
|
103
|
125
|
data () {
|
104
|
126
|
return {
|
|
127
|
+ areaIdOld: '.',
|
|
128
|
+ dangerType: false,
|
|
129
|
+ getAreaTree1: [], // 分析对象名称列表
|
105
|
130
|
dangerImage: '',
|
106
|
131
|
dangerDesc: '', // 隐患描述
|
107
|
132
|
controlMeasures: '', // 任务名称
|
|
@@ -111,6 +136,7 @@ export default {
|
111
|
136
|
registTime: '', // 发现时间
|
112
|
137
|
dangerName: '', // 隐患名称
|
113
|
138
|
areaId: '', // 所属区域
|
|
139
|
+ hazardId: '', // 分析对象名称
|
114
|
140
|
dangerLevel: 0, // 隐患等级
|
115
|
141
|
dangerSrc: '', // 隐患来源
|
116
|
142
|
hazardDangerType: '', // 隐患类型
|
|
@@ -143,10 +169,17 @@ export default {
|
143
|
169
|
}
|
144
|
170
|
},
|
145
|
171
|
|
146
|
|
- created () {
|
|
172
|
+ async created () {
|
147
|
173
|
console.log(new Date('2023-09-25 15:55:12').getDate())
|
148
|
174
|
if (this.$route.params.id) {
|
149
|
|
- this.addForm.areaId = this.$route.params.id
|
|
175
|
+ this.dangerType = true
|
|
176
|
+ this.getAreaTree1 = this.$route.params.list
|
|
177
|
+ this.addForm.areaId = this.$route.params.areaId
|
|
178
|
+ this.areaIdOld = this.$route.params.areaId
|
|
179
|
+ this.addForm.hazardId = this.$route.params.hazardId
|
|
180
|
+ // await this.getHazardList(this.$route.params.areaId)
|
|
181
|
+ console.log(this.addForm.hazardId, '第一个')
|
|
182
|
+ console.log(this.addForm.areaId, '第二个')
|
150
|
183
|
}
|
151
|
184
|
if (this.$route.query.id) {
|
152
|
185
|
getDangerItem(this.$route.query.id).then(({ data }) => {
|
|
@@ -158,6 +191,7 @@ export default {
|
158
|
191
|
this.addForm.registTime = data.data.registTime
|
159
|
192
|
this.addForm.dangerName = data.data.dangerName
|
160
|
193
|
this.addForm.areaId = data.data.areaId
|
|
194
|
+ this.addForm.hazardId = data.data.hazardId
|
161
|
195
|
this.addForm.dangerLevel = data.data.dangerLevel
|
162
|
196
|
this.addForm.dangerSrc = data.data.dangerSrc
|
163
|
197
|
this.addForm.hazardDangerType = data.data.hazardDangerType
|
|
@@ -180,6 +214,19 @@ export default {
|
180
|
214
|
},
|
181
|
215
|
|
182
|
216
|
methods: {
|
|
217
|
+ getHazardList (id) {
|
|
218
|
+ getHazardList({ areaId: id }).then(({ data }) => {
|
|
219
|
+ if (data.code === 200) {
|
|
220
|
+ this.getAreaTree1 = this.getUsers(data.data)
|
|
221
|
+ this.addForm.hazardId = ''
|
|
222
|
+ }
|
|
223
|
+ })
|
|
224
|
+ },
|
|
225
|
+ getUsers (data) {
|
|
226
|
+ return data.map(item => {
|
|
227
|
+ return { text: item.hazardName, value: item.id }
|
|
228
|
+ })
|
|
229
|
+ },
|
183
|
230
|
async toBase (list) {
|
184
|
231
|
for await (const item of list) {
|
185
|
232
|
const { data } = await convertImageToBase64Str({ url: item })
|
|
@@ -246,6 +293,7 @@ export default {
|
246
|
293
|
this.itemForm.registTime = this.addForm.registTime
|
247
|
294
|
this.itemForm.dangerName = this.addForm.dangerName
|
248
|
295
|
this.itemForm.areaId = this.addForm.areaId
|
|
296
|
+ this.itemForm.hazardId = this.addForm.hazardId
|
249
|
297
|
this.itemForm.dangerLevel = this.addForm.dangerLevel
|
250
|
298
|
this.itemForm.dangerSrc = this.addForm.dangerSrc
|
251
|
299
|
this.itemForm.hazardDangerType = this.addForm.hazardDangerType
|
|
@@ -266,7 +314,10 @@ export default {
|
266
|
314
|
})
|
267
|
315
|
} else {
|
268
|
316
|
addDanger({
|
|
317
|
+ riskMeasureId: this.$route.params.riskMeasureId || '',
|
|
318
|
+ checkTaskInventoryRecordId: this.$route.params.id || '',
|
269
|
319
|
areaId: this.addForm.areaId,
|
|
320
|
+ hazardId: this.addForm.hazardId,
|
270
|
321
|
controlMeasures: this.controlMeasures,
|
271
|
322
|
dangerDesc: this.dangerDesc,
|
272
|
323
|
dangerImage: this.dangerImage,
|