You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

223 lines
6.3 KiB

12 months ago
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<Search ref="seachRef" :showSearchTableQueryFields="['supplierCode','itemCode']" :hiddenFilterBtnFields="['supplierCode','itemCode']" :schema="DemandforecastingMain.allSchemas.searchSchema" @search="searchClick" @reset="searchClick" @searchTableSuccess="searchQueryTableSuccess" @onChange="onSearchChange"/>
12 months ago
</ContentWrap>
<!-- 列表头部 -->
<TableHead
:HeadButttondata="HeadButttondata"
@button-base-click="buttonBaseClick"
:routeName="routeName"
@updataTableColumns="updataTableColumns"
@searchFormClick="searchFormClick"
:allSchemas="DemandforecastingMain.allSchemas"
/>
12 months ago
<!-- 列表 -->
<ContentWrap>
<Table v-clientTable
12 months ago
: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 v-for="name in tableObjectHead.tableList" :key="name" #[name]="{row}">
8 months ago
<span :class="{'success-text':row['planType_F'].indexOf(name)>-1}">{{ row[name] }}</span>
</template>
</Table>
12 months ago
</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
8 months ago
const orginTableColumns = ref(DemandforecastingMain.allSchemas.tableColumns)
const tableColumns = ref(DemandforecastingMain.allSchemas.tableColumns)
12 months ago
// 字段设置 更新主列表字段
const updataTableColumns = (val) => {
8 months ago
orginTableColumns.value = val
}
8 months ago
12 months ago
// 查询页面返回
const searchQueryTableSuccess = (formField, searchField, val, formRef, type, row ) => {
console.log('searchQueryTableSuccess',formField, searchField, val, formRef, type, row )
12 months ago
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{
12 months ago
setV[formField] = val[0][searchField]
formRef.setValues(setV)
}
})
}
8 months ago
const { tableObject:tableObjectHead, tableMethods:tableMethodsHead } = useTable({
getListApi: DemandforecastingDetailApi.getPageTableHead // 分页接口
})
// 获得表格的各种操作
const { getList:getListHead, setSearchParams:setSearchParamsHead } = tableMethodsHead
12 months ago
8 months ago
watch(()=>tableObjectHead.tableList,()=>{
updateDateTableColumns()
},{deep:true})
const updateDateTableColumns = ()=>{
console.log('tableObjectHead',tableObjectHead)
let dateColumns = []
8 months ago
if(tableObjectHead.tableList.length>10){
tableObjectHead.tableList.forEach(item=>{
8 months ago
dateColumns.push({
8 months ago
width:120,
field: item,
label: item
})
8 months ago
})
8 months ago
}else{
tableObjectHead.tableList.forEach(item=>{
dateColumns.push({
field: item,
label: item
})
})
}
8 months ago
tableColumns.value = [...orginTableColumns.value,...dateColumns]
console.log('tableColumns',tableColumns.value)
}
12 months ago
const { tableObject, tableMethods } = useTable({
getListApi: DemandforecastingDetailApi.getDemandforecastingDetailPage // 分页接口
12 months ago
})
// 获得表格的各种操作
const { getList, setSearchParams } = tableMethods
// 列表头部按钮
const HeadButttondata = [
defaultButtons.defaultExportBtn({hasPermi:'wms:demandforecasting-main:export'}), // 导出
defaultButtons.defaultFreshBtn(null), // 刷新
8 months ago
// defaultButtons.defaultFilterBtn(null), // 筛选
12 months ago
defaultButtons.defaultSetBtn(null), // 设置
]
// 头部按钮事件
8 months ago
const buttonBaseClick = async (val, item) => {
if (val == 'export') { // 导出
12 months ago
handleExport()
} else if (val == 'refresh') { // 刷新
if (tableObject.params.filters && tableObject.params.filters.length > 0 ) {
searchFormClick({
filters: tableObject.params.filters
})
} else {
8 months ago
await getListHead()
8 months ago
// updateDateTableColumns()
12 months ago
getList()
8 months ago
12 months ago
}
} else if (val == 'filtrate') { // 筛选
} else { // 其他按钮
console.log('其他按钮', item)
}
}
11 months ago
const seachRef = ref()
const onSearchChange = (field, value)=>{
if(field=='planerId'){
if(value.length>0){
if(value[value.length-1]==''){
//全选
seachRef.value.setFormValues({
planerId:['']
})
}else{
seachRef.value.setFormValues({
planerId:value.filter(item=>item!='')
})
}
}
}
}
8 months ago
const searchClick = async (data)=>{
console.log('searchClick',data)
8 months ago
await setSearchParamsHead(data)
8 months ago
// updateDateTableColumns()
8 months ago
setSearchParams(data)
12 months ago
}
/** 导出按钮操作 */
const exportLoading = ref(false) // 导出的加载中
const handleExport = async () => {
try {
// 导出的二次确认
await message.exportConfirm()
// 发起导出
exportLoading.value = true
const data = await DemandforecastingMainApi.exportDemandforecastingMain(tableObject.params)
10 months ago
download.excel(data, `${t('ts.要货预测主')}.xlsx`)
12 months ago
} catch {
} finally {
exportLoading.value = false
}
}
// 导入附件弹窗所需的参数
const importTemplateData = reactive({
templateUrl: '',
10 months ago
templateTitle: `${t('ts.要货预测主导入模版')}.xlsx`
12 months ago
})
// 筛选提交
const searchFormClick = (searchData) => {
tableObject.params = {
isSearch: true,
filters: searchData.filters
}
getList() // 刷新当前列表
}
/** 初始化 **/
onMounted(async () => {
8 months ago
await getListHead()
8 months ago
// updateDateTableColumns()
12 months ago
getList()
importTemplateData.templateUrl = await DemandforecastingMainApi.importTemplate()
})
</script>
<style lang="scss" scoped>
8 months ago
.success-text{
color:var(--el-color-success);
font-weight:700;
}
</style>