Browse Source

Merge branch 'equipManage' into dev

huoyi 1 month ago
parent
commit
aebaf4ac30

+ 54 - 0
src/api/equipManage/equipLedger.js

@@ -0,0 +1,54 @@
1
+import request from '@/utils/request'
2
+
3
+// 查询设备台账列表
4
+export function listEquipLedger(query) {
5
+  return request({
6
+    url: '/equipment/ledger/list',
7
+    method: 'get',
8
+    params: query
9
+  })
10
+}
11
+
12
+// 获取设备台账详细信息
13
+export function getEquipLedger(ledgerId) {
14
+  return request({
15
+    url: '/equipment/ledger/' + ledgerId,
16
+    method: 'get'
17
+  })
18
+}
19
+
20
+// 新增设备台账
21
+export function addEquipLedger(data) {
22
+  return request({
23
+    url: '/equipment/ledger',
24
+    method: 'post',
25
+    data: data
26
+  })
27
+}
28
+
29
+// 修改设备台账
30
+export function updateEquipLedger(data) {
31
+  return request({
32
+    url: '/equipment/ledger',
33
+    method: 'put',
34
+    data: data
35
+  })
36
+}
37
+
38
+// 删除设备台账
39
+export function delEquipLedger(ledgerIds) {
40
+  return request({
41
+    url: '/equipment/ledger/' + ledgerIds,
42
+    method: 'delete'
43
+  })
44
+}
45
+
46
+// 导出设备台账列表
47
+export function exportEquipLedger(data) {
48
+  return request({
49
+    url: '/equipment/ledger/export',
50
+    method: 'post',
51
+    data: data,
52
+    responseType: 'blob'
53
+  })
54
+}

+ 591 - 0
src/views/equipManage/equipLedger/index.vue

@@ -0,0 +1,591 @@
1
+<template>
2
+  <div class="app-container">
3
+    <!-- 查询条件 -->
4
+    <div class="filter-container">
5
+      <el-form :model="queryParams" ref="queryFormRef" :inline="true" class="search-form">
6
+        <el-form-item label="设备名称" prop="equipmentName">
7
+          <el-input v-model="queryParams.equipmentName" placeholder="请输入设备名称" clearable style="width: 200px" />
8
+        </el-form-item>
9
+        <el-form-item label="使用状态" prop="usageStatus">
10
+          <el-select v-model="queryParams.usageStatus" placeholder="请选择使用状态" clearable style="width: 200px">
11
+            <el-option v-for="dict in equipment_usage_status" :key="dict.value" :label="dict.label" :value="dict.value" />
12
+          </el-select>
13
+        </el-form-item>
14
+        <el-form-item label="最近定/自检日期" prop="inspectionSelfCheckDate">
15
+          <el-date-picker v-model="queryParams.inspectionSelfCheckDate" type="date" value-format="YYYY-MM-DD" placeholder="请选择日期" style="width: 200px" />
16
+        </el-form-item>
17
+        <el-form-item label="检查成员" prop="inspectionTeamUserName">
18
+          <el-input v-model="queryParams.inspectionTeamUserName" placeholder="请输入检查成员" clearable style="width: 200px" />
19
+        </el-form-item>
20
+        <el-form-item>
21
+          <el-button type="primary" icon="Search" @click="handleQuery">查询</el-button>
22
+          <el-button icon="Refresh" @click="resetQuery">重置</el-button>
23
+        </el-form-item>
24
+      </el-form>
25
+    </div>
26
+
27
+    <!-- 操作按钮 -->
28
+    <div class="operation-container">
29
+      <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['equipment:ledger:add']">新增</el-button>
30
+      <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleBatchDelete" v-hasPermi="['equipment:ledger:delete']">删除</el-button>
31
+      <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['equipment:ledger:export']">导出</el-button>
32
+      <el-button type="info" plain icon="Upload" @click="handleImport" v-hasPermi="['equipment:ledger:import']">导入</el-button>
33
+    </div>
34
+
35
+    <!-- 数据表格 -->
36
+    <el-table v-loading="loading" :data="tableData" border @selection-change="handleSelectionChange">
37
+      <el-table-column type="selection" width="55" align="center" />
38
+      <el-table-column label="序号" prop="rowIndex" width="70" align="center">
39
+        <template #default="scope">
40
+          {{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
41
+        </template>
42
+      </el-table-column>
43
+      <el-table-column label="设备编号" prop="equipmentCode" align="center" min-width="120">
44
+        <template #default="scope">
45
+          <el-link type="primary" @click="handleDetail(scope.row)">{{ scope.row.equipmentCode }}</el-link>
46
+        </template>
47
+      </el-table-column>
48
+      <el-table-column label="设备名称" prop="equipmentName" align="center" min-width="150" show-overflow-tooltip />
49
+      <el-table-column label="设备序列号" prop="equipmentSerialNumber" align="center" min-width="150" show-overflow-tooltip />
50
+      <el-table-column label="安装位置" prop="installationLocation" align="center" min-width="150" show-overflow-tooltip />
51
+      <el-table-column label="使用状态" prop="usageStatus" align="center" min-width="100">
52
+        <template #default="scope">
53
+          <dict-tag :options="equipment_usage_status" :value="scope.row.usageStatus" />
54
+          
55
+        </template>
56
+      </el-table-column>
57
+      <el-table-column label="定/自检小组组长" prop="inspectionTeamLeaderName" align="center" min-width="120" show-overflow-tooltip />
58
+      <el-table-column label="定/自检小组组员1" prop="inspectionTeamMember1Name" align="center" min-width="120" show-overflow-tooltip />
59
+      <el-table-column label="定/自检小组组员2" prop="inspectionTeamMember2Name" align="center" min-width="120" show-overflow-tooltip />
60
+      <el-table-column label="最近定检/自检日期" prop="inspectionSelfCheckDate" align="center" min-width="120" />
61
+      <el-table-column label="操作" align="center" width="220" fixed="right">
62
+        <template #default="scope">
63
+          <el-button link type="primary" icon="View" @click="handleDetail(scope.row)">详情</el-button>
64
+          <el-button link type="primary" icon="Edit" @click="handleEdit(scope.row)">编辑</el-button>
65
+          <el-button link type="danger" icon="Delete" @click="handleDelete(scope.row)">删除</el-button>
66
+        </template>
67
+      </el-table-column>
68
+    </el-table>
69
+
70
+    <!-- 分页 -->
71
+    <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
72
+
73
+    <!-- 编辑/详情弹窗 -->
74
+    <el-dialog :title="dialog.title" v-model="dialog.visible" width="1000px" :close-on-click-modal="false">
75
+      <el-form :model="form" ref="formRef" :rules="rules" label-width="160px">
76
+        <el-row :gutter="20">
77
+          <el-col :span="12">
78
+            <el-form-item label="设备名称" prop="equipmentName">
79
+              <el-input v-model="form.equipmentName" placeholder="请输入设备名称" :disabled="formDisabled" />
80
+            </el-form-item>
81
+          </el-col>
82
+          <el-col :span="12">
83
+            <el-form-item label="设备种类" prop="equipmentType">
84
+              <el-input v-model="form.equipmentType" placeholder="请输入设备种类" :disabled="formDisabled" />
85
+            </el-form-item>
86
+          </el-col>
87
+          <el-col :span="12">
88
+            <el-form-item label="设备类别" prop="equipmentCategory">
89
+              <el-input v-model="form.equipmentCategory" placeholder="请输入设备类别" :disabled="formDisabled" />
90
+            </el-form-item>
91
+          </el-col>
92
+          <el-col :span="12">
93
+            <el-form-item label="设备品牌" prop="equipmentBrand">
94
+              <el-input v-model="form.equipmentBrand" placeholder="请输入设备品牌" :disabled="formDisabled" />
95
+            </el-form-item>
96
+          </el-col>
97
+          <el-col :span="12">
98
+            <el-form-item label="设备型号" prop="equipmentModel">
99
+              <el-input v-model="form.equipmentModel" placeholder="请输入设备型号" :disabled="formDisabled" />
100
+            </el-form-item>
101
+          </el-col>
102
+          <el-col :span="12">
103
+            <el-form-item label="设备序列号" prop="equipmentSerialNumber">
104
+              <el-input v-model="form.equipmentSerialNumber" placeholder="请输入设备序列号" :disabled="formDisabled" />
105
+            </el-form-item>
106
+          </el-col>
107
+          <el-col :span="12">
108
+            <el-form-item label="生产厂家" prop="manufacturer">
109
+              <el-input v-model="form.manufacturer" placeholder="请输入生产厂家" :disabled="formDisabled" />
110
+            </el-form-item>
111
+          </el-col>
112
+          <el-col :span="12">
113
+            <el-form-item label="出厂日期" prop="manufacturingDate">
114
+              <el-date-picker v-model="form.manufacturingDate" type="date" value-format="YYYY-MM-DD" placeholder="请选择出厂日期" :disabled="formDisabled" />
115
+            </el-form-item>
116
+          </el-col>
117
+          <el-col :span="12">
118
+            <el-form-item label="验收日期" prop="acceptanceDate">
119
+              <el-date-picker v-model="form.acceptanceDate" type="date" value-format="YYYY-MM-DD" placeholder="请选择验收日期" :disabled="formDisabled" />
120
+            </el-form-item>
121
+          </el-col>
122
+          <el-col :span="12">
123
+            <el-form-item label="启用日期" prop="commissioningDate">
124
+              <el-date-picker v-model="form.commissioningDate" type="date" value-format="YYYY-MM-DD" placeholder="请选择启用日期" :disabled="formDisabled" />
125
+            </el-form-item>
126
+          </el-col>
127
+          <el-col :span="12">
128
+            <el-form-item label="使用状态" prop="usageStatus">
129
+              <el-select v-model="form.usageStatus" placeholder="请选择使用状态" :disabled="formDisabled">
130
+                <el-option v-for="dict in equipment_usage_status" :key="dict.value" :label="dict.label" :value="dict.value" />
131
+              </el-select>
132
+            </el-form-item>
133
+          </el-col>
134
+          <el-col :span="12">
135
+            <el-form-item label="报废日期" prop="scrappingDate">
136
+              <el-date-picker v-model="form.scrappingDate" type="date" value-format="YYYY-MM-DD" placeholder="请选择报废日期" :disabled="formDisabled" />
137
+            </el-form-item>
138
+          </el-col>
139
+          <el-col :span="12">
140
+            <el-form-item label="安装位置" prop="installationLocation">
141
+              <el-input v-model="form.installationLocation" placeholder="请输入安装位置" :disabled="formDisabled" />
142
+            </el-form-item>
143
+          </el-col>
144
+          <el-col :span="12">
145
+            <el-form-item label="定/自检日期" prop="inspectionSelfCheckDate">
146
+              <el-date-picker v-model="form.inspectionSelfCheckDate" type="date" value-format="YYYY-MM-DD" placeholder="请选择定/自检日期" :disabled="formDisabled" @change="calculateDueDate" />
147
+            </el-form-item>
148
+          </el-col>
149
+          <el-col :span="12">
150
+            <el-form-item label="定/自检周期" prop="inspectionSelfCheckCycle">
151
+              <el-input-number v-model="form.inspectionSelfCheckCycle" placeholder="请输入定/自检周期" :min="0" :precision="0" :disabled="formDisabled" @change="calculateDueDate" />&nbsp;月
152
+            </el-form-item>
153
+          </el-col>
154
+          <el-col :span="12">
155
+            <el-form-item label="最近定/自检到期日期" prop="nextInspectionDueDate">
156
+              <el-date-picker v-model="form.nextInspectionDueDate" type="date" value-format="YYYY-MM-DD" placeholder="请选择最近定/自检到期日期" :disabled="formDisabled" />
157
+            </el-form-item>
158
+          </el-col>
159
+          <el-col :span="12">
160
+            <el-form-item label="定/自检小组组长" prop="inspectionTeamLeaderId">
161
+              <UserSelect v-model="form.inspectionTeamLeaderId" :disabled="formDisabled" width="100%" placeholder="请选择组长" />
162
+            </el-form-item>
163
+          </el-col>
164
+          <el-col :span="12">
165
+            <el-form-item label="定/自检小组组员1" prop="inspectionTeamMember1Id">
166
+              <UserSelect v-model="form.inspectionTeamMember1Id" :disabled="formDisabled" width="100%" placeholder="请选择组员1" />
167
+            </el-form-item>
168
+          </el-col>
169
+          <el-col :span="12">
170
+            <el-form-item label="定/自检小组组员2" prop="inspectionTeamMember2Id">
171
+              <UserSelect v-model="form.inspectionTeamMember2Id" :disabled="formDisabled" width="100%" placeholder="请选择组员2" />
172
+            </el-form-item>
173
+          </el-col>
174
+          <el-col :span="24">
175
+            <el-form-item label="首次验收情况" prop="initialAcceptanceStatus">
176
+              <el-input v-model="form.initialAcceptanceStatus" type="textarea" :rows="3" placeholder="请输入首次验收情况" :disabled="formDisabled" />
177
+            </el-form-item>
178
+          </el-col>
179
+          <el-col :span="24">
180
+            <el-form-item label="设备图片" prop="baseAttachmentList">
181
+              <ImageUpload v-model="form.baseAttachmentList" :disabled="formDisabled" :limit="3" result-type="object" />
182
+            </el-form-item>
183
+          </el-col>
184
+        </el-row>
185
+
186
+        <!-- 定检记录表格 -->
187
+        <el-divider content-position="left">定检记录</el-divider>
188
+        <el-button type="primary" plain icon="Plus" @click="addCheckRecord" v-if="!formDisabled">新增定检记录</el-button>
189
+        <el-table :data="form.equipmentInspectionRecordList" border style="margin-top: 10px">
190
+          <el-table-column label="定检日期" prop="inspectionDate">
191
+            <template #default="scope">
192
+              <el-date-picker v-model="scope.row.inspectionDate" type="date" value-format="YYYY-MM-DD" placeholder="选择日期" :disabled="formDisabled" @change="handleInspectionDateChange(scope.row, scope.$index)" />
193
+            </template>
194
+          </el-table-column>
195
+          <el-table-column label="定检小组" prop="inspectionTeamName">
196
+            <template #default="scope">
197
+              <UserSelect v-model="scope.row.inspectionTeamIds" :multiple="true" :disabled="formDisabled" width="100%" placeholder="请选择" />
198
+            </template>
199
+          </el-table-column>
200
+          <el-table-column label="定检结论" prop="inspectionResult">
201
+            <template #default="scope">
202
+              <el-input v-model="scope.row.inspectionResult" placeholder="定检结论" :disabled="formDisabled" />
203
+            </template>
204
+          </el-table-column>
205
+          <el-table-column label="定检性质" prop="inspectionNature">
206
+            <template #default="scope">
207
+              <el-select v-model="scope.row.inspectionNature" placeholder="请选择" :disabled="formDisabled">
208
+                <el-option v-for="dict in equipment_inspection_nature" :key="dict.value" :label="dict.label" :value="dict.value" />
209
+              </el-select>
210
+            </template>
211
+          </el-table-column>
212
+          <el-table-column label="操作" width="80" v-if="!formDisabled">
213
+            <template #default="scope">
214
+              <el-button type="danger" link icon="Delete" @click="removeCheckRecord(scope.$index)" v-hasPermi="['equipment:ledger:delete']">删除</el-button>
215
+            </template>
216
+          </el-table-column>
217
+        </el-table>
218
+      </el-form>
219
+
220
+      <template #footer>
221
+        <el-button @click="dialog.visible = false">取消</el-button>
222
+        <el-button type="primary" @click="submitForm" v-if="!formDisabled">确定</el-button>
223
+      </template>
224
+    </el-dialog>
225
+
226
+    <!-- 导入对话框 -->
227
+    <el-dialog :title="upload.title" v-model="upload.open" width="400px" append-to-body>
228
+      <el-upload ref="uploadRef" :limit="1" accept=".xlsx, .xls" :headers="upload.headers" :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
229
+        <el-icon class="el-icon--upload"><UploadFilled /></el-icon>
230
+        <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
231
+        <template #tip>
232
+          <div class="el-upload__tip text-center">
233
+            <span>仅允许导入xls、xlsx格式文件。</span>
234
+            <el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline" @click="importTemplate">下载模板</el-link>
235
+          </div>
236
+        </template>
237
+      </el-upload>
238
+      <template #footer>
239
+        <div class="dialog-footer">
240
+          <el-button type="primary" @click="submitFileForm">确 定</el-button>
241
+          <el-button @click="upload.open = false">取 消</el-button>
242
+        </div>
243
+      </template>
244
+    </el-dialog>
245
+  </div>
246
+</template>
247
+
248
+<script setup>
249
+import { ref, reactive, onMounted, getCurrentInstance } from 'vue'
250
+import { ElMessage } from 'element-plus'
251
+import { UploadFilled } from '@element-plus/icons-vue'
252
+import ImageUpload from '@/components/ImageUpload/index.vue'
253
+import UserSelect from '@/components/UserSelect/index.vue'
254
+import { listEquipLedger, getEquipLedger, addEquipLedger, updateEquipLedger, delEquipLedger, exportEquipLedger } from '@/api/equipManage/equipLedger'
255
+import { getUser } from '@/api/system/user'
256
+import { getToken } from '@/utils/auth'
257
+
258
+const { proxy } = getCurrentInstance()
259
+
260
+const { equipment_usage_status, equipment_inspection_nature } = proxy.useDict('equipment_usage_status', 'equipment_inspection_nature')
261
+
262
+const loading = ref(false)
263
+
264
+const queryFormRef = ref()
265
+const formRef = ref()
266
+const tableData = ref([])
267
+const total = ref(0)
268
+const single = ref(true)
269
+const multiple = ref(true)
270
+const queryParams = reactive({
271
+  pageNum: 1,
272
+  pageSize: 10,
273
+  equipmentName: '',
274
+  usageStatus: '',
275
+  inspectionSelfCheckDate: '',
276
+  inspectionTeamUserName: ''
277
+})
278
+const dialog = reactive({
279
+  visible: false,
280
+  title: ''
281
+})
282
+const formDisabled = ref(false)
283
+const form = reactive({
284
+  id: null,
285
+  equipmentName: '',
286
+  equipmentType: '',
287
+  equipmentCategory: '',
288
+  equipmentBrand: '',
289
+  equipmentModel: '',
290
+  equipmentSerialNumber: '',
291
+  manufacturer: '',
292
+  manufacturingDate: '',
293
+  acceptanceDate: '',
294
+  commissioningDate: '',
295
+  usageStatus: '',
296
+  scrappingDate: '',
297
+  installationLocation: '',
298
+  inspectionSelfCheckDate: '',
299
+  inspectionSelfCheckCycle: 0,
300
+  nextInspectionDueDate: '',
301
+  inspectionTeamLeaderId: '',
302
+  inspectionTeamMember1Id: '',
303
+  inspectionTeamMember2Id: '',
304
+  initialAcceptanceStatus: '',
305
+  baseAttachmentList: [],
306
+  equipmentInspectionRecordList: []
307
+})
308
+const baseAttachmentListInternal = ref([])
309
+
310
+watch(() => form.baseAttachmentList, (newVal) => {
311
+  if (newVal && Array.isArray(newVal)) {
312
+    baseAttachmentListInternal.value = newVal.map(item => ({
313
+      attachmentName: item.name || item.originalFilename || '',
314
+      attachmentUrl: item.url || ''
315
+    }))
316
+  }
317
+}, { deep: true, immediate: true })
318
+const rules = {
319
+  equipmentName: [{ required: true, message: '设备名称不能为空', trigger: 'blur' }],
320
+  equipmentSerialNumber: [{ required: true, message: '设备序列号不能为空', trigger: 'blur' }]
321
+}
322
+const selectedIds = ref([])
323
+
324
+const upload = reactive({
325
+  open: false,
326
+  title: '',
327
+  isUploading: false,
328
+  updateSupport: 0,
329
+  headers: { Authorization: 'Bearer ' + getToken() },
330
+  url: import.meta.env.VITE_APP_BASE_API + '/equipment/ledger/importData'
331
+})
332
+
333
+function getList() {
334
+  loading.value = true
335
+  listEquipLedger(queryParams).then(response => {
336
+    tableData.value = response.rows
337
+    total.value = response.total
338
+    loading.value = false
339
+  })
340
+}
341
+
342
+function handleQuery() {
343
+  queryParams.pageNum = 1
344
+  getList()
345
+}
346
+
347
+function resetQuery() {
348
+  queryFormRef.value?.resetFields()
349
+  handleQuery()
350
+}
351
+
352
+function handleSelectionChange(selection) {
353
+  selectedIds.value = selection.map(item => item.id)
354
+  single.value = selection.length !== 1
355
+  multiple.value = !selection.length
356
+}
357
+
358
+function handleAdd() {
359
+  resetForm()
360
+  formDisabled.value = false
361
+  dialog.title = '新增设备'
362
+  dialog.visible = true
363
+}
364
+
365
+function handleEdit(row) {
366
+  getEquipLedger(row.id).then(response => {
367
+    Object.assign(form, response.data)
368
+    if (form.baseAttachmentList && Array.isArray(form.baseAttachmentList)) {
369
+      form.baseAttachmentList = form.baseAttachmentList.map(item => ({
370
+        name: item.attachmentName || item.name || '',
371
+        url: item.attachmentUrl || item.url || ''
372
+      }))
373
+    } else {
374
+      form.baseAttachmentList = []
375
+    }
376
+    if (!form.equipmentInspectionRecordList || !Array.isArray(form.equipmentInspectionRecordList)) {
377
+      form.equipmentInspectionRecordList = []
378
+    }
379
+    formDisabled.value = false
380
+    dialog.title = '编辑设备'
381
+    dialog.visible = true
382
+  })
383
+}
384
+
385
+function handleDetail(row) {
386
+  getEquipLedger(row.id).then(response => {
387
+    Object.assign(form, response.data)
388
+    if (form.baseAttachmentList && Array.isArray(form.baseAttachmentList)) {
389
+      form.baseAttachmentList = form.baseAttachmentList.map(item => ({
390
+        name: item.attachmentName || item.name || '',
391
+        url: item.attachmentUrl || item.url || ''
392
+      }))
393
+    } else {
394
+      form.baseAttachmentList = []
395
+    }
396
+    if (!form.equipmentInspectionRecordList || !Array.isArray(form.equipmentInspectionRecordList)) {
397
+      form.equipmentInspectionRecordList = []
398
+    }
399
+    formDisabled.value = true
400
+    dialog.title = '设备详情'
401
+    dialog.visible = true
402
+  })
403
+}
404
+
405
+function handleDelete(row) {
406
+  proxy.$modal.confirm('是否确认删除该设备?').then(function () {
407
+    return delEquipLedger(row.id)
408
+  }).then(() => {
409
+    getList()
410
+    proxy.$modal.msgSuccess('删除成功')
411
+  }).catch(() => { })
412
+}
413
+
414
+function handleBatchDelete() {
415
+  proxy.$modal.confirm('是否确认删除选中的设备?').then(function () {
416
+    return delEquipLedger(selectedIds.value.join(','))
417
+  }).then(() => {
418
+    getList()
419
+    proxy.$modal.msgSuccess('删除成功')
420
+  }).catch(() => { })
421
+}
422
+
423
+function handleExport() {
424
+  proxy.download('equipment/ledger/export', {
425
+    ...queryParams
426
+  }, `equipLedger_${new Date().getTime()}.xlsx`)
427
+}
428
+
429
+function handleImport() {
430
+  upload.title = '设备台账导入'
431
+  upload.open = true
432
+}
433
+
434
+function importTemplate() {
435
+  proxy.download('equipment/ledger/importTemplate', {}, `equipLedger_template_${new Date().getTime()}.xlsx`)
436
+}
437
+
438
+function resetForm() {
439
+  Object.assign(form, {
440
+    id: null,
441
+    equipmentName: '',
442
+    equipmentType: '',
443
+    equipmentCategory: '',
444
+    equipmentBrand: '',
445
+    equipmentModel: '',
446
+    equipmentSerialNumber: '',
447
+    manufacturer: '',
448
+    manufacturingDate: '',
449
+    acceptanceDate: '',
450
+    commissioningDate: '',
451
+    usageStatus: '1',
452
+    scrappingDate: '',
453
+    installationLocation: '',
454
+    inspectionSelfCheckDate: '',
455
+    inspectionSelfCheckCycle: 0,
456
+    nextInspectionDueDate: '',
457
+    inspectionTeamLeaderId: '',
458
+    inspectionTeamMember1Id: '',
459
+    inspectionTeamMember2Id: '',
460
+    initialAcceptanceStatus: '',
461
+    baseAttachmentList: [],
462
+    equipmentInspectionRecordList: []
463
+  })
464
+}
465
+
466
+async function submitForm() {
467
+  formRef.value?.validate(async valid => {
468
+    if (valid) {
469
+      const submitData = { ...form }
470
+      submitData.baseAttachmentList = baseAttachmentListInternal.value
471
+      
472
+      try {
473
+        if (submitData.inspectionTeamLeaderId) {
474
+          const leaderRes = await getUser(submitData.inspectionTeamLeaderId)
475
+          submitData.inspectionTeamLeaderName = leaderRes.data?.nickName || ''
476
+        }
477
+        if (submitData.inspectionTeamMember1Id) {
478
+          const member1Res = await getUser(submitData.inspectionTeamMember1Id)
479
+          submitData.inspectionTeamMember1Name = member1Res.data?.nickName || ''
480
+        }
481
+        if (submitData.inspectionTeamMember2Id) {
482
+          const member2Res = await getUser(submitData.inspectionTeamMember2Id)
483
+          submitData.inspectionTeamMember2Name = member2Res.data?.nickName || ''
484
+        }
485
+      } catch (error) {
486
+        console.error('获取用户信息失败:', error)
487
+      }
488
+
489
+      if (submitData.id != null) {
490
+        updateEquipLedger(submitData).then(response => {
491
+          proxy.$modal.msgSuccess('修改成功')
492
+          dialog.visible = false
493
+          getList()
494
+        })
495
+      } else {
496
+        addEquipLedger(submitData).then(response => {
497
+          proxy.$modal.msgSuccess('新增成功')
498
+          dialog.visible = false
499
+          getList()
500
+        })
501
+      }
502
+    }
503
+  })
504
+}
505
+
506
+function addCheckRecord() {
507
+  const teamIds = []
508
+  if (form.inspectionTeamLeaderId) {
509
+    teamIds.push(form.inspectionTeamLeaderId)
510
+  }
511
+  if (form.inspectionTeamMember1Id) {
512
+    teamIds.push(form.inspectionTeamMember1Id)
513
+  }
514
+  if (form.inspectionTeamMember2Id) {
515
+    teamIds.push(form.inspectionTeamMember2Id)
516
+  }
517
+  form.equipmentInspectionRecordList.push({
518
+    inspectionDate: '',
519
+    inspectionTeamIds: teamIds,
520
+    inspectionTeamName: '',
521
+    inspectionResult: '',
522
+    inspectionNature: ''
523
+  })
524
+}
525
+
526
+function removeCheckRecord(index) {
527
+  form.equipmentInspectionRecordList.splice(index, 1)
528
+}
529
+
530
+function handleInspectionDateChange(row, index) {
531
+  if (row.inspectionDate) {
532
+    const recordDate = new Date(row.inspectionDate)
533
+    const checkDate = form.inspectionSelfCheckDate ? new Date(form.inspectionSelfCheckDate) : null
534
+    
535
+    if (!checkDate || recordDate > checkDate) {
536
+      form.inspectionSelfCheckDate = row.inspectionDate
537
+      calculateDueDate()
538
+    }
539
+  }
540
+}
541
+
542
+function calculateDueDate() {
543
+  if (form.inspectionSelfCheckDate && form.inspectionSelfCheckCycle && form.inspectionSelfCheckCycle > 0) {
544
+    const checkDate = new Date(form.inspectionSelfCheckDate)
545
+    checkDate.setMonth(checkDate.getMonth() + form.inspectionSelfCheckCycle)
546
+    const year = checkDate.getFullYear()
547
+    const month = String(checkDate.getMonth() + 1).padStart(2, '0')
548
+    const day = String(checkDate.getDate()).padStart(2, '0')
549
+    form.nextInspectionDueDate = `${year}-${month}-${day}`
550
+  }
551
+}
552
+
553
+function handleFileUploadProgress(event, file, fileList) {
554
+  upload.isUploading = true
555
+}
556
+
557
+function handleFileSuccess(response, file, fileList) {
558
+  upload.open = false
559
+  upload.isUploading = false
560
+  proxy.$refs['uploadRef'].handleRemove(file)
561
+  proxy.$alert('<div style="overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;">' + response.msg + '</div>', '导入结果', { dangerouslyUseHTMLString: true })
562
+  getList()
563
+}
564
+
565
+function submitFileForm() {
566
+  proxy.$refs['uploadRef'].submit()
567
+}
568
+
569
+onMounted(() => {
570
+  getList()
571
+})
572
+</script>
573
+
574
+<style scoped>
575
+.app-container {
576
+  padding: 20px;
577
+}
578
+
579
+.filter-container {
580
+}
581
+
582
+.operation-container {
583
+  margin-bottom: 15px;
584
+}
585
+
586
+.search-form {
587
+  display: flex;
588
+  flex-wrap: wrap;
589
+  gap: 10px;
590
+}
591
+</style>

+ 0 - 0
src/views/equipManage/equipLedger/设备台账