|
@@ -120,16 +120,16 @@
|
|
<UploadImg v-model="formData.pic" height="55px" />
|
|
<UploadImg v-model="formData.pic" height="55px" />
|
|
</el-form-item>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-col>
|
|
- <!-- <el-col :span="8" v-if="formData.type === 'out'">-->
|
|
|
|
- <!-- <el-form-item label="供应商" prop="supplier" :rules="supplierRules">-->
|
|
|
|
- <!-- <el-select-->
|
|
|
|
- <!-- v-model="formData.supplier"-->
|
|
|
|
- <!-- placeholder="请输入供应商"-->
|
|
|
|
- <!-- :model-value="supplierLabel"-->
|
|
|
|
- <!-- @click="openCustomer('supplier')"-->
|
|
|
|
- <!-- />-->
|
|
|
|
- <!-- </el-form-item>-->
|
|
|
|
- <!-- </el-col>-->
|
|
|
|
|
|
+ <el-col :span="8" v-if="formData.type === 'out'&&formData.maintainPerson===userId">
|
|
|
|
+ <el-form-item label="供应商" prop="supplier" :rules="supplierRules">
|
|
|
|
+ <el-select
|
|
|
|
+ v-model="formData.supplier"
|
|
|
|
+ placeholder="请输入供应商"
|
|
|
|
+ :model-value="supplierLabel"
|
|
|
|
+ @click="openCustomer('supplier')"
|
|
|
|
+ />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
<el-col :span="8" v-if="formData.type === 'in'">
|
|
<el-col :span="8" v-if="formData.type === 'in'">
|
|
<el-form-item label="维修费用(元)" prop="maintainFee">
|
|
<el-form-item label="维修费用(元)" prop="maintainFee">
|
|
<el-input-number
|
|
<el-input-number
|
|
@@ -142,11 +142,11 @@
|
|
/>
|
|
/>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-col>
|
|
- <!-- <el-col :span="8" v-if="formData.type === 'out'">-->
|
|
|
|
- <!-- <el-form-item label="委外相关附件" prop="outFile">-->
|
|
|
|
- <!-- <UploadFile v-model="formData.outFile" class="min-w-80px" />-->
|
|
|
|
- <!-- </el-form-item>-->
|
|
|
|
- <!-- </el-col>-->
|
|
|
|
|
|
+ <el-col :span="8" v-if="formData.type === 'out'&&formData.maintainPerson===userId">
|
|
|
|
+ <el-form-item label="委外相关附件" prop="outFile">
|
|
|
|
+ <UploadFile v-model="formData.outFile" class="min-w-80px" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
<el-col :span="16">
|
|
<el-col :span="16">
|
|
<el-form-item label="故障描述" prop="description">
|
|
<el-form-item label="故障描述" prop="description">
|
|
<el-input type="textarea" v-model="formData.description" />
|
|
<el-input type="textarea" v-model="formData.description" />
|
|
@@ -196,7 +196,11 @@
|
|
<el-table-column label="资产编码" align="center" prop="deviceCode" />
|
|
<el-table-column label="资产编码" align="center" prop="deviceCode" />
|
|
<el-table-column label="设备名称" align="center" prop="deviceName" />
|
|
<el-table-column label="设备名称" align="center" prop="deviceName" />
|
|
<el-table-column label="维修项" align="center" prop="name" />
|
|
<el-table-column label="维修项" align="center" prop="name" />
|
|
-
|
|
|
|
|
|
+ <el-table-column label="已选物料数" align="center" prop="materialCount" >
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ <el-tag v-if="scope.row.materialCount" type="danger"> {{scope.row.materialCount}}</el-tag>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
<el-table-column label="操作" align="center" min-width="120px">
|
|
<el-table-column label="操作" align="center" min-width="120px">
|
|
<template #default="scope">
|
|
<template #default="scope">
|
|
<div style="display: flex; justify-content: center; align-items: center; width: 100%">
|
|
<div style="display: flex; justify-content: center; align-items: center; width: 100%">
|
|
@@ -205,7 +209,7 @@
|
|
style="vertical-align: middle"
|
|
style="vertical-align: middle"
|
|
link
|
|
link
|
|
type="danger"
|
|
type="danger"
|
|
- @click="handleDelete(scope.row.code)"
|
|
|
|
|
|
+ @click="handleDelete(scope.row.bomNodeId)"
|
|
>
|
|
>
|
|
<Icon style="vertical-align: middle; color: #ea3434" icon="ep:zoom-out" />
|
|
<Icon style="vertical-align: middle; color: #ea3434" icon="ep:zoom-out" />
|
|
移除
|
|
移除
|
|
@@ -218,7 +222,7 @@
|
|
</div>
|
|
</div>
|
|
<div style="margin-left: 12px">
|
|
<div style="margin-left: 12px">
|
|
<el-button link type="primary" @click="handleViewNew(scope.row.bomNodeId)">
|
|
<el-button link type="primary" @click="handleViewNew(scope.row.bomNodeId)">
|
|
- 物料详情
|
|
|
|
|
|
+ 查看物料
|
|
</el-button>
|
|
</el-button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@@ -246,6 +250,7 @@
|
|
@update:model-value="(val) => (drawerVisible = val)"
|
|
@update:model-value="(val) => (drawerVisible = val)"
|
|
:node-id="currentBomNodeId"
|
|
:node-id="currentBomNodeId"
|
|
:materials="materialList.filter((item) => item.bomNodeId === currentBomNodeId)"
|
|
:materials="materialList.filter((item) => item.bomNodeId === currentBomNodeId)"
|
|
|
|
+ @delete = "materialDelete"
|
|
/>
|
|
/>
|
|
<Dialog title="维修项" v-model="addItemVisible" style="min-height: 300px">
|
|
<Dialog title="维修项" v-model="addItemVisible" style="min-height: 300px">
|
|
<el-form
|
|
<el-form
|
|
@@ -282,7 +287,6 @@ import { IotMaintainApi } from '@/api/pms/maintain'
|
|
import { DICT_TYPE, getBoolDictOptions, getStrDictOptions } from '@/utils/dict'
|
|
import { DICT_TYPE, getBoolDictOptions, getStrDictOptions } from '@/utils/dict'
|
|
import DeviceList from '@/views/pms/failure/DeviceList.vue'
|
|
import DeviceList from '@/views/pms/failure/DeviceList.vue'
|
|
import * as UserApi from '@/api/system/user'
|
|
import * as UserApi from '@/api/system/user'
|
|
-import { useUserStore } from '@/store/modules/user'
|
|
|
|
import { ref } from 'vue'
|
|
import { ref } from 'vue'
|
|
import { IotMaintainMaterialVO } from '@/api/pms/maintain/material'
|
|
import { IotMaintainMaterialVO } from '@/api/pms/maintain/material'
|
|
import { useTagsViewStore } from '@/store/modules/tagsView'
|
|
import { useTagsViewStore } from '@/store/modules/tagsView'
|
|
@@ -291,7 +295,7 @@ import WorkOrderMaterial from '@/views/pms/iotmainworkorder/WorkOrderMaterial.vu
|
|
import { IotMainWorkOrderBomMaterialVO } from '@/api/pms/iotmainworkorderbommaterial'
|
|
import { IotMainWorkOrderBomMaterialVO } from '@/api/pms/iotmainworkorderbommaterial'
|
|
import MaterialListDrawer from '@/views/pms/iotmainworkorder/SelectedMaterialDrawer.vue'
|
|
import MaterialListDrawer from '@/views/pms/iotmainworkorder/SelectedMaterialDrawer.vue'
|
|
import ChooseMaintain from '@/views/pms/maintain/material/ChooseMaintain.vue'
|
|
import ChooseMaintain from '@/views/pms/maintain/material/ChooseMaintain.vue'
|
|
-
|
|
|
|
|
|
+import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
|
|
/** 维修工单 表单 */
|
|
/** 维修工单 表单 */
|
|
defineOptions({ name: 'MaintainAdd' })
|
|
defineOptions({ name: 'MaintainAdd' })
|
|
const addItemVisible = ref(false) // 弹窗的是否展示
|
|
const addItemVisible = ref(false) // 弹窗的是否展示
|
|
@@ -311,11 +315,12 @@ const { params, name } = useRoute() // 查询参数
|
|
const id = params.id
|
|
const id = params.id
|
|
const supplierLabel = ref('') // 表单的类型:create - 新增;update - 修改
|
|
const supplierLabel = ref('') // 表单的类型:create - 新增;update - 修改
|
|
const totalFee = ref(0)
|
|
const totalFee = ref(0)
|
|
|
|
+const { wsCache } = useCache()
|
|
const addFormData = ref({
|
|
const addFormData = ref({
|
|
name: '',
|
|
name: '',
|
|
deviceName: '',
|
|
deviceName: '',
|
|
deviceCode: '',
|
|
deviceCode: '',
|
|
- bomNodeId: ''
|
|
|
|
|
|
+ bomNodeId: '',
|
|
})
|
|
})
|
|
const formData = ref({
|
|
const formData = ref({
|
|
id: undefined,
|
|
id: undefined,
|
|
@@ -364,20 +369,6 @@ const formRules = reactive({
|
|
const addFormRules = reactive({
|
|
const addFormRules = reactive({
|
|
name: [{ required: true, message: '维修项不能为空', trigger: 'blur' }]
|
|
name: [{ required: true, message: '维修项不能为空', trigger: 'blur' }]
|
|
})
|
|
})
|
|
-const outFormRules = reactive({
|
|
|
|
- deviceName: [{ required: true, message: '设备不能为空', trigger: 'blur' }],
|
|
|
|
- failureCode: [{ required: true, message: '故障编码不能为空', trigger: 'blur' }],
|
|
|
|
- type: [{ required: true, message: '维修类型不能为空', trigger: 'blur' }],
|
|
|
|
- ifStop: [{ required: true, message: '是否停机不能为空', trigger: 'blur' }],
|
|
|
|
- failureName: [{ required: true, message: '故障名称不能为空', trigger: 'blur' }],
|
|
|
|
- maintainStartTime: [{ required: true, message: '维修开始时间不能为空', trigger: 'blur' }],
|
|
|
|
- maintainEndTime: [{ required: true, message: '维修结束时间不能为空', trigger: 'blur' }],
|
|
|
|
- maintainDescription: [{ required: true, message: '维修描述不能为空', trigger: 'blur' }],
|
|
|
|
- // maintainPerson: [{ required: true, message: '维修负责人不能为空', trigger: 'blur' }],
|
|
|
|
- deviceId: [{ required: true, message: '设备id不能为空', trigger: 'blur' }],
|
|
|
|
- // maintainFee: [{ required: true, message: '维修费用不能为空', trigger: 'blur' }],
|
|
|
|
- supplier: [{ required: true, message: '供应商不能为空', trigger: 'blur' }]
|
|
|
|
-})
|
|
|
|
|
|
|
|
const handleConfirm = () => {
|
|
const handleConfirm = () => {
|
|
addFormData.value.bomNodeId = Math.floor(100000 + Math.random() * 900000)
|
|
addFormData.value.bomNodeId = Math.floor(100000 + Math.random() * 900000)
|
|
@@ -457,11 +448,31 @@ const closeDialog = () => {
|
|
const handleViewNew = (nodeId) => {
|
|
const handleViewNew = (nodeId) => {
|
|
currentBomNodeId.value = nodeId
|
|
currentBomNodeId.value = nodeId
|
|
drawerVisible.value = true
|
|
drawerVisible.value = true
|
|
- // showDrawer.value.openDrawer()
|
|
|
|
console.log('当前bom节点:', currentBomNodeId.value)
|
|
console.log('当前bom节点:', currentBomNodeId.value)
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+const materialDelete = (row) =>{
|
|
|
|
+ totalFee.value = 0
|
|
|
|
+ list.value.forEach((item)=>{
|
|
|
|
+ if (item.bomNodeId === row.bomNodeId){
|
|
|
|
+ const index = item.materials.findIndex((item) => item.materialCode === row.materialCode)
|
|
|
|
+ if (index > -1) {
|
|
|
|
+ item.materials.splice(index, 1)
|
|
|
|
+ item.materialCount = item.materials.length;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (item.materials) {
|
|
|
|
+ item.materials.forEach((it) => {
|
|
|
|
+ totalFee.value = it.unitPrice * it.quantity + totalFee.value
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ formData.value.maintainFee = totalFee.value
|
|
|
|
+}
|
|
|
|
+
|
|
const materialList = ref<IotMainWorkOrderBomMaterialVO[]>([]) // 保养工单bom关联物料列表
|
|
const materialList = ref<IotMainWorkOrderBomMaterialVO[]>([]) // 保养工单bom关联物料列表
|
|
const bomNodeId = ref() // 最新的bomNodeId
|
|
const bomNodeId = ref() // 最新的bomNodeId
|
|
|
|
+
|
|
const selectChoose = (selectedMaterial) => {
|
|
const selectChoose = (selectedMaterial) => {
|
|
selectedMaterial.bomNodeId = bomNodeId.value
|
|
selectedMaterial.bomNodeId = bomNodeId.value
|
|
// 关联 bomNodeId
|
|
// 关联 bomNodeId
|
|
@@ -481,12 +492,13 @@ const selectChoose = (selectedMaterial) => {
|
|
materialList.value.push(newMaterial)
|
|
materialList.value.push(newMaterial)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
-
|
|
|
|
|
|
+ totalFee.value = 0;
|
|
list.value.forEach((item) => {
|
|
list.value.forEach((item) => {
|
|
if (item.bomNodeId === bomNodeId.value) {
|
|
if (item.bomNodeId === bomNodeId.value) {
|
|
- item.materials = processedMaterials
|
|
|
|
- }
|
|
|
|
- if (item.materials) {
|
|
|
|
|
|
+ item.materials = materialList.value
|
|
|
|
+ if (item.materials) {
|
|
|
|
+ item.materialCount = item.materials.length;
|
|
|
|
+ }
|
|
item.materials.forEach((it) => {
|
|
item.materials.forEach((it) => {
|
|
totalFee.value = it.unitPrice * it.quantity + totalFee.value
|
|
totalFee.value = it.unitPrice * it.quantity + totalFee.value
|
|
})
|
|
})
|
|
@@ -502,12 +514,6 @@ const maintainChoose = (formData) => {
|
|
list.value.push(item)
|
|
list.value.push(item)
|
|
})
|
|
})
|
|
}
|
|
}
|
|
-const handleChildSubmit = (formData) => {
|
|
|
|
- const modified = removeOnesFromKeys(formData)
|
|
|
|
- modified.forEach((item) => {
|
|
|
|
- list.value.push(item)
|
|
|
|
- })
|
|
|
|
-}
|
|
|
|
|
|
|
|
const removeOnesFromKeys = (obj: Record<string, any>) => {
|
|
const removeOnesFromKeys = (obj: Record<string, any>) => {
|
|
return Object.keys(obj).reduce(
|
|
return Object.keys(obj).reduce(
|
|
@@ -582,9 +588,10 @@ const resetForm = () => {
|
|
}
|
|
}
|
|
formRef.value?.resetFields()
|
|
formRef.value?.resetFields()
|
|
}
|
|
}
|
|
|
|
+const userId = ref('')
|
|
onMounted(async () => {
|
|
onMounted(async () => {
|
|
- const deptId = useUserStore().getUser.deptId
|
|
|
|
- //deptUsers.value = await UserApi.getDeptUsersByDeptId(deptId)
|
|
|
|
|
|
+ const userInfo = wsCache.get(CACHE_KEY.USER)
|
|
|
|
+ userId.value = userInfo.user.id;
|
|
if (id) {
|
|
if (id) {
|
|
formType.value = 'update'
|
|
formType.value = 'update'
|
|
const iotMaintain = await IotMaintainApi.getIotMaintain(id)
|
|
const iotMaintain = await IotMaintainApi.getIotMaintain(id)
|
|
@@ -594,17 +601,21 @@ onMounted(async () => {
|
|
} else {
|
|
} else {
|
|
formData.value.type = 'in'
|
|
formData.value.type = 'in'
|
|
formType.value = 'create'
|
|
formType.value = 'create'
|
|
- // const { wsCache } = useCache()
|
|
|
|
- // const userInfo = wsCache.get(CACHE_KEY.USER)
|
|
|
|
- // formData.value.maintainPerson = userInfo.user.id
|
|
|
|
}
|
|
}
|
|
})
|
|
})
|
|
const handleDelete = async (id: number) => {
|
|
const handleDelete = async (id: number) => {
|
|
try {
|
|
try {
|
|
- const index = list.value.findIndex((item) => item.code === id)
|
|
|
|
|
|
+ const index = list.value.findIndex((item) => item.bomNodeId === id)
|
|
if (index !== -1) {
|
|
if (index !== -1) {
|
|
// 通过 splice 删除元素
|
|
// 通过 splice 删除元素
|
|
list.value.splice(index, 1)
|
|
list.value.splice(index, 1)
|
|
|
|
+ totalFee.value = 0
|
|
|
|
+ list.value.forEach(item => {
|
|
|
|
+ item.materials.forEach((it) => {
|
|
|
|
+ totalFee.value = it.unitPrice * it.quantity + totalFee.value
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ formData.value.maintainFee = totalFee.value
|
|
}
|
|
}
|
|
} catch {}
|
|
} catch {}
|
|
}
|
|
}
|