@@ -1,18 +1,20 @@
< script lang = "ts" setup >
import Bas ePageableTable from "@/components/base/bas e-pageable-table/Bas ePageableTable.vue" ;
import Expandabl ePageableTable from "@/components/base/expandabl e-pageable-table/Expandabl ePageableTable.vue" ;
import DefaultToolButton from "@/components/base/default-tool-button/DefaultToolButton.vue" ;
import DefaultOperateButtonColumn from "@/components/base/default-column/DefaultOperateButtonColumn.vue" ;
import DefaultStatusSwitchColumn from "@/components/base/default-column/DefaultStatusSwitchColumn.vue" ;
import { usePage } from "@/composables/use-page" ;
import BaseFormWithTable from "@/components/base/base-form-with-table/BaseFormWithTable.vue" ;
import { $t } from "@/common/languages" ;
import BaseFormWithTable from "@/components/base/base-form-with-table/BaseFormWithTable.vue" ;
import { ElMessage , ElMessageBox , type FormInstance , type FormRules } from "element-plus" ;
import { formatDate } from "@/common/utils/format-utils" ;
import BaseItemDialog from "@/components/base/base-item-dialog/BaseItemDialog.vue" ;
import BaseSelect from "@/components/base/base-select/BaseSelect.vue" ;
import BaseTableForm from "@/components/base/base-table-form/BaseTableForm.vue" ;
import { generateDucumentNo } from "@/common/utils/document-no-generator/document-no-generator" ;
import { get , post } from "@/common/http/request" ;
import { useStatus } from "@/common/languages/mapping/base-info-mapping" ;
import { type FieldMappingConfig } from "@/components/base/base-form-with-table/type" ;
/**
* 必须要的变量
@@ -22,11 +24,12 @@ const getPageUrl = "/production/finishedproductreceipt/getFinishedProductReceipt
const addUrl = "/production/finishedproductreceipt/addFinishedProductReceipt" ;
const editUrl = "/production/finishedproductreceipt/updateFinishedProductReceipt" ;
const removeUrl = "/production/finishedproductreceipt/deleteFinishedProductReceipt" ;
const approveUrl = "/production/finishedproductreceipt/approveFinishedProductReceipt" ;
const unapproveUrl = "/production/finishedproductreceipt/unapproveFinishedProductReceipt" ;
const getDetailUrl = "/production/finishedproductreceipt/getFinishedProductReceiptDetail" ;
const importI tems Url = "/production/finishedproductreceipt/impor tFinishedProductReceiptItems " ;
const itemUrl = "/production/finishedproductreceipt/ge tFinishedProductReceiptDetail " ;
const getWarehouseSelectListUrl = "/warehouse/warehouse/getWarehouseSelectList" ;
const getOutstockDataUrl = "/production/finishedproductreceipt/getOutstockData" ;
const saveOutstockUrl = "/production/finishedproductreceipt/saveOutstock" ;
const getKeyAccountSelectListUrl = "/sys/keyaccount/getKeyAccountSelectList" ;
const itemArrayName = "deviceItems" ;
const searchers = [
{ name : "searchCode" , type : "text" as const , placeholder : $t ( "_prop.production.finishedproductreceipt.formCode" ) } ,
@@ -58,12 +61,98 @@ const rules = reactive<FormRules>({
/**
* 基本不变通用变量
*/
const tableRef = ref < InstanceType < typeof Bas ePageableTable> | null > ( null ) ;
const tableRef = ref < InstanceType < typeof Expandabl ePageableTable> | null > ( null ) ;
const { useAdd , useEdit , useRemove , useGeneralPageRef } = usePage ( tableRef ) ;
const { title , visible , formType , form , itemVisible , itemParentId } = useGeneralPageRef ( ) ;
const baseFormWithTableRef = ref < InstanceType < typeof BaseFormWithTable > > ( ) ;
const warehouseSelectRef = ref < InstanceType < typeof BaseSelect > > ( ) ;
const { getFormStatusLabel } = useStatus ( ) ;
const outstockDialogRef = ref < InstanceType < typeof BaseTableForm > > ( ) ;
const keyAccountSelectRef = ref < InstanceType < typeof BaseSelect > > ( ) ;
const { getFinishedProductReceiptStatusLabel , getActivationStatusLabel , getActivationStatusTxtLabel } = useStatus ( ) ;
// 出货相关变量
const outstockVisible = ref ( false ) ;
const outstockTableData = ref ( [ ] ) ;
const currentOutstockId = ref ( ) ;
const currentOutstockRow = ref < any > ( { } ) ;
const outstockForm = ref ( {
keyAccountId : "" ,
formMark : "" ,
} ) ;
const selectedOutstockDevices = ref < any [ ] > ( [ ] ) ;
const handleOutstockSelectionChange = ( selection : any [ ] ) => {
selectedOutstockDevices . value = selection ;
} ;
// Excel导入映射配置
const mappingConfig : FieldMappingConfig = {
// productType <- "型号" (默认空字符串)
productType : {
sourceKey : "型号" ,
defaultValue : "" ,
} ,
// productSn <- "SN号" (默认空字符串)
productSn : {
sourceKey : "SN号" ,
defaultValue : "" ,
} ,
// mac <- "MAC地址" (默认空字符串)
mac : {
sourceKey : "MAC地址" ,
defaultValue : "" ,
} ,
// serialNum <- "序列号" (默认空字符串)
serialNum : {
sourceKey : "序列号" ,
defaultValue : "" ,
} ,
// softVersion <- "软件版本" (默认空字符串)
softVersion : {
sourceKey : "软件版本" ,
defaultValue : "" ,
} ,
// alVersion <- "算法版本" (默认空字符串)
alVersion : {
sourceKey : "算法版本" ,
defaultValue : "" ,
} ,
// alNum <- "算法标志" (默认空字符串)
alNum : {
sourceKey : "算法标志" ,
defaultValue : "" ,
} ,
// alTxt <- "激活状态" (默认"未激活")
alTxt : {
sourceKey : "激活状态" ,
defaultValue : "未激活" ,
transform : ( val : any ) => {
if ( val === "已激活" || val === "Activated" || val === true || val === "1" ) return "已激活" ;
if ( val === "未激活" || val === "Not Activated" || val === false || val === "0" ) return "未激活" ;
return "未激活" ;
} ,
} ,
// createDate <- "生产日期" (默认空字符串)
createDate : {
sourceKey : "生产日期" ,
defaultValue : "" ,
} ,
// mark <- "备注" (默认空字符串)
mark : {
sourceKey : "备注" ,
defaultValue : "" ,
} ,
} ;
/**
* 可以自定义的变量
*/
@@ -75,6 +164,7 @@ const add = () => {
visible . value = true ;
formType . value = false ;
} ;
const edit = ( row : any ) => {
title . value = "_title.production.finishedproductreceipt.edit" ;
form . value = { ... row } ;
@@ -84,33 +174,73 @@ const edit = (row: any) => {
const remove = ( row : any ) => {
useRemove ( removeUrl , row . id , "_message.production.finishedproductreceipt.delete_message" ) ;
} ;
const approve = ( row : any ) => {
ElMessageBox . confirm ( $t ( "_message.production.finishedproductreceipt.approve_confirm" ) , $t ( "_level.warning" ) , {
confirmButtonText : $t ( "_button.confirm" ) ,
cancelButtonText : $t ( "_button.cancel" ) ,
type : "warning" ,
} ) . then ( async ( ) => {
try {
await post ( approveUrl , { id : row . id } ) ;
ElMessage . success ( $t ( "_message.production.finishedproductreceipt.approve_success" ) ) ;
tableRef . value ? . reload ( ) ;
} catch ( err : any ) {
ElMessage . error ( $t ( "_message.production.finishedproductreceipt.approve_fail" ) + err ) ;
}
} ) ;
const outstock = async ( row : any ) => {
// 检查单据状态,只有待出货和出货中状态才能出货
if ( row . formStatus !== 1 && row . formStatus !== 3 ) {
ElMessage . warning ( $t ( "_message.production.finishedproductreceipt.only_pending_outstocking_can_outstock" ) ) ;
return ;
}
currentOutstockId . value = row . id ;
currentOutstockRow . value = row ;
try {
const outstockData = await get ( getOutstockDataUrl , { id : row . id } ) . then ( res => res . data ) ;
outstockTableData . value = outstockData . map ( ( item : any ) => ( {
... item ,
selected : false ,
} ) ) ;
// 重置出货表单
outstockForm . value = {
keyAccountId : "" ,
formMark : "" ,
} ;
outstockVisible . value = true ;
} catch ( error ) {
ElMessage . error ( $t ( "_message.production.finishedproductreceipt.get_outstock_data_failed" ) ) ;
console . error ( "获取出货数据失败:" , error ) ;
}
} ;
const unapprove = ( row : any ) => {
ElMessageBox . confirm ( $t ( "_message.production.finishedproductreceipt.reject_confirm" ) , $t ( "_level.warning" ) , {
const saveOutstock = async ( ) => {
if ( ! outstockForm . value . keyAccountId ) {
ElMessage . warning ( $t ( "_message.production.finishedproductreceipt.select_key_account" ) ) ;
return ;
}
if ( selectedOutstockDevices . value . length === 0 ) {
ElMessage . warning ( $t ( "_message.production.finishedproductreceipt.select_devices" ) ) ;
return ;
}
ElMessageBox . confirm ( $t ( "_message.production.finishedproductreceipt.outstock_confirm" ) , $t ( "_level.warning" ) , {
confirmButtonText : $t ( "_button.confirm" ) ,
cancelButtonText : $t ( "_button.cancel" ) ,
type : "warning" ,
} ) . then ( async ( ) => {
try {
await post ( unapproveUrl , { id : row . id } ) ;
ElMessage . success ( $t ( "_message.production.finishedproductreceipt.reject_success" ) ) ;
tableRef . value ? . reload ( ) ;
} catch ( err : any ) {
ElMessage . error ( $t ( "_message.production.finishedproductreceipt.reject_fail" ) + err ) ;
const requestData = {
id : currentOutstockId . value ,
keyAccountId : parseInt ( outstockForm . value . keyAccountId ) ,
outstockList : selectedOutstockDevices . value . map ( ( item : any ) => ( {
productSn : item . productSn ,
} ) ) ,
} ;
const res = await post ( saveOutstockUrl , requestData ) ;
if ( res . code === 0 ) {
ElMessage . success ( $t ( "_message.production.finishedproductreceipt.outstock_success" ) ) ;
outstockVisible . value = false ;
tableRef . value ? . reload ( ) ;
} else {
ElMessage . error ( $t ( "_message.production.finishedproductreceipt.outstock_fail" ) + res . msg ) ;
}
} catch ( error ) {
ElMessage . error ( $t ( "_message.production.finishedproductreceipt.outstock_fail" ) + error ) ;
console . error ( "出货失败:" , error ) ;
}
} ) ;
} ;
@@ -144,17 +274,22 @@ const operateButtonClick = (eventName: string, row: any) => {
case "remove" :
remove ( row ) ;
break ;
case "approve" :
approve ( row ) ;
break ;
case "unapprove" :
unapprove ( row ) ;
break ;
case "showItem" :
showItem ( row ) ;
break ;
case "outstock" :
outstock ( row ) ;
break ;
}
} ;
const authShowFunc = ( row : any , button : globalThis . ButtonProp ) => {
// 只有已完成的入库单不能出货( formStatus === 4)
if ( row . formStatus === 4 && button . eventName === "outstock" ) return false ;
// 其他按钮根据业务需求显示
return true ;
} ;
const setName = ( ) => {
form . value [ "storeName" ] = warehouseSelectRef . value ? . getLabel ( ) ;
} ;
@@ -163,7 +298,15 @@ const handleReset = () => {
} ;
< / script >
< template >
< Bas ePageableTable :url = "getPageUrl" :searchers = "searchers" ref = "tableRef" >
< Expandabl ePageableTable
:url = "getPageUrl"
:searchers = "searchers"
ref = "tableRef"
:item-url = "itemUrl"
item -id -key = " id "
item -id -name = " id "
item -field -name = " deviceItems "
>
< template # tool -button >
< DefaultToolButton @ top -button -click = " topButtonClick " / >
< / template >
@@ -174,10 +317,31 @@ const handleReset = () => {
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.formMark')" prop = "formMark" / >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.totalValue')" prop = "totalValue" / >
< el-table-column :label = "$t('_prop.common.createDate')" prop = "createDate" :formatter = "formatDate" / >
< DefaultStatusSwitchColumn status -param -name = " formStatus " :status-label-mapping = "getFormStatusLabel" / >
< DefaultOperateButtonColumn @ operate -button -click = " operateButtonClick " / >
< DefaultStatusSwitchColumn
status -param -name = " formStatus "
:status-label-mapping = "getFinishedProductReceiptStatusLabel"
/ >
< DefaultOperateButtonColumn @ operate -button -click = " operateButtonClick " :auth-show-func = "authShowFunc" / >
< / template >
< / BasePageableTable >
< template # item -content = " { itemData } " >
< el-table :data = "itemData" size = "small" border stripe >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.productType')" prop = "productType" / >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.productSn')" prop = "productSn" / >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.macAddress')" prop = "mac" / >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.serialNumber')" prop = "serialNum" / >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.softwareVersion')" prop = "softVersion" / >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.algorithmVersion')" prop = "alVersion" / >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.algorithmFlag')" prop = "alNum" / >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.activationStatus')" prop = "alStatus" >
< template # default = "{ row }" >
{ { getActivationStatusLabel ( row . alStatus ) } }
< / template >
< / el-table-column >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.productionDate')" prop = "createDate" / >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.remark')" prop = "mark" / >
< / el-table >
< / template >
< / ExpandablePageableTable >
< BaseFormWithTable
ref = "baseFormWithTableRef"
v -model :visible = "visible"
@@ -189,7 +353,7 @@ const handleReset = () => {
:table-title = "$t('_title.production.finishedproductreceipt.tableTitle')"
:item-array-name = "itemArrayName"
upload -desc = " 设备信息 "
:import-url = "importItemsUrl "
:mapping-config = "mappingConfig "
@reset ="handleReset"
>
< template # form -items >
@@ -256,85 +420,82 @@ const handleReset = () => {
< / template >
< / el-table-column >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.mac')" width = "150" >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.macAddress ')" width = "150" >
< template # default = "{ row, $index }" >
< el-form-item :prop = "`${itemArrayName}.${$index}.mac`" >
< el-input
v-model = "row.mac"
size = "small"
:placeholder = "$t('_message.production.finishedproductreceipt.input_mac')"
:placeholder = "$t('_message.production.finishedproductreceipt.input_macAddress ')"
/ >
< / el-form-item >
< / template >
< / el-table-column >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.serialNum')" width = "150" >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.serialNumber')" width = "150" >
< template # default = "{ row, $index }" >
< el-form-item :prop = "`${itemArrayName}.${$index}.serialNum`" >
< el-input
v-model = "row.serialNum"
size = "small"
:placeholder = "$t('_message.production.finishedproductreceipt.input_serialNum')"
:placeholder = "$t('_message.production.finishedproductreceipt.input_serialNumber ')"
/ >
< / el-form-item >
< / template >
< / el-table-column >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.softVersion')" width = "150" >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.softwareVersion')" width = "150" >
< template # default = "{ row, $index }" >
< el-form-item :prop = "`${itemArrayName}.${$index}.softVersion`" >
< el-input
v-model = "row.softVersion"
size = "small"
:placeholder = "$t('_message.production.finishedproductreceipt.input_softVersion')"
:placeholder = "$t('_message.production.finishedproductreceipt.input_software Version')"
/ >
< / el-form-item >
< / template >
< / el-table-column >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.alVersion')" width = "150" >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.algorithmVersion')" width = "150" >
< template # default = "{ row, $index }" >
< el-form-item :prop = "`${itemArrayName}.${$index}.alVersion`" >
< el-input
v-model = "row.alVersion"
size = "small"
:placeholder = "$t('_message.production.finishedproductreceipt.input_alVersion')"
:placeholder = "$t('_message.production.finishedproductreceipt.input_algorithm Version')"
/ >
< / el-form-item >
< / template >
< / el-table-column >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.alNum')" width = "150" >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.algorithmFlag')" width = "150" >
< template # default = "{ row, $index }" >
< el-form-item :prop = "`${itemArrayName}.${$index}.alNum`" >
< el-input
v-model = "row.alNum"
size = "small"
:placeholder = "$t('_message.production.finishedproductreceipt.input_alNum ')"
:placeholder = "$t('_message.production.finishedproductreceipt.input_algorithmFlag ')"
/ >
< / el-form-item >
< / template >
< / el-table-column >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.alTxt')" width = "150" >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.activationStatus')" width = "150" >
< template # default = "{ row, $index }" >
< el-form-item :prop = "`${itemArrayName}.${$index}.alTxt`" >
< el-inpu t
< el-selec t
v-model = "row.alTxt"
size = "small"
:placeholder = "$t('_message.production.finishedproductreceipt.input_alTxt ')"
/ >
:placeholder = "$t('_message.production.finishedproductreceipt.input_activationStatus ')"
>
< el-option :label = "$t('_base_info.activation_status.activated')" value = "已激活" / >
< el-option :label = "$t('_base_info.activation_status.not_activated')" value = "未激活" / >
< / el-select >
< / el-form-item >
< / template >
< / el-table-column >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.mark')" width = "150" >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.remark')" width = "150" >
< template # default = "{ row, $index }" >
< el-form-item :prop = "`${itemArrayName}.${$index}.mark`" >
< el-input
v-model = "row.mark"
size = "small"
:placeholder = "$t('_message.production.finishedproductreceipt.input_mark')"
:placeholder = "$t('_message.production.finishedproductreceipt.input_re mark')"
/ >
< / el-form-item >
< / template >
@@ -347,17 +508,113 @@ const handleReset = () => {
:url = "getDetailUrl"
parent -param -name = " id "
v -model :parent-param-value = "itemParentId"
width = "80%"
>
< template # columns >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.productType')" prop = "productType" / >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.productSn')" prop = "productSn" / >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.mac')" prop = "mac" / >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.serialNum')" prop = "serialNum" / >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.softVersion')" prop = "softVersion" />
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.alVersio n')" prop = "alVersion " / >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.alNum ')" prop = "alNum " / >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.alTxt')" prop = "alTxt" / >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.mark')" prop = "mark" / >
< el-table-column
:label = "$t('_prop.production.finishedproductreceipt.productType')"
prop = "productType"
width = "120"
/ >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.productS n')" prop = "productSn" width = "150 " / >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.macAddress ')" prop = "mac" width = "150 " / >
< el-table-column
:label = "$t('_prop.production.finishedproductreceipt.serialNumber')"
prop = "serialNum"
width = "150"
/ >
< el-table-column
:label = "$t('_prop.production.finishedproductreceipt.softwareVersion')"
prop = "softVersion"
width = "120"
/ >
< el-table-column
:label = "$t('_prop.production.finishedproductreceipt.algorithmVersion')"
prop = "alVersion"
width = "120"
/ >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.algorithmFlag')" prop = "alNum" width = "120" / >
< el-table-column
:label = "$t('_prop.production.finishedproductreceipt.activationStatus')"
prop = "alStatus"
width = "120"
>
< template # default = "{ row }" >
{ { getActivationStatusLabel ( row . alStatus ) } }
< / template >
< / el-table-column >
< el-table-column
:label = "$t('_prop.production.finishedproductreceipt.productionDate')"
prop = "createDate"
width = "150"
/ >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.remark')" prop = "mark" width = "150" / >
< / template >
< / BaseItemDialog >
<!-- 出货对话框 -- >
< BaseTableForm
ref = "outstockDialogRef"
v -model :visible = "outstockVisible"
:title = "$t('_title.production.finishedproductreceipt.outstockDialog')"
:tableData = "outstockTableData"
:selectable = "true"
:useAuth = "false"
@ selection -change = " handleOutstockSelectionChange "
>
< template # filter >
< el-row :gutter = "20" >
< el-col :span = "8" >
< el-form-item :label = "$t('_prop.production.finishedproductreceipt.formCode')" >
< el-input v-model = "currentOutstockRow.formCode" disabled / >
< / el-form-item >
< / el-col >
< el-col :span = "8" >
< el-form-item :label = "$t('_prop.production.finishedproductreceipt.keyAccountId')" >
< BaseSelect
v-model = "outstockForm.keyAccountId"
:url = "getKeyAccountSelectListUrl"
ref = "keyAccountSelectRef"
/ >
< / el-form-item >
< / el-col >
< el-col :span = "8" >
< el-form-item :label = "$t('_prop.production.finishedproductreceipt.formMark')" >
< el-input
v-model = "outstockForm.formMark"
:placeholder = "$t('_message.production.finishedproductreceipt.input_outstock_mark')"
type = "textarea"
autosize
/ >
< / el-form-item >
< / el-col >
< / el-row >
< / template >
< template # table -columns >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.productType')" prop = "productType" / >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.productSn')" prop = "productSn" / >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.macAddress')" prop = "mac" / >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.serialNumber')" prop = "serialNum" / >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.softwareVersion')" prop = "softVersion" / >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.algorithmVersion')" prop = "alVersion" / >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.algorithmFlag')" prop = "alNum" / >
< el-table-column :label = "$t('_prop.production.finishedproductreceipt.activationStatus')" prop = "alStatus" >
< template # default = "{ row }" >
{ { getActivationStatusLabel ( row . alStatus ) } }
< / template >
< / el-table-column >
< el-table-column
:label = "$t('_prop.production.finishedproductreceipt.createDate')"
prop = "createDate"
:formatter = "formatDate"
/ >
< / template >
< template # attachment >
< el-button type = "primary" @click ="saveOutstock" >
{{ $ t ( " _button.submit " ) }}
< / el -button >
< / template >
< / BaseTableForm >
< / template >