zhaoyiran
2 months ago
6 changed files with 1055 additions and 0 deletions
@ -0,0 +1,53 @@ |
|||||
|
import request from '@/config/axios' |
||||
|
|
||||
|
export interface PurchaseBarterRequestDetailVO { |
||||
|
masterId: number |
||||
|
itemCode: string |
||||
|
itemName: string |
||||
|
uom: string |
||||
|
batch: string |
||||
|
packUnit: string |
||||
|
qty: number |
||||
|
reason: string |
||||
|
} |
||||
|
|
||||
|
// 查询采购换货申请明细列表
|
||||
|
export const getPurchaseBarterRequestDetailPage = async (params) => { |
||||
|
if (params.isSearch) { |
||||
|
delete params.isSearch |
||||
|
const data = {...params} |
||||
|
return await request.post({ url: '/wms/purchase-barter-request-detail/senior', data }) |
||||
|
} else { |
||||
|
return await request.get({ url: `/wms/purchase-barter-request-detail/page`, params }) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 查询采购换货申请明细详情
|
||||
|
export const getPurchaseBarterRequestDetail = async (id: number) => { |
||||
|
return await request.get({ url: `/wms/purchase-barter-request-detail/get?id=` + id }) |
||||
|
} |
||||
|
|
||||
|
// 新增采购换货申请明细
|
||||
|
export const createPurchaseBarterRequestDetail = async (data: PurchaseBarterRequestDetailVO) => { |
||||
|
return await request.post({ url: `/wms/purchase-barter-request-detail/create`, data }) |
||||
|
} |
||||
|
|
||||
|
// 修改采购换货申请明细
|
||||
|
export const updatePurchaseBarterRequestDetail = async (data: PurchaseBarterRequestDetailVO) => { |
||||
|
return await request.put({ url: `/wms/purchase-barter-request-detail/update`, data }) |
||||
|
} |
||||
|
|
||||
|
// 删除采购换货申请明细
|
||||
|
export const deletePurchaseBarterRequestDetail = async (id: number) => { |
||||
|
return await request.delete({ url: `/wms/purchase-barter-request-detail/delete?id=` + id }) |
||||
|
} |
||||
|
|
||||
|
// 导出采购换货申请明细 Excel
|
||||
|
export const exportPurchaseBarterRequestDetail = async (params) => { |
||||
|
return await request.download({ url: `/wms/purchase-barter-request-detail/export-excel`, params }) |
||||
|
} |
||||
|
|
||||
|
// 下载用户导入模板
|
||||
|
export const importTemplate = () => { |
||||
|
return request.download({ url: '/wms/purchase-barter-request-detail/get-import-template' }) |
||||
|
} |
@ -0,0 +1,96 @@ |
|||||
|
import request from '@/config/axios' |
||||
|
|
||||
|
export interface PurchaseBarterRequestMainVO { |
||||
|
id: number |
||||
|
number: string |
||||
|
status: string |
||||
|
supplierCode: string |
||||
|
supplierName: string |
||||
|
available: string |
||||
|
creatorName: string |
||||
|
updaterName: string |
||||
|
deleteTime: Date |
||||
|
deleter: string |
||||
|
deleteName: string |
||||
|
} |
||||
|
|
||||
|
// 查询采购换货申请主列表
|
||||
|
export const getPurchaseBarterRequestMainPage = async (params) => { |
||||
|
if (params.isSearch) { |
||||
|
delete params.isSearch |
||||
|
const data = {...params} |
||||
|
return await request.post({ url: '/wms/purchase-barter-request-main/senior', data }) |
||||
|
} else { |
||||
|
return await request.get({ url: `/wms/purchase-barter-request-main/page`, params }) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 查询采购换货申请主详情
|
||||
|
export const getPurchaseBarterRequestMain = async (id: number) => { |
||||
|
return await request.get({ url: `/wms/purchase-barter-request-main/get?id=` + id }) |
||||
|
} |
||||
|
|
||||
|
// 新增采购换货申请主
|
||||
|
export const createPurchaseBarterRequestMain = async (data: PurchaseBarterRequestMainVO) => { |
||||
|
return await request.post({ url: `/wms/purchase-barter-request-main/create`, data }) |
||||
|
} |
||||
|
|
||||
|
// 修改采购换货申请主
|
||||
|
export const updatePurchaseBarterRequestMain = async (data: PurchaseBarterRequestMainVO) => { |
||||
|
return await request.put({ url: `/wms/purchase-barter-request-main/update`, data }) |
||||
|
} |
||||
|
|
||||
|
// 删除采购换货申请主
|
||||
|
export const deletePurchaseBarterRequestMain = async (id: number) => { |
||||
|
return await request.delete({ url: `/wms/purchase-barter-request-main/delete?id=` + id }) |
||||
|
} |
||||
|
|
||||
|
// 导出采购换货申请主 Excel
|
||||
|
export const exportPurchaseBarterRequestMain = async (params) => { |
||||
|
return await request.download({ url: `/wms/purchase-barter-request-main/export-excel`, params }) |
||||
|
} |
||||
|
|
||||
|
// 下载用户导入模板
|
||||
|
export const importTemplate = () => { |
||||
|
return request.download({ url: '/wms/purchase-barter-request-main/get-import-template' }) |
||||
|
} |
||||
|
|
||||
|
// 审批通过
|
||||
|
export async function agreePurchaseBarterRequestMain(id: number) { |
||||
|
return await request.put({ url: `/wms/purchase-barter-request-main/agree?id=` + id }) |
||||
|
} |
||||
|
|
||||
|
// 驳回
|
||||
|
export async function refusedPurchaseBarterRequestMain(id: number) { |
||||
|
return await request.put({ url: `/wms/purchase-barter-request-main/refused?id=` + id }) |
||||
|
} |
||||
|
|
||||
|
// 提交审批
|
||||
|
export async function submitPurchaseBarterRequestMain(id: number) { |
||||
|
return await request.put({ url: `/wms/purchase-barter-request-main/submit?id=` + id }) |
||||
|
} |
||||
|
|
||||
|
// 重新添加
|
||||
|
export async function reAddPurchaseBarterRequestMain(id: number) { |
||||
|
return await request.put({ url: `/wms/purchase-barter-request-main/reAdd?id=` + id }) |
||||
|
} |
||||
|
|
||||
|
// 关闭
|
||||
|
export async function closePurchaseBarterRequestMain(id: number) { |
||||
|
return await request.put({ url: `/wms/purchase-barter-request-main/close?id=` + id }) |
||||
|
} |
||||
|
|
||||
|
// 出库
|
||||
|
export async function outStoragePurchaseBarterRequestMain(id: number) { |
||||
|
return await request.put({ url: `/wms/purchase-barter-request-main/outStorage?id=` + id }) |
||||
|
} |
||||
|
|
||||
|
// 入库
|
||||
|
export async function inStoragePurchaseBarterRequestMain(id: number) { |
||||
|
return await request.put({ url: `/wms/purchase-barter-request-main/inStorage?id=` + id }) |
||||
|
} |
||||
|
|
||||
|
// 中止
|
||||
|
export async function suspendPurchaseBarterRequestMain(id: number) { |
||||
|
return await request.put({ url: `/wms/purchase-barter-request-main/suspend?id=` + id }) |
||||
|
} |
@ -0,0 +1,613 @@ |
|||||
|
<template> |
||||
|
<ContentWrap> |
||||
|
<!-- 搜索工作栏 --> |
||||
|
<Search :schema="[...PurchaseBarterRequestMain.allSchemas.searchSchema,...PurchaseBarterRequestDetail.allSchemas.searchSchema]" @search="setSearchParams" @reset="setSearchParams" /> |
||||
|
</ContentWrap> |
||||
|
|
||||
|
<!-- 列表头部 --> |
||||
|
<TableHead |
||||
|
:HeadButttondata="HeadButttondata" |
||||
|
@button-base-click="buttonBaseClick" |
||||
|
:routeName="routeName" |
||||
|
@updataTableColumns="updataTableColumns" |
||||
|
@searchFormClick="searchFormClick" |
||||
|
:allSchemas="PurchaseBarterRequestMain.allSchemas" |
||||
|
:detailAllSchemas="PurchaseBarterRequestDetail.allSchemas" |
||||
|
/> |
||||
|
|
||||
|
<!-- 列表 --> |
||||
|
<ContentWrap> |
||||
|
<Table v-clientTable |
||||
|
:columns="tableColumns" |
||||
|
:data="tableObject.tableList" |
||||
|
:loading="tableObject.loading" |
||||
|
:pagination="{ |
||||
|
total: tableObject.total |
||||
|
}" |
||||
|
v-model:pageSize="tableObject.pageSize" |
||||
|
v-model:currentPage="tableObject.currentPage" |
||||
|
v-model:sort="tableObject.sort" |
||||
|
> |
||||
|
<template #number="{row}"> |
||||
|
<el-button type="primary" link @click="openDetail(row, '单据号', row.number)"> |
||||
|
<span>{{ row.number }}</span> |
||||
|
</el-button> |
||||
|
</template> |
||||
|
<template #action="{ row,$index }"> |
||||
|
<ButtonBase :Butttondata="butttondata(row,$index)" @button-base-click="buttonTableClick($event,row)" /> |
||||
|
</template> |
||||
|
</Table> |
||||
|
</ContentWrap> |
||||
|
|
||||
|
<!-- 表单弹窗:添加/修改 --> |
||||
|
<BasicForm |
||||
|
ref="formRef" |
||||
|
:isOpenSearchTable="true" |
||||
|
fieldTableColumn="itemCode" |
||||
|
@success="getList" |
||||
|
:rules="PurchaseBarterRequestMainRules" |
||||
|
:formAllSchemas="PurchaseBarterRequestMain.allSchemas" |
||||
|
:tableAllSchemas="PurchaseBarterRequestDetail.allSchemas" |
||||
|
:tableFormRules="PurchaseBarterRequestDetailRules" |
||||
|
:tableData="tableData" |
||||
|
:apiUpdate="PurchaseBarterRequestMainApi.updatePurchaseBarterRequestMain" |
||||
|
:apiCreate="PurchaseBarterRequestMainApi.createPurchaseBarterRequestMain" |
||||
|
:isBusiness="true" |
||||
|
@handleAddTable="handleAddTable" |
||||
|
@handleDeleteTable="handleDeleteTable" |
||||
|
:isShowReduceButtonSelection="true" |
||||
|
@tableSelectionDelete="tableSelectionDelete" |
||||
|
@searchTableSuccess="searchTableSuccess" |
||||
|
@submitForm="submitForm" |
||||
|
@inputNumberChange="inputNumberChange" |
||||
|
@tableFormSelectOnBlur="tableFormSelectOnBlur" |
||||
|
> |
||||
|
</BasicForm> |
||||
|
|
||||
|
<Detail |
||||
|
ref="detailRef" |
||||
|
:isBasic="false" |
||||
|
:allSchemas="PurchaseBarterRequestMain.allSchemas" |
||||
|
:detailAllSchemas="PurchaseBarterRequestDetail.allSchemas" |
||||
|
:detailAllSchemasRules="PurchaseBarterRequestDetailRules" |
||||
|
@handleSubmitForm="handleDetailSubmitForm" |
||||
|
:apiPage="PurchaseBarterRequestDetailApi.getPurchaseBarterRequestDetailPage" |
||||
|
:apiDelete="PurchaseBarterRequestDetailApi.deletePurchaseBarterRequestDetail" |
||||
|
:Echo="Echo" |
||||
|
@searchTableSuccessDetail="searchTableSuccessDetail" |
||||
|
:detailValidate="detailValidate" |
||||
|
|
||||
|
@detailOpenForm="detailOpenForm" |
||||
|
@onBlur="onBlur" |
||||
|
/> |
||||
|
|
||||
|
|
||||
|
<!-- 导入 --> |
||||
|
<ImportForm ref="importFormRef" url="/wms/purchase-barter-request-main/import" :importTemplateData="importTemplateData" |
||||
|
@success="importSuccess" :updateIsDisable="true" :coverIsDisable="true" :mode="2" /> |
||||
|
</template> |
||||
|
|
||||
|
<script setup lang="ts"> |
||||
|
import { addDay } from '@/utils/formatTime' |
||||
|
import download from '@/utils/download' |
||||
|
import { CACHE_KEY, useCache } from '@/hooks/web/useCache' |
||||
|
import { |
||||
|
PurchaseBarterRequestMain, |
||||
|
PurchaseBarterRequestMainRules, |
||||
|
PurchaseBarterRequestDetail, |
||||
|
PurchaseBarterRequestDetailRules |
||||
|
} from './purchaseBarterRequestMain.data' |
||||
|
import * as PurchaseBarterRequestMainApi from '@/api/wms/purchaseBarterRequestMain' |
||||
|
import * as PurchaseBarterRequestDetailApi from '@/api/wms/purchaseBarterRequestDetail' |
||||
|
import * as defaultButtons from '@/utils/disposition/defaultButtons' |
||||
|
import * as ItembasicApi from "@/api/wms/itembasic"; |
||||
|
import { formatTime } from '@/utils' |
||||
|
import { formatDate } from '@/utils/formatTime' |
||||
|
import { usePageLoading } from '@/hooks/web/usePageLoading' |
||||
|
|
||||
|
const { loadStart, loadDone } = usePageLoading() |
||||
|
// 采购换货申请 |
||||
|
defineOptions({ name: 'PurchaseBarterRequestMain' }) |
||||
|
|
||||
|
const message = useMessage() // 消息弹窗 |
||||
|
const { t } = useI18n() // 国际化 |
||||
|
|
||||
|
const route = useRoute() // 路由信息 |
||||
|
const routeName = ref() |
||||
|
routeName.value = route.name |
||||
|
const tableColumns = ref([...PurchaseBarterRequestMain.allSchemas.tableColumns,...PurchaseBarterRequestDetail.allSchemas.tableMainColumns]) |
||||
|
|
||||
|
// 字段设置 更新主列表字段 |
||||
|
const updataTableColumns = (val) => { |
||||
|
tableColumns.value = val |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
// 查询页面返回 |
||||
|
const searchTableSuccess = (formField, searchField, val, formRef, type, row ) => { |
||||
|
nextTick(async () => { |
||||
|
if (type == 'tableForm') { |
||||
|
if(formField == 'itemCode'){ |
||||
|
let itemCodes = val.filter(item=>tableData.value.find(item1=>item1['itemCode']==item['itemCode'])) |
||||
|
if(itemCodes.length>0){ |
||||
|
itemCodes = itemCodes.map(item=>(item['itemCode'])) |
||||
|
message.warning(`物料${itemCodes.join(',')}已经存在`) |
||||
|
} |
||||
|
val = val.filter(item=>!tableData.value.find(item1=>item1['itemCode']==item['itemCode'])) |
||||
|
if(val.length==0){ |
||||
|
return |
||||
|
} |
||||
|
let newVal = val.filter(item=>!tableData.value.find(item1=>item1['itemCode']==item['itemCode'])) |
||||
|
newVal.forEach(item=>{ |
||||
|
let tfk = JSON.parse(JSON.stringify(tableFormKeys)) |
||||
|
tfk.batch = formatTime(new Date(), 'yyyyMMdd') |
||||
|
tfk['itemCode'] = item['itemCode'] |
||||
|
tfk['itemName'] = item['itemName'] |
||||
|
tfk['uom'] = item['supplierUom'] |
||||
|
tfk['packUnit'] = item['packUnit'] |
||||
|
tableData.value.push(tfk) |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
const setV = {} |
||||
|
if(formField === 'supplierCode'){ |
||||
|
setV['supplierCode'] = val[0]['code'] |
||||
|
setV['supplierName'] = val[0]['name'] |
||||
|
} |
||||
|
formRef.setValues(setV) |
||||
|
}) |
||||
|
} |
||||
|
const handleDetailSubmitForm = async (formType, data) => { |
||||
|
if (formType === 'create') { |
||||
|
await PurchaseBarterRequestDetailApi.createPurchaseBarterRequestDetail(data) |
||||
|
message.success(t('common.createSuccess')) |
||||
|
|
||||
|
} else { |
||||
|
await PurchaseBarterRequestDetailApi.updatePurchaseBarterRequestDetail(data) |
||||
|
message.success(t('common.updateSuccess')) |
||||
|
} |
||||
|
detailRef.value.submitUpdateList() |
||||
|
|
||||
|
} |
||||
|
// 查询页面返回——详情 |
||||
|
const searchTableSuccessDetail = (formField, searchField, val, formRef ) => { |
||||
|
nextTick(() => { |
||||
|
const setV = {} |
||||
|
setV[formField] = val[0][searchField] |
||||
|
if(formField == 'itemCode'){ |
||||
|
setV['itemCode'] = val[0]['itemCode'] |
||||
|
setV['itemName'] = val[0]['itemName'] |
||||
|
setV['uom'] = val[0]['supplierUom'] |
||||
|
setV['packUnit'] = val[0]['packUnit'] |
||||
|
setV['batch'] = formatTime(new Date(), 'yyyyMMdd') |
||||
|
} |
||||
|
formRef.setValues(setV) |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
const Echo = [] |
||||
|
|
||||
|
const { tableObject, tableMethods } = useTable({ |
||||
|
getListApi: PurchaseBarterRequestDetailApi.getPurchaseBarterRequestDetailPage // 分页接口 |
||||
|
}) |
||||
|
|
||||
|
// 获得表格的各种操作 |
||||
|
const { getList, setSearchParams } = tableMethods |
||||
|
|
||||
|
// 列表头部按钮 |
||||
|
const HeadButttondata = [ |
||||
|
defaultButtons.defaultAddBtn({hasPermi:'wms:purchase-barter-request-main:create'}), // 新增 |
||||
|
defaultButtons.defaultImportBtn({hasPermi:'wms:purchase-barter-request-main:import'}), // 导入 |
||||
|
defaultButtons.defaultExportBtn({hasPermi:'wms:purchase-barter-request-main:export'}), // 导出 |
||||
|
defaultButtons.defaultFreshBtn(null), // 刷新 |
||||
|
defaultButtons.defaultFilterBtn(null), // 筛选 |
||||
|
defaultButtons.defaultSetBtn(null), // 设置 |
||||
|
] |
||||
|
|
||||
|
// 头部按钮事件 |
||||
|
const buttonBaseClick = (val, item) => { |
||||
|
if (val == 'add') { // 新增 |
||||
|
openForm('create') |
||||
|
} else if (val == 'import') { // 导入 |
||||
|
handleImport() |
||||
|
} else if (val == 'export') { // 导出 |
||||
|
handleExport() |
||||
|
} else if (val == 'refresh') { // 刷新 |
||||
|
if (tableObject.params.filters && tableObject.params.filters.length > 0 ) { |
||||
|
searchFormClick({ |
||||
|
filters: tableObject.params.filters |
||||
|
}) |
||||
|
} else { |
||||
|
getList() |
||||
|
} |
||||
|
} else if (val == 'filtrate') { // 筛选 |
||||
|
} else { // 其他按钮 |
||||
|
console.log('其他按钮', item) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 根据状态返回该按钮是否显示 |
||||
|
const isShowMainButton = (row,val) => { |
||||
|
if (val.indexOf(row.status) > -1) { |
||||
|
return false |
||||
|
} else { |
||||
|
return true |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 列表-操作按钮 |
||||
|
const butttondata = (row,$index) => { |
||||
|
const findIndex = row['masterId']?tableObject.tableList.findIndex(item=>item['masterId'] == row['masterId']):-1 |
||||
|
if(findIndex>-1&&findIndex<$index){ |
||||
|
return [] |
||||
|
} |
||||
|
return [ |
||||
|
defaultButtons.mainListCloseBtn({hide:isShowMainButton(row,['1','2','3']),hasPermi:'wms:purchase-barter-request-main:close'}), // 关闭 |
||||
|
defaultButtons.mainListReAddBtn({hide:isShowMainButton(row,['4','5']),hasPermi:'wms:purchase-barter-request-main:reAdd'}), // 重新添加 |
||||
|
defaultButtons.mainListSubmitBtn({hide:isShowMainButton(row,['1']),hasPermi:'wms:purchase-barter-request-main:submit'}), // 提交审批 |
||||
|
defaultButtons.mainListTurnDownBtn({hide:isShowMainButton(row,['2']),hasPermi:'wms:purchase-barter-request-main:refused'}), // 驳回 |
||||
|
defaultButtons.mainListApproveBtn({hide:isShowMainButton(row,['2']),hasPermi:'wms:purchase-barter-request-main:agree'}), // 审批通过 |
||||
|
defaultButtons.outBtn({hide:isShowMainButton(row,['3']),hasPermi:'wms:unplannedreceipt-request-main:out'}), // 出库 |
||||
|
defaultButtons.inBtn({hide:isShowMainButton(row,['11']),hasPermi:'wms:unplannedreceipt-request-main:in'}), // 入库 |
||||
|
defaultButtons.mainListSuspend1Btn({hide:isShowMainButton(row,['11']),hasPermi:'wms:unplannedreceipt-request-main:suspend'}), // 中止 |
||||
|
// defaultButtons.mainListEditBtn({hide:isShowMainButton(row,['1']),hasPermi:'wms:purchase-barter-request-main:update'}), // 编辑 |
||||
|
defaultButtons.mainListDeleteBtn({hide:isShowMainButton(row,['1']),hasPermi:'wms:purchase-barter-request-main:delete'}), // 删除 |
||||
|
] |
||||
|
} |
||||
|
|
||||
|
// 列表-操作按钮事件 |
||||
|
const buttonTableClick = async (val, row) => { |
||||
|
console.log("val",val) |
||||
|
if (val == 'mainClose') { // 关闭 |
||||
|
console.log('列表-操作按钮事件-关闭') |
||||
|
handleClose(row.masterId) |
||||
|
} else if (val == 'mainReAdd') { // 重新添加 |
||||
|
console.log('列表-操作按钮事件-重新添加') |
||||
|
handleReAdd(row.masterId) |
||||
|
} else if (val == 'mainSubmit') { // 提交审批 |
||||
|
console.log('列表-操作按钮事件-提交审批') |
||||
|
handleSubmit(row.masterId) |
||||
|
} else if (val == 'mainTurnDown') { // 驳回 |
||||
|
console.log('列表-操作按钮事件-驳回') |
||||
|
handleRefused(row.masterId) |
||||
|
} else if (val == 'mainApprove') { // 审批通过 |
||||
|
console.log('列表-操作按钮事件-审批通过') |
||||
|
handleAgree(row.masterId) |
||||
|
} else if (val == 'out') { // 出库 |
||||
|
console.log('列表-操作按钮事件-出库') |
||||
|
handleOut(row.masterId) |
||||
|
} else if (val == 'in') { // 入库 |
||||
|
console.log('列表-操作按钮事件-入库') |
||||
|
handleIn(row.masterId) |
||||
|
}else if (val == 'suspend') { // 中止 |
||||
|
console.log('列表-操作按钮事件-中止') |
||||
|
handleSuspend(row.masterId) |
||||
|
}else if (val == 'edit') { // 编辑 |
||||
|
openForm('update', row) |
||||
|
} else if (val == 'delete') { // 删除 |
||||
|
handleDelete(row.masterId) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** 关闭按钮操作 */ |
||||
|
const handleClose = async (id: number) => { |
||||
|
await message.confirm(t('common.confirmColse')) |
||||
|
tableObject.loading = true |
||||
|
try{ |
||||
|
await PurchaseBarterRequestMainApi.closePurchaseBarterRequestMain(id) |
||||
|
message.success(t('common.closeSuccess')) |
||||
|
tableObject.loading = false |
||||
|
buttonBaseClick('refresh',null) |
||||
|
}catch{ |
||||
|
tableObject.loading = false |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** 重新添加按钮操作 */ |
||||
|
const handleReAdd = async (id: number) => { |
||||
|
await message.confirm(t('common.confirmReAdd')) |
||||
|
tableObject.loading = true |
||||
|
try{ |
||||
|
await PurchaseBarterRequestMainApi.reAddPurchaseBarterRequestMain(id) |
||||
|
message.success(t('common.reAddSuccess')) |
||||
|
tableObject.loading = false |
||||
|
buttonBaseClick('refresh',null) |
||||
|
}catch{ |
||||
|
tableObject.loading = false |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** 提交按钮操作 */ |
||||
|
const handleSubmit = async (id: number) => { |
||||
|
await message.confirm(t('common.confirmSubmit')) |
||||
|
tableObject.loading = true |
||||
|
try{ |
||||
|
await PurchaseBarterRequestMainApi.submitPurchaseBarterRequestMain(id) |
||||
|
message.success(t('common.submitSuccess')) |
||||
|
tableObject.loading = false |
||||
|
buttonBaseClick('refresh',null) |
||||
|
}catch{ |
||||
|
tableObject.loading = false |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** 审批驳回按钮操作 */ |
||||
|
const handleRefused = async (id: number) => { |
||||
|
await message.confirm(t('common.confirmRefused')) |
||||
|
tableObject.loading = true |
||||
|
try{ |
||||
|
await PurchaseBarterRequestMainApi.refusedPurchaseBarterRequestMain(id) |
||||
|
message.success(t('common.refusedSuccess')) |
||||
|
tableObject.loading = false |
||||
|
buttonBaseClick('refresh',null) |
||||
|
}catch{ |
||||
|
tableObject.loading = false |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** 审批通过按钮操作 */ |
||||
|
const handleAgree = async (id: number) => { |
||||
|
await message.confirm(t('common.confirmAgree')) |
||||
|
tableObject.loading = true |
||||
|
try{ |
||||
|
await PurchaseBarterRequestMainApi.agreePurchaseBarterRequestMain(id) |
||||
|
message.success(t('common.agreeSuccess')) |
||||
|
tableObject.loading = false |
||||
|
buttonBaseClick('refresh',null) |
||||
|
}catch{ |
||||
|
tableObject.loading = false |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** 出库按钮操作 */ |
||||
|
const handleOut = async (id: number) => { |
||||
|
await message.confirm(t('common.confirmOutStorage')) |
||||
|
tableObject.loading = true |
||||
|
try { |
||||
|
await PurchaseBarterRequestMainApi.outStoragePurchaseBarterRequestMain(id) |
||||
|
message.success(t('common.handleSuccess')) |
||||
|
buttonBaseClick('refresh',null) |
||||
|
} finally { |
||||
|
tableObject.loading = false |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
const handleIn = async (id: number) => { |
||||
|
await message.confirm(t('common.confirmInStorage')) |
||||
|
tableObject.loading = true |
||||
|
try { |
||||
|
await PurchaseBarterRequestMainApi.inStoragePurchaseBarterRequestMain(id) |
||||
|
message.success(t('common.handleSuccess')) |
||||
|
buttonBaseClick('refresh',null) |
||||
|
} finally { |
||||
|
tableObject.loading = false |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
const handleSuspend = async (id: number) => { |
||||
|
await message.confirm(t('common.confirmSuspend')) |
||||
|
tableObject.loading = true |
||||
|
try { |
||||
|
await PurchaseBarterRequestMainApi.suspendPurchaseBarterRequestMain(id) |
||||
|
message.success(t('common.handleSuccess')) |
||||
|
buttonBaseClick('refresh',null) |
||||
|
} finally { |
||||
|
tableObject.loading = false |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** 添加/修改操作 */ |
||||
|
const formRef = ref() |
||||
|
const openForm =async (type: string, row?: number) => { |
||||
|
PurchaseBarterRequestMain.allSchemas.formSchema.forEach((item) => { |
||||
|
if(type == "update"){ |
||||
|
|
||||
|
}else{ |
||||
|
|
||||
|
} |
||||
|
}) |
||||
|
|
||||
|
tableData.value = [] // 重置明细数据 |
||||
|
formRef.value.open(type, row) |
||||
|
} |
||||
|
|
||||
|
// 获取部门 用于详情 部门回显 |
||||
|
const { wsCache } = useCache() |
||||
|
/** 详情操作 */ |
||||
|
const detailRef = ref() |
||||
|
const openDetail = (row: any, titleName: any, titleValue: any) => { |
||||
|
const departmentCode = wsCache.get(CACHE_KEY.DEPT).find((account) => account.id == row.departmentCode)?.name |
||||
|
if (departmentCode) row.departmentCode = JSON.parse(JSON.stringify(departmentCode)) |
||||
|
detailRef.value.openDetail(row, titleName, titleValue,'requestUnplannedreceiptMain') |
||||
|
} |
||||
|
|
||||
|
/** 删除按钮操作 */ |
||||
|
const handleDelete = async (id: number) => { |
||||
|
try { |
||||
|
// 删除的二次确认 |
||||
|
await message.delConfirm() |
||||
|
tableObject.loading = true |
||||
|
// 发起删除 |
||||
|
await PurchaseBarterRequestMainApi.deletePurchaseBarterRequestMain(id) |
||||
|
message.success(t('common.delSuccess')) |
||||
|
tableObject.loading = false |
||||
|
// 刷新列表 |
||||
|
buttonBaseClick('refresh',null) |
||||
|
} catch {} |
||||
|
} |
||||
|
|
||||
|
/** 导出按钮操作 */ |
||||
|
const handleExport = async () => { |
||||
|
try { |
||||
|
// 导出的二次确认 |
||||
|
await message.exportConfirm() |
||||
|
// 发起导出 |
||||
|
loadStart() |
||||
|
const excelTitle = ref(route.meta.title) |
||||
|
tableObject.params.detailDataType = 1 |
||||
|
const data = await PurchaseBarterRequestMainApi.exportPurchaseBarterRequestMain(tableObject.params) |
||||
|
download.excel(data, `【${excelTitle.value}】【${formatDate(new Date())}】.xlsx`) |
||||
|
} catch { |
||||
|
} finally { |
||||
|
loadDone() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* tableForm方法 |
||||
|
*/ |
||||
|
const tableFormKeys = {} |
||||
|
PurchaseBarterRequestDetail.allSchemas.tableFormColumns.forEach(item => { |
||||
|
tableFormKeys[item.field] = item.default ? item.default : '' |
||||
|
}) |
||||
|
const tableData = ref([]) |
||||
|
|
||||
|
// 添加明细 |
||||
|
const handleAddTable = () => { |
||||
|
let tfk = JSON.parse(JSON.stringify(tableFormKeys)) |
||||
|
tfk.batch = formatTime(new Date(), 'yyyyMMdd') |
||||
|
tableData.value.push(tfk) |
||||
|
} |
||||
|
// 删除明细 |
||||
|
const handleDeleteTable = (item, index) => { |
||||
|
let itemIndex = tableData.value.indexOf(item) |
||||
|
if(itemIndex>-1){ |
||||
|
tableData.value.splice(itemIndex, 1) |
||||
|
} |
||||
|
} |
||||
|
const tableSelectionDelete = (selection) => { |
||||
|
tableData.value = tableData.value.filter(item => !selection.includes(item)) |
||||
|
} |
||||
|
// 主子数据 提交 |
||||
|
const submitForm = async (formType, submitData) => { |
||||
|
|
||||
|
let data = {...submitData} |
||||
|
if(data.masterId){ |
||||
|
data.id = data.masterId |
||||
|
} |
||||
|
data.subList = tableData.value // 拼接子表数据参数 |
||||
|
try { |
||||
|
if (formType === 'create') { |
||||
|
if(data.subList.length == 0){ |
||||
|
message.warning("请添加子列表数据") |
||||
|
return; |
||||
|
} |
||||
|
let flag = false; |
||||
|
data.subList.forEach((item) => { |
||||
|
if(item.qty == 0){ |
||||
|
message.warning("数量不能为0") |
||||
|
flag = true; |
||||
|
return; |
||||
|
} |
||||
|
}) |
||||
|
if(flag){ |
||||
|
return |
||||
|
} |
||||
|
formRef.value.formLoading = true |
||||
|
await PurchaseBarterRequestMainApi.createPurchaseBarterRequestMain(data) |
||||
|
message.success(t('common.createSuccess')) |
||||
|
} else { |
||||
|
formRef.value.formLoading = true |
||||
|
await PurchaseBarterRequestMainApi.updatePurchaseBarterRequestMain(data) |
||||
|
message.success(t('common.updateSuccess')) |
||||
|
} |
||||
|
formRef.value.dialogVisible = false |
||||
|
// 刷新当前列表 |
||||
|
if (formType === 'create') { |
||||
|
getList() |
||||
|
}else{ |
||||
|
buttonBaseClick('refresh',null) |
||||
|
} |
||||
|
} finally { |
||||
|
formRef.value.formLoading = false |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 子表新增/编辑校验 |
||||
|
const detailValidate = (data) => { |
||||
|
let tag = false; |
||||
|
if(data.qty <= 0){ |
||||
|
message.warning('数量必须大于0') |
||||
|
tag = false; |
||||
|
return tag; |
||||
|
}else { |
||||
|
tag = true; |
||||
|
return tag; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** 导入 */ |
||||
|
const importFormRef = ref() |
||||
|
const handleImport = () => { |
||||
|
importFormRef.value.open() |
||||
|
} |
||||
|
|
||||
|
// 导入附件弹窗所需的参数 |
||||
|
const importTemplateData = reactive({ |
||||
|
templateUrl: '', |
||||
|
templateTitle: `【${route.meta.title}】导入模版.xlsx` |
||||
|
}) |
||||
|
|
||||
|
// 导入成功之后 |
||||
|
const importSuccess = () => { |
||||
|
getList() |
||||
|
} |
||||
|
|
||||
|
// 筛选提交 |
||||
|
const searchFormClick = (searchData) => { |
||||
|
tableObject.params = { |
||||
|
isSearch: true, |
||||
|
filters: searchData.filters |
||||
|
} |
||||
|
getList() // 刷新当前列表 |
||||
|
} |
||||
|
|
||||
|
// 创建标签 |
||||
|
const inputNumberChange = (field, index, row, val) => { |
||||
|
if(field == 'qty' || field == 'singlePrice'){ |
||||
|
row.amount = row.qty * row.singlePrice |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
let validityDays = 0 |
||||
|
const detailOpenForm = (type, row)=>{ |
||||
|
console.log('detailOpenForm',row) |
||||
|
if(type=='update'){ |
||||
|
//有效期 |
||||
|
ItembasicApi.getItembasicPage({ |
||||
|
code:row.itemCode |
||||
|
}).then((res)=>{ |
||||
|
res.list.forEach((item,index)=>{ |
||||
|
const findItem = tableData.value.find(item1=>item1['itemCode']==row['code']) |
||||
|
if(findItem){ |
||||
|
validityDays = findItem['expireTime'] |
||||
|
} |
||||
|
}) |
||||
|
detailRef.value.formRef.formRef.formModel.expireDate = addDay(detailRef.value.formRef.formRef.formModel.produceDate,validityDays).valueOf() |
||||
|
}) |
||||
|
}else{ |
||||
|
validityDays = 0 |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
const onBlur = (field, e) => { |
||||
|
if (field == 'reason') { |
||||
|
detailRef.value.formRef.formRef.formModel[field] = e.target.value |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
const tableFormSelectOnBlur = (field, val, row, index) => { |
||||
|
if (field == 'reason') { |
||||
|
tableData.value[index][field] = val.target.value |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** 初始化 **/ |
||||
|
onMounted(async () => { |
||||
|
getList() |
||||
|
importTemplateData.templateUrl = await PurchaseBarterRequestMainApi.importTemplate() |
||||
|
}) |
||||
|
</script> |
@ -0,0 +1,277 @@ |
|||||
|
import type { CrudSchema } from '@/hooks/web/useCrudSchemas' |
||||
|
import {Supplier} from "@/views/wms/basicDataManage/supplierManage/supplier/supplier.data"; |
||||
|
import * as SupplierApi from "@/api/wms/supplier"; |
||||
|
import * as ItembasicApi from "@/api/wms/itembasic"; |
||||
|
import { |
||||
|
Supplieritem |
||||
|
} from "@/views/wms/basicDataManage/supplierManage/supplieritem/supplieritem.data"; |
||||
|
import * as SupplieritemApi from "@/api/wms/supplieritem"; |
||||
|
|
||||
|
/** |
||||
|
* @returns {Array} 采购换货申请主表 |
||||
|
*/ |
||||
|
export const PurchaseBarterRequestMain = useCrudSchemas(reactive<CrudSchema[]>([ |
||||
|
{ |
||||
|
label: '申请单号', |
||||
|
field: 'number', |
||||
|
sort: 'custom', |
||||
|
isSearch: true, |
||||
|
isForm: false, |
||||
|
table: { |
||||
|
width: 180, |
||||
|
fixed: 'left' |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
label: '状态', |
||||
|
field: 'status', |
||||
|
sort: 'custom', |
||||
|
isSearch: true, |
||||
|
isForm: false, |
||||
|
dictType: DICT_TYPE.REQUEST_STATUS, |
||||
|
dictClass: 'string', |
||||
|
}, |
||||
|
{ |
||||
|
label: '供应商代码', |
||||
|
field: 'supplierCode', |
||||
|
sort: 'custom', |
||||
|
isSearch: true, |
||||
|
form: { |
||||
|
// labelMessage: '信息提示说明!!!',
|
||||
|
componentProps: { |
||||
|
enterSearch: true, |
||||
|
isSearchList: true, // 开启查询弹窗
|
||||
|
searchListPlaceholder: '请选择供应商代码', // 输入框占位文本
|
||||
|
searchField: 'code', // 查询弹窗赋值字段
|
||||
|
searchTitle: '供应商', // 查询弹窗标题
|
||||
|
searchAllSchemas: Supplier.allSchemas, // 查询弹窗所需类
|
||||
|
searchPage: SupplierApi.getSupplierPage, // 查询弹窗所需分页方法
|
||||
|
searchCondition: [{ |
||||
|
key: 'available', |
||||
|
value: 'TRUE', |
||||
|
isMainValue: false |
||||
|
}], |
||||
|
verificationParams: [{ |
||||
|
key: 'code', |
||||
|
action: '==', |
||||
|
value: '', |
||||
|
isMainValue: false, |
||||
|
isSearch: true, |
||||
|
isFormModel: true, |
||||
|
}], // 失去焦点校验参数
|
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
label: '供应商名称', |
||||
|
field: 'supplierName', |
||||
|
sort: 'custom', |
||||
|
isSearch: false, |
||||
|
form: { |
||||
|
componentProps: { |
||||
|
disabled: true |
||||
|
} |
||||
|
}, |
||||
|
}, |
||||
|
{ |
||||
|
label: '操作', |
||||
|
field: 'action', |
||||
|
isForm: false, |
||||
|
isDetail: false, |
||||
|
table: { |
||||
|
width: 250, |
||||
|
fixed: 'right' |
||||
|
} |
||||
|
} |
||||
|
])) |
||||
|
|
||||
|
//表单校验
|
||||
|
export const PurchaseBarterRequestMainRules = reactive({ |
||||
|
supplierCode: [ |
||||
|
{ required: true, message: '请输入供应商代码', trigger: 'blur' } |
||||
|
], |
||||
|
}) |
||||
|
|
||||
|
/** |
||||
|
* @returns {Array} 采购换货申请子表 |
||||
|
*/ |
||||
|
export const PurchaseBarterRequestDetail = useCrudSchemas(reactive<CrudSchema[]>([ |
||||
|
{ |
||||
|
label: '物料代码', |
||||
|
field: 'itemCode', |
||||
|
sort: 'custom', |
||||
|
isSearch: true, |
||||
|
table: { |
||||
|
width: 150 |
||||
|
}, |
||||
|
tableForm:{ |
||||
|
multiple:true,//多选
|
||||
|
isInpuFocusShow: true, // 开启查询弹窗
|
||||
|
searchListPlaceholder: '请选择物料代码',// 输入框占位文本
|
||||
|
searchField: 'itemCode', // 查询弹窗赋值字段
|
||||
|
searchTitle: '供应商物料信息', // 查询弹窗标题
|
||||
|
searchAllSchemas: Supplieritem.allSchemas, // 查询弹窗所需类
|
||||
|
searchPage: SupplieritemApi.getSupplieritemPage, // 查询弹窗所需分页方法
|
||||
|
searchCondition: [{ |
||||
|
key: 'available', |
||||
|
value: 'TRUE', |
||||
|
action: '==', |
||||
|
isSearch: true, |
||||
|
isMainValue: false |
||||
|
},{ |
||||
|
key: 'supplierCode', |
||||
|
value: 'supplierCode', |
||||
|
action: '==', |
||||
|
message: '供应商代码不能为空!', |
||||
|
isFormModel:true, // filters中添加筛选的数据--取于formModel
|
||||
|
required:true, // 前置添加必有,和isFormModel结合使用
|
||||
|
isSearch: true, |
||||
|
isMainValue: false |
||||
|
}], |
||||
|
verificationPage: ItembasicApi.getItemListByCodes, // tableForm下方输入框校验失去焦点之后是否正确的方法
|
||||
|
isShowTableFormSearch: false, //tableForm下方是否出现输入框
|
||||
|
verificationParams: [{ |
||||
|
key: 'itemCode', |
||||
|
action: '==', |
||||
|
value: '', |
||||
|
isMainValue: false, |
||||
|
isSearch: true, |
||||
|
isFormModel: true, |
||||
|
}], // 失去焦点校验参数
|
||||
|
}, |
||||
|
form: { |
||||
|
// labelMessage: '信息提示说明!!!',
|
||||
|
componentProps: { |
||||
|
disabled:true, |
||||
|
enterSearch: true, |
||||
|
isSearchList: true, // 开启查询弹窗
|
||||
|
searchListPlaceholder: '请选择物料代码', // 输入框占位文本
|
||||
|
searchField: 'itemCode', // 查询弹窗赋值字段
|
||||
|
searchTitle: '供应商物料信息', // 查询弹窗标题
|
||||
|
searchAllSchemas: Supplieritem.allSchemas, // 查询弹窗所需类
|
||||
|
searchPage: SupplieritemApi.getSupplieritemPage, // 查询弹窗所需分页方法
|
||||
|
searchCondition: [ |
||||
|
{ |
||||
|
key: 'available', |
||||
|
value: 'TRUE', |
||||
|
isMainValue: false |
||||
|
},{ |
||||
|
key: 'supplierCode', |
||||
|
value: 'supplierCode', |
||||
|
message: '供应商代码不能为空!', |
||||
|
isMainValue:true |
||||
|
} |
||||
|
], |
||||
|
verificationParams: [ |
||||
|
{ |
||||
|
key: 'itemCode', |
||||
|
action: '==', |
||||
|
value: '', |
||||
|
isMainValue: false, |
||||
|
isSearch: true, |
||||
|
isFormModel: true |
||||
|
} |
||||
|
] // 失去焦点校验参数
|
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
label: '物料名称', |
||||
|
field: 'itemName', |
||||
|
sort: 'custom', |
||||
|
isSearch: false, |
||||
|
tableForm: { |
||||
|
disabled: true |
||||
|
}, |
||||
|
form:{ |
||||
|
componentProps:{ |
||||
|
disabled:true |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
label: '计量单位', |
||||
|
field: 'uom', |
||||
|
sort: 'custom', |
||||
|
isSearch: false, |
||||
|
tableForm: { |
||||
|
disabled: true |
||||
|
}, |
||||
|
form:{ |
||||
|
componentProps:{ |
||||
|
disabled:true |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
label: '批次', |
||||
|
field: 'batch', |
||||
|
sort: 'custom', |
||||
|
isSearch: true, |
||||
|
tableForm: { |
||||
|
disabled: true |
||||
|
}, |
||||
|
form:{ |
||||
|
componentProps:{ |
||||
|
disabled:true |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
label: '包装规格', |
||||
|
field: 'packUnit', |
||||
|
sort: 'custom', |
||||
|
isSearch: false, |
||||
|
tableForm: { |
||||
|
disabled: true |
||||
|
}, |
||||
|
form:{ |
||||
|
componentProps:{ |
||||
|
disabled:true |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
label: '换货数量', |
||||
|
field: 'qty', |
||||
|
sort: 'custom', |
||||
|
isSearch: false, |
||||
|
form: { |
||||
|
component: 'InputNumber', |
||||
|
value: 0 |
||||
|
}, |
||||
|
}, |
||||
|
{ |
||||
|
label: '换货原因 ', |
||||
|
field: 'reason', |
||||
|
sort: 'custom', |
||||
|
isSearch: false, |
||||
|
}, |
||||
|
{ |
||||
|
label: '操作', |
||||
|
field: 'action', |
||||
|
isDetail: false, |
||||
|
hiddenInMain:true, |
||||
|
isForm: false , |
||||
|
table: { |
||||
|
width: 150, |
||||
|
fixed: 'right' |
||||
|
}, |
||||
|
isTableForm:false, |
||||
|
} |
||||
|
])) |
||||
|
|
||||
|
function validateQty(rule, value, callback) { |
||||
|
const numericValue = Number(value); |
||||
|
if (Number.isInteger(numericValue) && numericValue > 0) { |
||||
|
callback(); |
||||
|
} else { |
||||
|
callback(new Error('数量必须是一个正整数')); |
||||
|
} |
||||
|
} |
||||
|
//表单校验
|
||||
|
export const PurchaseBarterRequestDetailRules = reactive({ |
||||
|
qty:[ |
||||
|
{ validator:validateQty, message: '数量必须是一个正整数', trigger: 'change'} |
||||
|
], |
||||
|
}) |
Loading…
Reference in new issue