陈薪名
5 months ago
41 changed files with 5318 additions and 2550 deletions
@ -0,0 +1,65 @@ |
|||||
|
import request from '@/config/axios' |
||||
|
|
||||
|
export interface SupplierCycleVO { |
||||
|
id: number |
||||
|
supplierCode: string |
||||
|
monday: string |
||||
|
tuesday: string |
||||
|
wednesday: string |
||||
|
thursday: string |
||||
|
friday: string |
||||
|
saturday: string |
||||
|
sunday: string |
||||
|
version: string |
||||
|
remark: string |
||||
|
extraProperties: string |
||||
|
siteId: string |
||||
|
beginTime: Date |
||||
|
endTime: Date |
||||
|
available: string |
||||
|
status: string |
||||
|
concurrencyStamp: string |
||||
|
ruleUserId: number |
||||
|
departmentCode: string |
||||
|
} |
||||
|
|
||||
|
// 查询要货预测周期列表
|
||||
|
export const getSupplierCyclePage = async (params) => { |
||||
|
if (params.isSearch) { |
||||
|
delete params.isSearch |
||||
|
const data = {...params} |
||||
|
return await request.post({ url: '/wms/supplier-cycle/senior', data }) |
||||
|
} else { |
||||
|
return await request.get({ url: `/wms/supplier-cycle/page`, params }) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 查询要货预测周期详情
|
||||
|
export const getSupplierCycle = async (id: number) => { |
||||
|
return await request.get({ url: `/wms/supplier-cycle/get?id=` + id }) |
||||
|
} |
||||
|
|
||||
|
// 新增要货预测周期
|
||||
|
export const createSupplierCycle = async (data: SupplierCycleVO) => { |
||||
|
return await request.post({ url: `/wms/supplier-cycle/create`, data }) |
||||
|
} |
||||
|
|
||||
|
// 修改要货预测周期
|
||||
|
export const updateSupplierCycle = async (data: SupplierCycleVO) => { |
||||
|
return await request.put({ url: `/wms/supplier-cycle/update`, data }) |
||||
|
} |
||||
|
|
||||
|
// 删除要货预测周期
|
||||
|
export const deleteSupplierCycle = async (id: number) => { |
||||
|
return await request.delete({ url: `/wms/supplier-cycle/delete?id=` + id }) |
||||
|
} |
||||
|
|
||||
|
// 导出要货预测周期 Excel
|
||||
|
export const exportSupplierCycle = async (params) => { |
||||
|
return await request.download({ url: `/wms/supplier-cycle/export-excel`, params }) |
||||
|
} |
||||
|
|
||||
|
// 下载用户导入模板
|
||||
|
export const importTemplate = () => { |
||||
|
return request.download({ url: '/wms/supplier-cycle/get-import-template' }) |
||||
|
} |
@ -0,0 +1,276 @@ |
|||||
|
<template> |
||||
|
<ContentWrap> |
||||
|
<!-- 搜索工作栏 --> |
||||
|
<Search :schema="SupplierCycle.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" /> |
||||
|
</ContentWrap> |
||||
|
|
||||
|
<!-- 列表头部 --> |
||||
|
<TableHead |
||||
|
:HeadButttondata="HeadButttondata" |
||||
|
@button-base-click="buttonBaseClick" |
||||
|
:routeName="routeName" |
||||
|
@updataTableColumns="updataTableColumns" |
||||
|
@searchFormClick="searchFormClick" |
||||
|
:allSchemas="SupplierCycle.allSchemas" |
||||
|
/> |
||||
|
|
||||
|
<!-- 列表 --> |
||||
|
<ContentWrap> |
||||
|
<Table |
||||
|
: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 #monday="{row}"> |
||||
|
<Icon :size="16" v-show="row.monday==1" icon="ep:check" /> |
||||
|
</template> |
||||
|
<template #tuesday="{row}"> |
||||
|
<Icon :size="16" v-show="row.tuesday==1" icon="ep:check" /> |
||||
|
</template> |
||||
|
<template #wednesday="{row}"> |
||||
|
<Icon :size="16" v-show="row.wednesday==1" icon="ep:check" /> |
||||
|
</template> |
||||
|
<template #thursday="{row}"> |
||||
|
<Icon :size="16" v-show="row.thursday==1" icon="ep:check" /> |
||||
|
</template> |
||||
|
<template #friday="{row}"> |
||||
|
<Icon :size="16" v-show="row.friday==1" icon="ep:check" /> |
||||
|
</template> |
||||
|
<template #saturday="{row}"> |
||||
|
<Icon :size="16" v-show="row.saturday==1" icon="ep:check" /> |
||||
|
</template> |
||||
|
<template #sunday="{row}"> |
||||
|
<Icon :size="16" v-show="row.sunday==1" icon="ep:check" /> |
||||
|
</template> |
||||
|
<template #action="{ row }"> |
||||
|
<ButtonBase :Butttondata="butttondata" @button-base-click="buttonTableClick($event,row)" /> |
||||
|
</template> |
||||
|
</Table> |
||||
|
</ContentWrap> |
||||
|
|
||||
|
<!-- 表单弹窗:添加/修改 --> |
||||
|
<BasicForm |
||||
|
ref="basicFormRef" |
||||
|
@success="formsSuccess" |
||||
|
:rules="SupplierCycleRules" |
||||
|
:formAllSchemas="SupplierCycle.allSchemas" |
||||
|
:apiUpdate="SupplierCycleApi.updateSupplierCycle" |
||||
|
:apiCreate="SupplierCycleApi.createSupplierCycle" |
||||
|
@searchTableSuccess="searchTableSuccess" |
||||
|
:isBusiness="false" |
||||
|
/> |
||||
|
<!-- 详情 --> |
||||
|
<Detail ref="detailRef" :isBasic="true" :allSchemas="SupplierCycle.allSchemas" /> |
||||
|
|
||||
|
<!-- 导入 --> |
||||
|
<ImportForm ref="importFormRef" url="/wms/supplier-cycle/import" :importTemplateData="importTemplateData" @success="importSuccess" /> |
||||
|
</template> |
||||
|
|
||||
|
<script setup lang="ts"> |
||||
|
import download from '@/utils/download' |
||||
|
import { SupplierCycle,SupplierCycleRules } from './supplierCycle.data' |
||||
|
import * as SupplierCycleApi from '@/api/wms/supplierCycle' |
||||
|
import * as defaultButtons from '@/utils/disposition/defaultButtons' |
||||
|
import TableHead from '@/components/TableHead/src/TableHead.vue' |
||||
|
import ImportForm from '@/components/ImportForm/src/ImportForm.vue' |
||||
|
import Detail from '@/components/Detail/src/Detail.vue' |
||||
|
// 要货预测周期管理 |
||||
|
defineOptions({ name: 'SupplierCycle' }) |
||||
|
|
||||
|
const message = useMessage() // 消息弹窗 |
||||
|
const { t } = useI18n() // 国际化 |
||||
|
|
||||
|
const route = useRoute() // 路由信息 |
||||
|
const routeName = ref() |
||||
|
routeName.value = route.name |
||||
|
const tableColumns = ref(SupplierCycle.allSchemas.tableColumns) |
||||
|
|
||||
|
// 查询页面返回 |
||||
|
const searchTableSuccess = (formField, searchField, val, formRef) => { |
||||
|
nextTick(() => { |
||||
|
const setV = {} |
||||
|
setV[formField] = val[0][searchField] |
||||
|
formRef.setValues(setV) |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
// 字段设置 更新主列表字段 |
||||
|
const updataTableColumns = (val) => { |
||||
|
tableColumns.value = val |
||||
|
} |
||||
|
|
||||
|
const { tableObject, tableMethods } = useTable({ |
||||
|
getListApi: SupplierCycleApi.getSupplierCyclePage // 分页接口 |
||||
|
}) |
||||
|
|
||||
|
// 获得表格的各种操作 |
||||
|
const { getList, setSearchParams } = tableMethods |
||||
|
|
||||
|
// 列表头部按钮 |
||||
|
const HeadButttondata = [ |
||||
|
defaultButtons.defaultAddBtn({hasPermi:'wms:supplier-cycle:create'}), // 新增 |
||||
|
defaultButtons.defaultImportBtn({hasPermi:'wms:supplier-cycle:import'}), // 导入 |
||||
|
defaultButtons.defaultExportBtn({hasPermi:'wms:supplier-cycle:export'}), // 导出 |
||||
|
// defaultButtons.defaultFreshBtn(null), // 刷新 |
||||
|
// defaultButtons.defaultFilterBtn(null), // 筛选 |
||||
|
// defaultButtons.defaultSetBtn(null), // 设置 |
||||
|
// { |
||||
|
// label: '自定义扩展按钮', |
||||
|
// name: 'zdy', |
||||
|
// hide: false, |
||||
|
// type: 'primary', |
||||
|
// icon: 'Select', |
||||
|
// color: '' |
||||
|
// }, |
||||
|
] |
||||
|
|
||||
|
// 头部按钮事件 |
||||
|
const buttonBaseClick = (val, item) => { |
||||
|
if (val == 'add') { // 新增 |
||||
|
openForm('create') |
||||
|
} else if (val == 'import') { // 导入 |
||||
|
handleImport() |
||||
|
} else if (val == 'export') { // 导出 |
||||
|
handleExport() |
||||
|
} else if (val == 'refresh') { // 刷新 |
||||
|
getList() |
||||
|
} else if (val == 'filtrate') { // 筛选 |
||||
|
} else { // 其他按钮 |
||||
|
console.log('其他按钮', item) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 列表-操作按钮 |
||||
|
const butttondata = [ |
||||
|
defaultButtons.mainListEditBtn({hasPermi:'wms:supplier-cycle:update'}), // 编辑 |
||||
|
defaultButtons.mainListDeleteBtn({hasPermi:'wms:supplier-cycle:delete'}), // 删除 |
||||
|
] |
||||
|
|
||||
|
// 列表-操作按钮事件 |
||||
|
const buttonTableClick = async (val, row) => { |
||||
|
if (val == 'edit') { // 编辑 |
||||
|
openForm('update', row) |
||||
|
} else if (val == 'delete') { // 删除 |
||||
|
handleDelete(row.id) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** 添加/修改操作 */ |
||||
|
const basicFormRef = ref() |
||||
|
const openForm = (type: string, row?: any) => { |
||||
|
if('update'==type){ |
||||
|
let cycle = [] |
||||
|
let week = ['monday','tuesday','wednesday','thursday','friday','saturday','sunday'] |
||||
|
week.forEach(item=>{ |
||||
|
if(row[item]==1){ |
||||
|
cycle.push(item) |
||||
|
} |
||||
|
}) |
||||
|
row.cycle = cycle |
||||
|
} |
||||
|
basicFormRef.value.open(type, row) |
||||
|
} |
||||
|
|
||||
|
// form表单提交 |
||||
|
const formsSuccess = async (formType,submitData) => { |
||||
|
let data = {...submitData} |
||||
|
let cycle = data.cycle |
||||
|
cycle.forEach(item=>{ |
||||
|
data[item] = 1 |
||||
|
}) |
||||
|
delete data.cycle |
||||
|
console.log('formsSuccess',formType,data) |
||||
|
var isHave =SupplierCycle.allSchemas.formSchema.some(function (item) { |
||||
|
return item.field === 'activeTime' || item.field === 'expireTime'; |
||||
|
}); |
||||
|
if(isHave){ |
||||
|
if(data.activeTime && data.expireTime && data.activeTime >=data.expireTime){ |
||||
|
message.error('失效时间要大于生效时间') |
||||
|
return; |
||||
|
} |
||||
|
} |
||||
|
if(data.activeTime==0)data.activeTime = null; |
||||
|
if(data.expireTime==0)data.expireTime = null; |
||||
|
if (formType === 'create') { |
||||
|
await SupplierCycleApi.createSupplierCycle(data) |
||||
|
message.success(t('common.createSuccess')) |
||||
|
} else { |
||||
|
await SupplierCycleApi.updateSupplierCycle(data) |
||||
|
message.success(t('common.updateSuccess')) |
||||
|
} |
||||
|
basicFormRef.value.dialogVisible = false |
||||
|
getList() |
||||
|
} |
||||
|
|
||||
|
/** 详情操作 */ |
||||
|
const detailRef = ref() |
||||
|
const openDetail = (row: any, titleName: any, titleValue: any) => { |
||||
|
detailRef.value.openDetail(row, titleName, titleValue, 'basicSupplierCycle') |
||||
|
} |
||||
|
|
||||
|
/** 删除按钮操作 */ |
||||
|
const handleDelete = async (id: number) => { |
||||
|
try { |
||||
|
// 删除的二次确认 |
||||
|
await message.delConfirm() |
||||
|
// 发起删除 |
||||
|
await SupplierCycleApi.deleteSupplierCycle(id) |
||||
|
message.success(t('common.delSuccess')) |
||||
|
// 刷新列表 |
||||
|
await getList() |
||||
|
} catch {} |
||||
|
} |
||||
|
|
||||
|
/** 导出按钮操作 */ |
||||
|
const exportLoading = ref(false) // 导出的加载中 |
||||
|
const handleExport = async () => { |
||||
|
try { |
||||
|
// 导出的二次确认 |
||||
|
await message.exportConfirm() |
||||
|
// 发起导出 |
||||
|
exportLoading.value = true |
||||
|
const data = await SupplierCycleApi.exportSupplierCycle(tableObject.params) |
||||
|
download.excel(data, '要货预测周期.xlsx') |
||||
|
} catch { |
||||
|
} finally { |
||||
|
exportLoading.value = false |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** 导入 */ |
||||
|
const importFormRef = ref() |
||||
|
const handleImport = () => { |
||||
|
importFormRef.value.open() |
||||
|
} |
||||
|
// 导入附件弹窗所需的参数 |
||||
|
const importTemplateData = reactive({ |
||||
|
templateUrl: '', |
||||
|
templateTitle: '要货预测周期导入模版.xlsx' |
||||
|
}) |
||||
|
// 导入成功之后 |
||||
|
const importSuccess = () => { |
||||
|
getList() |
||||
|
} |
||||
|
|
||||
|
// 筛选提交 |
||||
|
const searchFormClick = (searchData) => { |
||||
|
tableObject.params = { |
||||
|
isSearch: true, |
||||
|
filters: searchData.filters |
||||
|
} |
||||
|
getList() // 刷新当前列表 |
||||
|
} |
||||
|
|
||||
|
/** 初始化 **/ |
||||
|
onMounted(async () => { |
||||
|
getList() |
||||
|
importTemplateData.templateUrl = await SupplierCycleApi.importTemplate() |
||||
|
}) |
||||
|
|
||||
|
</script> |
@ -0,0 +1,160 @@ |
|||||
|
import type { CrudSchema } from '@/hooks/web/useCrudSchemas' |
||||
|
import { dateFormatter } from '@/utils/formatTime' |
||||
|
import * as SupplierApi from '@/api/wms/supplier' |
||||
|
import { Supplier } from '@/views/wms/basicDataManage/supplierManage/supplier/supplier.data' |
||||
|
// 表单校验
|
||||
|
|
||||
|
|
||||
|
export const SupplierCycle = useCrudSchemas(reactive<CrudSchema[]>([ |
||||
|
{ |
||||
|
label: 'id', |
||||
|
field: 'id', |
||||
|
sort: 'custom', |
||||
|
isForm: false, |
||||
|
isTable:false, |
||||
|
}, |
||||
|
{ |
||||
|
label: '供应商代码', |
||||
|
field: 'supplierCode', |
||||
|
sort: 'custom', |
||||
|
isSearch: true, |
||||
|
form: { |
||||
|
componentProps: { |
||||
|
enterSearch:true, |
||||
|
isSearchList: true, // 开启查询弹窗
|
||||
|
searchListPlaceholder: '请选择供应商代码', // 输入框占位文本
|
||||
|
searchField: 'code', // 查询弹窗赋值字段
|
||||
|
searchTitle: '供应商信息', // 查询弹窗标题
|
||||
|
searchAllSchemas: Supplier.allSchemas, // 查询弹窗所需类
|
||||
|
searchPage: SupplierApi.getSupplierPageSCP, // 查询弹窗所需分页方法
|
||||
|
searchCondition: [{ |
||||
|
key: 'available', |
||||
|
value: 'TRUE', |
||||
|
isMainValue: false |
||||
|
}] |
||||
|
} |
||||
|
}, |
||||
|
search: { |
||||
|
componentProps: { |
||||
|
enterSearch:true, |
||||
|
isSearchList: true, // 开启查询弹窗
|
||||
|
searchListPlaceholder: '请选择供应商代码', // 输入框占位文本
|
||||
|
searchField: 'code', // 查询弹窗赋值字段
|
||||
|
searchTitle: '供应商信息', // 查询弹窗标题
|
||||
|
searchAllSchemas: Supplier.allSchemas, // 查询弹窗所需类
|
||||
|
searchPage: SupplierApi.getSupplierPageSCP, // 查询弹窗所需分页方法
|
||||
|
searchCondition: [{ |
||||
|
key: 'available', |
||||
|
value: 'TRUE', |
||||
|
isMainValue: false |
||||
|
}] |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
label: '星期一', |
||||
|
field: 'monday', |
||||
|
sort: 'custom', |
||||
|
isForm:false, |
||||
|
|
||||
|
}, |
||||
|
{ |
||||
|
label: '星期二', |
||||
|
field: 'tuesday', |
||||
|
sort: 'custom', |
||||
|
isForm:false, |
||||
|
|
||||
|
}, |
||||
|
{ |
||||
|
label: '星期三', |
||||
|
field: 'wednesday', |
||||
|
sort: 'custom', |
||||
|
isForm:false, |
||||
|
|
||||
|
}, |
||||
|
{ |
||||
|
label: '星期四', |
||||
|
field: 'thursday', |
||||
|
sort: 'custom', |
||||
|
isForm:false, |
||||
|
|
||||
|
}, |
||||
|
{ |
||||
|
label: '星期五', |
||||
|
field: 'friday', |
||||
|
sort: 'custom', |
||||
|
isForm:false, |
||||
|
|
||||
|
}, |
||||
|
{ |
||||
|
label: '星期六', |
||||
|
field: 'saturday', |
||||
|
sort: 'custom', |
||||
|
isForm:false, |
||||
|
|
||||
|
}, |
||||
|
{ |
||||
|
label: '星期日', |
||||
|
field: 'sunday', |
||||
|
sort: 'custom', |
||||
|
isForm:false, |
||||
|
|
||||
|
}, |
||||
|
{ |
||||
|
label: '是否可用', |
||||
|
field: 'available', |
||||
|
dictType: DICT_TYPE.TRUE_FALSE, |
||||
|
dictClass: 'string', |
||||
|
isTable: true, |
||||
|
isSearch: false, |
||||
|
sort: 'custom', |
||||
|
table: { |
||||
|
width: 150 |
||||
|
}, |
||||
|
form: { |
||||
|
component: 'Switch', |
||||
|
value: 'TRUE', |
||||
|
componentProps: { |
||||
|
inactiveValue: 'FALSE', |
||||
|
activeValue: 'TRUE' |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
label: '同步周期', |
||||
|
field: 'cycle', |
||||
|
isForm:true, |
||||
|
isDetail: false, |
||||
|
sort: 'custom', |
||||
|
isTable:false, |
||||
|
form: { |
||||
|
value:[], |
||||
|
component:'Checkbox', |
||||
|
componentProps: { |
||||
|
options: [ |
||||
|
{label:'星期一',value:'monday'}, |
||||
|
{label:'星期二',value:'tuesday'}, |
||||
|
{label:'星期三',value:'wednesday'}, |
||||
|
{label:'星期四',value:'thursday'}, |
||||
|
{label:'星期五',value:'friday'}, |
||||
|
{label:'星期六',value:'saturday'}, |
||||
|
{label:'星期日',value:'sunday'} |
||||
|
] |
||||
|
}, |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
label: '操作', |
||||
|
field: 'action', |
||||
|
isForm: false, |
||||
|
table: { |
||||
|
width: 150, |
||||
|
fixed: 'right' |
||||
|
} |
||||
|
} |
||||
|
])) |
||||
|
export const SupplierCycleRules = reactive({ |
||||
|
supplierCode: [ |
||||
|
{ required: true, message: '供应商代码不能为空', trigger: 'blur' }, |
||||
|
], |
||||
|
}) |
@ -0,0 +1,399 @@ |
|||||
|
import type { CrudSchema } from '@/hooks/web/useCrudSchemas' |
||||
|
import { dateFormatter,dateFormatter2 } from '@/utils/formatTime' |
||||
|
import * as SupplierApi from '@/api/wms/supplier' |
||||
|
import { Supplier} from '@/views/wms/basicDataManage/supplierManage/supplier/supplier.data' |
||||
|
import * as SupplieritemApi from '@/api/wms/supplieritem' |
||||
|
import { Supplieritem } from '@/views/wms/basicDataManage/supplierManage/supplieritem/supplieritem.data' |
||||
|
import * as ItembasicApi from '@/api/wms/itembasic' |
||||
|
import {Itembasic} from "@/views/wms/basicDataManage/itemManage/itembasic/itembasic.data"; |
||||
|
import * as PurchaseMainApi from '@/api/wms/purchaseMain' |
||||
|
import * as PurchaseDetailApi from '@/api/wms/purchaseDetail' |
||||
|
import { PurchaseDetail, PurchaseMain } from '../purchaseMain/purchaseMain.data' |
||||
|
import * as DemandforecastingMainApi from '@/api/wms/demandforecastingMain' |
||||
|
import * as DemandforecastingDetailApi from '@/api/wms/demandforecastingDetail' |
||||
|
import dayjs from 'dayjs' |
||||
|
|
||||
|
const { t } = useI18n() // 国际化
|
||||
|
|
||||
|
/** |
||||
|
* @returns {Array} 要货预测主表 |
||||
|
*/ |
||||
|
Supplieritem.allSchemas.searchSchema = Supplieritem.allSchemas.searchSchema.filter(item=>item.field!="allowOverShipment") |
||||
|
export const Version = useCrudSchemas(reactive<CrudSchema[]>([ |
||||
|
{ |
||||
|
label: '供应商代码', |
||||
|
field: 'supplerCodes', |
||||
|
sort: 'custom', |
||||
|
isSearch:true, |
||||
|
}, |
||||
|
{ |
||||
|
label: '订单号', |
||||
|
field: 'poNumber', |
||||
|
sort: 'custom', |
||||
|
isSearch:true, |
||||
|
}, |
||||
|
{ |
||||
|
label: '订单行', |
||||
|
field: 'poLine', |
||||
|
sort: 'custom', |
||||
|
}, |
||||
|
{ |
||||
|
label: '物料代码', |
||||
|
field: 'itemCode', |
||||
|
isSearch:true, |
||||
|
sort: 'custom', |
||||
|
}, |
||||
|
{ |
||||
|
label: '子表版本', |
||||
|
field: 'detailVersion', |
||||
|
sort: 'custom', |
||||
|
} |
||||
|
])) |
||||
|
export const DemandforecastingMain = useCrudSchemas(reactive<CrudSchema[]>([ |
||||
|
{ |
||||
|
label: '是否已读', |
||||
|
field: 'isRead', |
||||
|
sort: 'custom', |
||||
|
table: { |
||||
|
width: 150 |
||||
|
}, |
||||
|
}, |
||||
|
{ |
||||
|
label: '订单号', |
||||
|
field: 'poNumber', |
||||
|
sort: 'custom', |
||||
|
table: { |
||||
|
width: 150 |
||||
|
}, |
||||
|
}, |
||||
|
{ |
||||
|
label: '订单行', |
||||
|
field: 'poLine', |
||||
|
sort: 'custom', |
||||
|
table: { |
||||
|
width: 150 |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
label: '物料代码', |
||||
|
field: 'itemCode', |
||||
|
sort: 'custom', |
||||
|
table: { |
||||
|
width: 150 |
||||
|
}, |
||||
|
isSearch:true, |
||||
|
isTable:true, |
||||
|
isForm: false, |
||||
|
search: { |
||||
|
// labelMessage: '信息提示说明!!!',
|
||||
|
componentProps: { |
||||
|
multiple: true, |
||||
|
enterSearch: true, |
||||
|
isSearchList: true, // 开启查询弹窗
|
||||
|
searchListPlaceholder: '请选择物料代码', // 输入框占位文本
|
||||
|
searchField: 'itemCode', // 查询弹窗赋值字段
|
||||
|
searchTitle: '物料基础信息', // 查询弹窗标题
|
||||
|
searchAllSchemas: Supplieritem.allSchemas, // 查询弹窗所需类
|
||||
|
searchPage: SupplieritemApi.getSupplieritemPageSCP, // 查询弹窗所需分页方法
|
||||
|
searchCondition: [{ |
||||
|
key: 'supplierCodes', |
||||
|
value: 'supplierCode', |
||||
|
message: '请填写供应商代码!', |
||||
|
isMainValue: true, |
||||
|
isCSV:true,//是否用逗号分隔参数
|
||||
|
},{ |
||||
|
key: 'available', |
||||
|
value: 'TRUE', |
||||
|
isMainValue: false |
||||
|
}] |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
label: '版本号', |
||||
|
field: 'version', |
||||
|
sort: 'custom', |
||||
|
table: { |
||||
|
width: 150 |
||||
|
}, |
||||
|
isSearch:true, |
||||
|
search: { |
||||
|
// labelMessage: '信息提示说明!!!',
|
||||
|
componentProps: { |
||||
|
multiple: true, |
||||
|
enterSearch: true, |
||||
|
isSearchList: true, // 开启查询弹窗
|
||||
|
searchListPlaceholder: '请选择版本号', // 输入框占位文本
|
||||
|
searchField: 'detailVersion', // 查询弹窗赋值字段
|
||||
|
searchTitle: '版本号', // 查询弹窗标题
|
||||
|
searchAllSchemas: Version.allSchemas, // 查询弹窗所需类
|
||||
|
searchPage: DemandforecastingDetailApi.queryVersion, // 查询弹窗所需分页方法
|
||||
|
searchCondition: [{ |
||||
|
key: 'supplierCodes', |
||||
|
value: 'supplierCode', |
||||
|
message: '请填写供应商代码!', |
||||
|
isMainValue: true, |
||||
|
isCSV:true,//是否用逗号分隔参数
|
||||
|
},{ |
||||
|
key: 'itemCodes', |
||||
|
value: 'itemCode', |
||||
|
message: '请填写物料代码!', |
||||
|
isMainValue: true, |
||||
|
isCSV:true,//是否用逗号分隔参数
|
||||
|
},{ |
||||
|
key: 'available', |
||||
|
value: 'TRUE', |
||||
|
isMainValue: false |
||||
|
}] |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
label: '到货日期', |
||||
|
field: 'dueDate', |
||||
|
formatter: dateFormatter, |
||||
|
sort: 'custom', |
||||
|
table: { |
||||
|
width: 150 |
||||
|
}, |
||||
|
isSearch:true, |
||||
|
isTable:false, |
||||
|
isForm: false, |
||||
|
search: { |
||||
|
value: [dayjs(), dayjs().subtract(-3,'month')], |
||||
|
component: 'DatePicker', |
||||
|
componentProps: { |
||||
|
valueFormat: 'YYYY-MM-DD', |
||||
|
type: 'daterange', |
||||
|
defaultTime: [new Date('1 '), new Date('1 ')] |
||||
|
} |
||||
|
}, |
||||
|
} |
||||
|
])) |
||||
|
|
||||
|
//表单校验
|
||||
|
export const DemandforecastingMainRules = reactive({ |
||||
|
available: [ |
||||
|
{ required: true, message: '请选择是否可用', trigger: 'change' } |
||||
|
], |
||||
|
supplierCode: [ |
||||
|
{ required: true, message: '请选择供应商代码', trigger: 'change' } |
||||
|
], |
||||
|
version: [ |
||||
|
{ max: 50, message: '不得超过50个字符', trigger: 'blur' } |
||||
|
], |
||||
|
remark: [ |
||||
|
{ max: 50, message: '不得超过50个字符', trigger: 'blur' } |
||||
|
], |
||||
|
}) |
||||
|
|
||||
|
/** |
||||
|
* @returns {Array} 要货预测子表 |
||||
|
*/ |
||||
|
export const DemandforecastingDetail = useCrudSchemas(reactive<CrudSchema[]>([ |
||||
|
{ |
||||
|
label: '单据号', |
||||
|
field: 'number', |
||||
|
sort: 'custom', |
||||
|
table: { |
||||
|
width: 180 |
||||
|
}, |
||||
|
isTableForm: false, |
||||
|
hiddenInMain:true, |
||||
|
form: { |
||||
|
componentProps: { |
||||
|
disbaled: true |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
label: '预测时间类型', |
||||
|
field: 'predictTimeType', |
||||
|
dictType: DICT_TYPE.PREDICT_TIME_TYPE, |
||||
|
sort: 'custom', |
||||
|
dictClass: 'string', |
||||
|
isTable: false, |
||||
|
table: { |
||||
|
width: 150 |
||||
|
}, |
||||
|
tableForm: { |
||||
|
type: 'Select' |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
label: '预测日期', |
||||
|
field: 'predictTime', |
||||
|
formatter: dateFormatter2, |
||||
|
detail: { |
||||
|
dateFormat: 'YYYY-MM-DD' |
||||
|
}, |
||||
|
sort: 'custom', |
||||
|
table: { |
||||
|
width: 180 |
||||
|
}, |
||||
|
isTable:false, |
||||
|
form: { |
||||
|
component: 'DatePicker', |
||||
|
componentProps: { |
||||
|
style: {width: '100%'}, |
||||
|
type: 'date', |
||||
|
dateFormat: 'YYYY-MM-DD', |
||||
|
valueFormat: 'x', |
||||
|
} |
||||
|
}, |
||||
|
tableForm: { |
||||
|
type: 'FormDate', |
||||
|
dateFormat: 'YYYY-MM-DD', |
||||
|
valueFormat: 'x', |
||||
|
} |
||||
|
}, |
||||
|
|
||||
|
{ |
||||
|
label: '计量单位', |
||||
|
field: 'uom', |
||||
|
sort: 'custom', |
||||
|
dictType: DICT_TYPE.UOM, |
||||
|
dictClass: 'string', |
||||
|
isTable: true, |
||||
|
table: { |
||||
|
width: 150 |
||||
|
}, |
||||
|
tableForm: { |
||||
|
type: 'Select', |
||||
|
disabled: true |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
label: '计划数量', |
||||
|
field: 'planQty', |
||||
|
sort: 'custom', |
||||
|
table: { |
||||
|
width: 150 |
||||
|
}, |
||||
|
form: { |
||||
|
component: 'InputNumber', |
||||
|
componentProps: { |
||||
|
min: 1, |
||||
|
precision: 6 |
||||
|
} |
||||
|
}, |
||||
|
tableForm: { |
||||
|
type: 'InputNumber', |
||||
|
min: 1, |
||||
|
precision: 6 |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
label: '备注', |
||||
|
field: 'remark', |
||||
|
sort: 'custom', |
||||
|
table: { |
||||
|
width: 150 |
||||
|
}, |
||||
|
}, |
||||
|
{ |
||||
|
label: '创建时间', |
||||
|
field: 'createTime', |
||||
|
formatter: dateFormatter, |
||||
|
detail: { |
||||
|
dateFormat: 'YYYY-MM-DD HH:mm:ss' |
||||
|
}, |
||||
|
sort: 'custom', |
||||
|
table: { |
||||
|
width: 180 |
||||
|
}, |
||||
|
form: { |
||||
|
component: 'DatePicker', |
||||
|
componentProps: { |
||||
|
style: { width: '100%' }, |
||||
|
type: 'datetime', |
||||
|
dateFormat: 'YYYY-MM-DD HH:mm:ss', |
||||
|
valueFormat: 'x', |
||||
|
} |
||||
|
}, |
||||
|
isTableForm: false, |
||||
|
isForm: false, |
||||
|
}, |
||||
|
{ |
||||
|
label: '创建者', |
||||
|
field: 'creator', |
||||
|
sort: 'custom', |
||||
|
table: { |
||||
|
width: 150 |
||||
|
}, |
||||
|
isTableForm: false, |
||||
|
isForm: false, |
||||
|
}, |
||||
|
{ |
||||
|
label: '最后更新时间', |
||||
|
field: 'updateTime', |
||||
|
formatter: dateFormatter, |
||||
|
detail: { |
||||
|
dateFormat: 'YYYY-MM-DD HH:mm:ss' |
||||
|
}, |
||||
|
sort: 'custom', |
||||
|
table: { |
||||
|
width: 180 |
||||
|
}, |
||||
|
form: { |
||||
|
component: 'DatePicker', |
||||
|
componentProps: { |
||||
|
style: { width: '100%' }, |
||||
|
type: 'datetime', |
||||
|
dateFormat: 'YYYY-MM-DD HH:mm:ss', |
||||
|
valueFormat: 'x', |
||||
|
} |
||||
|
}, |
||||
|
isTableForm: false, |
||||
|
isForm: false, |
||||
|
}, |
||||
|
{ |
||||
|
label: '最后更新者', |
||||
|
field: 'updater', |
||||
|
sort: 'custom', |
||||
|
table: { |
||||
|
width: 150 |
||||
|
}, |
||||
|
isTableForm: false, |
||||
|
isForm: false, |
||||
|
}, |
||||
|
{ |
||||
|
label: '操作', |
||||
|
hiddenInMain:true, |
||||
|
field: 'action', |
||||
|
isDetail: false, |
||||
|
isForm: false, |
||||
|
table: { |
||||
|
width: 150, |
||||
|
fixed: 'right' |
||||
|
}, |
||||
|
isTableForm: false, |
||||
|
} |
||||
|
])) |
||||
|
|
||||
|
//表单校验
|
||||
|
export const DemandforecastingDetailRules = reactive({ |
||||
|
predictTimeType: [ |
||||
|
{ required: true, message: '请选择预测时间类型', trigger: 'change' }, |
||||
|
{ max: 50, message: '不得超过50个字符', trigger: 'blur' } |
||||
|
], |
||||
|
predictTime: [ |
||||
|
{ required: true, message: '请输入预测时间', trigger: 'change' } |
||||
|
], |
||||
|
planQty: [ |
||||
|
{ required: true, message: '请输入计划数量', trigger: 'blur' } |
||||
|
], |
||||
|
uom: [ |
||||
|
{ required: true, message: '请选择计量单位', trigger: 'change' } |
||||
|
], |
||||
|
number: [ |
||||
|
{ required: true, message: '请输入单据号', trigger: 'blur' } |
||||
|
], |
||||
|
itemCode: [ |
||||
|
{ required: true, message: '请选择物料代码', trigger: 'change' } |
||||
|
], |
||||
|
remark: [ |
||||
|
{ max: 50, message: '不得超过50个字符', trigger: 'blur' } |
||||
|
], |
||||
|
poLine: [{required:true, message: '请选择订单行', trigger: 'blur'}] |
||||
|
}) |
@ -0,0 +1,285 @@ |
|||||
|
<template> |
||||
|
<ContentWrap> |
||||
|
<!-- 搜索工作栏 --> |
||||
|
<Search :showSearchTableQueryFields="['supplierCode','itemCode','version']" :hiddenFilterBtnFields="['supplierCode','itemCode','version']" :schema="DemandforecastingMain.allSchemas.searchSchema" @search="searchClick" @reset="searchClick" @searchTableSuccess="searchQueryTableSuccess"/> |
||||
|
</ContentWrap> |
||||
|
|
||||
|
<!-- 列表头部 --> |
||||
|
<TableHead |
||||
|
:HeadButttondata="HeadButttondata" |
||||
|
@button-base-click="buttonBaseClick" |
||||
|
:routeName="routeName" |
||||
|
@updataTableColumns="updataTableColumns" |
||||
|
@searchFormClick="searchFormClick" |
||||
|
:allSchemas="DemandforecastingMain.allSchemas" |
||||
|
/> |
||||
|
|
||||
|
<!-- 列表 --> |
||||
|
<ContentWrap> |
||||
|
<Table ref="tableRef" v-clientTable |
||||
|
:selection="true" |
||||
|
: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" |
||||
|
@getSelectionRows="getSelectionRows" |
||||
|
> |
||||
|
<template #isRead="{row}" > |
||||
|
<el-button v-show="row.isRead!=2" :type="row.isRead==1?'info':'primary'" link @click="readHandle(row,false)"> |
||||
|
<span>{{ row.isRead==1?'已读':'未读' }}</span> |
||||
|
</el-button> |
||||
|
</template> |
||||
|
<template v-for="name in tableObjectHead.tableList" :key="name" #[name]="{row}"> |
||||
|
<span :class="{'success-text':row['planType_F'].indexOf(name)>-1}">{{ row[name] }}</span> |
||||
|
</template> |
||||
|
</Table> |
||||
|
</ContentWrap> |
||||
|
|
||||
|
|
||||
|
</template> |
||||
|
|
||||
|
<script setup lang="ts"> |
||||
|
import download from '@/utils/download' |
||||
|
import { DemandforecastingMain,DemandforecastingMainRules,DemandforecastingDetail,DemandforecastingDetailRules } from './demandforecastingMain.data' |
||||
|
import * as DemandforecastingMainApi from '@/api/wms/demandforecastingMain' |
||||
|
import * as DemandforecastingDetailApi from '@/api/wms/demandforecastingDetail' |
||||
|
import * as defaultButtons from '@/utils/disposition/defaultButtons' |
||||
|
|
||||
|
// 要货预测 |
||||
|
defineOptions({ name: 'DemandforecastingMain' }) |
||||
|
|
||||
|
const message = useMessage() // 消息弹窗 |
||||
|
const { t } = useI18n() // 国际化 |
||||
|
|
||||
|
const route = useRoute() // 路由信息 |
||||
|
const routeName = ref() |
||||
|
routeName.value = route.name |
||||
|
const orginTableColumns = ref(DemandforecastingMain.allSchemas.tableColumns) |
||||
|
const tableColumns = ref(DemandforecastingMain.allSchemas.tableColumns) |
||||
|
// 字段设置 更新主列表字段 |
||||
|
const updataTableColumns = (val) => { |
||||
|
orginTableColumns.value = val |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
// 查询页面返回 |
||||
|
const searchQueryTableSuccess = (formField, searchField, val, formRef, type, row ) => { |
||||
|
console.log('searchQueryTableSuccess',formField, searchField, val, formRef, type, row ) |
||||
|
nextTick(() => { |
||||
|
const setV = {} |
||||
|
if(formField == 'supplierCode'||formField == 'itemCode'||formField == 'version'){ |
||||
|
//供应商代码 物料代码 版本号 |
||||
|
let list = [] |
||||
|
val.forEach(item=>{ |
||||
|
list.push(item[searchField]) |
||||
|
}) |
||||
|
setV[formField] = list.join(' ') |
||||
|
formRef.setValues(setV) |
||||
|
}else{ |
||||
|
setV[formField] = val[0][searchField] |
||||
|
formRef.setValues(setV) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
|
||||
|
const { tableObject:tableObjectHead, tableMethods:tableMethodsHead } = useTable({ |
||||
|
getListApi: DemandforecastingDetailApi.getPageTableHead // 分页接口 |
||||
|
}) |
||||
|
|
||||
|
// 获得表格的各种操作 |
||||
|
const { getList:getListHead, setSearchParams:setSearchParamsHead } = tableMethodsHead |
||||
|
|
||||
|
watch(()=>tableObjectHead.tableList,()=>{ |
||||
|
updateDateTableColumns() |
||||
|
},{deep:true}) |
||||
|
const updateDateTableColumns = ()=>{ |
||||
|
console.log('tableObjectHead',tableObjectHead) |
||||
|
let dateColumns = [] |
||||
|
if(tableObjectHead.tableList.length>10){ |
||||
|
tableObjectHead.tableList.forEach(item=>{ |
||||
|
dateColumns.push({ |
||||
|
width:120, |
||||
|
field: item, |
||||
|
label: item |
||||
|
}) |
||||
|
}) |
||||
|
}else{ |
||||
|
tableObjectHead.tableList.forEach(item=>{ |
||||
|
dateColumns.push({ |
||||
|
field: item, |
||||
|
label: item |
||||
|
}) |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
tableColumns.value = [...orginTableColumns.value,...dateColumns] |
||||
|
console.log('tableColumns',tableColumns.value) |
||||
|
} |
||||
|
const { tableObject, tableMethods } = useTable({ |
||||
|
getListApi: DemandforecastingDetailApi.getDemandforecastingDetailPage // 分页接口 |
||||
|
}) |
||||
|
|
||||
|
// 获得表格的各种操作 |
||||
|
const { getList, setSearchParams } = tableMethods |
||||
|
|
||||
|
// 列表头部按钮 |
||||
|
const HeadButttondata = [ |
||||
|
defaultButtons.defaultExportBtn({hasPermi:'wms:demandforecasting-main:export'}), // 导出 |
||||
|
defaultButtons.defaultFreshBtn(null), // 刷新 |
||||
|
// defaultButtons.defaultFilterBtn(null), // 筛选 |
||||
|
defaultButtons.defaultSetBtn(null), // 设置 |
||||
|
{ |
||||
|
label: t('ts.全部已读'), |
||||
|
name: 'read', |
||||
|
hide: false, |
||||
|
type: 'primary', |
||||
|
// icon: 'ep:operation', |
||||
|
color: '', |
||||
|
float:'left', |
||||
|
link: false, // 文本展现按钮 |
||||
|
hasPermi: '' |
||||
|
} |
||||
|
] |
||||
|
|
||||
|
// 头部按钮事件 |
||||
|
const buttonBaseClick = async (val, item) => { |
||||
|
if (val == 'export') { // 导出 |
||||
|
handleExport() |
||||
|
} else if (val == 'refresh') { // 刷新 |
||||
|
if (tableObject.params.filters && tableObject.params.filters.length > 0 ) { |
||||
|
searchFormClick({ |
||||
|
filters: tableObject.params.filters |
||||
|
}) |
||||
|
} else { |
||||
|
await getListHead() |
||||
|
// updateDateTableColumns() |
||||
|
getList() |
||||
|
|
||||
|
} |
||||
|
} else if (val == 'filtrate') { // 筛选 |
||||
|
} else if (val == 'read') { // 全部已读 |
||||
|
readHandle(null,true) |
||||
|
} else { // 其他按钮 |
||||
|
console.log('其他按钮', item) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
const searchClick = async (data)=>{ |
||||
|
console.log('searchClick',data) |
||||
|
await setSearchParamsHead(data) |
||||
|
// updateDateTableColumns() |
||||
|
setSearchParams(data) |
||||
|
} |
||||
|
/** 导出按钮操作 */ |
||||
|
const exportLoading = ref(false) // 导出的加载中 |
||||
|
const handleExport = async () => { |
||||
|
try { |
||||
|
// 导出的二次确认 |
||||
|
await message.exportConfirm() |
||||
|
// 发起导出 |
||||
|
exportLoading.value = true |
||||
|
const data = await DemandforecastingMainApi.exportDemandforecastingMain(tableObject.params) |
||||
|
download.excel(data, `${t('ts.要货预测主')}.xlsx`) |
||||
|
} catch { |
||||
|
} finally { |
||||
|
exportLoading.value = false |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
// 导入附件弹窗所需的参数 |
||||
|
const importTemplateData = reactive({ |
||||
|
templateUrl: '', |
||||
|
templateTitle: `${t('ts.要货预测主导入模版')}.xlsx` |
||||
|
}) |
||||
|
|
||||
|
// 筛选提交 |
||||
|
const searchFormClick = (searchData) => { |
||||
|
tableObject.params = { |
||||
|
isSearch: true, |
||||
|
filters: searchData.filters |
||||
|
} |
||||
|
getList() // 刷新当前列表 |
||||
|
} |
||||
|
|
||||
|
const selectionRows = ref<any>([]) |
||||
|
const tableRef = ref() |
||||
|
const getSelectionRows = (currentPage,currentPageSelectionRows) => { |
||||
|
console.log("getSelectionRows",currentPage,currentPageSelectionRows) |
||||
|
const currentRows = selectionRows.value.find(item=>item.currentPage==currentPage) |
||||
|
if(currentRows){ |
||||
|
currentRows.selectionRows = currentPageSelectionRows |
||||
|
}else{ |
||||
|
selectionRows.value.push({ |
||||
|
currentPage, |
||||
|
selectionRows:currentPageSelectionRows |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
const readHandle = (row,isAll)=>{ |
||||
|
let rows:any = [] |
||||
|
if(isAll){ |
||||
|
//全部已读 |
||||
|
if(selectionRows.value==0){ |
||||
|
return |
||||
|
} |
||||
|
selectionRows.value.forEach(item=>{ |
||||
|
let itemSelectionRows = item.selectionRows.filter(item1=>item1.isRead==0) |
||||
|
console.log('itemSelectionRows',itemSelectionRows) |
||||
|
rows = [...rows,...itemSelectionRows.map(item1=>item1.mainId)] |
||||
|
}) |
||||
|
console.log('selectionRows',selectionRows) |
||||
|
console.log('全部已读',rows.join(',')) |
||||
|
}else{ |
||||
|
//单行 |
||||
|
if(row.isRead==1){ |
||||
|
return |
||||
|
} |
||||
|
rows = [row.mainId] |
||||
|
console.log('已读',rows.join(',')) |
||||
|
} |
||||
|
|
||||
|
let getLoading = ElLoading.service({ |
||||
|
lock: true, |
||||
|
text: 'loading...', |
||||
|
background: 'rgba(0, 0, 0, 0.7)' |
||||
|
}) |
||||
|
DemandforecastingMainApi.updateIsRead({isReadMainIds:rows.join(',')}).then(res => { |
||||
|
console.log('res',res); |
||||
|
getLoading?.close() |
||||
|
getList() |
||||
|
if(isAll){ |
||||
|
selectionRows.value = [] |
||||
|
} |
||||
|
}).catch(err => { |
||||
|
console.log(err) |
||||
|
getLoading?.close() |
||||
|
}) |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/** 初始化 **/ |
||||
|
onMounted(async () => { |
||||
|
await getListHead() |
||||
|
// updateDateTableColumns() |
||||
|
getList() |
||||
|
importTemplateData.templateUrl = await DemandforecastingMainApi.importTemplate() |
||||
|
}) |
||||
|
</script> |
||||
|
<style lang="scss" scoped> |
||||
|
|
||||
|
.success-text{ |
||||
|
color:var(--el-color-success); |
||||
|
font-weight:700; |
||||
|
} |
||||
|
</style> |
File diff suppressed because it is too large
@ -0,0 +1,509 @@ |
|||||
|
<template> |
||||
|
<el-dialog v-model="dialogTableVisible" title="标签" width="1100"> |
||||
|
<el-table |
||||
|
:data="showTableData()" |
||||
|
border |
||||
|
row-key="id" |
||||
|
style="width: 1050px; max-height: 70vh; overflow-y: auto" |
||||
|
v-if="tableData.length > 0 && dialogTableVisible == true" |
||||
|
v-loading="isLoading" |
||||
|
> |
||||
|
<el-table-column type="expand" width="50"> |
||||
|
<template #default="scope"> |
||||
|
<div |
||||
|
style="margin-left: 400px; margin-top: -8px; margin-bottom: -8px" |
||||
|
v-if="scope.row.secondPackUnit && scope.row.secondPackQty" |
||||
|
> |
||||
|
<el-table |
||||
|
:data="scope.row.packageList" |
||||
|
border |
||||
|
style="width: 550px" |
||||
|
row-key="id" |
||||
|
:row-class-name="getRowClass" |
||||
|
> |
||||
|
<el-table-column type="expand" width="50"> |
||||
|
<template #default="scope1"> |
||||
|
<div style="margin-left: 150px; margin-top: -8px; margin-bottom: -8px"> |
||||
|
<el-table :data="scope1.row.children" border style="width: 300px" row-key="id"> |
||||
|
<el-table-column label="箱行号" width="100" prop="xPoNumber" align="center" /> |
||||
|
<el-table-column label="数量" width="100" prop="qtyTwo" align="center"> |
||||
|
<template #default="scope2"> |
||||
|
<el-input |
||||
|
v-model="scope2.row.qtyTwo" |
||||
|
@blur="blurTwo(scope.row, scope1.row, scope2.row)" |
||||
|
/> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
<el-table-column label="添加箱" width="100" prop="add" align="center"> |
||||
|
<template #header> |
||||
|
<el-button |
||||
|
type="primary" |
||||
|
link |
||||
|
@click="addX(scope.row, scope.$index, scope1.row, scope1.$index, 1)" |
||||
|
>添加箱</el-button |
||||
|
> |
||||
|
</template> |
||||
|
<template #default="scope2"> |
||||
|
<el-button |
||||
|
type="warning" |
||||
|
link |
||||
|
@click=" |
||||
|
removeX( |
||||
|
scope.row, |
||||
|
scope.$index, |
||||
|
scope1.row, |
||||
|
scope1.$index, |
||||
|
scope2.row, |
||||
|
scope2.$index, |
||||
|
1 |
||||
|
) |
||||
|
" |
||||
|
>移出</el-button |
||||
|
> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
</el-table> |
||||
|
</div> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
<el-table-column label="托行号" width="100" prop="tPoNumber" align="center" /> |
||||
|
<el-table-column label="箱个数" width="100" prop="xNumber" align="center"> |
||||
|
<template #default="scope1"> |
||||
|
<el-input v-model="scope1.row.xNumber" @blur="blurOne(scope.row, scope1.row)" /> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
<el-table-column label="数量" width="100" prop="qtyOne" align="center" /> |
||||
|
<el-table-column label="操作" width="100" prop="action" align="center"> |
||||
|
<template #default="scope1"> |
||||
|
<el-button |
||||
|
type="warning" |
||||
|
link |
||||
|
@click="removeT(scope.row, scope.$index, scope1.row, scope1.$index)" |
||||
|
>移出</el-button |
||||
|
> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
<el-table-column label="添加托" width="100" prop="add" align="center"> |
||||
|
<template #header> |
||||
|
<el-button type="primary" link @click="addT(scope.row)">添加托</el-button> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
</el-table> |
||||
|
</div> |
||||
|
<div style="margin-left: 550px; margin-top: -8px; margin-bottom: -8px" v-else> |
||||
|
<div v-for="(item, index) in scope.row.packageList" :key="index"> |
||||
|
<el-table :data="item.children" border style="width: 300px" row-key="id"> |
||||
|
<el-table-column label="箱行号" width="100" prop="xPoNumber" align="center" /> |
||||
|
<el-table-column label="数量" width="100" prop="qtyOne" align="center"> |
||||
|
<template #default="scope1"> |
||||
|
<el-input |
||||
|
v-model="scope1.row.qtyTwo" |
||||
|
@blur="blurThree(scope.row, item, scope1.row)" |
||||
|
/> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
<el-table-column label="添加箱" width="100" prop="add" align="center"> |
||||
|
<template #header> |
||||
|
<el-button |
||||
|
type="primary" |
||||
|
link |
||||
|
@click="addX(scope.row, scope.$index, item, index)" |
||||
|
>添加箱</el-button |
||||
|
> |
||||
|
</template> |
||||
|
<template #default="scope1"> |
||||
|
<el-button |
||||
|
type="warning" |
||||
|
link |
||||
|
@click="removeX(scope.row, scope.$index, item, index)" |
||||
|
>移出</el-button |
||||
|
> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
</el-table> |
||||
|
</div> |
||||
|
</div> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
<el-table-column label="物料代码" width="150" prop="itemCode" align="center" /> |
||||
|
<el-table-column label="批次" width="150" prop="batch" align="center" /> |
||||
|
<el-table-column label="数量" width="100" prop="qty" align="center" /> |
||||
|
<el-table-column label="计量单位" width="100" prop="uom" align="center" /> |
||||
|
<el-table-column label="托个数" width="100" prop="allTuoQty" align="center" /> |
||||
|
<el-table-column label="托规格" width="100" prop="secondPackUnit" align="center" /> |
||||
|
<el-table-column label="托数量" width="100" prop="secondPackQty" align="center" /> |
||||
|
<el-table-column label="箱规格" width="100" prop="packUnit" align="center" /> |
||||
|
<el-table-column label="箱数量" width="100" prop="packQty" align="center" /> |
||||
|
</el-table> |
||||
|
<el-pagination |
||||
|
v-show="tableData.length > 10" |
||||
|
style="margin-top: 10px" |
||||
|
v-model:current-page="currentPage" |
||||
|
v-model:page-size="pageSize" |
||||
|
:small="true" |
||||
|
:background="false" |
||||
|
layout="total, prev, pager, next, jumper" |
||||
|
:total="tableData.length" |
||||
|
/> |
||||
|
<template #footer> |
||||
|
<slot name="foorter"></slot> |
||||
|
<ButtonBase :Butttondata="Butttondata" @button-base-click="buttonBaseClick" /> |
||||
|
</template> |
||||
|
</el-dialog> |
||||
|
</template> |
||||
|
<script setup lang="ts"> |
||||
|
import * as defaultButtons from '@/utils/disposition/defaultButtons' |
||||
|
const message = useMessage() // 消息弹窗 |
||||
|
const { t } = useI18n() // 国际化 |
||||
|
|
||||
|
const props = defineProps({ |
||||
|
// 列表 相关信息 |
||||
|
tableAllSchemas: { |
||||
|
type: Array, |
||||
|
required: true, |
||||
|
default: null |
||||
|
} |
||||
|
}) |
||||
|
|
||||
|
const dialogTableVisible = ref(false) |
||||
|
const defaultExpandAll = ref(false) |
||||
|
const tableData = ref([]) |
||||
|
const isLoading = ref(false) |
||||
|
const oneId = ref(0) //每托的id |
||||
|
const twoId = ref(0) //每箱的id |
||||
|
const openLabel =async (tableList) => { |
||||
|
dialogTableVisible.value = true |
||||
|
tableData.value = tableList |
||||
|
defaultExpandAll.value = false |
||||
|
await intData() |
||||
|
} |
||||
|
const currentPage = ref(1) |
||||
|
const pageSize = ref(10) |
||||
|
const showTableData = () => { |
||||
|
if (tableData.value.length > 10) { |
||||
|
return tableData.value.slice( |
||||
|
(currentPage.value - 1) * pageSize.value, |
||||
|
currentPage.value * pageSize.value |
||||
|
) |
||||
|
} else { |
||||
|
return tableData.value |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
const intData =async () => { |
||||
|
tableData.value.forEach((row) => { |
||||
|
if (row.secondPackUnit && row.secondPackQty) { |
||||
|
// 数量%托数量 获取总共几托 |
||||
|
row.allTuoQty = Math.ceil(parseFloat(row.qty) / parseFloat(row.secondPackQty)) |
||||
|
} else { |
||||
|
// 数量%每箱数量 获取总共几箱 |
||||
|
row.allTuoQty = Math.ceil(parseFloat(row.qty) / parseFloat(row.packQty)) |
||||
|
} |
||||
|
expandChange(row) |
||||
|
}) |
||||
|
} |
||||
|
const expandChange = (row: any, expandedRows: any[]) => { |
||||
|
// 判断托信息是否存在 |
||||
|
if (row.secondPackUnit && row.secondPackQty) { |
||||
|
// 数量除以托数量获取余数 |
||||
|
row.lastNumber = parseFloat(row.qty) % parseFloat(row.secondPackQty) |
||||
|
// 托数量/箱数量 一托可以放几箱 |
||||
|
row.otherNumber = parseFloat(row.secondPackQty) / parseFloat(row.packQty) |
||||
|
// 数量%托数量 获取总共几托 |
||||
|
row.allTuoQty = Math.ceil(parseFloat(row.qty) / parseFloat(row.secondPackQty)) |
||||
|
row.packageList = [] |
||||
|
// 循环托 |
||||
|
for (let i = 0; i < row.allTuoQty; i++) { |
||||
|
oneId.value++ |
||||
|
// 先给所有托一个默认对象值 |
||||
|
row.packageList[i] = { |
||||
|
id: oneId.value, |
||||
|
tPoNumber: i + 1, |
||||
|
xNumber: '', |
||||
|
qtyOne: '', |
||||
|
isTuo: 1 //有托 |
||||
|
} |
||||
|
// 如果有余数 |
||||
|
if (row.lastNumber) { |
||||
|
// 最后一条信息直接展示余数的信息 |
||||
|
if (i == row.allTuoQty - 1) { |
||||
|
row.packageList[i].xNumber = Math.ceil(row.lastNumber / parseFloat(row.packQty)) |
||||
|
row.packageList[i].qtyOne = row.lastNumber |
||||
|
} else { |
||||
|
// 其他数据展示一托的全部箱数和全部数量 |
||||
|
row.packageList[i].xNumber = row.otherNumber |
||||
|
row.packageList[i].qtyOne = row.secondPackQty |
||||
|
} |
||||
|
} else { |
||||
|
// 如果沒有余数,直接展示一托的全部箱数和全部数量 |
||||
|
row.packageList[i].xNumber = row.otherNumber |
||||
|
row.packageList[i].qtyOne = row.secondPackQty |
||||
|
} |
||||
|
} |
||||
|
// 判断箱信息是否存在 |
||||
|
if (row.packUnit && row.packQty) { |
||||
|
row.packageList.forEach((cur, key) => { |
||||
|
cur.children = [] |
||||
|
// 数量除以箱数量获取余数 |
||||
|
cur.xLastNumber = parseFloat(cur.qtyOne) % parseFloat(row.packQty) |
||||
|
// cur.xiangNumber = Math.ceil(parseFloat(cur.qtyOne) / parseFloat(item.secondPackQty)) |
||||
|
for (let j = 0; j < cur.xNumber; j++) { |
||||
|
twoId.value++ |
||||
|
cur.children[j] = { |
||||
|
id: twoId.value, |
||||
|
xPoNumber: j + 1 |
||||
|
} |
||||
|
// 如果有余数 |
||||
|
if (cur.xLastNumber) { |
||||
|
// 最后一条信息直接展示余数的信息 |
||||
|
if (j == cur.xNumber - 1) { |
||||
|
cur.children[j].qtyTwo = cur.xLastNumber |
||||
|
} else { |
||||
|
// 其他数据展示一托的全部箱数和全部数量 |
||||
|
cur.children[j].qtyTwo = row.packQty |
||||
|
} |
||||
|
} else { |
||||
|
// 如果沒有余数,直接展示一托的全部箱数和全部数量 |
||||
|
cur.children[j].qtyTwo = row.packQty |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} else { |
||||
|
// 数量%每箱数量 获取总共几箱 |
||||
|
row.allXiangQty = Math.ceil(parseFloat(row.qty) / parseFloat(row.packQty)) |
||||
|
row.packageList = [] |
||||
|
row.allTuoQty = 1 |
||||
|
// 循环箱 |
||||
|
for (let i = 0; i < row.allTuoQty; i++) { |
||||
|
oneId.value++ |
||||
|
// 先给所有托一个默认对象值 |
||||
|
row.packageList[i] = { |
||||
|
id: oneId.value, |
||||
|
xPoNumber: i + 1, |
||||
|
qtyOne: row.qty, |
||||
|
isTuo: 0 //无托 |
||||
|
} |
||||
|
} |
||||
|
row.packageList.forEach((cur) => { |
||||
|
cur.children = [] |
||||
|
for (let j = 0; j < row.allXiangQty; j++) { |
||||
|
twoId.value++ |
||||
|
cur.children[j] = { |
||||
|
id: twoId.value, |
||||
|
xPoNumber: j + 1 |
||||
|
} |
||||
|
// 数量除以箱数量获取余数 |
||||
|
cur.lastNumber = parseFloat(row.qty) % parseFloat(row.packQty) |
||||
|
// 如果有余数 |
||||
|
if (cur.lastNumber) { |
||||
|
// 最后一条信息直接展示余数的信息 |
||||
|
if (j == row.allXiangQty - 1) { |
||||
|
cur.children[j].qtyTwo = cur.lastNumber |
||||
|
} else { |
||||
|
// 其他数据展示一托的全部箱数和全部数量 |
||||
|
cur.children[j].qtyTwo = row.packQty |
||||
|
} |
||||
|
} else { |
||||
|
// 如果沒有余数,直接展示一托的全部箱数和全部数量 |
||||
|
cur.children[j].qtyTwo = row.packQty |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** 弹窗按钮 */ |
||||
|
let Butttondata: any = [] |
||||
|
Butttondata = [ |
||||
|
defaultButtons.formSaveBtn(null), // 保存 |
||||
|
defaultButtons.formCloseBtn(null) // 关闭 |
||||
|
] |
||||
|
|
||||
|
/** 按钮事件 */ |
||||
|
const buttonBaseClick = (val) => { |
||||
|
// 保存 |
||||
|
if (val == 'save') { |
||||
|
submitForm() |
||||
|
} |
||||
|
// 关闭 |
||||
|
else if (val == 'close') { |
||||
|
dialogTableVisible.value = false |
||||
|
} |
||||
|
} |
||||
|
// 保存 |
||||
|
const submitForm = () => { |
||||
|
let arr = tableData.value.map((item) => { |
||||
|
item.allNumber = 0 |
||||
|
// 判断托信息是否存在 |
||||
|
item.packageList.forEach((cur) => { |
||||
|
item.allNumber += parseFloat(cur.qtyOne) || 0 |
||||
|
}) |
||||
|
if (item.allNumber == parseFloat(item.qty)) { |
||||
|
return true |
||||
|
} else { |
||||
|
return false |
||||
|
} |
||||
|
}) |
||||
|
const isBol = arr.some((item) => item == false) |
||||
|
if (isBol) { |
||||
|
message.warning('当前添加的数量与总数量不一致') |
||||
|
return |
||||
|
} |
||||
|
emit('submitForm', tableData.value) |
||||
|
} |
||||
|
// 添加托 |
||||
|
const addT = (oneRow) => { |
||||
|
oneId.value++ |
||||
|
oneRow.packageList.push({ |
||||
|
id: oneId.value, |
||||
|
tPoNumber: oneRow?.packageList?.length>0?oneRow.packageList[oneRow.packageList.length - 1]?.tPoNumber + 1 :1, //行号是上一行的行号加1 |
||||
|
xNumber: '', |
||||
|
qtyOne: '' |
||||
|
}) |
||||
|
oneRow.allTuoQty = oneRow.packageList.length |
||||
|
} |
||||
|
// 移出托 |
||||
|
const removeT = (oneRow, oneIndex, twoRow, twoIndex) => { |
||||
|
oneRow.packageList.splice(twoIndex, 1) |
||||
|
oneRow.allTuoQty = oneRow.packageList.length |
||||
|
} |
||||
|
// 添加箱 |
||||
|
const addX = (oneRow, oneIndex, twoRow, twoIndex, type) => { |
||||
|
twoId.value++ |
||||
|
// 有父级托的时候 |
||||
|
if (type == 1) { |
||||
|
// 在托下添加箱 |
||||
|
twoRow.children.push({ |
||||
|
id: twoId.value, |
||||
|
xPoNumber: twoRow?.children?.length>0? twoRow?.children[twoRow.children.length - 1]?.xPoNumber + 1 :1, |
||||
|
qtyOne: '' |
||||
|
}) |
||||
|
twoRow.xNumber = twoRow.children.length |
||||
|
} else { |
||||
|
// 直接添加箱 |
||||
|
twoRow.children.push({ |
||||
|
id: twoId.value, |
||||
|
xPoNumber:twoRow.children.length>0? twoRow.children[twoRow.children.length - 1].xPoNumber + 1:1, |
||||
|
qtyTwo: '' |
||||
|
}) |
||||
|
oneRow.allTuoQty = twoRow.children.length |
||||
|
} |
||||
|
} |
||||
|
// 移除箱 |
||||
|
const removeX = (oneRow, oneIndex, twoRow, twoIndex, threeRow, threeIndex, type) => { |
||||
|
// 有父级托的时候 |
||||
|
if (type == 1) { |
||||
|
// 在托下移除箱 |
||||
|
twoRow.children.splice(threeIndex, 1) |
||||
|
let num = 0 |
||||
|
twoRow.children.forEach((item) => { |
||||
|
num += parseFloat(item.qtyTwo) || 0 |
||||
|
}) |
||||
|
twoRow.qtyOne = num |
||||
|
twoRow.xNumber = twoRow.children.length |
||||
|
} else { |
||||
|
twoRow.children.splice(twoIndex, 1) |
||||
|
oneRow.allTuoQty = twoRow.children.length |
||||
|
} |
||||
|
} |
||||
|
// 是否显示展开图标 |
||||
|
const getRowClass = (row) => { |
||||
|
if (!row.row.children || row.row.children.length == 0) { |
||||
|
return 'row-expand-cover' |
||||
|
} |
||||
|
} |
||||
|
// 托失去焦点 |
||||
|
const blurOne = (oneRow, twoRow) => { |
||||
|
if (!twoRow.xNumber) { |
||||
|
twoRow.qtyOne = '' |
||||
|
} |
||||
|
if (parseFloat(twoRow.xNumber) > parseFloat(oneRow.otherNumber)) { |
||||
|
message.warning('每托箱个数最多' + oneRow.otherNumber + '箱') |
||||
|
twoRow.xNumber = oneRow.otherNumber |
||||
|
twoRow.children = [] |
||||
|
twoRow.qtyOne = parseFloat(twoRow.xNumber) * parseFloat(oneRow.packQty) |
||||
|
} |
||||
|
twoRow.qtyOne = parseFloat(twoRow.xNumber) * parseFloat(oneRow.packQty) |
||||
|
let num = 0 |
||||
|
oneRow.packageList.forEach((item) => { |
||||
|
num += parseFloat(item.xNumber) || 0 |
||||
|
}) |
||||
|
if (num > oneRow.allPackQty) { |
||||
|
message.warning('总箱数不可以大于' + oneRow.allPackQty) |
||||
|
twoRow.xNumber = '' |
||||
|
twoRow.qtyOne = '' |
||||
|
return |
||||
|
} |
||||
|
// 托信息修改的時候箱数据自动排列 |
||||
|
// 判断箱信息是否存在 |
||||
|
if (oneRow.packUnit && oneRow.packQty) { |
||||
|
oneRow.packageList.forEach((cur, key) => { |
||||
|
cur.children = [] |
||||
|
// 数量除以托数量获取余数 |
||||
|
cur.xLastNumber = parseFloat(cur.xNumber) % parseFloat(oneRow.packQty) |
||||
|
for (let j = 0; j < cur.xNumber; j++) { |
||||
|
twoId.value++ |
||||
|
// 如果有余数 |
||||
|
if (cur.xLastNumber) { |
||||
|
// 最后一条信息直接展示余数的信息 |
||||
|
if (j == cur.xNumbery - 1) { |
||||
|
cur.children.push({ |
||||
|
id: twoId.value, |
||||
|
xPoNumber: j + 1, |
||||
|
qtyTwo: cur.xLastNumber |
||||
|
}) |
||||
|
} else { |
||||
|
// 其他数据展示一托的全部箱数和全部数量 |
||||
|
cur.children.push({ |
||||
|
id: twoId.value, |
||||
|
xPoNumber: j + 1, |
||||
|
qtyTwo: oneRow.packQty |
||||
|
}) |
||||
|
} |
||||
|
} else { |
||||
|
// 如果沒有余数,直接展示一托的全部箱数和全部数量 |
||||
|
cur.children.push({ |
||||
|
id: twoId.value, |
||||
|
xPoNumber: j + 1, |
||||
|
qtyTwo: oneRow.packQty |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
//在托下方的箱数量失去焦点 |
||||
|
const blurTwo = (oneRow, twoRow, threeRow) => { |
||||
|
if (parseFloat(threeRow.qtyTwo) > parseFloat(oneRow.packQty)) { |
||||
|
message.warning('数量最多为' + oneRow.packQty) |
||||
|
threeRow.qtyTwo = oneRow.packQty |
||||
|
return |
||||
|
} |
||||
|
let num = 0 |
||||
|
twoRow.children.forEach((item) => { |
||||
|
num += parseFloat(item.qtyTwo) || 0 |
||||
|
}) |
||||
|
twoRow.qtyOne = num |
||||
|
} |
||||
|
// 箱数量失去焦点 |
||||
|
const blurThree = (oneRow, twoRow, thereeRow) => { |
||||
|
if (parseFloat(thereeRow.qtyTwo) > parseFloat(oneRow.packQty)) { |
||||
|
message.warning('每箱个数最多' + oneRow.packQty) |
||||
|
thereeRow.qtyTwo = oneRow.packQty |
||||
|
} |
||||
|
let num = 0 |
||||
|
twoRow.children.forEach((item) => { |
||||
|
num += parseFloat(item.qtyTwo) || 0 |
||||
|
}) |
||||
|
twoRow.qtyOne = num |
||||
|
} |
||||
|
// 传递给父类 |
||||
|
const emit = defineEmits(['submitForm']) |
||||
|
defineExpose({ openLabel, dialogTableVisible, isLoading }) // 提供 open 方法,用于打开弹窗 |
||||
|
</script> |
||||
|
<style lang="scss" scoped> |
||||
|
::v-deep .row-expand-cover td .el-table__expand-icon { |
||||
|
visibility: hidden; |
||||
|
} |
||||
|
</style> |
File diff suppressed because it is too large
Loading…
Reference in new issue