zhuo
2025-04-22 00d9d8d47463c1ecc7d2218593a6efb313d084a2
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
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
<template>
  <div class="capacity-scope">
    <div style="display: flex;justify-content: space-between;align-items: flex-start">
      <el-form :model="queryParams0" ref="queryParams0" size="small" :inline="true">
        <el-form-item label="年月" prop="month">
          <el-date-picker v-model="queryParams0.month" type="month" placeholder="选择月" format="yyyy-MM"
                          value-format="yyyy-MM" size="small" @change="refreshTable()">
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" size="mini" @click="refreshTable">查询</el-button>
          <el-button size="mini" @click="refresh">重置</el-button>
        </el-form-item>
      </el-form>
      <el-button size="small" type="primary" @click="handleAdd0">新增</el-button>
    </div>
    <div class="table">
      <lims-table :tableData="tableData0" :column="column0" :tableLoading="tableLoading"
                  key="tableData0" :height="'calc(100vh - 240px)'" :page="page0" @pagination="pagination0"></lims-table>
    </div>
    <el-dialog title="详情" :visible.sync="editDialogVisible" width="70%">
      <el-button size="small" type="primary" @click="handleAdd('add')" style="margin-bottom: 10px">新增</el-button>
      <lims-table :tableData="tableData" :column="column" :tableLoading="tableLoading"
                  key="tableData" :height="'calc(100vh - 290px)'">
      </lims-table>
      <span slot="footer" class="dialog-footer">
        <el-button @click="editDialogVisible = false">取消</el-button>
      </span>
    </el-dialog>
    <!-- 新增样品 -->
    <el-dialog title="新增" :visible.sync="addDialogVisible" width="400px" @close="closeAddDialogVisible">
      <el-form ref="addInfo" :model="addInfo" :rules="rules" label-width="120px">
        <el-row>
          <el-col :span="24">
            <el-form-item label="样品名称" prop="sampleName">
              <el-input size="small" placeholder="请输入" clearable
                        v-model="addInfo.sampleName"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="样品编号" prop="sampleCode">
              <el-input size="small" placeholder="请输入" clearable
                        v-model="addInfo.sampleCode"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="供样单位" prop="sampleSupplier">
              <el-select v-model="addInfo.sampleSupplier" size="small">
                <el-option :label="item.company" :value="item.company" v-for="(item, index) in customPageList"
                           :key="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="数量" prop="num">
              <el-input size="small" placeholder="请输入" clearable
                        v-model="addInfo.num"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="处理方式" prop="dealMethod">
              <el-input size="small" placeholder="请输入" clearable
                        v-model="addInfo.dealMethod"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="时间" prop="dealTime">
              <el-date-picker v-model="addInfo.dealTime" type="date" size="small" placeholder="选择日期" format="yyyy-MM-dd"
                              value-format="yyyy-MM-dd" style="width: 100%;">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="closeAddDialogVisible">取 消</el-button>
        <el-button type="primary" @click="submitAdd" :loading="addLoading">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 新增历史 -->
    <el-dialog title="新增" :visible.sync="addDialogVisibleDeal" width="400px" @close="closeDiaDeal">
      <el-form ref="addInfoDeal" :model="addInfoDeal" :rules="rulesDeal" label-width="80px">
        <el-row>
          <el-col :span="24">
            <el-form-item label="月份" prop="month">
              <el-date-picker v-model="addInfoDeal.month" type="month" size="small" placeholder="选择月份" format="yyyy-MM"
                              value-format="yyyy-MM" style="width: 100%;">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="closeDiaDeal">取 消</el-button>
        <el-button type="primary" @click="submitAddDeal" :loading="addLoading">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 详情/下载/审核/批准 -->
    <el-dialog :title="title0" :visible.sync="lookDialogVisible" width="400px" :class="{ downPdf: title0 == '下载' }"
      :modal="title0 != '下载'" top="5vh">
      <span>是否通过{{title0}}?</span>
      <span slot="footer" class="dialog-footer" v-if="title0 == '审核' || title0 == '批准'">
        <el-button @click="submitCheck('不通过')" :loading="noCheckLoading">不通过</el-button>
        <el-button type="primary" @click="submitCheck('通过')" :loading="checkLoading">通 过</el-button>
      </span>
    </el-dialog>
  </div>
</template>
 
<script>
import limsTable from "@/components/Table/lims-table.vue";
import filePreview from "@/components/Preview/filePreview.vue";
import { selectCustomPageList } from "@/api/system/customer";
import {
  doProcessDeal,
  addProcessDeal,
  submitProcessTotaldeal,
  checkProcessTotaldeal,
  ratifyProcessTotaldeal,
  delProcessDeal,
  pageProcessTotaldeal, getProcessDeal, addProcessTotaldeal,
  exportProcessTotaldeal
} from "@/api/cnas/process/sampleDisposal";
export default {
  name: 'SampleDisposal',
  components: {
    limsTable,
    filePreview,
  },
  data() {
    return {
      title: '新增',
      addDialogVisible: false,
      addLoading: false,
      outLoading: false,
      editDialogVisible: false,
      queryParams: {},
      submitState: '',
      lookDialogVisible: false,
      title0: '查看',
      noCheckLoading: false,
      checkLoading: false,
      // 历史列表
      addInfo: {},//新增样品
      addInfoDeal: {
        month: ''
      },//新增样品
      addDialogVisibleDeal: false,
      rules: {
        sampleName: [{ required: true, message: '请填写样品名称', trigger: 'blur' }],
        sampleCode: [{ required: true, message: '请填写样品编号', trigger: 'blur' }],
        sampleSupplier: [{ required: true, message: '请选择供样单位', trigger: 'change' }],
        num: [{ required: true, message: '请填写数量', trigger: 'blur' }],
        dealMethod: [{ required: true, message: '请填写处理方式', trigger: 'blur' }],
        dealTime: [{ required: true, message: '请选择时间', trigger: 'change' }],
      },
      rulesDeal: {
        month: [{ required: true, message: '请选择月份', trigger: 'change' }],
      },
      customPageList: [],
      currentInfo: {
        arr: []
      },//查看的详情
      outPower: false,
      addPower: false,
      tableData: [],
      column: [
        { label: "样品名称", prop: "sampleName" },
        { label: "样品编号", prop: "sampleCode" },
        { label: "供样单位", prop: "sampleSupplier" },
        { label: "数量", prop: "num" },
        { label: "处理方式", prop: "dealMethod" },
        { label: "时间", prop: "dealTime" },
        {
          dataType: "action",
          label: "操作",
          operation: [
            {
              name: "编辑",
              type: "text",
              clickFun: (row) => {
                this.handleAdd('edit',row);
              },
              disabled: (row) => {
                return this.submitState === '已提交'
              }
            },
            {
              name: "删除",
              type: "text",
              clickFun: (row) => {
                this.handleDelete(row);
              },
              disabled: (row) => {
                return this.submitState === '已提交'
              }
            },
          ],
        },
      ],
      tableLoading: false,
      queryParams0: {},
      tableData0: [],
      column0: [
        { label: "月份", prop: "month" },
        { label: "提交人", prop: "submitUserName" },
        {
          dataType: 'tag',
          label: '提交状态',
          prop: 'submitState',
          formatData: (params) => {
            return params
          },
          formatType: (params) => {
            if (params === '待提交') {
              return 'danger';
            } else if (params === '已提交') {
              return 'success';
            } else {
              return null;
            }
          }
        },
        { label: "审核人", prop: "examineUserName" },
        {
          dataType: 'tag',
          label: '审核状态',
          prop: 'examineState',
          formatData: (params) => {
            return params
          },
          formatType: (params) => {
            if (params === '不通过') {
              return 'danger';
            } else if (params === '通过') {
              return 'success';
            } else {
              return null;
            }
          }
        },
        { label: "批准人", prop: "ratifyUserName" },
        {
          dataType: 'tag',
          label: '批准状态',
          prop: 'ratifyState',
          formatData: (params) => {
            return params
          },
          formatType: (params) => {
            if (params === '不通过') {
              return 'danger';
            } else if (params === '通过') {
              return 'success';
            } else {
              return null;
            }
          }
        },
        {
          dataType: "action",
          label: "操作",
          operation: [
            {
              name: "查看",
              type: "text",
              clickFun: (row) => {
                this.handleLook(row);
              },
            },
            {
              name: "下载",
              type: "text",
              clickFun: (row) => {
                this.handleDown0(row);
              }
            },
            {
              name: "提交",
              type: "text",
              clickFun: (row) => {
                this.handleSubmit(row);
              },
              disabled: (row) => {
                return !!row.submitState && row.submitState != '待提交'
              }
            },
            {
              name: "审核",
              type: "text",
              clickFun: (row) => {
                this.handleCheck(row);
              },
              disabled: (row) => {
                return row.examineState == '通过' || row.submitState == '待提交'
              }
            },
            {
              name: "批准",
              type: "text",
              clickFun: (row) => {
                this.handleApproval(row);
              },
              disabled: (row) => {
                return row.ratifyState == '通过' || row.submitState == '待提交'
              }
            },
          ],
        },
      ],
      page0: {
        total: 0,
        size: 20,
        current: 1,
      },
      operationType: ''
    };
  },
  mounted() {
    this.getList0()
  },
  methods: {
    // 获取送样单位列表
    getCustomPageList() {
      selectCustomPageList({
        current: -1,
        size: -1
      }).then(res => {
        this.customPageList = res.data.records
      }).catch(err => { });
    },
    handleDown() { },
    refresh() {
      this.queryParams0 = {};
      this.page0.current = 1;
      this.getList0();
    },
    refreshTable() {
      this.page0.current = 1;
      this.getList0();
    },
    // 查询全部记录
    getList0() {
      this.tableLoading = true;
      let param = { ...this.queryParams0, ...this.page0 };
      delete param.total;
      pageProcessTotaldeal({ ...param })
        .then((res) => {
          this.tableLoading = false;
          if (res.code === 200) {
            this.tableData0 = res.data.records;
            this.page0.total = res.data.total;
          }
        })
        .catch((err) => {
          this.tableLoading = false;
        });
    },
    pagination0({ page, limit }) {
      this.page0.current = page;
      this.page0.size = limit;
      this.getList0();
    },
    // 打开新增历史界面
    handleAdd0() {
      this.addDialogVisibleDeal = true
      this.addInfoDeal.month = ''
    },
    closeAddDialogVisible() {
      this.$refs['addInfo'].resetFields();
      this.addDialogVisible = false
    },
    // 提交新增-历史
    submitAddDeal () {
      this.$refs.addInfoDeal.validate(valid => {
        if (valid) {
          // 新增
          this.addLoading = true
          addProcessTotaldeal({
            ...this.addInfoDeal
          }).then(res => {
            this.addLoading = false
            this.addDialogVisibleDeal = false
            this.$message({
              type: 'success',
              message: '新增成功!'
            });
            this.getList0()
          }).catch(err => {
            this.addLoading = false
          });
        }
      })
    },
    closeDiaDeal() {
      this.$refs['addInfoDeal'].resetFields();
      this.addDialogVisibleDeal = false
    },
    // 提交
    handleSubmit(row) {
      this.$confirm('是否提交 ' + row.month + ' 月份的数据', '提交', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        submitProcessTotaldeal({
          id: row.id
        }).then(res => {
          this.$message({
            type: 'success',
            message: '提交成功!'
          });
          this.refreshTable()
        }).catch(err => { });
      })
    },
    // 查看
    handleLook(row) {
      this.queryParams.id = row.id
      this.submitState = row.submitState
      this.$nextTick(() => {
        this.editDialogVisible = true
        this.getList();
      })
    },
    getList() {
      this.tableLoading = true;
      let param = { ...this.queryParams };
      getProcessDeal({ ...param }).then((res) => {
          this.tableLoading = false;
          if (res.code === 200) {
            this.tableData = res.data;
          }
        })
        .catch((err) => {
          this.tableLoading = false;
        });
    },
    // 打开新增详情弹框
    handleAdd(type, row) {
      this.addDialogVisible = true
      this.getCustomPageList()
      this.operationType = type
      if (row) {
        this.addInfo = {...row}
      }
    },
    // 提交-详情
    submitAdd() {
      this.$refs.addInfo.validate(valid => {
        if (valid) {
          this.addLoading = true
          addProcessDeal({
            totaldealId: this.queryParams.id,
            ...this.addInfo
          }).then(res => {
            this.addLoading = false
            this.addDialogVisible = false
            this.$message({
              type: 'success',
              message: '新增成功!'
            });
            this.getList()
          }).catch(err => {
            this.addLoading = false
          });
        }
      })
    },
    // 提交修改详情
    handleEdit() {
      if (type === 'submit') {
        doProcessDeal({
          id: row.id,
          ...row
        }).then(res => {
          this.$message({
            type: 'success',
            message: '编辑成功!'
          });
          this.getList();
        }).catch(err => { });
      }
    },
    // 审核
    handleCheck(row) {
      this.title0 = '审核'
      this.lookDialogVisible = true
      this.currentInfo = row
      this.queryParams.id = row.id
    },
    // 批准
    handleApproval(row) {
      this.title0 = '批准'
      this.lookDialogVisible = true
      this.currentInfo = row
      this.queryParams.id = row.id
    },
    // 提交审核/批准
    submitCheck(state) {
      if (state == '通过') {
        this.checkLoading = true
      } else {
        this.noCheckLoading = true
      }
      if (this.title0 == '审核') {
        checkProcessTotaldeal({
          id: this.currentInfo.id,
          state: state
        }).then(res => {
          this.checkLoading = false
          this.noCheckLoading = false
          this.$message({
            type: 'success',
            message: '操作成功!'
          });
          this.refreshTable()
          this.lookDialogVisible = false
        }).catch(err => { });
      } else if (this.title0 == '批准') {
        ratifyProcessTotaldeal({
          id: this.currentInfo.id,
          state: state
        }).then(res => {
          this.checkLoading = false
          this.noCheckLoading = false
          this.$message({
            type: 'success',
            message: '操作成功!'
          });
          this.refreshTable()
          this.lookDialogVisible = false
        }).catch(err => { });
      }
    },
    // 导出详情
    handleDown0(row) {
      exportProcessTotaldeal({ id: row.id }).then(res => {
        this.outLoading = false
        const blob = new Blob([res], { type: 'application/msword' });
        this.$download.saveAs(blob, '样品处理' + '.docx');
      })
    },
    handleDelete(row) {
      this.$confirm("是否删除该条数据?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        delProcessDeal({ id: row.id }).then((res) => {
          this.$message.success("删除成功");
          this.getList();
         });
      }).catch(() => { });
    },
  },
}
</script>
 
<style scoped>
>>>.el-dialog__body {
  padding-top: 10px;
}
</style>