licp
2025-01-06 efad6058c9c9ee6ba754dc9cc61c8d744cd199b8
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
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
<template>
  <div>
    <div>
      <div class="view-title">
        <span>标准查新</span>
        <span style="display: flex; align-items: center;">
          <el-button size="medium" type="primary" @click="openHandleOut">导 出</el-button>
          <el-upload ref='upload' :action="action"
                     :before-upload="beforeUpload" :headers="headers" :on-error="onError"
                     :on-success="handleSuccessUp" :show-file-list="false" accept='.jpg,.jpeg,.png,.gif,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.pdf,.zip,.rar'
                     style="display: inline-block; margin-left: 10px;">
            <el-button :loading="upLoading" size="medium" type="primary">导入</el-button>
          </el-upload>
          <el-button size="medium" style="margin-left: 10px;" type="primary" @click="openFormDia">新 增</el-button>
        </span>
      </div>
      <div class="search-background">
        <span v-if="tabIndex == 1" class="search-group">
          <span>年份:</span>
          <el-date-picker
            v-model="searchForm.year"
            format="yyyy"
            placeholder="选择年"
            type="year"
            value-format="yyyy">
          </el-date-picker>
        </span>
        <span class="search-group">
          <span>时间:</span>
          <el-select v-model="searchForm.date" clearable placeholder="请选择">
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </span>
        <span class="search-group">
          <el-button size="medium"  @click="resetSearchForm">重 置</el-button>
          <el-button size="medium" type="primary" @click="searchList">查 询</el-button>
        </span>
      </div>
      <div class="table">
        <div class="table-tab">
          <el-radio-group v-model="tabIndex" @change="searchList">
            <el-radio-button label="0">今年标准记录</el-radio-button>
            <el-radio-button label="1">历史标准记录</el-radio-button>
          </el-radio-group>
        </div>
        <div v-if="tabIndex === '0'">
          <TableCard :showForm="false" :showTitle="false">
            <template v-slot:table>
              <ZTTable
                :column="tableColumn"
                :height="'calc(100vh - 26em)'"
                :table-data="tableData"
                :table-loading="tableLoading"
                style="padding: 0 15px;margin-bottom: 16px">
              </ZTTable>
            </template>
          </TableCard>
          <el-pagination :current-page="1" :page-size="page.size" :page-sizes="[10, 20, 30, 50, 100]"
                         :total="total" layout="->,total, sizes, prev, pager, next, jumper"
                         @size-change="handleSizeChange"
                         @current-change="handleCurrentChange">
          </el-pagination>
        </div>
        <div v-if="tabIndex === '1'">
          <TableCard :showForm="false" :showTitle="false">
            <template v-slot:table>
              <ZTTable
                :column="oldTableColumn"
                :height="'calc(100vh - 27em)'"
                :table-data="oldTableData"
                :table-loading="oldTableLoading"
                style="padding: 0 15px;margin-bottom: 16px">
              </ZTTable>
            </template>
          </TableCard>
          <el-pagination :current-page="1" :page-size="oldPage.size" :page-sizes="[10, 20, 30, 50, 100]"
                         :total="oldTotal" layout="->,total, sizes, prev, pager, next, jumper"
                         @size-change="handleOldSizeChange"
                         @current-change="handleOldCurrentChange">
          </el-pagination>
        </div>
      </div>
      <el-dialog :visible.sync="ratifyDialog" title="导出" width="30%" @close="ratifyDialog = false">
        <span>编制人:
          <el-select v-model="ratifyInfo.writeUserId" placeholder="请选择" size="small" style="width: 100%">
            <el-option v-for="item in userList" :key="item.id" :label="item.name" :value="item.id"></el-option>
          </el-select>
        </span>
        <span>编制日期:
            <el-date-picker v-model="ratifyInfo.writeDate" style="width:100%"
              type="date" format="yyyy-MM-dd" value-format="yyyy-MM-dd" size="small"
              placeholder="选择日期">
            </el-date-picker>
        </span>
        <span>批准人:
          <el-select v-model="ratifyInfo.ratifyUserId" placeholder="请选择" size="small" style="width: 100%">
            <el-option v-for="item in userList" :key="item.id" :label="item.name" :value="item.id"></el-option>
          </el-select>
        </span>
        <span>批准日期:
          <el-date-picker v-model="ratifyInfo.ratifyDate" style="width:100%"
            type="date" format="yyyy-MM-dd" value-format="yyyy-MM-dd" size="small"
            placeholder="选择日期">
          </el-date-picker>
        </span>
        <span slot="footer" class="dialog-footer">
        <el-button @click="ratifyDialog = false">取 消</el-button>
        <el-button :loading="outLoading" type="primary" @click="handleOut">确 认</el-button>
      </span>
      </el-dialog>
      <FormDialog v-if="formDialog" ref="formDialog" @closeDia="closeDia"></FormDialog>
      <EditFormDia v-if="editFormDialog" ref="editFormDialog" @closeEditDia="closeEditDia"></EditFormDia>
    </div>
  </div>
</template>
 
<script>
import ZTTable from '../caorui/ZTTable/index.vue';
import TableCard from '../caorui/TableCard/index.vue';
import FormDialog from '../do/a7-standard-novelty-retrieval/FormDialog.vue';
import EditFormDia from '../do/a7-standard-novelty-retrieval/EditFormDia.vue';
 
export default {
  name: 'a7-standard-novelty-retrieval',
  // import 引入的组件需要注入到对象中才能使用
  components: { FormDialog, TableCard, ZTTable, EditFormDia },
  data() {
    // 这里存放数据
    return {
      searchForm: {
        year: '',
        date: '',
      },
      options: [
        {label: '上半年', value: '1'},
        {label: '下半年', value: '2'},
      ],
      tableColumn: [
        {
          label: '标准名称',
          prop: 'methodName',
          minWidth: '100'
        },
        {
          label: '标准号',
          prop: 'standardNo',
          minWidth: '100'
        },
        {
          label: '文件编号',
          prop: 'fileNo',
          minWidth: '100'
        },
        {
          dataType: 'tag',
          label: '是否是新标准',
          prop: 'isNewStandard',
          minWidth: '100',
          formatData: (params) => {
            if (params == 0) {
              return '否';
            } else if (params == 1) {
              return '是';
            } else {
              return null
            }
          },
          formatType: (params) => {
            if (params == 0) {
              return 'danger';
            } else if (params == 1) {
              return 'success';
            } else {
              return null
            }
          }
        },
        {
          label: '新标准名称',
          prop: 'newMethodName',
          minWidth: '100'
        },
        {
          label: '新标准号',
          prop: 'newStandardNo',
          minWidth: '100'
        },
        {
          dataType: 'tag',
          label: '查询记录来源',
          prop: 'searchNewSource',
          minWidth: '100',
          formatData: (params) => {
            if (params == 0) {
              return '标准网';
            } else if (params == 1) {
              return '委托情报';
            } else if (params == 2) {
              return '标准数';
            } else if (params == 3) {
              return '其他';
            } else {
              return null
            }
          },
          formatType: (params) => {
            if (params == 0) {
              return 'success';
            } else if (params == 1) {
              return 'danger';
            } else if (params == 2) {
              return 'warning';
            } else if (params == 3) {
              return 'info';
            } else {
              return null
            }
          }
        },
        {
          dataType: 'tag',
          label: '备注',
          prop: 'remark',
          minWidth: '100',
          formatData: (params) => {
            if (params == 0) {
              return '作废';
            } else if (params == 1) {
              return '替换';
            } else {
              return null
            }
          },
          formatType: (params) => {
            if (params == 0) {
              return 'danger';
            } else if (params == 1) {
              return 'success';
            } else {
              return null
            }
          }
        },
        {
          dataType: 'action',
          minWidth: '50',
          label: '操作',
          operation: [
            {
              name: '编辑',
              type: 'text',
              clickFun: (row) => {
                this.openEditFormDia(row);
              },
            }
          ]
        }
      ],
      tableData: [],
      tableLoading: false,
      page: {
        size: 20,
        current: 1,
      },
      total: 0,
      oldTotal: 0,
      oldPage: {
        size: 20,
        current: 1,
      },
      oldTableColumn: [
        {
          label: '标准名称',
          prop: 'methodName',
          minWidth: '100'
        },
        {
          label: '标准号',
          prop: 'standardNo',
          minWidth: '100'
        },
        {
          label: '文件编号',
          prop: 'fileNo',
          minWidth: '100'
        },
        {
          dataType: 'tag',
          label: '是否是新标准',
          prop: 'isNewStandard',
          minWidth: '100',
          formatData: (params) => {
            if (params == 0) {
              return '否';
            } else if (params == 1) {
              return '是';
            } else {
              return null
            }
          },
          formatType: (params) => {
            if (params == 0) {
              return 'danger';
            } else if (params == 1) {
              return 'success';
            } else {
              return null
            }
          }
        },
        {
          label: '新标准名称',
          prop: 'newMethodName',
          minWidth: '100'
        },
        {
          label: '新标准号',
          prop: 'newStandardNo',
          minWidth: '100'
        },
        {
          dataType: 'tag',
          label: '查询记录来源',
          prop: 'searchNewSource',
          minWidth: '100',
          formatData: (params) => {
            if (params == 0) {
              return '标准网';
            } else if (params == 1) {
              return '委托情报';
            } else if (params == 2) {
              return '标准数';
            } else if (params == 3) {
              return '其他';
            } else {
              return null
            }
          },
          formatType: (params) => {
            if (params == 0) {
              return 'success';
            } else if (params == 1) {
              return 'danger';
            } else if (params == 2) {
              return 'warning';
            } else if (params == 3) {
              return 'info';
            } else {
              return null
            }
          }
        },
        {
          dataType: 'tag',
          label: '备注',
          prop: 'remark',
          minWidth: '100',
          formatData: (params) => {
            if (params == 0) {
              return '作废';
            } else if (params == 1) {
              return '替换';
            } else {
              return null
            }
          },
          formatType: (params) => {
            if (params == 0) {
              return 'danger';
            } else if (params == 1) {
              return 'success';
            } else {
              return null
            }
          }
        },
        {
          label: '创建时间',
          prop: 'createTime',
          minWidth: '100'
        },
      ],
      oldTableData: [],
      oldTableLoading: false,
      tabIndex: '0',
      formDialog: false,
      editFormDialog: false,
      upLoading:false,
      outLoading:false,
      ratifyDialog:false,
      ratifyInfo: {
        writeUserId: '',
        ratifyUserId: '',
        writeDate: '',
        ratifyDate: '',
      },
      userList: []
    };
  },
  mounted() {
    this.searchList()
  },
  // 方法集合
  methods: {
    // 查询列表
    searchList () {
      let beginDate = ''
      let endDate = ''
      const currentYear = new Date().getFullYear()
      if (this.searchForm.year && this.searchForm.date) {
        if (this.searchForm.date ===  '1') {
          beginDate = this.searchForm.year + '-' + '01-01' + ' ' + '00:00:00'
          endDate = this.searchForm.year + '-' + '06-30' + ' ' + '23:59:59'
        } else {
          beginDate = this.searchForm.year + '-' + '07-01' + ' ' + '00:00:00'
          endDate = this.searchForm.year + '-' + '12-31' + ' ' + '23:59:59'
        }
      } else if (!this.searchForm.year && this.searchForm.date) {
        if (this.searchForm.date ===  '1') {
          beginDate = currentYear  + '-' + '01-01' + ' ' + '00:00:00'
          endDate = currentYear + '-' + '06-30' + ' ' + '23:59:59'
        } else {
          beginDate = currentYear + '-' + '07-01' + ' ' + '00:00:00'
          endDate = currentYear + '-' + '12-31' + ' ' + '23:59:59'
        }
      } else if (this.searchForm.year && !this.searchForm.date) {
        beginDate = this.searchForm.year  + '-' + '01-01' + ' ' + '00:00:00'
        endDate = this.searchForm.year + '-' + '12-31' + ' ' + '23:59:59'
      }
      const entity = {
        beginDate: beginDate,
        endDate: endDate,
      }
      this.tableLoading = true
      this.oldTableLoading = true
      const page = this.tabIndex === '0' ? this.page : this.oldPage
      this.$axios.post(this.$api.processMethodSearchNew.pageMethodSearchNew, {entity, page}, {
        headers: {
          "Content-Type": "application/json"
        },
        noQs: true
      }).then(res => {
        this.tableLoading = false
        this.oldTableLoading = false
        if (res.code === 201) return
        if (this.tabIndex === '0') {
          this.tableData = res.data.records
          this.total = res.data.total
        } else {
          this.oldTableData = res.data.records
          this.oldTotal = res.data.total
        }
      }).catch(err => {
        console.log('err---', err);
        this.tableLoading = false
        this.oldTableLoading = false
      })
    },
    // 重置查询条件
    resetSearchForm () {
      this.searchForm.year = '';
      this.searchForm.date = '';
      this.searchList()
    },
    // 操作新增框
    openFormDia (row) {
      this.formDialog = true
      this.$nextTick(() => {
        this.$refs.formDialog.openDia(row)
      })
    },
    // 关闭新增弹框
    closeDia () {
      this.formDialog = false
      this.searchList()
    },
    // 打开修改弹框
    openEditFormDia (row) {
      this.editFormDialog = true
      this.$nextTick(() => {
        this.$refs.editFormDialog.openDia(row)
      })
    },
    //
    closeEditDia () {
      this.editFormDialog = false
      this.searchList()
    },
    // 打开导出弹框选择编制人、批准人
    openHandleOut () {
      this.ratifyDialog = true
      this.getUserList()
    },
    // 导出
    handleOut () {
      let beginDate = ''
      let endDate = ''
      const currentYear = new Date().getFullYear()
      if (this.searchForm.year && this.searchForm.date) {
        if (this.searchForm.date ===  '1') {
          beginDate = this.searchForm.year + '-' + '01-01' + ' ' + '00:00:00'
          endDate = this.searchForm.year + '-' + '06-30' + ' ' + '23:59:59'
        } else {
          beginDate = this.searchForm.year + '-' + '07-01' + ' ' + '00:00:00'
          endDate = this.searchForm.year + '-' + '12-31' + ' ' + '23:59:59'
        }
      } else if (!this.searchForm.year && this.searchForm.date) {
        if (this.searchForm.date ===  '1') {
          beginDate = currentYear  + '-' + '01-01' + ' ' + '00:00:00'
          endDate = currentYear + '-' + '06-30' + ' ' + '23:59:59'
        } else {
          beginDate = currentYear + '-' + '07-01' + ' ' + '00:00:00'
          endDate = currentYear + '-' + '12-31' + ' ' + '23:59:59'
        }
      } else if (this.searchForm.year && !this.searchForm.date) {
        beginDate = this.searchForm.year  + '-' + '01-01' + ' ' + '00:00:00'
        endDate = this.searchForm.year + '-' + '12-31' + ' ' + '23:59:59'
      }
      const entity = {
        beginDate: beginDate,
        endDate: endDate,
        writeUserId: this.ratifyInfo.writeUserId,
        ratifyUserId: this.ratifyInfo.ratifyUserId,
        writeDate: this.ratifyInfo.writeDate,
        ratifyDate: this.ratifyInfo.ratifyDate,
      }
      this.outLoading = true
      this.$axios.post(this.$api.processMethodSearchNew.exportMethodSearchNew,{
        entity:entity
      },{
        headers: {
          'Content-Type': 'application/json'
        },
        noQs: true,responseType: "blob"}).then(res => {
        this.outLoading = false
        const blob = new Blob([res],{ type: 'application/octet-stream' });
        //将Blob 对象转换成字符串
        let reader = new FileReader();
        reader.readAsText(blob, 'utf-8');
        reader.onload = () => {
          try {
            let result = JSON.parse(reader.result);
            if (result.message) {
              this.$message.error(result.message);
            } else {
              const url = URL.createObjectURL(blob);
              const link = document.createElement('a');
              link.href = url;
              link.download = '标准查新导出.xlsx';
              link.click();
              this.$message.success('导出成功')
            }
          } catch (err) {
            console.log(err);
            const url = URL.createObjectURL(blob);
            const link = document.createElement('a');
            link.href = url;
            link.download = '标准查新导出.xlsx';
            link.click();
            this.$message.success('导出成功')
          }
        }
      })
    },
    // 导入
    beforeUpload(file) {
      if (file.size > 1024 * 1024 * 10) {
        this.$message.error('上传文件不超过10M');
        this.$refs.upload.clearFiles()
        return false;
      } else {
        this.upLoading = true;
        return true;
      }
    },
    onError(err, file, fileList) {
      this.$message.error('上传失败')
      this.$refs.upload.clearFiles()
    },
    handleSuccessUp(response) {
      this.upLoading = false;
      if (response.code == 200) {
        this.$message.success('上传成功');
        this.searchList()
      }
    },
    // 分页
    handleSizeChange(val) {
      this.page.size = val;
      this.searchList();
    },
    handleCurrentChange(val) {
      this.page.current = val;
      this.searchList();
    },
    //
    // 分页
    handleOldSizeChange(val) {
      this.oldPage.size = val;
      this.searchList();
    },
    handleOldCurrentChange(val) {
      this.oldPage.current = val;
      this.searchList();
    },
    //
    getUserList(){
      this.$axios.post(this.$api.user.selectUserList, {
        page: {current: -1, size: -1,},
        entity: {name: null}
      }, {
        headers: {
          'Content-Type': 'application/json'
        }
      }).then(res => {
        if (res.code === 201) {
          return
        }
        this.userList = res.data.body.records
      })
    },
  },
  // 用于上传文件的信息
  computed: {
    headers() {
      return {
        'token': sessionStorage.getItem('token')
      }
    },
    action() {
      return this.javaApi + this.$api.processMethodSearchNew.importMethodSearchNew
    }
  },
};
</script>
 
<style scoped>
.view-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 60px;
  padding-left: 20px;
}
.search-background {
  width: 100%;
  height: 80px;
  line-height: 80px;
  background-color: #ffffff;
  display: flex;
}
.search-group {
  display: flex;
  align-items: center;
  margin: 0 20px;
}
.table {
  margin-top: 20px;
  background-color: #ffffff;
  padding-top: 10px;
}
.table-tab {
  margin: 0 10px 10px 14px;
}
.inline-upload {
  display: inline-block;
  vertical-align: middle;
}
</style>