|
|
|
|
@ -256,18 +256,77 @@
|
|
|
|
|
<el-dialog
|
|
|
|
|
v-model="criticalComponentDialogVisible"
|
|
|
|
|
title="选择关键件"
|
|
|
|
|
width="860px"
|
|
|
|
|
width="1200px"
|
|
|
|
|
class="device-ledger-transfer-dialog"
|
|
|
|
|
append-to-body
|
|
|
|
|
>
|
|
|
|
|
<div class="device-ledger-transfer">
|
|
|
|
|
<!-- <div class="device-ledger-transfer">
|
|
|
|
|
<el-transfer
|
|
|
|
|
v-model="criticalComponentDraft"
|
|
|
|
|
:data="criticalComponentTransferData"
|
|
|
|
|
filterable
|
|
|
|
|
:filter-placeholder="t('EquipmentManagement.EquipmentLedger.placeholderComponentIds')"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>-->
|
|
|
|
|
<el-form class="-mb-15px" :model="queryParams" ref="queryFormRef" :inline="true" min-label-width="68px" style="margin-bottom: 10px">
|
|
|
|
|
<el-form-item :label="t('EquipmentManagement.EquipmentKeyItems.code')" prop="code">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="queryParams.code" :placeholder="t('EquipmentManagement.EquipmentKeyItems.placeholderCode')"
|
|
|
|
|
clearable @keyup.enter="handleQuery" class="!w-240px" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item :label="t('EquipmentManagement.EquipmentKeyItems.name')" prop="name">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="queryParams.name" :placeholder="t('EquipmentManagement.EquipmentKeyItems.placeholderName')"
|
|
|
|
|
clearable @keyup.enter="handleQuery" class="!w-240px" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item :label="t('EquipmentManagement.EquipmentKeyItems.description')" prop="description">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="queryParams.description"
|
|
|
|
|
:placeholder="t('EquipmentManagement.EquipmentKeyItems.placeholderDescription')" clearable
|
|
|
|
|
@keyup.enter="handleQuery" class="!w-240px" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item>
|
|
|
|
|
<el-button @click="handleQuery">
|
|
|
|
|
<Icon icon="ep:search" class="mr-5px" />
|
|
|
|
|
{{ t('common.query') }}
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button @click="resetQuery">
|
|
|
|
|
<Icon icon="ep:refresh" class="mr-5px" />
|
|
|
|
|
{{ t('common.reset') }}
|
|
|
|
|
</el-button>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
<ContentWrap>
|
|
|
|
|
<el-table
|
|
|
|
|
ref="multipleTableRef"
|
|
|
|
|
v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true"
|
|
|
|
|
@selection-change="handleSelectionChange" row-key="id">
|
|
|
|
|
<el-table-column type="selection" width="55" :reserve-selection="true" />
|
|
|
|
|
<el-table-column
|
|
|
|
|
:label="t('EquipmentManagement.EquipmentKeyItems.code')" align="center" prop="code"
|
|
|
|
|
min-width="140" sortable />
|
|
|
|
|
<el-table-column
|
|
|
|
|
:label="t('EquipmentManagement.EquipmentKeyItems.name')" align="center" prop="name"
|
|
|
|
|
min-width="140" sortable />
|
|
|
|
|
<el-table-column
|
|
|
|
|
:label="t('EquipmentManagement.EquipmentKeyItems.description')" align="center" prop="description"
|
|
|
|
|
min-width="180" />
|
|
|
|
|
<el-table-column
|
|
|
|
|
:label="t('EquipmentManagement.EquipmentKeyItems.count')" align="center" prop="count"
|
|
|
|
|
min-width="180" />
|
|
|
|
|
<el-table-column
|
|
|
|
|
:label="t('EquipmentManagement.EquipmentKeyItems.remark')" align="center" prop="remark"
|
|
|
|
|
min-width="180" />
|
|
|
|
|
<el-table-column
|
|
|
|
|
:label="t('EquipmentManagement.EquipmentKeyItems.createTime')" align="center" prop="createTime"
|
|
|
|
|
:formatter="dateFormatter" width="180" sortable />
|
|
|
|
|
</el-table>
|
|
|
|
|
|
|
|
|
|
<Pagination
|
|
|
|
|
:total="total" v-model:page="queryParams.pageNo" v-model:limit="queryParams.pageSize"
|
|
|
|
|
@pagination="getList" />
|
|
|
|
|
|
|
|
|
|
</ContentWrap>
|
|
|
|
|
<template #footer>
|
|
|
|
|
<el-button @click="criticalComponentDialogVisible = false">{{ t('common.cancel') }}</el-button>
|
|
|
|
|
<el-button type="primary" @click="confirmCriticalComponentDialog">{{ t('common.ok') }}</el-button>
|
|
|
|
|
@ -281,14 +340,64 @@
|
|
|
|
|
class="device-ledger-transfer-dialog"
|
|
|
|
|
append-to-body
|
|
|
|
|
>
|
|
|
|
|
<div class="device-ledger-transfer">
|
|
|
|
|
<!-- <div class="device-ledger-transfer">
|
|
|
|
|
<el-transfer
|
|
|
|
|
v-model="beijianDraft"
|
|
|
|
|
:data="beijianTransferData"
|
|
|
|
|
filterable
|
|
|
|
|
:filter-placeholder="t('EquipmentManagement.EquipmentLedger.placeholderBeijianIds')"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>-->
|
|
|
|
|
<!-- 列表 -->
|
|
|
|
|
<el-form class="-mb-15px" :model="bjQueryParams" ref="bjQueryFormRef" :inline="true" min-label-width="68px" style="margin-bottom: 10px">
|
|
|
|
|
<el-form-item :label="t('SparePartsManagement.SpareInfo.code')" prop="barCode">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="bjQueryParams.barCode" :placeholder="t('SparePartsManagement.SpareInfo.placeholderCode')"
|
|
|
|
|
clearable @keyup.enter="handleQuery" class="!w-240px" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item :label="t('SparePartsManagement.SpareInfo.name')" prop="name">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="bjQueryParams.name" :placeholder="t('SparePartsManagement.SpareInfo.placeholderName')"
|
|
|
|
|
clearable @keyup.enter="bjHandleQuery" class="!w-240px" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item>
|
|
|
|
|
<el-button @click="bjHandleQuery">
|
|
|
|
|
<Icon icon="ep:search" class="mr-5px" />
|
|
|
|
|
{{ t('common.query') }}
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button @click="bjResetQuery">
|
|
|
|
|
<Icon icon="ep:refresh" class="mr-5px" />
|
|
|
|
|
{{ t('common.reset') }}
|
|
|
|
|
</el-button>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
<ContentWrap>
|
|
|
|
|
<el-table ref="bjMultipleTableRef" v-loading="loading" :data="bjList" :stripe="true" @selection-change="bjHandleSelectionChange" :show-overflow-tooltip="true" row-key="id">
|
|
|
|
|
<el-table-column type="selection" width="55" :reserve-selection="true" />
|
|
|
|
|
<el-table-column :label="t('SparePartsManagement.SpareInfo.code')" align="center" prop="barCode" width="240px" sortable />
|
|
|
|
|
<el-table-column :label="t('SparePartsManagement.SpareInfo.name')" align="left" prop="name" width="220px" sortable />
|
|
|
|
|
<el-table-column :label="t('SparePartsManagement.SpareInfo.unit')" align="center" prop="unitName" sortable />
|
|
|
|
|
<el-table-column :label="t('SparePartsManagement.SpareInfo.status')" align="center" prop="status" sortable>
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
:label="t('SparePartsManagement.SpareInfo.createTime')"
|
|
|
|
|
align="center"
|
|
|
|
|
prop="createTime"
|
|
|
|
|
:formatter="dateFormatter"
|
|
|
|
|
width="180px"
|
|
|
|
|
sortable />
|
|
|
|
|
</el-table>
|
|
|
|
|
<!-- 分页 -->
|
|
|
|
|
<Pagination
|
|
|
|
|
:total="bjTotal"
|
|
|
|
|
v-model:page="bjQueryParams.pageNo"
|
|
|
|
|
v-model:limit="bjQueryParams.pageSize"
|
|
|
|
|
@pagination="bjGetList"
|
|
|
|
|
/>
|
|
|
|
|
</ContentWrap>
|
|
|
|
|
<template #footer>
|
|
|
|
|
<el-button @click="beijianDialogVisible = false">{{ t('common.cancel') }}</el-button>
|
|
|
|
|
<el-button type="primary" @click="confirmBeijianDialog">{{ t('common.ok') }}</el-button>
|
|
|
|
|
@ -298,27 +407,41 @@
|
|
|
|
|
</template>
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { DeviceLedgerApi, DeviceLedgerVO } from '@/api/mes/deviceledger'
|
|
|
|
|
import { CriticalComponentApi } from '@/api/mes/criticalComponent'
|
|
|
|
|
import {CriticalComponentApi, CriticalComponentVO} from '@/api/mes/criticalComponent'
|
|
|
|
|
import { DeviceTypeApi, DeviceTypeTreeVO } from '@/api/mes/devicetype'
|
|
|
|
|
import { getSimpleUserList, UserVO } from '@/api/system/user'
|
|
|
|
|
import { formatDate } from '@/utils/formatTime'
|
|
|
|
|
import type { FormRules } from 'element-plus'
|
|
|
|
|
import { ProductApi } from '@/api/erp/product/product'
|
|
|
|
|
import {ProductApi, ProductVO} from '@/api/erp/product/product'
|
|
|
|
|
import { DeviceApi,DeviceVO } from '@/api/iot/device'
|
|
|
|
|
import QrcodeActionCard from '@/components/QrcodeActionCard/index.vue'
|
|
|
|
|
|
|
|
|
|
import { dateFormatter } from '@/utils/formatTime'
|
|
|
|
|
import {ref} from "vue";
|
|
|
|
|
import {ElTable} from "element-plus";
|
|
|
|
|
import { DICT_TYPE } from '@/utils/dict'
|
|
|
|
|
/** 设备类型 表单 */
|
|
|
|
|
defineOptions({ name: 'DeviceLedgerForm' })
|
|
|
|
|
|
|
|
|
|
const queryFormRef = ref()
|
|
|
|
|
const bjQueryFormRef = ref()
|
|
|
|
|
const { t } = useI18n() // 国际化
|
|
|
|
|
const message = useMessage() // 消息弹窗
|
|
|
|
|
|
|
|
|
|
const loading = ref(true)
|
|
|
|
|
const total = ref(0)
|
|
|
|
|
const bjTotal = ref(0)
|
|
|
|
|
const selectedIds = ref<number[]>([])
|
|
|
|
|
const bjSelectedIds = ref<number[]>([])
|
|
|
|
|
const dialogVisible = ref(false) // 弹窗的是否展示
|
|
|
|
|
const dialogTitle = ref('') // 弹窗的标题
|
|
|
|
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
|
|
|
|
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
|
|
|
|
const deviceList = ref<DeviceVO[]>([]) // 列表
|
|
|
|
|
|
|
|
|
|
const list = ref<CriticalComponentVO[]>([])
|
|
|
|
|
const bjList = ref<ProductVO[]>([])
|
|
|
|
|
const selectedRows = ref<any[]>([]) // 存储所有选中的行
|
|
|
|
|
const bjSelectedRows = ref<any[]>([]) // 存储所有选中的行
|
|
|
|
|
// 表格引用
|
|
|
|
|
const multipleTableRef = ref<InstanceType<typeof ElTable>>()
|
|
|
|
|
const bjMultipleTableRef = ref<InstanceType<typeof ElTable>>()
|
|
|
|
|
const parseIdsValue = (value: any): number[] => {
|
|
|
|
|
if (!value) return []
|
|
|
|
|
if (Array.isArray(value)) return value.map((v) => Number(v)).filter((v) => !Number.isNaN(v))
|
|
|
|
|
@ -510,15 +633,17 @@ const openBeijianDialog = () => {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const confirmCriticalComponentDialog = () => {
|
|
|
|
|
const validMap = new Set(criticalComponentOptions.value.map((item) => item.value))
|
|
|
|
|
const selected = Array.from(new Set(criticalComponentDraft.value.map((v) => Number(v)).filter((v) => validMap.has(v))))
|
|
|
|
|
formData.value.componentIds = selected
|
|
|
|
|
let ids = selectedRows.value.map(item => item.id);
|
|
|
|
|
//const validMap = new Set(criticalComponentOptions.value.map((item) => item.value))
|
|
|
|
|
//const selected = Array.from(new Set(criticalComponentDraft.value.map((v) => Number(v)).filter((v) => validMap.has(v))))
|
|
|
|
|
formData.value.componentIds = ids
|
|
|
|
|
criticalComponentDialogVisible.value = false
|
|
|
|
|
}
|
|
|
|
|
const confirmBeijianDialog = () => {
|
|
|
|
|
const validMap = new Set(beijianOptions.value.map((item) => item.value))
|
|
|
|
|
const selected = Array.from(new Set(beijianDraft.value.map((v) => Number(v)).filter((v) => validMap.has(v))))
|
|
|
|
|
formData.value.beijianIds = selected
|
|
|
|
|
let ids = bjSelectedRows.value.map(item => item.id);
|
|
|
|
|
/* const validMap = new Set(beijianOptions.value.map((item) => item.value))
|
|
|
|
|
const selected = Array.from(new Set(beijianDraft.value.map((v) => Number(v)).filter((v) => validMap.has(v))))*/
|
|
|
|
|
formData.value.beijianIds = ids
|
|
|
|
|
beijianDialogVisible.value = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -606,8 +731,147 @@ const open = async (type: string, id?: number, defaultDeviceTypeId?: number) =>
|
|
|
|
|
} else {
|
|
|
|
|
deviceList.value = await DeviceApi.getDeviceList2ByNoUsed(formData.value.dvId)
|
|
|
|
|
}
|
|
|
|
|
getList()
|
|
|
|
|
|
|
|
|
|
bjGetList()
|
|
|
|
|
}
|
|
|
|
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
|
|
|
|
const queryParams = reactive({
|
|
|
|
|
pageNo: 1,
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
code: undefined as string | undefined,
|
|
|
|
|
name: undefined as string | undefined,
|
|
|
|
|
description: undefined as string | undefined,
|
|
|
|
|
remark: undefined as string | undefined,
|
|
|
|
|
createTime: [] as string[]
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const bjQueryParams = reactive({
|
|
|
|
|
pageNo: 1,
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
name: undefined,
|
|
|
|
|
categoryId: undefined
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const handleQuery = () => {
|
|
|
|
|
queryParams.pageNo = 1
|
|
|
|
|
getList()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const resetQuery = () => {
|
|
|
|
|
queryFormRef.value.resetFields()
|
|
|
|
|
handleQuery()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 配件搜索按钮操作 */
|
|
|
|
|
const bjHandleQuery = () => {
|
|
|
|
|
bjQueryParams.pageNo = 1
|
|
|
|
|
bjGetList()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 配件重置按钮操作 */
|
|
|
|
|
const bjResetQuery = () => {
|
|
|
|
|
bjQueryFormRef.value.resetFields()
|
|
|
|
|
bjHandleQuery()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleSelectionChange = (rows: CriticalComponentVO[]) => {
|
|
|
|
|
selectedIds.value = rows.map((r) => r.id).filter((id): id is number => typeof id === 'number')
|
|
|
|
|
// 获取当前页所有行的 id
|
|
|
|
|
const currentPageIds = rows.map(item => item.id)
|
|
|
|
|
|
|
|
|
|
// 从已选中的数组中移除当前页的数据
|
|
|
|
|
selectedRows.value = selectedRows.value.filter(
|
|
|
|
|
item => !currentPageIds.includes(item.id)
|
|
|
|
|
)
|
|
|
|
|
// 添加当前页新选中的数据
|
|
|
|
|
selectedRows.value.push(...rows)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const bjHandleSelectionChange = (rows: CriticalComponentVO[]) => {
|
|
|
|
|
bjSelectedIds.value = rows.map((r) => r.id).filter((id): id is number => typeof id === 'number')
|
|
|
|
|
// 获取当前页所有行的 id
|
|
|
|
|
const currentPageIds = rows.map(item => item.id)
|
|
|
|
|
|
|
|
|
|
// 从已选中的数组中移除当前页的数据
|
|
|
|
|
bjSelectedRows.value = bjSelectedRows.value.filter(
|
|
|
|
|
item => !currentPageIds.includes(item.id)
|
|
|
|
|
)
|
|
|
|
|
// 添加当前页新选中的数据
|
|
|
|
|
bjSelectedRows.value.push(...rows)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getList = async () => {
|
|
|
|
|
loading.value = true
|
|
|
|
|
try {
|
|
|
|
|
const data = await CriticalComponentApi.getCriticalComponentPage(queryParams)
|
|
|
|
|
list.value = data.list
|
|
|
|
|
total.value = data.total
|
|
|
|
|
// 数据加载后,重新设置选中状态
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
toggleSelection()
|
|
|
|
|
})
|
|
|
|
|
} finally {
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 配件查询列表 */
|
|
|
|
|
const bjGetList = async () => {
|
|
|
|
|
loading.value = true
|
|
|
|
|
try {
|
|
|
|
|
bjQueryParams.categoryId = 5
|
|
|
|
|
const data = await ProductApi.getProductPage(bjQueryParams)
|
|
|
|
|
bjList.value = data.list
|
|
|
|
|
bjTotal.value = data.total
|
|
|
|
|
// 数据加载后,重新设置选中状态
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
bjToggleSelection()
|
|
|
|
|
})
|
|
|
|
|
} finally {
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 切换选中状态
|
|
|
|
|
const toggleSelection = () => {
|
|
|
|
|
if (!multipleTableRef.value || !selectedRows.value.length) return
|
|
|
|
|
|
|
|
|
|
// 遍历当前页的数据
|
|
|
|
|
list.value.forEach(row => {
|
|
|
|
|
// 检查这一行是否在已选中数组中
|
|
|
|
|
const isSelected = selectedRows.value.some(item => item.id === row.id)
|
|
|
|
|
|
|
|
|
|
if (isSelected) {
|
|
|
|
|
// 如果应该选中,就选中
|
|
|
|
|
multipleTableRef.value!.toggleRowSelection(row, true)
|
|
|
|
|
} else {
|
|
|
|
|
// 否则取消选中
|
|
|
|
|
multipleTableRef.value!.toggleRowSelection(row, false)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 切换选中状态
|
|
|
|
|
const bjToggleSelection = () => {
|
|
|
|
|
if (!bjMultipleTableRef.value || !bjSelectedRows.value.length) return
|
|
|
|
|
|
|
|
|
|
// 遍历当前页的数据
|
|
|
|
|
bjList.value.forEach(row => {
|
|
|
|
|
// 检查这一行是否在已选中数组中
|
|
|
|
|
const isSelected = bjSelectedRows.value.some(item => item.id === row.id)
|
|
|
|
|
|
|
|
|
|
if (isSelected) {
|
|
|
|
|
// 如果应该选中,就选中
|
|
|
|
|
bjMultipleTableRef.value!.toggleRowSelection(row, true)
|
|
|
|
|
} else {
|
|
|
|
|
// 否则取消选中
|
|
|
|
|
bjMultipleTableRef.value!.toggleRowSelection(row, false)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 提交表单 */
|
|
|
|
|
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
|
|
|
|
|