|
|
|
|
@ -1,187 +1,148 @@
|
|
|
|
|
<!-- ERP 产品的新增/修改 -->
|
|
|
|
|
<template>
|
|
|
|
|
<Dialog :title="dialogTitle" v-model="dialogVisible">
|
|
|
|
|
<el-form
|
|
|
|
|
ref="formRef"
|
|
|
|
|
:model="formData"
|
|
|
|
|
:rules="formRules"
|
|
|
|
|
label-width="120px"
|
|
|
|
|
v-loading="formLoading"
|
|
|
|
|
>
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogBarCodeLabel')" prop="barCode">
|
|
|
|
|
<el-row :gutter="10" style="width: 100%">
|
|
|
|
|
<el-col :xs="24" :sm="18" :md="16" :lg="14" :xl="20">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="formData.barCode"
|
|
|
|
|
:placeholder="t('FactoryModeling.ProductInformation.dialogBarCodePlaceholder')"
|
|
|
|
|
:disabled="Boolean(formData.isCode) || formType === 'update'"
|
|
|
|
|
/>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :xs="24" :sm="6" :md="4" :lg="3" :xl="2">
|
|
|
|
|
<div>
|
|
|
|
|
<el-switch
|
|
|
|
|
v-model="formData.isCode"
|
|
|
|
|
:disabled="formType === 'update'"
|
|
|
|
|
@change="handleCodeAutoChange"
|
|
|
|
|
<div class="dv-repair-panel">
|
|
|
|
|
<div class="dv-repair-panel__header">
|
|
|
|
|
<div class="dv-repair-panel__title">{{ dialogTitle }}</div>
|
|
|
|
|
<el-button text @click="closeForm">
|
|
|
|
|
<Icon icon="ep:close" />
|
|
|
|
|
</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="dv-repair-dialog" v-loading="formLoading">
|
|
|
|
|
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="120px">
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogBarCodeLabel')" prop="barCode">
|
|
|
|
|
<el-row :gutter="10" style="width: 100%">
|
|
|
|
|
<el-col :xs="24" :sm="18" :md="16" :lg="14" :xl="20">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="formData.barCode"
|
|
|
|
|
:placeholder="t('FactoryModeling.ProductInformation.dialogBarCodePlaceholder')"
|
|
|
|
|
:disabled="Boolean(formData.isCode) || formType === 'update'"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogNameLabel')" prop="name">
|
|
|
|
|
<el-input v-model="formData.name" :placeholder="t('FactoryModeling.ProductInformation.dialogNamePlaceholder')" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogCategoryLabel')" prop="categoryId">
|
|
|
|
|
<el-tree-select
|
|
|
|
|
v-model="formData.categoryId"
|
|
|
|
|
:data="categoryList"
|
|
|
|
|
:props="defaultProps"
|
|
|
|
|
check-strictly
|
|
|
|
|
default-expand-all
|
|
|
|
|
:placeholder="t('FactoryModeling.ProductInformation.dialogCategoryPlaceholder')"
|
|
|
|
|
class="w-1/1"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogUnitLabel')" prop="unitId">
|
|
|
|
|
<el-select v-model="formData.unitId" clearable :placeholder="t('FactoryModeling.ProductInformation.dialogUnitPlaceholder')" class="w-1/1">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="unit in unitList"
|
|
|
|
|
:key="unit.id"
|
|
|
|
|
:label="unit.name"
|
|
|
|
|
:value="unit.id"
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :xs="24" :sm="6" :md="4" :lg="3" :xl="2">
|
|
|
|
|
<div>
|
|
|
|
|
<el-switch
|
|
|
|
|
v-model="formData.isCode"
|
|
|
|
|
:disabled="formType === 'update'"
|
|
|
|
|
@change="handleCodeAutoChange"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogNameLabel')" prop="name">
|
|
|
|
|
<el-input v-model="formData.name" :placeholder="t('FactoryModeling.ProductInformation.dialogNamePlaceholder')" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogCategoryLabel')" prop="categoryId">
|
|
|
|
|
<el-tree-select
|
|
|
|
|
v-model="formData.categoryId"
|
|
|
|
|
:data="categoryList"
|
|
|
|
|
:props="defaultProps"
|
|
|
|
|
check-strictly
|
|
|
|
|
default-expand-all
|
|
|
|
|
:placeholder="t('FactoryModeling.ProductInformation.dialogCategoryPlaceholder')"
|
|
|
|
|
class="w-1/1"
|
|
|
|
|
/>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogStandardLabel')" prop="standard">
|
|
|
|
|
<el-input v-model="formData.standard" :placeholder="t('FactoryModeling.ProductInformation.dialogStandardPlaceholder')" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogExpiryDayLabel')" prop="expiryDay">
|
|
|
|
|
<el-input-number
|
|
|
|
|
v-model="formData.expiryDay"
|
|
|
|
|
:placeholder="t('FactoryModeling.ProductInformation.dialogExpiryDayPlaceholder')"
|
|
|
|
|
:min="0"
|
|
|
|
|
:precision="0"
|
|
|
|
|
class="!w-1/1"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<!-- <el-col :span="12">
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogWeightLabel')" prop="weight">
|
|
|
|
|
<el-input-number
|
|
|
|
|
v-model="formData.weight"
|
|
|
|
|
:placeholder="t('FactoryModeling.ProductInformation.dialogWeightPlaceholder')"
|
|
|
|
|
:min="0"
|
|
|
|
|
class="!w-1/1"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col> -->
|
|
|
|
|
<!-- <el-col :span="12">
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogPurchasePriceLabel')" prop="purchasePrice">
|
|
|
|
|
<el-input-number
|
|
|
|
|
v-model="formData.purchasePrice"
|
|
|
|
|
:placeholder="t('FactoryModeling.ProductInformation.dialogPurchasePricePlaceholder')"
|
|
|
|
|
:min="0"
|
|
|
|
|
:precision="2"
|
|
|
|
|
class="!w-1/1"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogSalePriceLabel')" prop="salePrice">
|
|
|
|
|
<el-input-number
|
|
|
|
|
v-model="formData.salePrice"
|
|
|
|
|
:placeholder="t('FactoryModeling.ProductInformation.dialogSalePricePlaceholder')"
|
|
|
|
|
:min="0"
|
|
|
|
|
:precision="2"
|
|
|
|
|
class="!w-1/1"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogMinPriceLabel')" prop="minPrice">
|
|
|
|
|
<el-input-number
|
|
|
|
|
v-model="formData.minPrice"
|
|
|
|
|
:placeholder="t('FactoryModeling.ProductInformation.dialogMinPricePlaceholder')"
|
|
|
|
|
:min="0"
|
|
|
|
|
:precision="2"
|
|
|
|
|
class="!w-1/1"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col> -->
|
|
|
|
|
<el-col v-if="isProductCategory" :span="12">
|
|
|
|
|
<el-form-item label="关联设备" prop="devices">
|
|
|
|
|
<el-input
|
|
|
|
|
:model-value="deviceDisplayText"
|
|
|
|
|
placeholder="点击选择设备"
|
|
|
|
|
readonly
|
|
|
|
|
@click="openDeviceSelectDialog"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col v-if="isProductCategory" :span="12">
|
|
|
|
|
<el-form-item label="关联模具" prop="molds">
|
|
|
|
|
<el-input
|
|
|
|
|
:model-value="moldDisplayText"
|
|
|
|
|
placeholder="点击选择模具"
|
|
|
|
|
readonly
|
|
|
|
|
@click="openMoldSelectDialog"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogStatusLabel')" prop="status">
|
|
|
|
|
<el-radio-group v-model="formData.status">
|
|
|
|
|
<el-radio
|
|
|
|
|
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
|
|
|
|
|
:key="dict.value"
|
|
|
|
|
:label="dict.value"
|
|
|
|
|
>
|
|
|
|
|
{{ dict.label }}
|
|
|
|
|
</el-radio>
|
|
|
|
|
</el-radio-group>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col v-if="formType === 'update'" :span="24">
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.qrcode')" prop="qrcodeUrl">
|
|
|
|
|
<QrcodeActionCard
|
|
|
|
|
:image-url="formData.qrcodeUrl"
|
|
|
|
|
:print-id="formData.id"
|
|
|
|
|
:print-template-type="1"
|
|
|
|
|
:print-title="`${formData.name || '产品'}二维码打印预览`"
|
|
|
|
|
:empty-text="t('FactoryModeling.ProductInformation.qrcodeEmpty')"
|
|
|
|
|
:refresh-url="getQrcodeRefreshUrl()"
|
|
|
|
|
:refresh-disabled="!formData.id || !formData.barCode"
|
|
|
|
|
refresh-confirm-text="确认刷新该产品二维码吗?"
|
|
|
|
|
:template-json="formData.templateJson"
|
|
|
|
|
:print-data="buildPrintData()"
|
|
|
|
|
@refresh-success="handleQrcodeRefreshSuccess"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogRemarkLabel')" prop="remark">
|
|
|
|
|
<el-input type="textarea" v-model="formData.remark" :placeholder="t('FactoryModeling.ProductInformation.dialogRemarkPlaceholder')" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
</el-form>
|
|
|
|
|
<template #footer>
|
|
|
|
|
<el-button @click="submitForm" type="primary" :disabled="formLoading">{{ t('common.ok') }}</el-button>
|
|
|
|
|
<el-button @click="dialogVisible = false">{{ t('common.cancel') }}</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</Dialog>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogUnitLabel')" prop="unitId">
|
|
|
|
|
<el-select v-model="formData.unitId" clearable :placeholder="t('FactoryModeling.ProductInformation.dialogUnitPlaceholder')" class="w-1/1">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="unit in unitList"
|
|
|
|
|
:key="unit.id"
|
|
|
|
|
:label="unit.name"
|
|
|
|
|
:value="unit.id"
|
|
|
|
|
/>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogStandardLabel')" prop="standard">
|
|
|
|
|
<el-input v-model="formData.standard" :placeholder="t('FactoryModeling.ProductInformation.dialogStandardPlaceholder')" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogExpiryDayLabel')" prop="expiryDay">
|
|
|
|
|
<el-input-number
|
|
|
|
|
v-model="formData.expiryDay"
|
|
|
|
|
:placeholder="t('FactoryModeling.ProductInformation.dialogExpiryDayPlaceholder')"
|
|
|
|
|
:min="0"
|
|
|
|
|
:precision="0"
|
|
|
|
|
class="!w-1/1"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col v-if="isProductCategory" :span="12">
|
|
|
|
|
<el-form-item label="关联设备" prop="devices">
|
|
|
|
|
<el-input
|
|
|
|
|
:model-value="deviceDisplayText"
|
|
|
|
|
placeholder="点击选择设备"
|
|
|
|
|
readonly
|
|
|
|
|
@click="openDeviceSelectDialog"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col v-if="isProductCategory" :span="12">
|
|
|
|
|
<el-form-item label="关联模具" prop="molds">
|
|
|
|
|
<el-input
|
|
|
|
|
:model-value="moldDisplayText"
|
|
|
|
|
placeholder="点击选择模具"
|
|
|
|
|
readonly
|
|
|
|
|
@click="openMoldSelectDialog"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogStatusLabel')" prop="status">
|
|
|
|
|
<el-radio-group v-model="formData.status">
|
|
|
|
|
<el-radio
|
|
|
|
|
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
|
|
|
|
|
:key="dict.value"
|
|
|
|
|
:label="dict.value"
|
|
|
|
|
>
|
|
|
|
|
{{ dict.label }}
|
|
|
|
|
</el-radio>
|
|
|
|
|
</el-radio-group>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col v-if="formType === 'update'" :span="24">
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.qrcode')" prop="qrcodeUrl">
|
|
|
|
|
<QrcodeActionCard
|
|
|
|
|
:image-url="formData.qrcodeUrl"
|
|
|
|
|
:print-id="formData.id"
|
|
|
|
|
:print-template-type="1"
|
|
|
|
|
:print-title="`${formData.name || '产品'}二维码打印预览`"
|
|
|
|
|
:empty-text="t('FactoryModeling.ProductInformation.qrcodeEmpty')"
|
|
|
|
|
:refresh-url="getQrcodeRefreshUrl()"
|
|
|
|
|
:refresh-disabled="!formData.id || !formData.barCode"
|
|
|
|
|
refresh-confirm-text="确认刷新该产品二维码吗?"
|
|
|
|
|
:template-json="formData.templateJson"
|
|
|
|
|
:print-data="buildPrintData()"
|
|
|
|
|
@refresh-success="handleQrcodeRefreshSuccess"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogRemarkLabel')" prop="remark">
|
|
|
|
|
<el-input type="textarea" v-model="formData.remark" :placeholder="t('FactoryModeling.ProductInformation.dialogRemarkPlaceholder')" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
</el-form>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="dv-repair-footer">
|
|
|
|
|
<el-button @click="closeForm">{{ t('common.cancel') }}</el-button>
|
|
|
|
|
<el-button v-if="formType !== 'detail'" @click="submitForm" type="primary" :disabled="formLoading">
|
|
|
|
|
{{ t('common.ok') }}
|
|
|
|
|
</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<TableSelectDialog
|
|
|
|
|
ref="deviceSelectDialogRef"
|
|
|
|
|
title="选择设备"
|
|
|
|
|
@ -191,9 +152,8 @@
|
|
|
|
|
@confirm="handleDeviceSelectConfirm"
|
|
|
|
|
:query-params="mergedQueryParams"
|
|
|
|
|
>
|
|
|
|
|
<!-- 使用 header 插槽插入查询表单 -->
|
|
|
|
|
<template #header>
|
|
|
|
|
<el-form ref="searchFormRef" :model="searchParams" :inline="true" >
|
|
|
|
|
<el-form ref="searchFormRef" :model="searchParams" :inline="true">
|
|
|
|
|
<el-form-item label="设备编号" prop="deviceCode">
|
|
|
|
|
<el-input v-model="searchParams.deviceCode" placeholder="请输入编号" clearable />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
@ -216,9 +176,8 @@
|
|
|
|
|
@confirm="handleMoldSelectConfirm"
|
|
|
|
|
:query-params="mergedMoldQueryParams"
|
|
|
|
|
>
|
|
|
|
|
<!-- 使用 header 插槽插入查询表单 -->
|
|
|
|
|
<template #header>
|
|
|
|
|
<el-form ref="searchMoldFormRef" :model="searchMoldParams" :inline="true" >
|
|
|
|
|
<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>
|
|
|
|
|
@ -248,24 +207,21 @@ import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
|
|
|
|
/** ERP 产品 表单 */
|
|
|
|
|
defineOptions({ name: 'ProductForm' })
|
|
|
|
|
|
|
|
|
|
const { t } = useI18n() // 国际化
|
|
|
|
|
const message = useMessage() // 消息弹窗
|
|
|
|
|
const { t } = useI18n()
|
|
|
|
|
const message = useMessage()
|
|
|
|
|
|
|
|
|
|
const dialogVisible = ref(false) // 弹窗的是否展示
|
|
|
|
|
const dialogTitle = ref('') // 弹窗的标题
|
|
|
|
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
|
|
|
|
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
|
|
|
|
const dialogTitle = ref('')
|
|
|
|
|
const formLoading = ref(false)
|
|
|
|
|
const formType = ref('')
|
|
|
|
|
const deviceSelectDialogRef = ref()
|
|
|
|
|
const moldSelectDialogRef = ref()
|
|
|
|
|
const searchFormRef = ref()
|
|
|
|
|
// 1. 自定义表单的查询参数
|
|
|
|
|
const searchParams = reactive({
|
|
|
|
|
deviceCode: undefined,
|
|
|
|
|
deviceName: undefined,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const handleSearch = () => {
|
|
|
|
|
// 触发弹窗内部重新加载数据
|
|
|
|
|
deviceSelectDialogRef.value?.reload?.()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -274,23 +230,20 @@ const resetSearch = () => {
|
|
|
|
|
handleSearch()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 1. 自定义表单的查询参数
|
|
|
|
|
const searchMoldParams = reactive({
|
|
|
|
|
code: undefined,
|
|
|
|
|
name: undefined,
|
|
|
|
|
})
|
|
|
|
|
const searchMoldFormRef = ref()
|
|
|
|
|
const handleMoldSearch = () => {
|
|
|
|
|
// 触发弹窗内部重新加载数据
|
|
|
|
|
moldSelectDialogRef.value?.reload?.()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const resetMoldSearch = () => {
|
|
|
|
|
searchMoldFormRef.value?.resetFields()
|
|
|
|
|
handleSearch()
|
|
|
|
|
handleMoldSearch()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 2. 合并参数:将表单参数与组件内部的分页参数合并
|
|
|
|
|
const mergedQueryParams = computed(() => ({ ...searchParams }))
|
|
|
|
|
const mergedMoldQueryParams = computed(() => ({ ...searchMoldParams }))
|
|
|
|
|
const formData = ref({
|
|
|
|
|
@ -485,20 +438,20 @@ const formRules = reactive({
|
|
|
|
|
unitId: [{ required: true, message: t('FactoryModeling.ProductInformation.validatorUnitRequired'), trigger: 'blur' }],
|
|
|
|
|
status: [{ required: true, message: t('FactoryModeling.ProductInformation.validatorStatusRequired'), trigger: 'blur' }]
|
|
|
|
|
})
|
|
|
|
|
const formRef = ref() // 表单 Ref
|
|
|
|
|
const categoryList = ref<ProductCategoryVO[]>([]) // 产品分类列表
|
|
|
|
|
const unitList = ref<ProductUnitVO[]>([]) // 产品单位列表
|
|
|
|
|
const formRef = ref()
|
|
|
|
|
const categoryList = ref<ProductCategoryVO[]>([])
|
|
|
|
|
const unitList = ref<ProductUnitVO[]>([])
|
|
|
|
|
|
|
|
|
|
let openRequestId = 0
|
|
|
|
|
|
|
|
|
|
/** 打开弹窗 */
|
|
|
|
|
const open = async (type: string, id?: number) => {
|
|
|
|
|
dialogVisible.value = true
|
|
|
|
|
const currentOpenId = ++openRequestId
|
|
|
|
|
dialogTitle.value = t('action.' + type)
|
|
|
|
|
formType.value = type
|
|
|
|
|
resetForm()
|
|
|
|
|
const categoryData = await ProductCategoryApi.getProductCategorySimpleList()
|
|
|
|
|
categoryList.value = handleTree(categoryData, 'id', 'parentId')
|
|
|
|
|
unitList.value = await ProductUnitApi.getProductUnitSimpleList()
|
|
|
|
|
// 修改时,设置数据
|
|
|
|
|
if (id) {
|
|
|
|
|
formLoading.value = true
|
|
|
|
|
try {
|
|
|
|
|
@ -533,7 +486,19 @@ const open = async (type: string, id?: number) => {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
|
|
|
|
|
|
|
|
|
defineExpose({ open })
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits(['success', 'closed'])
|
|
|
|
|
|
|
|
|
|
const closeForm = () => {
|
|
|
|
|
openRequestId++
|
|
|
|
|
emit('closed')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onBeforeUnmount(() => {
|
|
|
|
|
openRequestId++
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const handleCodeAutoChange = (value: boolean) => {
|
|
|
|
|
if (value) {
|
|
|
|
|
@ -573,12 +538,8 @@ const buildRelationIdListString = (list: { id: number; name: string }[]) => {
|
|
|
|
|
return list.map((item) => Number(item.id)).filter((id) => Number.isFinite(id))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 提交表单 */
|
|
|
|
|
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
|
|
|
|
const submitForm = async () => {
|
|
|
|
|
// 校验表单
|
|
|
|
|
await formRef.value.validate()
|
|
|
|
|
// 提交请求
|
|
|
|
|
formLoading.value = true
|
|
|
|
|
try {
|
|
|
|
|
const relationDevices = isProductCategory.value ? formData.value.devices : []
|
|
|
|
|
@ -597,15 +558,13 @@ const submitForm = async () => {
|
|
|
|
|
await ProductApi.updateProduct(data)
|
|
|
|
|
message.success(t('common.updateSuccess'))
|
|
|
|
|
}
|
|
|
|
|
dialogVisible.value = false
|
|
|
|
|
// 发送操作成功的事件
|
|
|
|
|
emit('success')
|
|
|
|
|
closeForm()
|
|
|
|
|
} finally {
|
|
|
|
|
formLoading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 重置表单 */
|
|
|
|
|
const resetForm = () => {
|
|
|
|
|
formData.value = {
|
|
|
|
|
id: undefined,
|
|
|
|
|
@ -643,4 +602,58 @@ watch(
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
</script>
|
|
|
|
|
<style scoped lang="scss"></style>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.dv-repair-panel {
|
|
|
|
|
background: #fff;
|
|
|
|
|
border-radius: 12px;
|
|
|
|
|
box-shadow: var(--el-box-shadow-light);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.dv-repair-panel__header {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
padding: 16px 20px;
|
|
|
|
|
border-bottom: 1px solid #ebeef5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.dv-repair-panel__title {
|
|
|
|
|
color: #1f2937;
|
|
|
|
|
font-size: 18px;
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.dv-repair-dialog {
|
|
|
|
|
max-height: calc(100vh - 220px);
|
|
|
|
|
padding: 20px 20px 0;
|
|
|
|
|
padding-right: 16px;
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.dv-repair-footer {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: flex-end;
|
|
|
|
|
gap: 12px;
|
|
|
|
|
width: 100%;
|
|
|
|
|
padding: 16px 20px 20px;
|
|
|
|
|
border-top: 1px solid #ebeef5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@media (max-width: 768px) {
|
|
|
|
|
.dv-repair-panel__header {
|
|
|
|
|
padding: 14px 16px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.dv-repair-dialog {
|
|
|
|
|
max-height: none;
|
|
|
|
|
padding: 16px 16px 0;
|
|
|
|
|
overflow-y: visible;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.dv-repair-footer {
|
|
|
|
|
padding: 16px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|