|
|
|
|
@ -11,28 +11,38 @@
|
|
|
|
|
</el-radio-group>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item :label="t('EquipmentManagement.TaskManagement.moldList')" prop="moldList">
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="formData.moldList"
|
|
|
|
|
multiple
|
|
|
|
|
filterable
|
|
|
|
|
<el-input
|
|
|
|
|
:model-value="selectedMoldText"
|
|
|
|
|
readonly
|
|
|
|
|
clearable
|
|
|
|
|
:placeholder="t('EquipmentManagement.TaskManagement.placeholderMoldList')"
|
|
|
|
|
class="!w-full"
|
|
|
|
|
@clear="clearMoldSelection"
|
|
|
|
|
>
|
|
|
|
|
<el-option v-for="item in deviceOptions" :key="String(item.id)" :label="item.name" :value="String(item.id)" />
|
|
|
|
|
</el-select>
|
|
|
|
|
<template #append>
|
|
|
|
|
<el-button @click="openMoldDialog">
|
|
|
|
|
<Icon icon="ep:search" class="mr-5px" />
|
|
|
|
|
{{ t('common.select') }}
|
|
|
|
|
</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item :label="t('EquipmentManagement.TaskManagement.projectForm')" prop="projectForm">
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="formData.projectForm"
|
|
|
|
|
multiple
|
|
|
|
|
filterable
|
|
|
|
|
<el-input
|
|
|
|
|
:model-value="selectedPlanText"
|
|
|
|
|
readonly
|
|
|
|
|
clearable
|
|
|
|
|
:placeholder="t('EquipmentManagement.TaskManagement.placeholderProjectForm')"
|
|
|
|
|
class="!w-full"
|
|
|
|
|
@clear="clearPlanSelection"
|
|
|
|
|
>
|
|
|
|
|
<el-option v-for="item in planOptions" :key="String(item.id)" :label="item.planName" :value="String(item.id)" />
|
|
|
|
|
</el-select>
|
|
|
|
|
<template #append>
|
|
|
|
|
<el-button @click="openPlanDialog">
|
|
|
|
|
<Icon icon="ep:search" class="mr-5px" />
|
|
|
|
|
{{ t('common.select') }}
|
|
|
|
|
</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item :label="t('EquipmentManagement.TaskManagement.planEndDate')" prop="endDate">
|
|
|
|
|
<el-date-picker
|
|
|
|
|
@ -79,13 +89,190 @@ v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)" :key="String(
|
|
|
|
|
<el-button @click="dialogVisible = false">{{ t('common.cancel') }}</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</Dialog>
|
|
|
|
|
|
|
|
|
|
<Dialog
|
|
|
|
|
title="选择模具"
|
|
|
|
|
v-model="moldDialogVisible"
|
|
|
|
|
:appendToBody="true"
|
|
|
|
|
width="1080px"
|
|
|
|
|
>
|
|
|
|
|
<el-form
|
|
|
|
|
ref="moldDialogQueryFormRef"
|
|
|
|
|
:model="moldDialogQueryParams"
|
|
|
|
|
:inline="true"
|
|
|
|
|
class="-mb-15px"
|
|
|
|
|
>
|
|
|
|
|
<el-form-item label="编码/名称/型号" prop="keyword">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="moldDialogQueryParams.keyword"
|
|
|
|
|
placeholder="请输入编码/名称/产品型号"
|
|
|
|
|
clearable
|
|
|
|
|
class="!w-280px"
|
|
|
|
|
@keyup.enter="handleMoldDialogQuery"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item>
|
|
|
|
|
<el-button @click="handleMoldDialogQuery">
|
|
|
|
|
<Icon icon="ep:search" class="mr-5px" />
|
|
|
|
|
{{ t('common.query') }}
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button @click="resetMoldDialogQuery">
|
|
|
|
|
<Icon icon="ep:refresh" class="mr-5px" />
|
|
|
|
|
{{ t('common.reset') }}
|
|
|
|
|
</el-button>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
|
|
|
|
|
<el-table
|
|
|
|
|
v-loading="moldDialogLoading"
|
|
|
|
|
:data="moldDialogList"
|
|
|
|
|
:stripe="true"
|
|
|
|
|
:show-overflow-tooltip="true"
|
|
|
|
|
row-key="id"
|
|
|
|
|
max-height="420"
|
|
|
|
|
@row-click="toggleMoldDialogRow"
|
|
|
|
|
>
|
|
|
|
|
<el-table-column width="55" align="center">
|
|
|
|
|
<template #header>
|
|
|
|
|
<el-checkbox
|
|
|
|
|
:model-value="isMoldCurrentPageAllSelected"
|
|
|
|
|
:indeterminate="isMoldCurrentPageIndeterminate"
|
|
|
|
|
@change="toggleMoldCurrentPageSelection"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
<el-checkbox
|
|
|
|
|
:model-value="isMoldDialogSelected(row)"
|
|
|
|
|
@click.stop
|
|
|
|
|
@change="(checked) => toggleMoldDialogSelection(row, checked)"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column :label="t('MoldManagement.MoldBrandPage.code')" prop="code" min-width="150" />
|
|
|
|
|
<el-table-column :label="t('MoldManagement.MoldBrandPage.name')" prop="name" min-width="160" />
|
|
|
|
|
<el-table-column :label="t('MoldManagement.MoldBrandPage.productName')" prop="productName" min-width="140" />
|
|
|
|
|
<el-table-column :label="t('MoldManagement.MoldBrandPage.status')" prop="status" width="100">
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
<dict-tag :type="DICT_TYPE.ERP_MOLD_STATUS" :value="row.status" />
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
|
|
|
|
|
<div class="task-selector-pagination flex items-center justify-between mt-15px">
|
|
|
|
|
<div class="task-selector-selected">
|
|
|
|
|
已选择 {{ moldDialogSelectedIds.length }} 个模具
|
|
|
|
|
</div>
|
|
|
|
|
<Pagination
|
|
|
|
|
:total="moldDialogTotal"
|
|
|
|
|
v-model:page="moldDialogQueryParams.pageNo"
|
|
|
|
|
v-model:limit="moldDialogQueryParams.pageSize"
|
|
|
|
|
@pagination="getMoldDialogList"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<template #footer>
|
|
|
|
|
<el-button type="primary" @click="confirmMoldSelection">{{ t('common.ok') }}</el-button>
|
|
|
|
|
<el-button @click="moldDialogVisible = false">{{ t('common.cancel') }}</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</Dialog>
|
|
|
|
|
|
|
|
|
|
<Dialog
|
|
|
|
|
:title="t('EquipmentManagement.TaskManagement.selectPlanDialogTitle')"
|
|
|
|
|
v-model="planDialogVisible"
|
|
|
|
|
:appendToBody="true"
|
|
|
|
|
width="960px"
|
|
|
|
|
>
|
|
|
|
|
<el-form
|
|
|
|
|
ref="planDialogQueryFormRef"
|
|
|
|
|
:model="planDialogQueryParams"
|
|
|
|
|
:inline="true"
|
|
|
|
|
class="-mb-15px"
|
|
|
|
|
>
|
|
|
|
|
<el-form-item :label="t('EquipmentManagement.PlanMaintenance.planName')" prop="planName">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="planDialogQueryParams.planName"
|
|
|
|
|
:placeholder="t('EquipmentManagement.PlanMaintenance.placeholderPlanName')"
|
|
|
|
|
clearable
|
|
|
|
|
class="!w-220px"
|
|
|
|
|
@keyup.enter="handlePlanDialogQuery"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item :label="t('EquipmentManagement.PlanMaintenance.planType')" prop="planType">
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="planDialogQueryParams.planType"
|
|
|
|
|
:placeholder="t('EquipmentManagement.PlanMaintenance.placeholderPlanType')"
|
|
|
|
|
clearable
|
|
|
|
|
class="!w-220px"
|
|
|
|
|
>
|
|
|
|
|
<el-option :value="1" :label="t('EquipmentManagement.PlanMaintenance.planTypeMaintain')" />
|
|
|
|
|
<el-option :value="2" :label="t('EquipmentManagement.PlanMaintenance.planTypeInspect')" />
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item>
|
|
|
|
|
<el-button @click="handlePlanDialogQuery">
|
|
|
|
|
<Icon icon="ep:search" class="mr-5px" />
|
|
|
|
|
{{ t('common.query') }}
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button @click="resetPlanDialogQuery">
|
|
|
|
|
<Icon icon="ep:refresh" class="mr-5px" />
|
|
|
|
|
{{ t('common.reset') }}
|
|
|
|
|
</el-button>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
|
|
|
|
|
<el-table
|
|
|
|
|
v-loading="planDialogLoading"
|
|
|
|
|
:data="planDialogList"
|
|
|
|
|
:stripe="true"
|
|
|
|
|
:show-overflow-tooltip="true"
|
|
|
|
|
row-key="id"
|
|
|
|
|
max-height="420"
|
|
|
|
|
@row-click="handlePlanDialogRowClick"
|
|
|
|
|
@row-dblclick="confirmPlanSelection"
|
|
|
|
|
>
|
|
|
|
|
<el-table-column width="55" align="center">
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
<el-radio
|
|
|
|
|
v-model="planDialogSelectedId"
|
|
|
|
|
:label="String(row.id)"
|
|
|
|
|
@click.stop
|
|
|
|
|
@change="handlePlanDialogRadioChange(row)"
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
</el-radio>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column :label="t('EquipmentManagement.PlanMaintenance.planName')" prop="planName" min-width="180" />
|
|
|
|
|
<el-table-column :label="t('EquipmentManagement.PlanMaintenance.planType')" prop="planType" width="120">
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
{{ getPlanTypeLabel(row.planType) }}
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column :label="t('EquipmentManagement.PlanMaintenance.description')" prop="description" min-width="220" />
|
|
|
|
|
<el-table-column :label="t('EquipmentManagement.PlanMaintenance.creatorName')" prop="creatorName" width="140" />
|
|
|
|
|
</el-table>
|
|
|
|
|
|
|
|
|
|
<div class="flex justify-end mt-15px">
|
|
|
|
|
<Pagination
|
|
|
|
|
:total="planDialogTotal"
|
|
|
|
|
v-model:page="planDialogQueryParams.pageNo"
|
|
|
|
|
v-model:limit="planDialogQueryParams.pageSize"
|
|
|
|
|
@pagination="getPlanDialogList"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<template #footer>
|
|
|
|
|
<el-button type="primary" @click="confirmPlanSelection">{{ t('common.ok') }}</el-button>
|
|
|
|
|
<el-button @click="planDialogVisible = false">{{ t('common.cancel') }}</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</Dialog>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { DICT_TYPE, getBoolDictOptions } from '@/utils/dict'
|
|
|
|
|
import { TaskManagementApi, TaskManagementVO } from '@/api/mold/taskManagement'
|
|
|
|
|
import { MoldBrandApi } from '@/api/erp/mold'
|
|
|
|
|
import { PlanMaintenanceApi } from '@/api/mold/planmaintenance'
|
|
|
|
|
import { MoldBrandApi, type MoldBrandVO } from '@/api/erp/mold'
|
|
|
|
|
import { PlanMaintenanceApi, PlanMaintenanceVO } from '@/api/mold/planmaintenance'
|
|
|
|
|
import { getSimpleUserList, UserVO } from '@/api/system/user'
|
|
|
|
|
|
|
|
|
|
defineOptions({ name: 'MoldTaskConfigurationForm' })
|
|
|
|
|
@ -99,19 +286,46 @@ const formLoading = ref(false)
|
|
|
|
|
const formType = ref('')
|
|
|
|
|
const formRef = ref()
|
|
|
|
|
|
|
|
|
|
type DeviceOption = {
|
|
|
|
|
type MoldOption = MoldBrandVO & {
|
|
|
|
|
id: number | string
|
|
|
|
|
code: string
|
|
|
|
|
name: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type PlanOption = {
|
|
|
|
|
type PlanOption = PlanMaintenanceVO & {
|
|
|
|
|
id: number | string
|
|
|
|
|
planName: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const deviceOptions = ref<DeviceOption[]>([])
|
|
|
|
|
const planOptions = ref<PlanOption[]>([])
|
|
|
|
|
const users = ref<UserVO[]>([])
|
|
|
|
|
const moldSelectionCache = ref<Record<string, MoldOption>>({})
|
|
|
|
|
const planSelectionCache = ref<Record<string, PlanOption>>({})
|
|
|
|
|
|
|
|
|
|
const moldDialogVisible = ref(false)
|
|
|
|
|
const moldDialogLoading = ref(false)
|
|
|
|
|
const moldDialogList = ref<MoldOption[]>([])
|
|
|
|
|
const moldDialogTotal = ref(0)
|
|
|
|
|
const moldDialogSelectedIds = ref<string[]>([])
|
|
|
|
|
const moldDialogQueryFormRef = ref()
|
|
|
|
|
const moldDialogQueryParams = reactive({
|
|
|
|
|
pageNo: 1,
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
keyword: undefined as string | undefined
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const planDialogVisible = ref(false)
|
|
|
|
|
const planDialogLoading = ref(false)
|
|
|
|
|
const planDialogList = ref<PlanOption[]>([])
|
|
|
|
|
const planDialogTotal = ref(0)
|
|
|
|
|
const planDialogSelectedId = ref('')
|
|
|
|
|
const planDialogSelectedRow = ref<PlanOption>()
|
|
|
|
|
const planDialogQueryFormRef = ref()
|
|
|
|
|
const planDialogQueryParams = reactive({
|
|
|
|
|
pageNo: 1,
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
planName: undefined as string | undefined,
|
|
|
|
|
planType: undefined as number | undefined
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const parseIdsValue = (value: any): string[] => {
|
|
|
|
|
if (!value) return []
|
|
|
|
|
@ -127,23 +341,75 @@ const toCommaSeparatedIds = (value: any): string | undefined => {
|
|
|
|
|
return ids.length ? ids.join(',') : undefined
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const normalizePageData = <T = any>(res: any): { list: T[]; total: number } => {
|
|
|
|
|
const pageResult = res?.pageResult ?? res
|
|
|
|
|
const list = Array.isArray(pageResult) ? pageResult : pageResult?.list ?? res?.list ?? res?.data?.list ?? []
|
|
|
|
|
const total = Array.isArray(pageResult) ? pageResult.length : pageResult?.total ?? res?.total ?? res?.data?.total ?? list.length
|
|
|
|
|
return { list: (Array.isArray(list) ? list : []) as T[], total: Number(total || 0) }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const cacheMoldRows = (rows: MoldOption[]) => {
|
|
|
|
|
const next = { ...moldSelectionCache.value }
|
|
|
|
|
rows.forEach((row) => {
|
|
|
|
|
if (row?.id !== undefined && row?.id !== null) {
|
|
|
|
|
next[String(row.id)] = row
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
moldSelectionCache.value = next
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const cachePlanRows = (rows: PlanOption[]) => {
|
|
|
|
|
const next = { ...planSelectionCache.value }
|
|
|
|
|
rows.forEach((row) => {
|
|
|
|
|
if (row?.id !== undefined && row?.id !== null) {
|
|
|
|
|
next[String(row.id)] = row
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
planSelectionCache.value = next
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getMoldLabel = (id: string) => {
|
|
|
|
|
const row = moldSelectionCache.value[id]
|
|
|
|
|
return row ? `${row.code ?? ''} ${row.name ?? ''}`.trim() || id : id
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getPlanLabel = (id?: number | string) => {
|
|
|
|
|
if (id === undefined || id === null) return ''
|
|
|
|
|
const key = String(id)
|
|
|
|
|
const row = planSelectionCache.value[key]
|
|
|
|
|
return row?.planName || key
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ensureOptionsLoaded = async () => {
|
|
|
|
|
const [deviceRes, planRes, userRes] = await Promise.all([
|
|
|
|
|
MoldBrandApi.getBrandList(),
|
|
|
|
|
PlanMaintenanceApi.getPlanMaintenancePage({}),
|
|
|
|
|
getSimpleUserList()
|
|
|
|
|
])
|
|
|
|
|
deviceOptions.value = (deviceRes ?? []) as DeviceOption[]
|
|
|
|
|
planOptions.value = (planRes?.list ?? []) as PlanOption[]
|
|
|
|
|
const userRes = await getSimpleUserList()
|
|
|
|
|
users.value = userRes ?? []
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const selectedMoldText = computed(() => {
|
|
|
|
|
const ids = parseIdsValue(formData.value.moldList)
|
|
|
|
|
return ids.map((id) => getMoldLabel(id)).join(', ')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const selectedPlanText = computed(() => getPlanLabel(formData.value.projectForm))
|
|
|
|
|
|
|
|
|
|
const isMoldCurrentPageAllSelected = computed(() => {
|
|
|
|
|
if (!moldDialogList.value.length) return false
|
|
|
|
|
return moldDialogList.value.every((row) => moldDialogSelectedIds.value.includes(String(row.id)))
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const isMoldCurrentPageIndeterminate = computed(() => {
|
|
|
|
|
const selectedCount = moldDialogList.value.filter((row) =>
|
|
|
|
|
moldDialogSelectedIds.value.includes(String(row.id))
|
|
|
|
|
).length
|
|
|
|
|
return selectedCount > 0 && selectedCount < moldDialogList.value.length
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const formData = ref({
|
|
|
|
|
id: undefined as number | undefined,
|
|
|
|
|
name: undefined as string | undefined,
|
|
|
|
|
taskType: undefined as number | undefined,
|
|
|
|
|
moldList: [] as string[],
|
|
|
|
|
projectForm: [] as string[],
|
|
|
|
|
projectForm: undefined as number | undefined,
|
|
|
|
|
endDate: undefined as string | undefined,
|
|
|
|
|
cronExpression: undefined as string | undefined,
|
|
|
|
|
operableUsers: [] as string[],
|
|
|
|
|
@ -165,7 +431,7 @@ const resetForm = () => {
|
|
|
|
|
name: undefined,
|
|
|
|
|
taskType: undefined,
|
|
|
|
|
moldList: [],
|
|
|
|
|
projectForm: [],
|
|
|
|
|
projectForm: undefined,
|
|
|
|
|
endDate: undefined,
|
|
|
|
|
cronExpression: undefined,
|
|
|
|
|
operableUsers: [],
|
|
|
|
|
@ -188,14 +454,28 @@ const open = async (type: string, row?: TaskManagementVO) => {
|
|
|
|
|
formData.value.moldList = parseIdsValue((row as any).moldList)
|
|
|
|
|
const projectFormIds = parseIdsValue((row as any).projectForm)
|
|
|
|
|
if (projectFormIds.length) {
|
|
|
|
|
formData.value.projectForm = projectFormIds
|
|
|
|
|
const n = Number(projectFormIds[0])
|
|
|
|
|
formData.value.projectForm = Number.isFinite(n) ? n : undefined
|
|
|
|
|
const projectFormName = String((row as any).projectFormName ?? '').trim()
|
|
|
|
|
if (formData.value.projectForm !== undefined && projectFormName) {
|
|
|
|
|
planSelectionCache.value[String(formData.value.projectForm)] = {
|
|
|
|
|
id: formData.value.projectForm,
|
|
|
|
|
planName: projectFormName,
|
|
|
|
|
planType: '' as any
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
const projectFormNames = parseIdsValue((row as any).projectFormName)
|
|
|
|
|
const mappedIds = projectFormNames
|
|
|
|
|
.map((name) => planOptions.value.find((p) => p.planName === name)?.id)
|
|
|
|
|
// try finding from cached plan dialog list
|
|
|
|
|
const mapped = projectFormNames
|
|
|
|
|
.map((name) => {
|
|
|
|
|
const found = Object.values(planSelectionCache.value).find((p) => p.planName === name)
|
|
|
|
|
return found?.id
|
|
|
|
|
})
|
|
|
|
|
.filter((id) => id !== undefined && id !== null)
|
|
|
|
|
.map((id) => String(id))
|
|
|
|
|
formData.value.projectForm = mappedIds
|
|
|
|
|
.map((id) => Number(id))
|
|
|
|
|
const firstId = mapped[0]
|
|
|
|
|
formData.value.projectForm = typeof firstId === 'number' && Number.isFinite(firstId) ? firstId : undefined
|
|
|
|
|
}
|
|
|
|
|
formData.value.endDate = row.endDate || undefined
|
|
|
|
|
formData.value.cronExpression = row.cronExpression
|
|
|
|
|
@ -214,6 +494,164 @@ defineExpose({ open })
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits(['success'])
|
|
|
|
|
|
|
|
|
|
// ---- 模具弹框方法 ----
|
|
|
|
|
const getMoldDialogList = async () => {
|
|
|
|
|
moldDialogLoading.value = true
|
|
|
|
|
try {
|
|
|
|
|
const data = await MoldBrandApi.getMoldBrandPage(moldDialogQueryParams)
|
|
|
|
|
const normalized = normalizePageData<MoldOption>(data)
|
|
|
|
|
moldDialogList.value = normalized.list
|
|
|
|
|
moldDialogTotal.value = normalized.total
|
|
|
|
|
cacheMoldRows(normalized.list)
|
|
|
|
|
} finally {
|
|
|
|
|
moldDialogLoading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const openMoldDialog = async () => {
|
|
|
|
|
moldDialogVisible.value = true
|
|
|
|
|
moldDialogSelectedIds.value = parseIdsValue(formData.value.moldList)
|
|
|
|
|
moldDialogQueryParams.pageNo = 1
|
|
|
|
|
moldDialogQueryParams.keyword = undefined
|
|
|
|
|
await getMoldDialogList()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleMoldDialogQuery = () => {
|
|
|
|
|
moldDialogQueryParams.pageNo = 1
|
|
|
|
|
getMoldDialogList()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const resetMoldDialogQuery = () => {
|
|
|
|
|
moldDialogQueryFormRef.value?.resetFields?.()
|
|
|
|
|
handleMoldDialogQuery()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const isMoldDialogSelected = (row: MoldOption) => {
|
|
|
|
|
return moldDialogSelectedIds.value.includes(String(row.id))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const toggleMoldDialogSelection = (row: MoldOption, checked: boolean) => {
|
|
|
|
|
const id = String(row.id)
|
|
|
|
|
const next = new Set(moldDialogSelectedIds.value)
|
|
|
|
|
checked ? next.add(id) : next.delete(id)
|
|
|
|
|
moldDialogSelectedIds.value = Array.from(next)
|
|
|
|
|
cacheMoldRows([row])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const toggleMoldDialogRow = (row: MoldOption) => {
|
|
|
|
|
toggleMoldDialogSelection(row, !isMoldDialogSelected(row))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const toggleMoldCurrentPageSelection = (checked: boolean) => {
|
|
|
|
|
const next = new Set(moldDialogSelectedIds.value)
|
|
|
|
|
moldDialogList.value.forEach((row) => {
|
|
|
|
|
const id = String(row.id)
|
|
|
|
|
checked ? next.add(id) : next.delete(id)
|
|
|
|
|
})
|
|
|
|
|
moldDialogSelectedIds.value = Array.from(next)
|
|
|
|
|
cacheMoldRows(moldDialogList.value)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const confirmMoldSelection = () => {
|
|
|
|
|
if (!moldDialogSelectedIds.value.length) {
|
|
|
|
|
message.warning(t('EquipmentManagement.TaskManagement.placeholderDeviceList'))
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
formData.value.moldList = [...moldDialogSelectedIds.value]
|
|
|
|
|
moldDialogVisible.value = false
|
|
|
|
|
formRef.value?.clearValidate?.('moldList')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const clearMoldSelection = () => {
|
|
|
|
|
formData.value.moldList = []
|
|
|
|
|
moldDialogSelectedIds.value = []
|
|
|
|
|
formRef.value?.clearValidate?.('moldList')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ---- 项目表单弹框方法 ----
|
|
|
|
|
const getPlanDialogList = async () => {
|
|
|
|
|
planDialogLoading.value = true
|
|
|
|
|
try {
|
|
|
|
|
const data = await PlanMaintenanceApi.getPlanMaintenancePage(planDialogQueryParams)
|
|
|
|
|
const normalized = normalizePageData<PlanOption>(data)
|
|
|
|
|
planDialogList.value = normalized.list
|
|
|
|
|
planDialogTotal.value = normalized.total
|
|
|
|
|
cachePlanRows(normalized.list)
|
|
|
|
|
} finally {
|
|
|
|
|
planDialogLoading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const openPlanDialog = async () => {
|
|
|
|
|
planDialogVisible.value = true
|
|
|
|
|
planDialogSelectedId.value =
|
|
|
|
|
formData.value.projectForm === undefined || formData.value.projectForm === null
|
|
|
|
|
? ''
|
|
|
|
|
: String(formData.value.projectForm)
|
|
|
|
|
planDialogSelectedRow.value = planDialogSelectedId.value
|
|
|
|
|
? planSelectionCache.value[planDialogSelectedId.value]
|
|
|
|
|
: undefined
|
|
|
|
|
planDialogQueryParams.pageNo = 1
|
|
|
|
|
planDialogQueryParams.planName = undefined
|
|
|
|
|
planDialogQueryParams.planType = undefined
|
|
|
|
|
await getPlanDialogList()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handlePlanDialogQuery = () => {
|
|
|
|
|
planDialogQueryParams.pageNo = 1
|
|
|
|
|
getPlanDialogList()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const resetPlanDialogQuery = () => {
|
|
|
|
|
planDialogQueryFormRef.value?.resetFields?.()
|
|
|
|
|
handlePlanDialogQuery()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handlePlanDialogRowClick = (row: PlanOption) => {
|
|
|
|
|
planDialogSelectedId.value = String(row.id)
|
|
|
|
|
planDialogSelectedRow.value = row
|
|
|
|
|
cachePlanRows([row])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handlePlanDialogRadioChange = (row: PlanOption) => {
|
|
|
|
|
planDialogSelectedRow.value = row
|
|
|
|
|
cachePlanRows([row])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getPlanTypeLabel = (value: any) => {
|
|
|
|
|
const normalized = Number(value)
|
|
|
|
|
if (normalized === 1) return t('EquipmentManagement.PlanMaintenance.planTypeMaintain')
|
|
|
|
|
if (normalized === 2) return t('EquipmentManagement.PlanMaintenance.planTypeInspect')
|
|
|
|
|
return value ?? '-'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const confirmPlanSelection = (row?: PlanOption) => {
|
|
|
|
|
const selected =
|
|
|
|
|
row?.id !== undefined && row?.id !== null
|
|
|
|
|
? row
|
|
|
|
|
: planDialogSelectedRow.value ||
|
|
|
|
|
planDialogList.value.find((item) => String(item.id) === planDialogSelectedId.value) ||
|
|
|
|
|
planSelectionCache.value[planDialogSelectedId.value]
|
|
|
|
|
|
|
|
|
|
if (!selected?.id) {
|
|
|
|
|
message.warning(t('EquipmentManagement.TaskManagement.placeholderProjectForm'))
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const id = Number(selected.id)
|
|
|
|
|
formData.value.projectForm = Number.isFinite(id) ? id : undefined
|
|
|
|
|
cachePlanRows([selected])
|
|
|
|
|
planDialogVisible.value = false
|
|
|
|
|
formRef.value?.clearValidate?.('projectForm')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const clearPlanSelection = () => {
|
|
|
|
|
formData.value.projectForm = undefined
|
|
|
|
|
planDialogSelectedId.value = ''
|
|
|
|
|
planDialogSelectedRow.value = undefined
|
|
|
|
|
formRef.value?.clearValidate?.('projectForm')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const submitForm = async () => {
|
|
|
|
|
await formRef.value.validate()
|
|
|
|
|
formLoading.value = true
|
|
|
|
|
@ -223,7 +661,7 @@ const submitForm = async () => {
|
|
|
|
|
name: formData.value.name,
|
|
|
|
|
taskType: formData.value.taskType,
|
|
|
|
|
moldList: toCommaSeparatedIds((formData.value as any).moldList),
|
|
|
|
|
projectForm: toCommaSeparatedIds((formData.value as any).projectForm),
|
|
|
|
|
projectForm: formData.value.projectForm,
|
|
|
|
|
endDate: formData.value.endDate || undefined,
|
|
|
|
|
cronExpression: formData.value.cronExpression,
|
|
|
|
|
operableUsers: toCommaSeparatedIds((formData.value as any).operableUsers),
|
|
|
|
|
@ -244,3 +682,10 @@ const submitForm = async () => {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.task-selector-pagination :deep(.pagination-container) {
|
|
|
|
|
margin: 0;
|
|
|
|
|
padding: 0;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|