licp
2024-12-25 8b106796403b21a72f35cb114b12d66df885da86
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
<template>
  <div>
    <div>
      <div class="view-title">
        <span>量值溯源计划</span>
        <span>
          <el-button size="medium" @click="exportFun">导 出</el-button>
          <el-button size="medium" @click="uploadDia = true">导 入</el-button>
          <el-button size="medium" type="primary" @click="openFormDia('add')">新 增</el-button>
        </span>
      </div>
      <div class="search-background">
        <span class="search-group">
          <span style="width: 120px">仪器名称:</span>
          <el-input v-model="searchForm.instrumentName" clearable size="small"></el-input>
        </span>
        <span class="search-group">
          <span style="width: 120px">管理编号:</span>
          <el-input v-model="searchForm.managementNumber" clearable size="small"></el-input>
        </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>
          <TableCard :showForm="false" :showTitle="false">
            <template v-slot:table>
              <ZTTable
                :column="tableColumn"
                :height="'calc(100vh - 23em)'"
                :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>
    </div>
    <form-dia v-if="formDia" ref="formDia" @closeFormDia="closeFormDia"></form-dia>
    <el-dialog :visible.sync="uploadDia" title="数据导入" width="500px">
      <div style="margin: 0 auto;">
        <el-upload ref="upload" :action="javaApi + $api.feCalibrationSchedule.importOfValueTraceabilityPlan" :auto-upload="false" :before-upload="beforeUpload" :file-list="fileList" :headers="token"
                   :limit="1" :on-error="onError" :on-success="onSuccess" accept=".xlsx" drag
                   name="file">
          <i class="el-icon-upload"></i>
          <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
        </el-upload>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="uploadDia = false">取 消</el-button>
        <el-button :loading="uploading" type="primary" @click="submitUpload()">上 传</el-button>
      </span>
    </el-dialog >
  </div>
</template>
 
<script>
import TableCard from '../caorui/TableCard/index.vue';
import ZTTable from '../caorui/ZTTable/index.vue';
import FormDia from '../do/a6-quantity-value-traceability-plan/formDia.vue';
 
export default {
  name: 'a6-quantity-value-traceability-plan',
  // import 引入的组件需要注入到对象中才能使用
  components: { FormDia, ZTTable, TableCard },
  data() {
    // 这里存放数据
    return {
      outLoading: false,
      searchForm: {
        instrumentName: '',
        managementNumber: '',
      },
      tableColumn: [
        {
          label: '仪器名称',
          prop: 'instrumentName',
          minWidth: '120'
        },
        {
          label: '规格型号',
          prop: 'model',
          minWidth: '100'
        },
        {
          label: '管理编号',
          prop: 'managementNumber',
          minWidth: '100'
        },
        {
          label: '技术指标',
          prop: 'technicalIndicators',
          minWidth: '100'
        },
        {
          label: '检定周期',
          prop: 'verificationCyde',
          minWidth: '100'
        },
        {
          label: '检定单位',
          prop: 'verificationUnit',
          minWidth: '100'
        },
        {
          label: '最近检定日期',
          prop: 'recentlyTime',
          minWidth: '100'
        },
        {
          label: '计划下次检定日期',
          prop: 'nextTime',
          minWidth: '100'
        },
        {
          label: '备注',
          prop: 'remark',
          minWidth: '100'
        },
        {
          dataType: 'action',
          fixed: 'right',
          minWidth: '180',
          label: '操作',
          operation: [
            {
              name: '编辑',
              type: 'text',
              clickFun: (row) => {
                this.openFormDia('edit', row);
              },
            },
            {
              name: '删除',
              type: 'text',
              color: '#f56c6c',
              clickFun: (row) => {
                this.delPlan(row)
              },
            }
          ]
        }
      ],
      tableData: [],
      tableLoading: false,
      uploadDia: false,
      uploading: false,
      page: {
        size: 20,
        current: 1,
      },
      total: 0,
      formDia: false,
      fileList: [],
      token: ""
    };
  },
  mounted() {
    this.token = {
      'token': sessionStorage.getItem('token')
    }
    this.searchList()
  },
  // 方法集合
  methods: {
    beforeUpload(file, fileList) {
      if (file.type != 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') {
        this.$message.error('上传文件格式不正确');
        this.$refs.upload.clearFiles()
        return false;
      }
    },
    submitUpload() {
      if (this.$refs.upload.uploadFiles.length == 0) {
        this.$message.error('未选择文件')
        return
      }
      this.uploading = true
      this.$refs.upload.submit();
      this.uploading = false
    },
    onError(err, file, fileList) {
      this.$message.error('上传失败')
      this.$refs.upload.clearFiles()
      this.uploading = false
    },
    onSuccess(response, file, fileList) {
      this.$refs.upload.clearFiles()
      this.uploadDia = false
      this.uploading = false
      if (response.code == 201) {
        this.$message.error(response.message)
        return
      }
      this.$message.success('上传成功')
      this.standardList = []
      this.productList = []
      this.searchList()
    },
    // 导出
    exportFun() {
      this.outLoading = true
      this.$axios.post(this.$api.feCalibrationSchedule.exportOfValueTraceabilityPlan, {
        instrumentName: this.searchForm.instrumentName,
        managementNumber:this.searchForm.managementNumber,
      }, {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('导出成功')
          }
        }
      }).finally(() => {
        this.outLoading = false
      })
    },
    // 查询列表
    searchList () {
      this.tableLoading = true
      this.$axios.get(this.$api.feCalibrationSchedule.getPageCalibrationSchedule + '?instrumentName=' + this.searchForm.instrumentName
        + '&managementNumber=' + this.searchForm.managementNumber
        + '&pages=' + this.page.current + '&size=' + this.page.size).then(res => {
        this.tableLoading = false
        if (res.code === 201) return
        this.tableData = res.data.records
        this.total = res.data.total
      }).catch(err => {
        console.log('err---', err);
        this.tableLoading = false
      })
    },
    // 删除
    delPlan (row) {
      this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.tableLoading = true
        this.$axios.get(this.$api.feCalibrationSchedule.removeCalibrationSchedule + '?id=' + row.id).then(res => {
          this.tableLoading = false
          if (res.code === 201) return
          this.$message.success('删除成功')
          this.searchList()
        }).catch(err => {
          this.tableLoading = false
          console.log('err---', err);
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },
    // 重置查询条件
    resetSearchForm () {
      this.searchForm.instrumentName = '';
      this.searchForm.managementNumber = '';
      this.searchList()
    },
    // 新增,编辑,批准弹框
    openFormDia (type, row) {
      this.formDia = true
      this.$nextTick(() => {
        this.$refs.formDia.openDia(type, row)
      })
    },
    closeFormDia () {
      this.formDia = false
      this.searchList()
    },
    // 分页
    handleSizeChange(val) {
      this.page.size = val;
      this.searchList();
    },
    handleCurrentChange(val) {
      this.page.current = val;
      this.searchList();
    },
  }
};
</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: 20px;
}
</style>