多体系建设信息化条统-前端
zhouwx
23 hours ago 88fb30f552ae51cc85d969e3a5ce050628ce0b7c
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
<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="['equipCalibrateConfirm:add']"
          >新增</el-button>
        </el-form-item>
        <el-form-item v-if="isAdmin" label="单位:" >
          <el-select v-model="data.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="data.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">导出</el-button>-->
        </el-form-item>
      </el-form>
    </div>
    <!-- 表格数据 -->
    <el-table v-loading="loading" :data="dataList" :border="true">
      <el-table-column type="index" label="序号"></el-table-column>
      <el-table-column prop="deviceName" align="center" label="确认单">
        <template #default="scope">
          {{scope.row.deviceName + '确认单'}}
        </template>
      </el-table-column>
      <el-table-column prop="calibrationTime" align="center" label="校准日期" />
      <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)" v-hasPermi="['equipCalibrateConfirm:edit']">编辑</el-button>
          <el-button link type="primary" @click="downloadFile(scope.row)">导出</el-button>
          <el-button link type="danger" @click="handleDelete(scope.row)" v-hasPermi="['equipCalibrateConfirm:del']">删除</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>
  </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 {
  delMaintenanceRecord,
  getMaintenanceRecordDetail,
  getMaintenanceRecordList
} from "@/api/infrastructureMng/ledger";
import {getInternalAuditCheckInfo} from "@/api/innerReview/meetingReview";
import {delCalibrationMonitoringEquipment, getCalibrationMonitoringEquipmentList} from "@/api/assetManage/assetMng";
 
 
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: [],
  expertData: [],
  isAdmin: false
});
const fields = ref({
  '序号':'index',
  '名称型号':'username',
  '部门':'idCard',
  '责任人/使用人':'entryTime',
  '编号':'deptName',
  '使用地点':'duty',
  '使用情况':'phone'
});
const { queryParams, total, dataList,companyList, isAdmin,  expertData } = toRefs(data);
const userInfo = ref()
onMounted(async ()=>{
  if(userStore.roles.includes('admin')){
    data.isAdmin = true
    await getCompanyList()
  }else{
    data.isAdmin = false
    data.queryParams.companyId = userStore.companyId
  }
  await getNowYear()
  await getList()
})
const getNowYear = () =>{
  data.queryParams.year = new Date().getFullYear().toString()
}
onUnmounted(()=>{
 
})
 
const getList = async () => {
  loading.value = true
  const res = await getCalibrationMonitoringEquipmentList(data.queryParams)
  if(res.code == 200){
    data.dataList = res.data.list.map(item => {
      return{
        ...item,
        calibrationTime: item.calibrationTime.substring(0,10)
      }
    }) || []
    data.total = res.data.total
  }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:[]
    // data.queryParams.companyId = data.companyList[0].id
  } else {
    ElMessage.warning(res.message)
  }
}
 
const openDialog = (type, value) => {
  dialogRef.value.openDialog(type, value, data.queryParams.companyId, data.isAdmin, data.companyList);
}
 
const downloadFile = async (val)=>{
  let tableData = val
  tableData.calibrationTime = tableData.calibrationTime.substring(0,10)
  tableData.confirmTime = tableData.confirmTime.substring(0,10)
  tableData.executiveTime = tableData.executiveTime.substring(0,10)
  tableData.typeList = [
    {
      id: 1,
      label: '满足使用要求',
      checked: tableData.calibrationResult == 1 ? false : true
    },
    {
      id: 2,
      label: '不满足使用要求',
      checked: tableData.calibrationResult == 2 ? false : true
    }
  ]
  try {
    generateWordDocument('/equipCalibrateConfirm.docx', tableData, tableData.deviceName + '使用确认单.docx');
  } catch (error){
    ElMessage({
      type: 'warning',
      message: '导出失败'
    });
  }
}
 
/** 重置新增的表单以及其他数据  */
const reset= async()=>{
  if(data.isAdmin){
    data.queryParams = {
      companyId: '',
      pageNum: 1,
      pageSize: 10,
      year: '',
 
    }
    data.companyList = [];
    await getCompanyList()
  }else {
    data.queryParams = {
      companyId: data.queryParams.companyId,
      pageNum: 1,
      pageSize: 10,
      year: '',
    }
  }
  await getNowYear()
  await getList();
 
}
const handleDelete = (val) => {
  ElMessageBox.confirm(
      '确定删除此条数据?',
      '提示',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
      .then( async() => {
        const res = await delCalibrationMonitoringEquipment({id: val.id})
        if(res.code == 200){
          ElMessage.success('数据删除成功')
          await getList()
        }else{
          ElMessage.warning(res.message)
        }
      })
}
 
</script>