|
|
|
@ -25,13 +25,12 @@
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<el-option v-for="opt in deviceOptions" :key="String(opt.value)" :label="opt.label" :value="opt.value" />
|
|
|
|
<el-option v-for="opt in deviceOptions" :key="String(opt.value)" :label="opt.label" :value="opt.value" />
|
|
|
|
</el-select>-->
|
|
|
|
</el-select>-->
|
|
|
|
|
|
|
|
|
|
|
|
<el-input :model-value="displayItemDevice" readonly clearable class="device-ledger-selection-input"
|
|
|
|
<el-input :model-value="displayItemDevice" readonly clearable class="device-ledger-selection-input"
|
|
|
|
:placeholder="t('MoldManagement.MoldOperate.placeholderDevice')"
|
|
|
|
:placeholder="t('MoldManagement.MoldOperate.placeholderDevice')"
|
|
|
|
@click="openCriticalComponentDialog" @clear="clearBeijian" />
|
|
|
|
@click="openCriticalComponentDialog" />
|
|
|
|
</el-form-item>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item :label="t('MoldManagement.MoldOperate.mold')" prop="moldId" v-if="formData.operateType == '1'">
|
|
|
|
<el-form-item :label="t('MoldManagement.MoldOperate.mold')" prop="moldId" v-if="formData.operateType == '1'">
|
|
|
|
<el-select
|
|
|
|
<!-- <el-select
|
|
|
|
v-model="formData.moldId"
|
|
|
|
v-model="formData.moldId"
|
|
|
|
multiple
|
|
|
|
multiple
|
|
|
|
clearable
|
|
|
|
clearable
|
|
|
|
@ -45,7 +44,13 @@
|
|
|
|
:label="item.name"
|
|
|
|
:label="item.name"
|
|
|
|
:value="item.id"
|
|
|
|
:value="item.id"
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</el-select>
|
|
|
|
</el-select>-->
|
|
|
|
|
|
|
|
<el-input
|
|
|
|
|
|
|
|
:model-value="moldDisplayText"
|
|
|
|
|
|
|
|
:placeholder="t('MoldManagement.MoldOperate.placeholderMold')"
|
|
|
|
|
|
|
|
readonly
|
|
|
|
|
|
|
|
@click="openMoldSelectDialog"
|
|
|
|
|
|
|
|
/>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item
|
|
|
|
<el-form-item
|
|
|
|
v-if="formData.operateType == '2' && formData.deviceId"
|
|
|
|
v-if="formData.operateType == '2' && formData.deviceId"
|
|
|
|
@ -78,92 +83,64 @@
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
</Dialog>
|
|
|
|
</Dialog>
|
|
|
|
|
|
|
|
|
|
|
|
<el-dialog
|
|
|
|
<TableSelectDialog
|
|
|
|
v-model="itemDialogVisible"
|
|
|
|
ref="deviceSelectDialogRef"
|
|
|
|
:title="t('QualityManagement.ZjSchema.selectItemDialogTitle')"
|
|
|
|
title="选择设备"
|
|
|
|
width="1300px"
|
|
|
|
:columns="deviceColumns"
|
|
|
|
draggable
|
|
|
|
:fetch-api="fetchDeviceLedgerPage"
|
|
|
|
|
|
|
|
row-key="id"
|
|
|
|
|
|
|
|
@confirm="handleDeviceSelectConfirm"
|
|
|
|
|
|
|
|
:query-params="mergedQueryParams"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<el-form class="-mb-15px" :model="queryParams" ref="queryFormRef" :inline="true"
|
|
|
|
<!-- 使用 header 插槽插入查询表单 -->
|
|
|
|
label-width="60px">
|
|
|
|
<template #header>
|
|
|
|
<el-form-item :label="t('EquipmentManagement.EquipmentLedger.deviceCode')"
|
|
|
|
<el-form ref="searchFormRef" :model="searchParams" :inline="true" >
|
|
|
|
prop="deviceCode">
|
|
|
|
<el-form-item label="设备编号" prop="deviceCode">
|
|
|
|
<el-input
|
|
|
|
<el-input v-model="searchParams.deviceCode" placeholder="请输入编号" clearable />
|
|
|
|
v-model="queryParams.deviceCode"
|
|
|
|
</el-form-item>
|
|
|
|
:placeholder="t('EquipmentManagement.EquipmentLedger.placeholderDeviceCode')"
|
|
|
|
<el-form-item label="设备名称" prop="deviceName">
|
|
|
|
clearable @keyup.enter="handleQuery"
|
|
|
|
<el-input v-model="searchParams.deviceName" placeholder="请输入名称" clearable />
|
|
|
|
class="!w-240px"/>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item>
|
|
|
|
<el-form-item :label="t('EquipmentManagement.EquipmentLedger.deviceName')"
|
|
|
|
<el-button type="primary" @click="handleSearch">{{ t('FactoryModeling.ProductInformation.searchButtonText') }}</el-button>
|
|
|
|
prop="deviceName">
|
|
|
|
<el-button @click="resetSearch">{{ t('FactoryModeling.ProductInformation.resetButtonText') }}</el-button>
|
|
|
|
<el-input
|
|
|
|
</el-form-item>
|
|
|
|
v-model="queryParams.deviceName"
|
|
|
|
</el-form>
|
|
|
|
:placeholder="t('EquipmentManagement.EquipmentLedger.placeholderDeviceName')"
|
|
|
|
|
|
|
|
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="deviceList" :stripe="true"
|
|
|
|
|
|
|
|
@selection-change="handleSelectionChange" @select="handleSelect" @select-all="handleSelectAll" :show-overflow-tooltip="true"
|
|
|
|
|
|
|
|
class="no-select-all"
|
|
|
|
|
|
|
|
row-key="id">
|
|
|
|
|
|
|
|
<el-table-column type="selection" width="55" :reserve-selection="true" />
|
|
|
|
|
|
|
|
<el-table-column :label="t('EquipmentManagement.EquipmentLedger.deviceCode')"
|
|
|
|
|
|
|
|
align="center" prop="deviceCode" min-width="160px" sortable/>
|
|
|
|
|
|
|
|
<el-table-column :label="t('EquipmentManagement.EquipmentLedger.deviceName')"
|
|
|
|
|
|
|
|
align="center" prop="deviceName" min-width="140px" sortable/>
|
|
|
|
|
|
|
|
<el-table-column :label="t('EquipmentManagement.EquipmentLedger.ratedCapacity')"
|
|
|
|
|
|
|
|
align="center" prop="ratedCapacity" min-width="120px"/>
|
|
|
|
|
|
|
|
<el-table-column :label="t('EquipmentManagement.EquipmentLedger.deviceSpec')"
|
|
|
|
|
|
|
|
align="center" prop="deviceSpec"/>
|
|
|
|
|
|
|
|
<!-- <el-table-column :label="t('EquipmentManagement.EquipmentLedger.deviceModel')"
|
|
|
|
|
|
|
|
align="center" prop="deviceModel"/>-->
|
|
|
|
|
|
|
|
<!-- <el-table-column :label="t('EquipmentManagement.EquipmentLedger.deviceBrand')" align="center" prop="deviceBrand" /> -->
|
|
|
|
|
|
|
|
<el-table-column
|
|
|
|
|
|
|
|
:label="t('EquipmentManagement.EquipmentLedger.productionDate')" align="center"
|
|
|
|
|
|
|
|
prop="productionDate" :formatter="dateFormatter2"
|
|
|
|
|
|
|
|
width="120px" sortable/>
|
|
|
|
|
|
|
|
<el-table-column
|
|
|
|
|
|
|
|
:label="t('EquipmentManagement.EquipmentLedger.factoryEntryDate')" align="center"
|
|
|
|
|
|
|
|
prop="factoryEntryDate" :formatter="dateFormatter2"
|
|
|
|
|
|
|
|
width="120px" sortable/>
|
|
|
|
|
|
|
|
</el-table>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<Pagination :total="total" v-model:page="queryParams.pageNo" v-model:limit="queryParams.pageSize"
|
|
|
|
|
|
|
|
@pagination="getList" />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</ContentWrap>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<template #footer>
|
|
|
|
|
|
|
|
<el-button @click="itemDialogVisible = false">
|
|
|
|
|
|
|
|
{{ t('common.cancel') }}
|
|
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
|
|
<el-button type="primary" @click="confirmSelectItems">
|
|
|
|
|
|
|
|
{{ t('common.ok') }}
|
|
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
</el-dialog>
|
|
|
|
</TableSelectDialog>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<TableSelectDialog
|
|
|
|
|
|
|
|
ref="moldSelectDialogRef"
|
|
|
|
|
|
|
|
title="选择模具"
|
|
|
|
|
|
|
|
:columns="moldColumns"
|
|
|
|
|
|
|
|
:fetch-api="MoldBrandApi.getMoldPage"
|
|
|
|
|
|
|
|
row-key="id"
|
|
|
|
|
|
|
|
@confirm="handleMoldSelectConfirm"
|
|
|
|
|
|
|
|
:query-params="mergedMoldQueryParams"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<!-- 使用 header 插槽插入查询表单 -->
|
|
|
|
|
|
|
|
<template #header>
|
|
|
|
|
|
|
|
<el-form ref="searchMoldFormRef" :model="searchMoldParams" :inline="true" >
|
|
|
|
|
|
|
|
<el-form-item label="模具编号" prop="code">
|
|
|
|
|
|
|
|
<el-input v-model="searchMoldParams.code" placeholder="请输入编号" clearable />
|
|
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
<el-form-item label="模具名称" prop="name">
|
|
|
|
|
|
|
|
<el-input v-model="searchMoldParams.name" placeholder="请输入名称" clearable />
|
|
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
<el-form-item>
|
|
|
|
|
|
|
|
<el-button type="primary" @click="handleMoldSearch">{{ t('FactoryModeling.ProductInformation.searchButtonText') }}</el-button>
|
|
|
|
|
|
|
|
<el-button @click="resetMoldSearch">{{ t('FactoryModeling.ProductInformation.resetButtonText') }}</el-button>
|
|
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
</TableSelectDialog>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
|
|
<script setup lang="ts">
|
|
|
|
import { MoldOperateApi, MoldOperateVO } from '@/api/mes/moldoperate'
|
|
|
|
import { MoldOperateApi, MoldOperateVO } from '@/api/mes/moldoperate'
|
|
|
|
import { MoldBrandApi, MoldVO } from '@/api/erp/mold'
|
|
|
|
import { MoldBrandApi, MoldVO } from '@/api/erp/mold'
|
|
|
|
import { DeviceLedgerApi, DeviceLedgerVO } from '@/api/mes/deviceledger'
|
|
|
|
import { DeviceLedgerApi, DeviceLedgerVO } from '@/api/mes/deviceledger'
|
|
|
|
import {ref} from "vue";
|
|
|
|
import TableSelectDialog from '@/components/TableSelectDialog/TableSelectDialog.vue'
|
|
|
|
import {ElTable} from "element-plus";
|
|
|
|
|
|
|
|
import {ZjItemApi, ZjItemVO} from "@/api/mes/zjitem";
|
|
|
|
|
|
|
|
import { dateFormatter2 } from '@/utils/formatTime'
|
|
|
|
|
|
|
|
/** 模具上下模 表单 */
|
|
|
|
/** 模具上下模 表单 */
|
|
|
|
defineOptions({ name: 'MoldOperateForm' })
|
|
|
|
defineOptions({ name: 'MoldOperateForm' })
|
|
|
|
|
|
|
|
|
|
|
|
@ -264,11 +241,11 @@ const open = async (type: string, id?: number) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
ids.value=[]
|
|
|
|
ids.value=[]
|
|
|
|
|
|
|
|
moldIds.value=[]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
|
|
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 提交表单 */
|
|
|
|
/** 提交表单 */
|
|
|
|
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
|
|
|
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
|
|
|
// const submitForm = async () => {
|
|
|
|
// const submitForm = async () => {
|
|
|
|
@ -304,11 +281,11 @@ const emit = defineEmits(['success']) // 定义 success 事件,用于操作成
|
|
|
|
const submitForm = async () => {
|
|
|
|
const submitForm = async () => {
|
|
|
|
// 立即开始 loading
|
|
|
|
// 立即开始 loading
|
|
|
|
formLoading.value = true
|
|
|
|
formLoading.value = true
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// 1. 表单校验
|
|
|
|
// 1. 表单校验
|
|
|
|
await formRef.value.validate()
|
|
|
|
await formRef.value.validate()
|
|
|
|
|
|
|
|
|
|
|
|
// 2. 组装提交数据
|
|
|
|
// 2. 组装提交数据
|
|
|
|
const raw = formData.value as any
|
|
|
|
const raw = formData.value as any
|
|
|
|
const submitData: any = {
|
|
|
|
const submitData: any = {
|
|
|
|
@ -343,13 +320,13 @@ const submitForm = async () => {
|
|
|
|
await MoldOperateApi.updateMoldOperate(submitData)
|
|
|
|
await MoldOperateApi.updateMoldOperate(submitData)
|
|
|
|
message.success(t('common.updateSuccess'))
|
|
|
|
message.success(t('common.updateSuccess'))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 4. 成功处理
|
|
|
|
// 4. 成功处理
|
|
|
|
dialogVisible.value = false
|
|
|
|
dialogVisible.value = false
|
|
|
|
emit('success')
|
|
|
|
emit('success')
|
|
|
|
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
// 确保 loading 状态被清除
|
|
|
|
// 确保 loading 状态被清除
|
|
|
|
formLoading.value = false
|
|
|
|
formLoading.value = false
|
|
|
|
@ -426,10 +403,98 @@ const resetForm = () => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
formRef.value?.resetFields()
|
|
|
|
formRef.value?.resetFields()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const deviceColumns = [
|
|
|
|
|
|
|
|
{ label: '设备编号', prop: 'deviceCode', minWidth: 140 },
|
|
|
|
|
|
|
|
{ label: '设备名称', prop: 'deviceName', minWidth: 160 },
|
|
|
|
|
|
|
|
{ label: '设备型号', prop: 'deviceModel', minWidth: 140 },
|
|
|
|
|
|
|
|
{ label: '所属车间', prop: 'workshop', minWidth: 140 }
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const moldColumns = [
|
|
|
|
|
|
|
|
{ label: '模具编码', prop: 'code', minWidth: 140 },
|
|
|
|
|
|
|
|
{ label: '模具名称', prop: 'name', minWidth: 160 },
|
|
|
|
|
|
|
|
{ label: '模具型号', prop: 'brandName', minWidth: 140 },
|
|
|
|
|
|
|
|
{ label: '状态', prop: 'status', minWidth: 100 }
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const fetchDeviceLedgerPage = (params: Record<string, any>) => {
|
|
|
|
|
|
|
|
return DeviceLedgerApi.getDeviceLedgerPage({
|
|
|
|
|
|
|
|
...params,
|
|
|
|
|
|
|
|
isScheduled: 1
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const selectedDeviceRows = ref<any[]>([])
|
|
|
|
|
|
|
|
const selectedMoldRows = ref<any[]>([])
|
|
|
|
|
|
|
|
const handleDeviceSelectConfirm = (payload: { ids: (number | string)[]; rows: any[] }) => {
|
|
|
|
|
|
|
|
formData.value.devices = payload.rows
|
|
|
|
|
|
|
|
.map((item) => {
|
|
|
|
|
|
|
|
const id = Number(item.id)
|
|
|
|
|
|
|
|
if (!Number.isFinite(id)) return undefined
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
id,
|
|
|
|
|
|
|
|
name: item.deviceName || item.name || item.code || `设备ID:${id}`
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.filter((item): item is { id: number; name: string } => Boolean(item))
|
|
|
|
|
|
|
|
selectedDeviceRows.value = payload.rows
|
|
|
|
|
|
|
|
formData.value.deviceId = payload.ids.join(',')
|
|
|
|
|
|
|
|
ids.value = payload.ids.map((id) => Number(id))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleMoldSelectConfirm = (payload: { ids: (number | string)[]; rows: any[] }) => {
|
|
|
|
|
|
|
|
formData.value.molds = payload.rows
|
|
|
|
|
|
|
|
.map((item) => {
|
|
|
|
|
|
|
|
const id = Number(item.id)
|
|
|
|
|
|
|
|
if (!Number.isFinite(id)) return undefined
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
id,
|
|
|
|
|
|
|
|
name: item.name || item.code || `模具ID:${id}`
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.filter((item): item is { id: number; name: string } => Boolean(item))
|
|
|
|
|
|
|
|
selectedMoldRows.value = payload.rows
|
|
|
|
|
|
|
|
formData.value.moldId = payload.ids.join(',')
|
|
|
|
|
|
|
|
moldIds.value = payload.ids.map((id) => Number(id))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 1. 自定义表单的查询参数
|
|
|
|
|
|
|
|
const searchParams = reactive({
|
|
|
|
|
|
|
|
deviceCode: undefined,
|
|
|
|
|
|
|
|
deviceName: undefined,
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
const searchFormRef = ref()
|
|
|
|
|
|
|
|
const handleSearch = () => {
|
|
|
|
|
|
|
|
// 触发弹窗内部重新加载数据
|
|
|
|
|
|
|
|
deviceSelectDialogRef.value?.reload?.()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const resetSearch = () => {
|
|
|
|
|
|
|
|
searchFormRef.value?.resetFields()
|
|
|
|
|
|
|
|
handleSearch()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 1. 自定义表单的查询参数
|
|
|
|
|
|
|
|
const searchMoldParams = reactive({
|
|
|
|
|
|
|
|
code: undefined,
|
|
|
|
|
|
|
|
name: undefined,
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
const searchMoldFormRef = ref()
|
|
|
|
|
|
|
|
const handleMoldSearch = () => {
|
|
|
|
|
|
|
|
// 触发弹窗内部重新加载数据
|
|
|
|
|
|
|
|
moldSelectDialogRef.value?.reload?.()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const resetMoldSearch = () => {
|
|
|
|
|
|
|
|
searchMoldFormRef.value?.resetFields()
|
|
|
|
|
|
|
|
handleSearch()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const moldSelectDialogRef = ref()
|
|
|
|
|
|
|
|
// 2. 合并参数:将表单参数与组件内部的分页参数合并
|
|
|
|
|
|
|
|
const mergedQueryParams = computed(() => ({ ...searchParams }))
|
|
|
|
|
|
|
|
const mergedMoldQueryParams = computed(() => ({ ...searchMoldParams }))
|
|
|
|
const ids = ref([])
|
|
|
|
const ids = ref([])
|
|
|
|
|
|
|
|
const moldIds= ref([])
|
|
|
|
const itemList = ref<DeviceLedgerVO[]>([])
|
|
|
|
const itemList = ref<DeviceLedgerVO[]>([])
|
|
|
|
const itemDialogVisible = ref(false)
|
|
|
|
const moldItemList = ref<MoldVO[]>([])
|
|
|
|
const multipleTableRef = ref<InstanceType<typeof ElTable>>()
|
|
|
|
const deviceSelectDialogRef = ref(false)
|
|
|
|
const deviceList = ref<DeviceLedgerVO[]>([])
|
|
|
|
const deviceList = ref<DeviceLedgerVO[]>([])
|
|
|
|
const selectedRows = ref<any[]>([])
|
|
|
|
const selectedRows = ref<any[]>([])
|
|
|
|
const total = ref(0)
|
|
|
|
const total = ref(0)
|
|
|
|
@ -447,134 +512,39 @@ const displayItemDevice = computed( () => {
|
|
|
|
return names.join(',')
|
|
|
|
return names.join(',')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const openCriticalComponentDialog = async () => {
|
|
|
|
const moldDisplayText = computed(() => {
|
|
|
|
itemDialogVisible.value = true
|
|
|
|
if (!moldIds.value.length)return ''
|
|
|
|
let initIds= formData.value.deviceId!=undefined?formData.value.deviceId.toString().split(","):[]
|
|
|
|
if (!moldItemList.value.length) {
|
|
|
|
ids.value=initIds.map((id) => Number(id))
|
|
|
|
return formData.value.moldId ? String(formData.value.moldId) : ''
|
|
|
|
setDefaultSelections()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置默认选中的行
|
|
|
|
|
|
|
|
const setDefaultSelections = () => {
|
|
|
|
|
|
|
|
// 等待DOM更新完成
|
|
|
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
|
|
|
if (!multipleTableRef.value) return
|
|
|
|
|
|
|
|
multipleTableRef.value.clearSelection()
|
|
|
|
|
|
|
|
let initIds= formData.value.deviceId!=undefined?formData.value.deviceId.toString().split(","):[]
|
|
|
|
|
|
|
|
const rawSubjectIds =initIds.map((id) => Number(id))
|
|
|
|
|
|
|
|
if (rawSubjectIds.length != 0) {
|
|
|
|
|
|
|
|
let row = {
|
|
|
|
|
|
|
|
id: undefined
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
multipleTableRef.value.toggleRowSelection(row, true)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 遍历数据,找到需要选中的行
|
|
|
|
|
|
|
|
deviceList.value.forEach(row => {
|
|
|
|
|
|
|
|
let id = row.id;
|
|
|
|
|
|
|
|
if (rawSubjectIds.includes(row.id)) {
|
|
|
|
|
|
|
|
multipleTableRef.value.toggleRowSelection(row, true)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const queryParams = reactive({
|
|
|
|
|
|
|
|
pageNo: 1,
|
|
|
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
|
|
|
deviceCode: undefined,
|
|
|
|
|
|
|
|
deviceName: undefined,
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
const clearBeijian = () => {
|
|
|
|
|
|
|
|
formData.value.item = ''
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 搜索按钮操作 */
|
|
|
|
|
|
|
|
const handleQuery = () => {
|
|
|
|
|
|
|
|
queryParams.pageNo = 1
|
|
|
|
|
|
|
|
getList()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 重置按钮操作 */
|
|
|
|
|
|
|
|
const resetQuery = () => {
|
|
|
|
|
|
|
|
queryFormRef.value.resetFields()
|
|
|
|
|
|
|
|
handleQuery()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const getList = async () => {
|
|
|
|
|
|
|
|
loading.value = true
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const data = await DeviceLedgerApi.getDeviceLedgerPage(queryParams)
|
|
|
|
|
|
|
|
deviceList.value = data.list
|
|
|
|
|
|
|
|
total.value = data.total
|
|
|
|
|
|
|
|
// 数据加载后,重新设置选中状态
|
|
|
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
|
|
|
toggleSelection()
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
loading.value = false
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const map = new Map(moldItemList.value.map((item) => [item.id, item.name]))
|
|
|
|
|
|
|
|
const names = moldIds.value
|
|
|
|
// 切换选中状态
|
|
|
|
.map((id) => map.get(id))
|
|
|
|
const toggleSelection = () => {
|
|
|
|
.filter((name) => name)
|
|
|
|
if (!multipleTableRef.value || !selectedRows.value.length) return
|
|
|
|
return names.join(',')
|
|
|
|
|
|
|
|
})
|
|
|
|
// 遍历当前页的数据
|
|
|
|
|
|
|
|
deviceList.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 handleSelectionChange = (rows: ZjItemVO[]) => {
|
|
|
|
|
|
|
|
// 获取当前页所有行的 id
|
|
|
|
|
|
|
|
const currentPageIds = rows.map(item => item.id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 从已选中的数组中移除当前页的数据
|
|
|
|
|
|
|
|
selectedRows.value = selectedRows.value.filter(
|
|
|
|
|
|
|
|
item => !currentPageIds.includes(item.id)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
// 添加当前页新选中的数据
|
|
|
|
|
|
|
|
selectedRows.value.push(...rows)
|
|
|
|
|
|
|
|
let a=1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 存储当前已选中的行
|
|
|
|
|
|
|
|
const currentSelectedRows = ref([])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleSelectAll = (selection) => {
|
|
|
|
const openCriticalComponentDialog = async () => {
|
|
|
|
let initIds=selection?.map((row) => row.id).filter((id) => id !== undefined) ?? []
|
|
|
|
searchParams.deviceCode=''
|
|
|
|
ids.value =initIds.map((id) => Number(id))
|
|
|
|
searchParams.deviceName=''
|
|
|
|
|
|
|
|
searchMoldParams.code=''
|
|
|
|
|
|
|
|
searchMoldParams.name=''
|
|
|
|
|
|
|
|
const rows = selectedDeviceRows.value.map((item) => ({ ...item, id: Number(item.id) }))
|
|
|
|
|
|
|
|
deviceSelectDialogRef.value?.open(rows)
|
|
|
|
|
|
|
|
let initIds= formData.value.deviceId!=undefined?formData.value.deviceId.toString().split(","):[]
|
|
|
|
|
|
|
|
ids.value=initIds.map((id) => Number(id))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// select 事件:row 是当前操作的行,selected 是操作后的状态
|
|
|
|
const openMoldSelectDialog = () => {
|
|
|
|
const handleSelect = (selection, row) => {
|
|
|
|
const rows = selectedMoldRows.value.map((item) => ({ ...item, id: Number(item.id) }))
|
|
|
|
// 判断是选中还是取消选中
|
|
|
|
moldSelectDialogRef.value?.open(rows)
|
|
|
|
const isSelected = selection.includes(row)
|
|
|
|
|
|
|
|
if (isSelected) {
|
|
|
|
|
|
|
|
// console.log(`✅ 行被选中: ID=${row.id}, Name=${row.name}`)
|
|
|
|
|
|
|
|
ids.value.push(row.id)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ids.value = ids.value.filter(
|
|
|
|
|
|
|
|
item => item !== row.id
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
// console.log(`❌ 行被取消选中: ID=${row.id}, Name=${row.name}`)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 更新当前选中状态
|
|
|
|
|
|
|
|
currentSelectedRows.value = selection
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const confirmSelectItems = () => {
|
|
|
|
const toDeviceRows = (split: any) => {
|
|
|
|
formData.value.deviceId = ids.value.join(',')
|
|
|
|
return split.map((item: any) => ({
|
|
|
|
itemDialogVisible.value = false
|
|
|
|
id: item,
|
|
|
|
|
|
|
|
deviceName: item
|
|
|
|
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const initSelectedItems = async () => {
|
|
|
|
const initSelectedItems = async () => {
|
|
|
|
@ -586,15 +556,13 @@ const initSelectedItems = async () => {
|
|
|
|
loading.value = false
|
|
|
|
loading.value = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!moldItemList.value.length) {
|
|
|
|
|
|
|
|
loading.value = true
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
moldItemList.value = await MoldBrandApi.getMoldAllList()
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
loading.value = false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** 初始化 **/
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
|
|
|
getList()
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
|
|
|
.no-select-all :deep(.el-table__header-wrapper .el-checkbox) {
|
|
|
|
|
|
|
|
display: none;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|