多体系建设信息化条统-前端
zhouwx
7 days ago 863e009aacba6079b82a1a4bedf9ed47370b8138
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
<template>
  <div class="app-container">
    <div style="display: flex;justify-content: space-between">
      <el-form :inline="true" style="display: flex;align-items: center;flex-wrap: wrap;" >
        <el-form-item>
          <el-button
              type="primary"
              plain
              icon="Plus"
              @click="openDialog('add',{})"
              v-hasPermi="['annualVerificationPlan:list:add']"
          >新增</el-button>
        </el-form-item>
        <el-form-item v-if="isAdmin" label="单位:" >
          <el-select v-model="queryParams.companyId" placeholder="请选择" clearable>
            <el-option
                v-for="item in companyList"
                :key="item.id"
                :label="item.name"
                :value="item.id">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="年份:">
          <el-date-picker
              v-model="queryParams.year"
              type="year"
              value-format="YYYY"
              placeholder="请选择年份"
          />
        </el-form-item>
        <el-form-item >
          <el-button  type="primary" @click="getList">查询</el-button>
          <el-button  type="primary" plain @click="reset">重置</el-button>
          <el-button type="primary"  @click="openDialog('edit',dataList)" v-if="data.hasInfo" v-hasPermi="['annualVerificationPlan:list:edit']">编辑</el-button>
          <el-button type="primary" plain @click="downloadFile()" v-if="data.hasInfo">导出</el-button>
          <el-button  type="primary" plain @click="copy">复制</el-button>
<!--          <el-button type="primary">导出</el-button>-->
        </el-form-item>
      </el-form>
    </div>
    <div style="background: #fff;padding: 20px;border-radius: 0.6rem">
      <el-form :model="dataList" label-position="left" size="default" label-width="120px" v-if="data.hasInfo">
        <el-form-item v-if="isAdmin" label="单位:" prop="companyId">
          <el-input
              v-model.trim="dataList.companyName"
              style="width: 100%;"
              readonly
          >
          </el-input>
        </el-form-item>
        <el-form-item label="计划名称:" prop="name">
          <el-input
              v-model.trim="dataList.name"
              style="width: 100%;"
              readonly
          >
          </el-input>
        </el-form-item>
        <el-form-item label="年份:" prop="year">
          <el-input
              v-model.trim="dataList.year"
              style="width: 100%;"
              readonly
          >
          </el-input>
        </el-form-item>
        <el-form-item label="设备列表:" prop="annualVerificationDevices">
 
        </el-form-item>
        <el-table v-if="dataList.annualVerificationDevices && dataList.annualVerificationDevices.length>0" :data="dataList.annualVerificationDevices" style="margin-bottom: 20px" :border="true">
          <el-table-column label="序号" type="index" width="80" align="center">
          </el-table-column>
          <el-table-column label="设备编号" prop="deviceNumber" align="center"/>
          <el-table-column label="设备名称" prop="deviceName" align="center"/>
          <el-table-column label="设备类型" prop="planType" align="center">
            <template #default="scope">
              {{scope.row.planType == 1?'软件':'硬件'}}
            </template>
          </el-table-column>
          <el-table-column label="规格型号" prop="model" align="center"/>
          <el-table-column label="校准周期" prop="calibrationCycle" align="center"/>
          <el-table-column label="下次校准时间" prop="nextCalibrationTime" align="center">
            <template #default="scope">
              {{scope.row.nextCalibrationTime?.substring(0,10)}}
            </template>
          </el-table-column>
          <el-table-column label="实际检定时间" prop="actCalibrationTime" align="center">
            <template #default="scope">
              {{scope.row.actCalibrationTime?.substring(0,10)}}
            </template>
          </el-table-column>
          <el-table-column label="校准人" prop="calibrationUser" align="center"/>
          <el-table-column label="目前状态" prop="status" align="center"/>
          <el-table-column label="使用单位" prop="useUser" align="center"/>
          <el-table-column label="证书编号" prop="certificateName" align="center"/>
          <el-table-column label="证书" prop="certificate" align="center">
            <template #default="scope">
              <div v-if="scope.row.certificate && scope.row.certificate!==''" style="cursor:pointer;">
                <iframe
                    v-if="scope.row.certificate.split('.').pop().toLowerCase() == 'pdf'"
                    :src="data.baseUrl + '/' + scope.row.certificate"
                    width="100px"
                    height="100px"
                    style="overflow: hidden"
                ></iframe>
                <el-image
                    v-else
                    style="width: 100px; height: 100px"
                    :src="data.baseUrl + '/' + scope.row.certificate"
                    :max-scale="7"
                    :min-scale="0.2"
                    :preview-src-list="[data.baseUrl + '/' + scope.row.certificate]"
                    :initial-index="0"
                    fit="cover"
                    :preview-teleported=true
                />
              </div>
              <el-link type="primary" :href="data.baseUrl + '/' + scope.row.certificate" target="_blank">预览</el-link>
            </template>
          </el-table-column>
        </el-table>
  <!--      <el-form-item label="检定证书:" prop="certificate">-->
  <!--        <el-upload accept=".pdf,image/*" :action="state.uploadUrl" :headers="state.header" method="post" :on-success="(res, uploadFile)=>handleAvatarSuccess(res, uploadFile)" :on-exceed="showTip" :limit='state.fileLimit' v-model:file-list="state.fileList" :before-upload="picSize" :on-remove="(file, uploadFiles)=>handleRemove(file, uploadFiles)" >-->
  <!--          <el-button type="primary">点击上传</el-button>-->
  <!--          <template #tip>-->
  <!--            <div class="el-upload__tip">支持上传pdf、图片格式,尺寸小于5M,最多可上传1份</div>-->
  <!--          </template>-->
  <!--        </el-upload>-->
  <!--      </el-form-item>-->
        <el-row :gutter="30">
          <el-col :span="12">
            <el-form-item label="编制:" prop="establishmentName">
              <el-input
                  v-model.trim="dataList.establishmentName"
                  style="width: 100%;"
                  readonly
              >
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="日期:" prop="establishmentTime" >
              <el-input
                  v-model.trim="dataList.establishmentTime"
                  style="width: 100%;"
                  readonly
              >
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="30">
          <el-col :span="12">
            <el-form-item label="审核:" prop="processName">
              <el-input
                  v-model.trim="dataList.processName"
                  style="width: 100%;"
                  readonly
              >
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="日期:" prop="processTime" >
              <el-input
                  v-model.trim="dataList.processTime"
                  style="width: 100%;"
                  readonly
              >
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div v-else>暂无计划</div>
    </div>
    <!-- 表格数据 -->
<!--    <el-table v-loading="loading" :data="dataList" :border="true">-->
<!--      <el-table-column type="index" label="序号"></el-table-column>-->
<!--      <el-table-column prop="name" align="center" label="计划名称"></el-table-column>-->
<!--      <el-table-column prop="certificateName" align="center" label="检定证书">-->
<!--        <template #default="scope">-->
<!--          {{scope.row.certificateName}}-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="操作" align="center">-->
<!--        <template #default="scope">-->
<!--          <el-button link type="primary" @click="openDialog('view',scope.row)">查看</el-button>-->
<!--          <el-button link type="primary" @click="openDialog('edit',scope.row)">编辑</el-button>-->
<!--          <el-button link type="primary" @click="openDialog('upload',scope.row)">上传证书</el-button>-->
<!--          <el-button link type="primary" @click="downloadFile(scope.row)">导出</el-button>-->
<!--          <el-button link type="danger" @click="handleDelete(scope.row)">删除</el-button>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--    </el-table>-->
 
<!--    <pagination-->
<!--        v-show="total > 0"-->
<!--        :total="total"-->
<!--        v-model:page="queryParams.pageNum"-->
<!--        v-model:limit="queryParams.pageSize"-->
<!--        @pagination="getList"-->
<!--    />-->
 
    <edit-dialog ref="dialogRef" @getList=getList></edit-dialog>
    <el-dialog
        v-model="copyVisible"
        width="500px"
        :before-close="handleCloseCopy"
        :close-on-press-escape="false"
        :close-on-click-modal="false"
    >
      <div v-if="data.isAdmin">
        <span style="display:block;margin-bottom: 8px">单位名称:</span>
        <el-select
            v-model="queryParams.companyId"
            filterable
            style="width: 100%;margin-bottom: 8px"
        >
          <el-option
              v-for="item in data.companyList"
              :key="item.id"
              :label="item.name"
              :value="item.id"
          />
        </el-select>
      </div>
      <span style="display:block;margin-bottom: 8px">将以下年份数据:</span>
      <el-date-picker
          v-model="data.sourceYear"
          type="year"
          value-format="YYYY"
          style="margin-bottom: 8px;width: 100%;"
          placeholder="请选择"
      />
      <span style="display:block;margin-bottom: 8px">复制到:</span>
      <el-date-picker
          v-model="data.targetYear"
          type="year"
          value-format="YYYY"
          style="margin-bottom: 8px;width: 100%"
          placeholder="请选择"
      />
      <div class="dialog-footer" style="display: flex;justify-content: right">
        <el-button @click="handleCloseCopy" size="default">取 消</el-button>
        <el-button type="primary"  @click="onSubmitCopy" size="default" v-preReClick>确认</el-button>
      </div>
    </el-dialog>
  </div>
</template>
 
<script setup>
import {getCurrentInstance, onMounted, onUnmounted, reactive, ref, toRefs} from "vue";
import {ElMessage, ElMessageBox} from "element-plus";
import {delCompany, getCompany} from "@/api/onlineEducation/company";
import Cookies from "js-cookie";
import editDialog from './components/editDialog.vue'
import useUserStore from "@/store/modules/user";
import {generateWordDocument} from "@/utils/exportWord";
import {
  delMaintenanceEvaluate,
  getMaintenanceEvaluateDetail,
  getMaintenanceEvaluateList
} from "@/api/infrastructureMng/ledger";
import {
  copyAnnualVerificationPlan,
  delAnnualVerificationPlan,
  getAnnualVerificationPlanDetail,
  getAnnualVerificationPlanList
} from "@/api/assetManage/assetMng";
import {copyControl} from "@/api/environment/factors";
 
 
const userStore = useUserStore()
const { proxy } = getCurrentInstance();
const loading = ref(false);
const dialogRef = ref();
const data = reactive({
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    companyId: null,
    year: ''
  },
  total: 0,
  dataList: {},
  companyList: [],
  isAdmin: false,
  baseUrl: import.meta.env.VITE_APP_BASE_API,
  hasInfo: false,
  copyVisible:false,
  targetYear:'',
  sourceYear:'',
});
 
const { queryParams, total, dataList,companyList, isAdmin, copyVisible } = toRefs(data);
const userInfo = ref()
onMounted(async ()=>{
  data.queryParams.year = new Date().getFullYear().toString()
  if(userStore.roles.includes('admin')){
    data.isAdmin = true
    await getCompanyList()
  }else{
    data.isAdmin = false
    data.queryParams.companyId = userStore.companyId
  }
  await getList()
})
 
onUnmounted(()=>{
 
})
 
const getList = async () => {
  loading.value = true
  const res = await getAnnualVerificationPlanList(data.queryParams)
  if(res.code == 200){
    if(Array.isArray(res.data.list) && res.data.list.length>0){
      data.hasInfo = true
      const re = await getAnnualVerificationPlanDetail({id: res.data.list[0].id})
      if(re.code == 200){
        if(re.data){
          data.dataList = re.data
          data.dataList.companyName = data.companyList.find(i=>i.id == data.dataList.companyId)?.name
          data.dataList.establishmentTime = data.dataList.establishmentTime.substring(0,10)
          data.dataList.processTime = data.dataList.processTime.substring(0,10)
          console.log(data.dataList,'data')
        }
      }else{
        data.hasInfo = false
        data.dataList = {}
        data.dataList.companyName = ''
        ElMessage.warning(res.message)
      }
    }else{
      data.hasInfo = false
      data.dataList = {}
      data.dataList.companyName = ''
    }
  }else{
    ElMessage.warning(res.message)
  }
  loading.value = false
}
 
const getCompanyList = async ()=>{
  const queryParams = {
    pageNum: 1,
    pageSize: 999
  }
  const res = await getCompany(queryParams)
  if (res.code == 200) {
    data.companyList = res.data.list?res.data.list:[]
  } else {
    ElMessage.warning(res.message)
  }
}
 
const downloadFile = async ()=>{
      let tableData = data.dataList
      tableData.table = data.dataList.annualVerificationDevices.map((item,index)=>{
        return {
          ...item,
          index: index + 1,
          nextCalibrationTime: item.nextCalibrationTime.substring(0,10),
          actCalibrationTime: item.actCalibrationTime.substring(0,10)
        }
      })
      tableData.establishmentTime = tableData.establishmentTime.substring(0,10)
      tableData.processTime = tableData.processTime.substring(0,10)
      try {
        generateWordDocument('/annualVerificationPlan.docx', tableData, tableData.name +'.docx');
      } catch (error){
        ElMessage({
          type: 'warning',
          message: '导出失败'
        });
      }
}
 
const openDialog = (type, value) => {
  if(!data.queryParams.companyId){
    ElMessage.warning('请先选择单位')
    return
  }
  dialogRef.value.openDialog(type, value, data.queryParams.companyId, data.isAdmin, data.companyList);
}
 
/** 重置新增的表单以及其他数据  */
const reset= async()=> {
  if(data.isAdmin){
    data.queryParams = {
      companyId: '',
      pageNum: 1,
      pageSize: 10,
      year: new Date().getFullYear().toString(),
    }
    data.companyList = [];
    await getCompanyList()
  }else {
    data.queryParams = {
      companyId: data.queryParams.companyId,
      pageNum: 1,
      pageSize: 10,
      year: new Date().getFullYear().toString(),
    }
  }
  await getList()
}
 
const handleDelete = (val) => {
  ElMessageBox.confirm(
      '确定删除此条数据?',
      '提示',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
      .then( async() => {
        const res = await delAnnualVerificationPlan({id: val.id})
        if(res.code == 200){
          ElMessage.success('数据删除成功')
          await getList()
        }else{
          ElMessage.warning(res.message)
        }
      })
}
const copy = () => {
 
  data.copyVisible = true
}
const onSubmitCopy = async () => {
  if(data.isAdmin && !data.queryParams.companyId){
    ElMessage.warning('请先选择单位')
    return
  }
  if(!data.sourceYear){
    ElMessage.warning('请先选择要复制的年份')
    return
  }
  if(!data.targetYear){
    ElMessage.warning('请选择目标年份')
    return
  }
  ElMessageBox.confirm(
      '该操作将覆盖目标年份的数据,是否继续?',
      '提示',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
      .then( async() => {
        const param = {
          companyId: data.queryParams.companyId,
          sourceYear: data.sourceYear,
          targetYear: data.targetYear
        }
        const res = await copyAnnualVerificationPlan(param);
        if(res.code === 200){
          ElMessage({
            type: 'success',
            message: res.data
          });
          await handleCloseCopy()
          await getList();
 
        }else{
          ElMessage.warning(res.message)
        }
      }).catch(err => {
  })
}
const handleCloseCopy = () => {
  data.targetYear=''
  data.sourceYear=''
  data.copyVisible = false
}
 
</script>