装备管理

This commit is contained in:
jiang 2025-07-31 17:41:14 +08:00
parent de842eefbb
commit 6625273a88
1 changed files with 121 additions and 163 deletions

View File

@ -1,19 +1,25 @@
<script setup lang="ts">
import TableComponent from 'components/TableComponent/index.vue'
import FormComponent from 'components/FormComponent/index.vue'
import PagingComponent from 'components/PagingComponent/index.vue'
import UploadComponentNew from 'components/uploadComponentNew/index.vue'
import TitleTip from 'components/TitleTip/index.vue'
import uploadComponent from 'components/uploadComponent/index.vue'
import previewImg from './previewImg/index.vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import type { FormInstance } from 'element-plus'
import { ElMessage, ElMessageBox } from 'element-plus'
import { ref } from 'vue'
import { useStore } from 'store/user'
const store = useStore()
import { mainStore } from 'store/main'
import { InfoFilled, UploadFilled, Delete } from '@element-plus/icons-vue'
import dayjs from 'dayjs'
import {
equipmentAddApi,
equipmentEditApi,
getCompanyListApi,
getDetailApi,
getEquipmentListApi,
getEquipmentTypeApi,
removeDeviceApi,
updateUpDownApi,
} from 'http/api/usercenter/goodsmang'
const store = useStore()
const store2 = mainStore()
const isViewForm = ref(false)
@ -23,18 +29,6 @@ const isAdd = ref(false)
const previewDialogVisible = ref(false)
const previewDialogImageUrl = ref('')
import {
getEquipmentTypeApi, //
getCompanyListApi, //
getEquipmentListApi, //
getDetailApi, //
equipmentAddApi, //
equipmentEditApi, //
insertDraftApi, //稿
removeDeviceApi, //
updateUpDownApi, //
downLoadTemplate, //
} from 'http/api/usercenter/goodsmang'
const batchAddVisible: any = ref(false) //
const batchAddData: any = ref([]) //
@ -261,7 +255,8 @@ const deleteRowInfo = async (row: any) => {
getList()
}
})
.catch(() => {})
.catch(() => {
})
}
//
const getDetailData = async (row: any) => {
@ -496,7 +491,8 @@ const handleUpdateUpDown = (row: any, maStatus: any) => {
getList()
}
})
.catch(() => {})
.catch(() => {
})
}
/*
@ -539,20 +535,6 @@ const dialogTypeCascader = ref()
const dialogTypeChange = async () => {
options.value = []
const deviceTypeList = dialogTypeCascader.value.getCheckedNodes()
// console.log(deviceTypeList)
// equipmentDeploymentParams.value.unitName = deviceTypeList[0].data.unitName
// equipmentDeploymentParams.value.dayLeasePrice = deviceTypeList[0].data.leasePrice
// isDisabled.value = true
// let manageType = deviceTypeList[0].data.manageType
// if (manageType == '1') {
// //
// equipmentDeploymentParams.value.deviceCount = 1
// countDisabled.value = false
// } else if (manageType == '0') {
// //
// equipmentDeploymentParams.value.deviceCount = 1
// countDisabled.value = true
// }
console.log('deviceTypeList', deviceTypeList[0].data)
warningDays.value = deviceTypeList[0].data.maintenanceAlarmDay
if (deviceTypeList[0].data.manageType == 0) {
@ -569,13 +551,11 @@ const dialogTypeChange = async () => {
deviceTypeList[0].data.maTypeProperties.forEach((item: any) => {
propertyNames.value.push({ propertyName: item.propertyName, propertyValue: '' })
})
// propertyNames.value = deviceTypeList[0].data.maTypeProperties
deviceTypeList[0].data.maTypeProperties.forEach((item: any) => {
options.value.push({ label: item.propertyName, value: item.propertyName })
})
console.log(propertyNames.value)
}
// propertyNames.value = deviceTypeList[0].data.propertyNames
isDisabled.value = true
addAndEditForm.unitName = deviceTypeList[0].data.unitName
addAndEditForm.dayLeasePrice = deviceTypeList[0].data.leasePrice
@ -689,35 +669,6 @@ const equipRules = ref({
],
mainFileList: [{ required: true, message: '请上传主展示图', trigger: 'change' }],
detailsFileList: [{ required: true, message: '请上传详情展示图', trigger: 'change' }],
// deviceWeight: [
// //
// { required: true, message: '', trigger: 'blur' },
// ],
// isZone: [
// {
// required: true,
// message: '',
// trigger: 'change',
// },
// ],
// zoneId: [
// {
// required: true,
// validator: (rule: any, value: any, callback: any) => {
// if (addAndEditForm.isZone) {
// if (value == '') {
// callback(new Error(''))
// } else {
// callback()
// }
// } else {
// callback()
// }
// },
// trigger: 'change',
// },
// ],
})
const getProertyNameRules = (item: any) => {
@ -747,7 +698,8 @@ const submitBtn = async () => {
}
const submitFun = (type: any) => {
// type 1 () 2 稿() 3 4 稿
if (isAdd.value) {
console.log(isAdd.value, isEditForm.value)
if (isAdd.value || isEditForm.value) {
addAndEditForm.mainFileList = Array.from(
new Set([...addAndEditForm.mainFileList, ...addAndEditForm.mainFileTempList]),
)
@ -755,109 +707,81 @@ const submitFun = (type: any) => {
new Set([...addAndEditForm.detailsFileList, ...addAndEditForm.detailsFileTempList]),
)
}
if (type === 2 || type === 4) {
equipRules.value.mainFileList = [] //
equipRules.value.detailsFileList = [] //
} else {
equipRules.value.mainFileList = [{ required: true, message: '请上传主展示图', trigger: 'change' }] //
equipRules.value.detailsFileList = [{ required: true, message: '请上传详情展示图', trigger: 'change' }] //
}
addAndEditFormRef.value.validate(async (valid: any) => {
if (valid) {
let isDescription = false
// addAndEditForm.identifyCode = []
descriptionFormList.value.forEach((e: any, index: number) => {
e.insurancePdfs = [...e.insurancePdfs, ...e.insuranceATempPdf]
e.examinationPdfs = [...e.examinationPdfs, ...e.examinationTempPdf]
if (type == 3 || type == 4) {
// addAndEditForm.identifyCode = e.identifyCode
// addAndEditForm.insurancePdf = e.insurancePdfs.map((e: any) => {
// return { fileNam: e.fileName, fileUrl: e.fileUrl }
// })
addAndEditForm.examinationPdf = e.examinationPdfs.map((e: any) => {
return { fileNam: e.fileName, fileUrl: e.fileUrl }
})
} else {
// addAndEditForm.insurancePdfs[index] = e.insurancePdfs
addAndEditForm.examinationPdfs[index] = e.examinationPdfs
// addAndEditForm.identifyCode.push(e.identifyCode)
}
})
// for (let index = 0; index < descriptionFormList.value.length; index++) {
// try {
// const result = await new Promise((resolve) => {
// descriptionFormRefList.value[index].validate((res: any) => {
// resolve(res)
// })
// })
// if (!result) {
// isDescription = true
// throw new Error('')
// }
// } catch (error) {}
// }
addAndEditForm.tableList = equipTableList.value
// console.log('🚀 ~ addAndEditFormRef.value.validate ~ addAndEditForm.tableList:', addAndEditForm.tableList)
for (let i = 0; i < addAndEditForm.tableList.length; i++) {
const row = addAndEditForm.tableList[i]
for (const key in row) {
if (
row.hasOwnProperty(key) &&
(row[key] === null || row[key] === '' || row[key]?.length === 0) &&
key !== 'name2' &&
key !== 'name6' &&
key !== 'id' &&
key !== 'insurancePdf'
) {
if (key == 'identifyCode') {
ElMessage({
type: 'error',
message: `${i + 1} 行的 ${'唯一标识符'} 字段不能为空`,
})
} else if (key == 'checkMan') {
ElMessage({
type: 'error',
message: `${i + 1} 行的 ${'检修人'} 字段不能为空`,
})
} else if (key == 'checkDate') {
ElMessage({
type: 'error',
message: `${i + 1} 行的 ${'检修日期'} 字段不能为空`,
})
} else if (key == 'nextCheckDate') {
ElMessage({
type: 'error',
message: `${i + 1} 行的 ${'下次检修日期'} 字段不能为空`,
})
} else {
// ElMessage({
// type: 'error',
// message: ` ${i + 1} ${key} `,
// })
console.log(`${i + 1} 行的 ${key} 字段不能为空`)
if (type != 2) {
for (let i = 0; i < addAndEditForm.tableList.length; i++) {
const row = addAndEditForm.tableList[i]
for (const key in row) {
if (
row.hasOwnProperty(key) &&
(row[key] === null || row[key] === '' || row[key]?.length === 0) &&
key !== 'name2' &&
key !== 'name6' &&
key !== 'id' &&
key !== 'insurancePdf'
) {
if (key == 'identifyCode') {
ElMessage({
type: 'error',
message: `${i + 1} 行的 ${'唯一标识符'} 字段不能为空`,
})
} else if (key == 'checkMan') {
ElMessage({
type: 'error',
message: `${i + 1} 行的 ${'检修人'} 字段不能为空`,
})
} else if (key == 'checkDate') {
ElMessage({
type: 'error',
message: `${i + 1} 行的 ${'检修日期'} 字段不能为空`,
})
} else if (key == 'nextCheckDate') {
ElMessage({
type: 'error',
message: `${i + 1} 行的 ${'下次检修日期'} 字段不能为空`,
})
} else {
console.log(`${i + 1} 行的 ${key} 字段不能为空`)
}
return //
}
// } else if (key == 'insurancePdf') {
// ElMessage({
// type: 'error',
// message: ` ${i + 1} `,
// })
// } else {
// ElMessage({
// type: 'error',
// message: ` ${i + 1} `,
// })
// }
return //
}
console.log(row, '-->提交')
if (row.examinationPdf.length === 0) {
ElMessage({
type: 'error',
message: `请上传第 ${i + 1} 行的检测证明`,
})
return
console.log(row, '-->提交')
if (row.examinationPdf.length === 0) {
ElMessage({
type: 'error',
message: `请上传第 ${i + 1} 行的检测证明`,
})
return
}
}
}
}
if (isDescription) return
addAndEditForm.mainFileList = Array.from(
new Set([...addAndEditForm.mainFileList, ...addAndEditForm.mainFileTempList]),
@ -882,18 +806,22 @@ const submitFun = (type: any) => {
if (type == 1) {
SEND_FUN_API = equipmentAddApi
addAndEditForm.maStatus = 1
addAndEditForm.type = 1
}
if (type == 2) {
SEND_FUN_API = equipmentAddApi
addAndEditForm.maStatus = 0
addAndEditForm.type = 2
}
if (type == 3) {
SEND_FUN_API = equipmentEditApi
addAndEditForm.maStatus = 1
addAndEditForm.type = 3
}
if (type == 4) {
SEND_FUN_API = equipmentEditApi
addAndEditForm.maStatus = 0
addAndEditForm.type = 4
}
let res = null
try {
@ -1587,28 +1515,33 @@ const handleDel = (index: any) => {
<el-col :span="18">
<el-form-item>
<el-button class="primary-lease" type="primary" @click="queryTableList"
>查询</el-button
>查询
</el-button
>
<el-button
class="primary-lease"
type="primary"
@click="resetTableList(queryFormRef)"
>重置</el-button
>重置
</el-button
>
<el-button class="primary-lease" type="primary" @click="equipmentDeployment"
>装备新增</el-button
>装备新增
</el-button
>
<el-button
class="primary-lease"
type="primary"
@click="handleUpdateUpDown(null, 2)"
>批量上架</el-button
>批量上架
</el-button
>
<el-button
class="primary-lease"
type="primary"
@click="handleUpdateUpDown(null, 1)"
>批量下架</el-button
>批量下架
</el-button
>
<!-- <el-button class="primary-lease" type="primary" @click="onTempDownLoad()"
>模板下载</el-button
@ -1617,7 +1550,8 @@ const handleDel = (index: any) => {
class="primary-lease"
type="primary"
@click="handleBatchAddVisible"
>批量新增</el-button
>批量新增
</el-button
>
</el-form-item>
</el-col>
@ -1653,7 +1587,7 @@ const handleDel = (index: any) => {
<el-table-column align="center" prop="typeName" label="装备类目">
<template #default="{ row }">
<span
>{{ row.firstName }} <span v-show="row.firstName">></span>
>{{ row.firstName }} <span v-show="row.firstName">></span>
{{ row.secondName }}<span v-show="row.secondName">></span
>{{ row.thirdName }}</span
>
@ -1663,8 +1597,8 @@ const handleDel = (index: any) => {
<el-table-column align="center" prop="nextCheckDate" label="下次检验日期">
<template #default="{ row }">
<span :style="{ backgroundColor: getUpdateTimeBgColor(row) }">{{
row.nextCheckDate
}}</span>
row.nextCheckDate
}}</span>
</template>
</el-table-column>
<el-table-column align="center" label="装备状态">
@ -1678,7 +1612,8 @@ const handleDel = (index: any) => {
<el-table-column prop="name" label="操作" min-width="160px" align="center">
<template #default="{ row }">
<el-button type="primary" size="small" @click="previewRowInfo(row)"
>查看</el-button
>查看
</el-button
>
<el-button
v-if="row.maStatus == 0 || row.maStatus == 1"
@ -2034,7 +1969,9 @@ const handleDel = (index: any) => {
@onFileChange="onMainFileChange"
>
<template v-slot:default>
<el-icon size="42" color="#aaa"><Plus /></el-icon>
<el-icon size="42" color="#aaa">
<Plus />
</el-icon>
</template>
</UploadComponentNew>
</el-form-item>
@ -2103,7 +2040,9 @@ const handleDel = (index: any) => {
@onFileChange="onDetailsFileChange"
>
<template v-slot:default>
<el-icon size="42" color="#aaa"><Plus /></el-icon>
<el-icon size="42" color="#aaa">
<Plus />
</el-icon>
</template>
</UploadComponentNew>
</el-form-item>
@ -2142,7 +2081,8 @@ const handleDel = (index: any) => {
style="margin-left: 20px; margin-top: 20px"
:disabled="!addAndEditForm.deviceTypeList"
v-if="settleinTitle == '新增装备'"
>添加</el-button
>添加
</el-button
>
</div>
<!-- <el-row :gutter="20" v-if="!isEditForm && !isViewForm">
@ -2572,7 +2512,8 @@ const handleDel = (index: any) => {
type="danger"
@click="handleDeleteBack($index)"
v-show="$index != 0"
>删除</el-button
>删除
</el-button
>
</div>
</template>
@ -2602,7 +2543,8 @@ const handleDel = (index: any) => {
<el-col :span="1.5" :offset="0">
<a :href="uploadUrlTemp" download="模板">
<el-button class="primary-lease" type="primary" style="margin-left: 20px"
>模板下载</el-button
>模板下载
</el-button
>
</a>
</el-col>
@ -2681,12 +2623,14 @@ const handleDel = (index: any) => {
display: flex;
align-items: center;
}
.title-sign {
display: inline-block;
width: 4px;
height: 16px;
background: #00a288;
}
.title-text {
font-weight: 700;
margin-left: 10px;
@ -2695,6 +2639,7 @@ const handleDel = (index: any) => {
.uploadBox {
margin: 20px 40px;
}
.labelBox {
width: auto;
height: auto;
@ -2702,6 +2647,7 @@ const handleDel = (index: any) => {
align-items: center;
margin-bottom: 20px;
}
.imgsBox {
width: 100%;
height: auto;
@ -2718,10 +2664,12 @@ const handleDel = (index: any) => {
margin-bottom: 30px;
border: 1px dashed #bbb;
position: relative;
.picture-card {
width: 150px;
height: 150px;
}
.icon-list {
width: 60px;
height: 20px;
@ -2731,10 +2679,12 @@ const handleDel = (index: any) => {
display: flex;
align-items: center;
}
.imgItem__icon {
margin: 0 5px;
cursor: pointer;
}
.file-name {
font-size: 10px;
width: 100%;
@ -2745,10 +2695,12 @@ const handleDel = (index: any) => {
.hide {
display: none;
}
.imgItem:hover .hide {
display: block;
}
}
.tipBox {
color: red;
font-size: 12px;
@ -2800,6 +2752,7 @@ const handleDel = (index: any) => {
}
}
}
.img-items:hover .mask-img {
visibility: visible;
}
@ -2839,22 +2792,27 @@ const handleDel = (index: any) => {
transform: translate(-50%, 0%) !important;
/* max-height: 100vh !important; */
height: 90vh;
.el-dialog__body {
flex: 1;
overflow-y: scroll !important;
.el-table__header-wrapper .el-checkbox {
display: none !important;
}
}
.dialog-content {
padding: 20px;
}
}
}
:deep(.el-button--primary) {
background-color: #3cb4a6 !important;
border-color: #3cb4a6 !important;
}
:deep(.el-button--primary:hover),
:deep(.el-button--primary:focus),
:deep(.el-button--primary:active) {