gaoluyang
2025-04-17 481ce9ffb9396cdd8c48bf9b28dffe228b83bc9e
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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
<!-- 作业指导书 -->
<template>
  <div>
    <div style="margin: 10px 0;text-align: right">
      <el-button size="small" type="primary" @click="getList">刷新</el-button>
      <el-button size="small" type="primary" @click="dialogVisible = true">受控申请</el-button>
    </div>
    <el-table :data="tableData" border height="calc(100vh - 18em)"
              :header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }">
      <el-table-column type="index" label="序号" width="120">
        <template v-slot="scope">
          <span>{{ (search.current - 1) * search.size + scope.$index + 1 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="申请编号" min-width="150" prop="applicationNumber"></el-table-column>
      <el-table-column label="设备名称" min-width="150" prop="deviceName"></el-table-column>
      <el-table-column label="设备编号" min-width="150" prop="deviceNumber"></el-table-column>
      <el-table-column label="设备型号" min-width="150" prop="deviceModel"></el-table-column>
      <el-table-column label="文件编号" min-width="150" prop="documentNumber"></el-table-column>
      <el-table-column label="文件名字" min-width="150" prop="fileName"></el-table-column>
      <el-table-column label="文档说明" min-width="150" prop="documentNote"></el-table-column>
      <el-table-column label="上传人" min-width="150" prop="uploaderName"></el-table-column>
      <el-table-column label="上传时间" min-width="150" prop="updateTime"></el-table-column>
      <el-table-column label="生效时间" min-width="150" prop="entryIntoForceTime"></el-table-column>
      <el-table-column label="审批人" min-width="150" prop="approverName"></el-table-column>
      <el-table-column label="审批状态" min-width="150" prop="status">
        <template v-slot="scope">
          {{ scope.row.status === true ? '通过' : scope.row.status === false ? '不通过' : '未审核' }}
        </template>
      </el-table-column>
      <el-table-column label="操作" min-width="180" fixed="right" prop="name">
        <template v-slot="scope">
          <el-button type="text" size="small" @click="downloadFile(scope.row.fileSystemName)">下载</el-button>
          <el-button type="text" size="small" style="color: red;"
            @click="deleteHomeworkGuidebook(scope.row)">删除</el-button>
          <el-button type="text" size="small" @click="instructionEditFun(scope.row)">编辑</el-button>
          <el-button type="text" size="small" @click="approval(scope.row)">审批</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="1"
      :page-sizes="[10, 20, 30, 50, 100]" :page-size="search.size" layout="->,total, sizes, prev, pager, next, jumper"
      :total="search.total" background>
    </el-pagination>
    <el-dialog :visible.sync="dialogVisible" title="受控申请" width="60%">
      <div style="height: 60vh; overflow-y: auto; overflow-x: hidden;">
        <el-form ref="form1" label-width="110px" :model="instructionForm">
          <el-row :gutter="20">
            <el-col :span="12">
              <el-form-item label="申请编号:">
                <el-input v-model="instructionForm.applicationNumber" disabled size="small" clearable></el-input>
              </el-form-item>
              <el-form-item label="附件:" style="float: left;">
                <el-upload ref="uploadFile" :action="action" :before-remove="beforeRemove" :file-list="fileList1"
                  :headers="uploadHeader" :limit="1" :on-error="onError" :on-exceed="handleExceed"
                  :on-remove="handleRemove1" :on-success="onSuccess1" class="upload-demo" multiple>
                  <el-button size="small" type="primary">点击上传</el-button>
                </el-upload>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="申请部门:">
                <el-input v-model="instructionForm.applicationDepartment" clearable size="small"></el-input>
              </el-form-item>
              <el-form-item label="责任人:">
                <el-input v-model="instructionForm.personLiable" clearable size="small"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="受控申请说明:" prop="controlledApplicationDescription"
                :rules="[{ required: true, message: '请输入受控申请说明', trigger: 'blur' }]">
                <el-input v-model="instructionForm.controlledApplicationDescription" type="textarea"
                  clearable></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <div style="text-align: right; margin-bottom: 10px">
          <el-button size="small" type="primary" @click="openAddDia">添加受控文件</el-button>
          <el-button size="small" @click="delFile">删除</el-button>
        </div>
        <el-table :data="documentTableData" border style="width: 100%;" tooltip-effect="dark" :row-key="getRowKey"
                  :header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }"
          @selection-change="handleSelectionChange" height="29em">
          <el-table-column type="selection" width="55%">
          </el-table-column>
          <el-table-column label="序号" prop="id" type="index" width="60"></el-table-column>
          <el-table-column label="设备名称" prop="deviceName" show-overflow-tooltip min-width="125"></el-table-column>
          <el-table-column label="设备编号" prop="deviceNumber" show-overflow-tooltip min-width="125"></el-table-column>
          <el-table-column label="设备型号" prop="deviceModel" show-overflow-tooltip min-width="125"></el-table-column>
          <el-table-column label="文档编号" prop="documentNumber" show-overflow-tooltip min-width="125"></el-table-column>
          <el-table-column label="文件名称" prop="fileName" show-overflow-tooltip min-width="125"></el-table-column>
          <el-table-column label="上传人" prop="author" show-overflow-tooltip min-width="125"></el-table-column>
          <el-table-column label="上传时间" prop="updateTime" show-overflow-tooltip min-width="125"></el-table-column>
          <el-table-column min-width="100" label="操作" fixed="right">
            <template v-slot="scope">
              <el-button type="text" size="small" @click="downloadFile(scope.row.fileSystemName)">下载</el-button>
              <el-button type="text" @click="editFun(scope.row, scope.$index)">编辑</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <span slot="footer">
        <el-button @click="dialogVisible = false" size="small">取 消</el-button>
        <el-button size="small" type="primary" @click="submitFun">提交</el-button>
      </span>
    </el-dialog>
    <el-dialog :visible.sync="dialogVisible1" title="添加设备作业指导书" width="40%">
      <div style="height: 50vh;">
        <el-form ref="form" :model="form" label-width="90px">
          <el-row :gutter="20">
            <el-col :span="12">
              <el-form-item label="文件类型:" prop="documentType"
                :rules="[{ required: true, message: '请输入文件类型', trigger: 'blur' }]">
                <el-input v-model="form.documentType" clearable size="small" placeholder="请输入文件类型"></el-input>
              </el-form-item>
              <el-form-item label="设备名称:" prop="deviceName"
                :rules="[{ required: true, message: '请选择设备', trigger: 'change' }]">
                <el-select v-model="form.deviceName" size="small" clearable style="width: 100%" placeholder="请选择设备名称"
                  @change="onDeviceNameChange" filterable>
                  <el-option v-for="item in deviceNameOption" :key="item.id" :label="item.label" :value="item.value">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="文档编号:" prop="documentNumber"
                :rules="[{ required: true, message: '请输入文档编号', trigger: 'blur' }]">
                <el-input v-model="form.documentNumber" size="small" clearable placeholder="请输入文档编号"></el-input>
              </el-form-item>
              <el-form-item label="管理编号:">
                <el-input v-model="form.deviceNumber" size="small" clearable disabled placeholder="请输入管理编号"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="文件版本:" prop="documentVersion"
                :rules="[{ required: true, message: '请输入文件版本', trigger: 'blur' }]">
                <el-input v-model="form.documentVersion" size="small" placeholder="请输入文件版本" clearable></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="作者:" prop="author" :rules="[{ required: true, message: '请输入作者', trigger: 'blur' }]">
                <el-input v-model="form.author" size="small" clearable></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="提交日期:" prop="submitDate"
                :rules="[{ required: true, message: '请选择提交日期', trigger: 'change' }]">
                <el-date-picker v-model="form.submitDate" format="yyyy-MM-dd" style="width: 100%" size="small" clearable
                  placeholder="选择日期" type="date" value-format="yyyy-MM-dd">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="文档说明:" prop="documentNote"
                :rules="[{ required: true, message: '请输入文档说明', trigger: 'blur' }]">
                <el-input v-model="form.documentNote" placeholder="请输入文档说明" type="textarea" clearable></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="附件:" style="float: left;">
                <el-upload ref="uploadFile" :action="action" :before-remove="beforeRemove" :file-list="fileList"
                  :headers="uploadHeader" :limit="1" :on-error="onError" :on-exceed="handleExceed"
                  :on-remove="handleRemove" :on-success="onSuccess" class="upload-demo" multiple>
                  <el-button size="small" type="primary">点击上传</el-button>
                </el-upload>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <span slot="footer">
        <el-button @click="closeDia" size="small">取 消</el-button>
        <el-button type="primary" @click="addFile" size="small">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
 
<script>
import fileDownload from "@/utils/file";
import {
  approvalOfHomeworkInstructionManual,
  homeworkGuidebook,
  homeworkGuidebookEditor,
  newHomeworkGuidebookAdded,
  deleteHomeworkGuidebook,
  pageByPageQueryOfHomeworkInstructions,
  selectDeviceParameter,
} from '@/api/cnas/resourceDemand/device.js'
export default {
  props: {
    clickNodeVal: {
      type: Object,
      default: () => {
        return {};
      }
    }
  },
  name: '',
  components: {},
  data() {
    return {
      search: {
        size: 20,
        current: 1,
        total: 0
      },
      dialogVisible: false,
      dialogVisible1: false,
      value: '',
      selectRow: null,
      device: null,
      tableDataIndex: '',
      form: {
        documentType: '',
        documentNumber: '',
        deviceName: '',
        deviceModel: '',
        deviceNumber: '',
        fileName: '',
        fileSystemName: '',
        submitDate: '',
        documentNote: '',
      },
      tableData: [],
      documentTableData: [],
      formData: {},
      fileList: [],
      fileList1: [],
      laboratoryNameIsNull: false,
      devices: [], //设备列表数据
      deviceNameOption: [], //设备名称下拉框数据
      entity: {
        deviceName: null,
        laboratoryName: '',
        storagePoint: ''
      },
      selectedRow: [],
      instructionForm: {
        applicationNumber: '', // 申请编号
        applicationDepartment: '', // 申请部门
        personLiable: '', // 责任人
        controlledApplicationDescription: '', // 受控申请说明
      }
    }
  },
  mounted() {
    this.getAllDevice();
    this.getList()
  },
  watch: {
    // 监听点击el-tree的数据,进行数据刷新
    clickNodeVal(newVal) {
      if (newVal) {
        this.getList()
        this.clickSidebar(newVal)
      }
    },
    dialogVisible(newVal) {
      if (newVal === false) {
        this.instructionForm = {}
        this.documentTableData = []
        this.fileList1 = []
      }
    }
  },
  methods: {
    approval(row) {
      this.$confirm('是否审批通过!', '提示', {
        confirmButtonText: '通过',
        cancelButtonText: '不通过',
        type: 'warning'
      }).then(() => {
        this.approvalFun(row.id, true)
      }).catch(() => {
        this.approvalFun(row.id, false)
      });
    },
    approvalFun(id, status) {
      approvalOfHomeworkInstructionManual({ id, status }).then(res => {
        this.getList()
        this.$message({
          type: 'success',
          message: '操作成功!'
        });
      })
 
    },
    getRowKey(row) {
      return row.index
    },
    deleteHomeworkGuidebook(row) {
      this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        homeworkGuidebook({
          id: row.id,
          instructionId: row.instructionId
        }).then(res => {
          this.$message.success('删除成功!')
          this.getList()
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },
    downloadFile(fileName) {
      let state = /\.(jpg|jpeg|png|gif)$/i.test(fileName)
      if (state) {
        let url = this.javaApi + '/img/' + fileName;
        fileDownload.downloadIamge(url, fileName)
      } else {
        const url = this.javaApi + '/word/' + fileName
        const link = document.createElement('a');
        link.href = url;
        link.download = fileName;
        link.click();
        this.$message.success('下载成功')
      }
    },
    instructionEditFun(row) {
      this.dialogVisible = true
      homeworkGuidebookEditor({ instructionId: row.instructionId }).then(res => {
        if (res.code == 200) {
          this.instructionForm = res.data.instruction;
          if (this.instructionForm.fileSystemName) {
            this.fileList1.push({ name: this.instructionForm.fileName })
          }
          this.documentTableData = res.data.list;
          // 删除用
          this.documentTableData.forEach((v, k) => {
            v.index = k
          })
        }
      })
    },
    handleSizeChange(val) {
      this.search.size = val
      this.getList()
    },
    handleCurrentChange(val) {
      this.search.current = val
      this.getList()
    },
    submitFun() {
      this.$refs.form1.validate((valid) => {
        if (valid) {
          this.instructionForm.feTempHumRecordList = this.documentTableData
          newHomeworkGuidebookAdded(this.instructionForm).then(res => {
            if (res.code == 200) {
              this.$message.success('操作成功!')
              this.dialogVisible = false
              this.getList()
            }
          })
        } else {
          return false;
        }
      });
    },
    clickSidebar(clickNodeVal) {
      this.laboratoryNameIsNull = false
      // 是否存在value,存在value代表为三级
      if (!clickNodeVal.value) {
        this.list = [];
        this.entity.laboratoryName = null
        this.entity.storagePoint = null
        // 等于1代表为树的一级,label为部门
        if (clickNodeVal.label === '其他') {
          this.laboratoryNameIsNull = true
          this.getAllDevice()
          return
        }
        if (clickNodeVal.level === 1) {
          this.entity.laboratoryName = clickNodeVal.label
          // 等于二级。label为存储地点
        } else if (clickNodeVal.level === 2) {
          // 其他表示没有配置实验室,只配置了地点
          if (clickNodeVal.parent.label === '其他') {
            this.laboratoryNameIsNull = true
          } else {
            this.entity.laboratoryName = clickNodeVal.parent.label
          }
          this.entity.storagePoint = clickNodeVal.label
        }
        this.getAllDevice()
      }
    },
    // 新增
    addFile() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          if (this.tableDataIndex !== undefined) {
            this.$set(this.documentTableData, this.tableDataIndex, this.form)
            this.dialogVisible1 = false;
            this.$message.success('修改成功');
            console.log('this.documentTableData---edit', this.documentTableData[this.tableDataIndex])
          } else {
            this.documentTableData.push(this.form);
            this.dialogVisible1 = false;
            this.$message.success('添加成功');
          }
        } else {
          return false;
        }
      });
    },
    openAddDia() {
      this.dialogVisible1 = true
      this.tableDataIndex = undefined;
      this.form = {}
      this.form.deviceName = this.clickNodeVal.label
      this.onDeviceNameChange()
      this.fileList = []
 
    },
    editFun(row, index) {
      this.form = { ...row }
      this.tableDataIndex = index;
      console.log('this.tableDataIndex', this.tableDataIndex)
      // 回显列表
      if (this.form.fileSystemName) {
        this.fileList.push({ name: this.form.fileName })
      }
      this.dialogVisible1 = true
    },
    closeDia() {
      this.dialogVisible1 = false
      this.$refs['form'].resetFields()
      this.fileList = []
    },
    handleSelectionChange(selected) {
      this.selectedRow = selected
    },
    async delFile() {
      if (this.selectedRow.length === 0) {
        this.$message.error('请选择要删除的选项');
        return;
      }
      // 删除保存好的数据
      let ids = this.selectedRow
        .filter(item => item.id !== undefined)
        .map(item => item.id).join(',');
      //有错误
      const res = await deleteHomeworkGuidebook({ ids });
      if (res.code === 200) {
        // 删除视图的数据
        for (const resKey in this.selectedRow) {
          this.documentTableData = this.documentTableData.filter(item => item.index === this.selectedRow[resKey].index)
        }
        this.$message.success({
          message: '删除成功',
          type: 'success'
        });
      }
    },
    onSuccess(response, file, fileList) {
      this.form.fileName = file.name;
      this.form.fileSystemName = response.data;
    },
    onSuccess1(response, file, fileList) {
      this.instructionForm.fileName = file.name;
      this.instructionForm.fileSystemName = response.data;
    },
    onError(error, file, fileList) {
      this.$message.error('上传失败:', error, file, fileList);
    },
    handleRemove(file, fileList) {
      this.form.fileName = ''
      this.form.fileSystemName = ''
    },
    handleRemove1(file, fileList) {
      this.form.fileName = ''
      this.form.fileSystemName = ''
    },
    beforeRemove(file) {
      return this.$confirm(`确定移除 ${file.name}?`)
    },
    handleExceed(files, fileList) {
      this.$message.warning(`当前限制选择 1 个文件,本次选择了 ${files.length} 个文件。`);
    },
    getList() {
      pageByPageQueryOfHomeworkInstructions({ ...this.search }).then(res => {
        if (res.code == 200) {
          this.tableData = res.data.records;
          this.search.total = res.data.total
        }
      })
    },
    getAllDevice() {
      selectDeviceParameter({ laboratoryNameIsNull: this.laboratoryNameIsNull }).then(res => {
        if (res.code == 200) {
          this.devices = res.data.records;
          this.updateDeviceNameOptions();
        }
      })
    },
    // 更新设备名称下拉框的选项
    updateDeviceNameOptions() {
      this.deviceNameOption = this.devices.map(device => ({
        value: device.deviceName,
        label: device.deviceName
      }));
    },
    // 设备名称改变时触发
    onDeviceNameChange() {
      // 根据选中的设备名称,更新管理编号下拉框的选项
      const selectedDevice = this.devices.find(device => device.deviceName === this.form.deviceName);
      if (selectedDevice) {
        this.form.deviceNumber = selectedDevice.managementNumber;
        this.form.deviceModel = selectedDevice.specificationModel;
        this.form.deviceId = selectedDevice.id
      }
    },
  },
  computed: {
    action() {
      return this.javaApi + '/personBasicInfo/saveCNASFile'
    }
  },
}
</script>
 
<style scoped>
h4 {
  font-weight: 400;
  font-size: 16px;
  display: flex;
  justify-content: flex-end;
  margin: 10px 0;
}
</style>