|
@@ -13,7 +13,7 @@
|
|
|
<el-col :span="8">
|
|
|
<el-form-item label="设备" prop="deviceName">
|
|
|
<el-select
|
|
|
- :disabled="formType==='update'"
|
|
|
+ :disabled="formType === 'update'"
|
|
|
v-model="formData.deviceName"
|
|
|
:model-value="deviceLabel"
|
|
|
placeholder="请选择设备"
|
|
@@ -128,7 +128,7 @@
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- <el-col :span="8" v-if="formData.type === 'out'" >
|
|
|
+ <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>
|
|
@@ -162,12 +162,16 @@
|
|
|
<!-- 搜索工作栏 -->
|
|
|
<el-form class="-mb-15px" ref="queryFormRef" :inline="true" label-width="68px">
|
|
|
<el-form-item>
|
|
|
- <el-button @click="openMaterialForm" type="primary"
|
|
|
- ><Icon icon="ep:plus" class="mr-5px" /> 选择物料</el-button
|
|
|
+ <!-- <el-button @click="openMaterialForm" type="primary"-->
|
|
|
+ <!-- ><Icon icon="ep:plus" class="mr-5px" /> 选择物料</el-button>-->
|
|
|
+ <el-button @click="openMaintainForm" type="primary"
|
|
|
+ ><Icon icon="ep:plus" class="mr-5px" /> 选择维修项</el-button
|
|
|
>
|
|
|
- <el-button @click="handleView" type="warning"
|
|
|
- ><Icon icon="ep:plus" class="mr-5px" /> 新增物料</el-button
|
|
|
+ <el-button @click="openMaintainItem" type="warning"
|
|
|
+ ><Icon icon="ep:plus" class="mr-5px" /> 新增维修项</el-button
|
|
|
>
|
|
|
+ <!-- <el-button @click="handleViewNew" type="warning"-->
|
|
|
+ <!-- ><Icon icon="ep:plus" class="mr-5px" /> 新增物料</el-button>-->
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
</ContentWrap>
|
|
@@ -175,26 +179,10 @@
|
|
|
<!-- 列表 -->
|
|
|
<ContentWrap>
|
|
|
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
|
|
- <el-table-column label="物料编码" align="center" prop="code" />
|
|
|
- <el-table-column label="物料名称" align="center" prop="name" />
|
|
|
- <el-table-column label="单位" align="center" prop="unit" />
|
|
|
- <el-table-column label="单价" align="center" prop="price">
|
|
|
- <template #default="{ row }">
|
|
|
- {{ row.price }}
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column label="消耗数量" align="center" prop="depleteCount">
|
|
|
- <template #default="scope">
|
|
|
- <el-input-number :precision="2" :step="0.1" v-model="scope.row.depleteCount" />
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column label="总库存数量" align="center" prop="totalCount" />
|
|
|
- <el-table-column label="备注" align="center" prop="remark">
|
|
|
- <template #default="scope">
|
|
|
- <el-input v-model="scope.row.remark" />
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column label="物料来源" align="center" prop="sourceType" />
|
|
|
+ <el-table-column label="资产编码" align="center" prop="deviceCode" />
|
|
|
+ <el-table-column label="设备名称" align="center" prop="deviceName" />
|
|
|
+ <el-table-column label="维修项" align="center" prop="name" />
|
|
|
+
|
|
|
<el-table-column label="操作" align="center" min-width="120px">
|
|
|
<template #default="scope">
|
|
|
<div style="display: flex; justify-content: center; align-items: center; width: 100%">
|
|
@@ -209,6 +197,16 @@
|
|
|
移除
|
|
|
</el-button>
|
|
|
</div>
|
|
|
+ <div style="margin-left: 12px">
|
|
|
+ <el-button link type="primary" @click="openMaterialForm(scope.row)">
|
|
|
+ 选择物料
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+ <div style="margin-left: 12px">
|
|
|
+ <el-button link type="primary" @click="handleViewNew(scope.row.bomNodeId)">
|
|
|
+ 物料详情
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
@@ -216,13 +214,8 @@
|
|
|
</ContentWrap>
|
|
|
|
|
|
<!-- 表单弹窗:添加/修改 -->
|
|
|
- <ChooseMaterial ref="materialFormRef" :deptId="formData.deptId" @choose="selectChoose" />
|
|
|
- <MaintainMaterialDrawer
|
|
|
- ref="showDrawer"
|
|
|
- :model-value="drawerVisible"
|
|
|
- @update:model-value="(val) => (drawerVisible = val)"
|
|
|
- @add="handleChildSubmit"
|
|
|
- />
|
|
|
+ <WorkOrderMaterial ref="materialFormRef" @choose="selectChoose" />
|
|
|
+ <ChooseMaintain ref="maintainFormRef" @choose="maintainChoose" />
|
|
|
</ContentWrap>
|
|
|
<ContentWrap>
|
|
|
<el-form>
|
|
@@ -234,6 +227,37 @@
|
|
|
</ContentWrap>
|
|
|
<DeviceList ref="deviceFormRef" @choose="deviceChoose" />
|
|
|
<CustomerList ref="customerFormRef" @choose="customerChoose" />
|
|
|
+ <MaterialListDrawer
|
|
|
+ :model-value="drawerVisible"
|
|
|
+ @update:model-value="(val) => (drawerVisible = val)"
|
|
|
+ :node-id="currentBomNodeId"
|
|
|
+ :materials="materialList.filter((item) => item.bomNodeId === currentBomNodeId)"
|
|
|
+ />
|
|
|
+ <Dialog title="维修项" v-model="addItemVisible" style="min-height: 300px">
|
|
|
+ <el-form
|
|
|
+ ref="addFormRef"
|
|
|
+ :model="addFormData"
|
|
|
+ :rules="addFormRules"
|
|
|
+ label-position="right"
|
|
|
+ label-width="68px"
|
|
|
+ >
|
|
|
+ <el-form-item label="资产编码" prop="deviceCode">
|
|
|
+ <el-input v-model="addFormData.deviceCode" disabled />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="设备名称" prop="deviceName">
|
|
|
+ <el-input v-model="addFormData.deviceName" disabled />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="维修项" prop="name">
|
|
|
+ <el-input v-model="addFormData.name" placeholder="请输入维修项" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <el-form>
|
|
|
+ <el-form-item style="float: right">
|
|
|
+ <el-button @click="handleConfirm" type="primary">确 定</el-button>
|
|
|
+ <el-button @click="closeDialog">取 消</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </Dialog>
|
|
|
</template>
|
|
|
<script setup lang="ts">
|
|
|
import { IotMaintainApi } from '@/api/pms/maintain'
|
|
@@ -241,17 +265,18 @@ import { DICT_TYPE, getBoolDictOptions, getStrDictOptions } from '@/utils/dict'
|
|
|
import DeviceList from '@/views/pms/failure/DeviceList.vue'
|
|
|
import * as UserApi from '@/api/system/user'
|
|
|
import { useUserStore } from '@/store/modules/user'
|
|
|
-import ChooseMaterial from '@/views/pms/maintain/material/ChooseMaterial.vue'
|
|
|
-import MaintainMaterialDrawer from '@/views/pms/maintain/material/MaintainMaterialDrawer.vue'
|
|
|
import { ref } from 'vue'
|
|
|
import { IotMaintainMaterialVO } from '@/api/pms/maintain/material'
|
|
|
import { useTagsViewStore } from '@/store/modules/tagsView'
|
|
|
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
|
|
|
import CustomerList from '@/views/pms/device/CustomerList.vue'
|
|
|
+import WorkOrderMaterial from '@/views/pms/iotmainworkorder/WorkOrderMaterial.vue'
|
|
|
+import { IotMainWorkOrderBomMaterialVO } from '@/api/pms/iotmainworkorderbommaterial'
|
|
|
+import MaterialListDrawer from '@/views/pms/iotmainworkorder/SelectedMaterialDrawer.vue'
|
|
|
|
|
|
/** 维修工单 表单 */
|
|
|
defineOptions({ name: 'IotMaintainAe' })
|
|
|
-
|
|
|
+const addItemVisible = ref(false) // 弹窗的是否展示
|
|
|
const { t } = useI18n() // 国际化
|
|
|
const message = useMessage() // 消息弹窗
|
|
|
const { delView } = useTagsViewStore() // 视图操作
|
|
@@ -267,6 +292,11 @@ const list = ref<IotMaintainMaterialVO[]>([]) // 列表的数据
|
|
|
const { params, name } = useRoute() // 查询参数
|
|
|
const id = params.id
|
|
|
const supplierLabel = ref('') // 表单的类型:create - 新增;update - 修改
|
|
|
+const addFormData = ref({
|
|
|
+ name: '',
|
|
|
+ deviceName: '',
|
|
|
+ deviceCode: ''
|
|
|
+})
|
|
|
const formData = ref({
|
|
|
id: undefined,
|
|
|
failureCode: undefined,
|
|
@@ -297,11 +327,11 @@ const formData = ref({
|
|
|
const strictRules = {
|
|
|
required: true,
|
|
|
message: '请输入维修费用'
|
|
|
-};
|
|
|
+}
|
|
|
const supplierRules = {
|
|
|
required: true,
|
|
|
message: '请选择供应商'
|
|
|
-};
|
|
|
+}
|
|
|
const formRules = reactive({
|
|
|
deviceName: [{ required: true, message: '设备不能为空', trigger: 'blur' }],
|
|
|
failureCode: [{ required: true, message: '故障编码不能为空', trigger: 'blur' }],
|
|
@@ -317,6 +347,9 @@ const formRules = reactive({
|
|
|
// status: [{ required: true, message: '状态不能为空', trigger: 'blur' }]
|
|
|
})
|
|
|
|
|
|
+const addFormRules = reactive({
|
|
|
+ name: [{ required: true, message: '维修项不能为空', trigger: 'blur' }]
|
|
|
+})
|
|
|
const outFormRules = reactive({
|
|
|
deviceName: [{ required: true, message: '设备不能为空', trigger: 'blur' }],
|
|
|
failureCode: [{ required: true, message: '故障编码不能为空', trigger: 'blur' }],
|
|
@@ -332,6 +365,10 @@ const outFormRules = reactive({
|
|
|
supplier: [{ required: true, message: '供应商不能为空', trigger: 'blur' }]
|
|
|
})
|
|
|
|
|
|
+const handleConfirm = () => {
|
|
|
+ list.value.push(addFormData.value)
|
|
|
+ addItemVisible.value = false
|
|
|
+}
|
|
|
const customerChoose = (row) => {
|
|
|
formData.value.supplier = row.id
|
|
|
supplierLabel.value = row.name
|
|
@@ -342,9 +379,11 @@ const openCustomer = (type) => {
|
|
|
customerFormRef.value.open(type)
|
|
|
}
|
|
|
const formRef = ref() // 表单 Ref
|
|
|
+const addFormRef = ref()
|
|
|
const deviceChoose = (row) => {
|
|
|
formData.value.deviceId = row.id
|
|
|
formData.value.deviceName = row.deviceName
|
|
|
+ formData.value.deviceCode = row.deviceCode
|
|
|
formData.value.deptId = row.deptId
|
|
|
deviceLabel.value = row.deviceName
|
|
|
}
|
|
@@ -354,12 +393,25 @@ const openForm = () => {
|
|
|
}
|
|
|
|
|
|
const materialFormRef = ref()
|
|
|
-const openMaterialForm = (type: string, id?: number) => {
|
|
|
- if (!formData.value.deptId) {
|
|
|
+const currentBomNodeId = ref() // 当前选中的bom节点
|
|
|
+const openMaterialForm = (row: any) => {
|
|
|
+ bomNodeId.value = row.bomNodeId
|
|
|
+ console.log('这是一个对象:', row.bomNodeId)
|
|
|
+ materialFormRef.value.open(formData.value.deptId, bomNodeId.value)
|
|
|
+}
|
|
|
+
|
|
|
+const maintainFormRef = ref()
|
|
|
+const openMaintainForm = (type: string, id?: number) => {
|
|
|
+ if (!formData.value.deviceId) {
|
|
|
message.error('请选择设备')
|
|
|
return
|
|
|
}
|
|
|
- materialFormRef.value.open(type, id)
|
|
|
+ maintainFormRef.value.open(type, formData.value.deviceId)
|
|
|
+}
|
|
|
+const openMaintainItem = () => {
|
|
|
+ addItemVisible.value = true
|
|
|
+ addFormData.value.deviceName = formData.value.deviceName
|
|
|
+ addFormData.value.deviceCode = formData.value.deviceCode
|
|
|
}
|
|
|
const endTimeBlur = () => {
|
|
|
if (formData.value.maintainEndTime <= formData.value.maintainStartTime) {
|
|
@@ -369,26 +421,55 @@ const endTimeBlur = () => {
|
|
|
}
|
|
|
const close = () => {
|
|
|
delView(unref(currentRoute))
|
|
|
- push({ name: 'IotMaintain', params:{}})
|
|
|
- // delView(unref(currentRoute))
|
|
|
- // push({
|
|
|
- // name: 'IotMaintain',
|
|
|
- // query: {
|
|
|
- // date: new Date().getTime()
|
|
|
- // }
|
|
|
- // })
|
|
|
+ push({ name: 'IotMaintain', params: {} })
|
|
|
+}
|
|
|
+const closeDialog = () => {
|
|
|
+ addItemVisible.value = false
|
|
|
}
|
|
|
-const handleView = () => {
|
|
|
+
|
|
|
+const handleViewNew = (nodeId) => {
|
|
|
+ currentBomNodeId.value = nodeId
|
|
|
drawerVisible.value = true
|
|
|
- showDrawer.value.openDrawer()
|
|
|
+ // showDrawer.value.openDrawer()
|
|
|
+ console.log('当前bom节点:', currentBomNodeId.value)
|
|
|
}
|
|
|
-const selectChoose = (formData) => {
|
|
|
- console.log('接收到的数据:', JSON.stringify(formData))
|
|
|
- list.value.push(formData)
|
|
|
+const materialList = ref<IotMainWorkOrderBomMaterialVO[]>([]) // 保养工单bom关联物料列表
|
|
|
+const bomNodeId = ref() // 最新的bomNodeId
|
|
|
+const selectChoose = (selectedMaterial) => {
|
|
|
+ // console.log('接收到的数据:', JSON.stringify(formData))
|
|
|
+ // list.value.push(formData)
|
|
|
+ selectedMaterial.bomNodeId = bomNodeId.value
|
|
|
+ // 关联 bomNodeId
|
|
|
+ const processedMaterials = selectedMaterial.map((material) => ({
|
|
|
+ ...material,
|
|
|
+ bomNodeId: bomNodeId.value // 统一关联当前行的 bomNodeId
|
|
|
+ }))
|
|
|
+
|
|
|
+ // 避免重复添加
|
|
|
+ processedMaterials.forEach((newMaterial) => {
|
|
|
+ // 检查是否已存在相同 bomNodeId + materialCode 的条目
|
|
|
+ const isExist = materialList.value.some(
|
|
|
+ (item) => item.bomNodeId === bomNodeId.value && item.materialCode === newMaterial.materialCode
|
|
|
+ )
|
|
|
+
|
|
|
+ if (!isExist) {
|
|
|
+ materialList.value.push(newMaterial)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ console.log('选择完成的数据:', JSON.stringify(selectedMaterial))
|
|
|
+ console.log('添加到本地列表的数据:', materialList.value)
|
|
|
+}
|
|
|
+const maintainChoose = (formData) => {
|
|
|
+ console.log('接收到的数据eee:', JSON.stringify(formData))
|
|
|
+ formData.forEach((item) => {
|
|
|
+ list.value.push(item)
|
|
|
+ })
|
|
|
}
|
|
|
const handleChildSubmit = (formData) => {
|
|
|
const modified = removeOnesFromKeys(formData)
|
|
|
- list.value.push(modified)
|
|
|
+ modified.forEach((item) => {
|
|
|
+ list.value.push(item)
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
const removeOnesFromKeys = (obj: Record<string, any>) => {
|
|
@@ -406,14 +487,14 @@ const emit = defineEmits(['success']) // 定义 success 事件,用于操作成
|
|
|
const submitForm = async () => {
|
|
|
// 校验表单
|
|
|
await formRef.value.validate()
|
|
|
- if (list.value.length > 0) {
|
|
|
- const nullList = list.value.filter((item) => item.depleteCount === null)
|
|
|
- debugger
|
|
|
- if (nullList.length > 0) {
|
|
|
- message.error('请填写消耗数量')
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
+ // if (list.value.length > 0) {
|
|
|
+ // const nullList = list.value.filter((item) => item.depleteCount === null)
|
|
|
+ // debugger
|
|
|
+ // if (nullList.length > 0) {
|
|
|
+ // message.error('请填写消耗数量')
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // }
|
|
|
// 提交请求
|
|
|
formLoading.value = true
|
|
|
try {
|