|
|
|
import {
|
|
|
|
getPageList,
|
|
|
|
getDetailed,
|
|
|
|
allSupplierByCodes,
|
|
|
|
postDelete
|
|
|
|
} from '@/api/wms-api'
|
|
|
|
export const tableMixins = {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
//分页参数
|
|
|
|
PageListParams: {
|
|
|
|
condition: {
|
|
|
|
filters: []
|
|
|
|
},
|
|
|
|
Sorting: "",
|
|
|
|
SkipCount: 0,
|
|
|
|
MaxResultCount: 20,
|
|
|
|
},
|
|
|
|
//当前数据总条数
|
|
|
|
totalCount: 0,
|
|
|
|
//改变当前页
|
|
|
|
oldSkipCount: 1,
|
|
|
|
//table渲染数据
|
|
|
|
tableData: [],
|
|
|
|
//选择当前表行数据
|
|
|
|
multipleSelection: [],
|
|
|
|
// 明细 details 数据集做分页处理
|
|
|
|
//当前数据总条数
|
|
|
|
totalCountDetails: 0,
|
|
|
|
//改变当前页
|
|
|
|
oldSkipCountDetails: 1,
|
|
|
|
//跳过前多少条记录数
|
|
|
|
SkipCountDetails: 0,
|
|
|
|
//每页最大显示数
|
|
|
|
MaxResultCountDetails: 20,
|
|
|
|
// 明细数据临时存储
|
|
|
|
tableDataDetails:[],
|
|
|
|
//默认tag
|
|
|
|
firstTabs:'xq',
|
|
|
|
//明细-前端手动添加的基础信息配置
|
|
|
|
showDetailBaseFromFE:['configuration']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
// 批量添加判断显示主子表默认按钮、字段设置
|
|
|
|
initPagingHeaderBtn(){
|
|
|
|
let _allBtns = []
|
|
|
|
this.currenButtonData.forEach(item => {
|
|
|
|
_allBtns.push(item.name)
|
|
|
|
});
|
|
|
|
if(_allBtns.indexOf('showMrt') < 0){
|
|
|
|
this.currenButtonData = [
|
|
|
|
...this.currenButtonData,
|
|
|
|
{
|
|
|
|
label: "查看主表",
|
|
|
|
name: "showMrt",
|
|
|
|
size: "small",
|
|
|
|
hide: ()=>{return localStorage.getItem('pageHasMOrDList').indexOf(this.$route.name+'_mrt') < 0}
|
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
if(_allBtns.indexOf('showDet') < 0){
|
|
|
|
this.currenButtonData = [
|
|
|
|
...this.currenButtonData,
|
|
|
|
{
|
|
|
|
label: "查看子表",
|
|
|
|
name: "showDet",
|
|
|
|
size: "small",
|
|
|
|
hide: ()=>{return localStorage.getItem('pageHasMOrDList').indexOf(this.$route.name+'_det') < 0}
|
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
//渲染数据
|
|
|
|
paging(callback) {
|
|
|
|
this.initPagingHeaderBtn()
|
|
|
|
this.Loading.tableLoading = true;
|
|
|
|
this.PageListParams.SkipCount = (this.oldSkipCount - 1) * this.PageListParams.MaxResultCount,
|
|
|
|
getPageList(this.PageListParams, this.URL,false,this.listURL).then(res => {
|
|
|
|
this.tableData = res.items
|
|
|
|
this.totalCount = res.totalCount
|
|
|
|
this.pagingCallback(callback)
|
|
|
|
}).catch(err => {
|
|
|
|
this.Loading.tableLoading = false
|
|
|
|
})
|
|
|
|
},
|
|
|
|
//接受排序信息并改变视图
|
|
|
|
sortChange(val) {
|
|
|
|
const {
|
|
|
|
prop,
|
|
|
|
order
|
|
|
|
} = val;
|
|
|
|
if (!prop || !order) {
|
|
|
|
this.PageListParams.Sorting = "";
|
|
|
|
this.oldSkipCount = 1;
|
|
|
|
this.paging();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let orderdata = order.substr(0, order.indexOf("c") + 1);
|
|
|
|
const props = prop.charAt(0).toUpperCase() + prop.slice(1)
|
|
|
|
this.PageListParams.Sorting = props + " " + orderdata.toUpperCase();
|
|
|
|
this.oldSkipCount = 1;
|
|
|
|
this.paging();
|
|
|
|
},
|
|
|
|
//接收分页组件emit改变每页最大页数
|
|
|
|
alterResultCount(val) {
|
|
|
|
this.PageListParams.MaxResultCount = val;
|
|
|
|
this.paging();
|
|
|
|
},
|
|
|
|
//接收分页组件emit改变当前页
|
|
|
|
alertoldSkipCount(val) {
|
|
|
|
this.oldSkipCount = val;
|
|
|
|
this.paging();
|
|
|
|
},
|
|
|
|
//点击Table行内名称
|
|
|
|
inlineDialog(val) {
|
|
|
|
// 打开抽屉后,点击其他信息,默认回到详情位置上,避免特殊需要重新点击获取接口的tag页面数据不更新
|
|
|
|
this.firstTabs = 'xq'
|
|
|
|
//打开抽屉
|
|
|
|
this.propsData = {}
|
|
|
|
this.Loading.DrawerLoading = true
|
|
|
|
this.displayDialog.detailsDialog = true;
|
|
|
|
let _url = this.detailURL ? this.detailURL : this.URL
|
|
|
|
getDetailed(val.id, _url).then(res => {
|
|
|
|
if (res.details) {
|
|
|
|
// 前端分页处理
|
|
|
|
this.tableDataDetails = JSON.parse(JSON.stringify(res))
|
|
|
|
let linshiTableDataDetails = JSON.parse(JSON.stringify(this.tableDataDetails))
|
|
|
|
this.totalCountDetails = res.details.length
|
|
|
|
// 删除除当前页面最大数以外数据
|
|
|
|
linshiTableDataDetails.details.splice(this.MaxResultCountDetails,this.totalCountDetails);
|
|
|
|
this.propsData = linshiTableDataDetails
|
|
|
|
} else {
|
|
|
|
this.propsData = res
|
|
|
|
}
|
|
|
|
this.inlineDialogCallback()
|
|
|
|
}).catch(err => {
|
|
|
|
this.Loading.DrawerLoading = false
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 明细 分页 接收分页组件emit改变每页最大页数
|
|
|
|
alterResultCountDetails(val) {
|
|
|
|
this.Loading.DrawerLoading = true
|
|
|
|
this.MaxResultCountDetails = val;
|
|
|
|
let linshiTableDataDetails = JSON.parse(JSON.stringify(this.tableDataDetails))
|
|
|
|
linshiTableDataDetails.details.splice(this.MaxResultCountDetails,this.totalCountDetails);
|
|
|
|
this.propsData = linshiTableDataDetails
|
|
|
|
this.Loading.DrawerLoading = false
|
|
|
|
},
|
|
|
|
// 明细 分页 接收分页组件emit改变当前页
|
|
|
|
alertoldSkipCountDetails(val) {
|
|
|
|
this.propsData = {}
|
|
|
|
this.Loading.DrawerLoading = true
|
|
|
|
this.oldSkipCountDetails = val;
|
|
|
|
let SkipCount = (this.oldSkipCountDetails - 1) * this.MaxResultCountDetails
|
|
|
|
let linshiTableDataDetails = null;
|
|
|
|
linshiTableDataDetails = JSON.parse(JSON.stringify(this.tableDataDetails))
|
|
|
|
// 删除当前页 之前数据
|
|
|
|
linshiTableDataDetails.details.splice(0,SkipCount);
|
|
|
|
// 删除当前页 之后的数据
|
|
|
|
linshiTableDataDetails.details.splice(this.MaxResultCountDetails,this.totalCountDetails);
|
|
|
|
this.propsData = linshiTableDataDetails
|
|
|
|
this.Loading.DrawerLoading = false
|
|
|
|
},
|
|
|
|
//选择当前行
|
|
|
|
handleSelectionChange(val) {
|
|
|
|
this.multipleSelection = val;
|
|
|
|
},
|
|
|
|
// 获取供应商信息过滤tableData
|
|
|
|
getSupplierByCodesHandle_table() {
|
|
|
|
for(let i=0;i<this.tableColumns.length;i++){
|
|
|
|
if(this.tableColumns[i].prop == 'supplierName' || this.tableColumns[i].prop == "supplierAddress"){
|
|
|
|
let _allSuCode = []
|
|
|
|
this.tableData.forEach((item)=>{
|
|
|
|
if(item.supplierCode && item.supplierCode.length > 0 && _allSuCode.indexOf(item.supplierCode) < 0){
|
|
|
|
_allSuCode.push(item.supplierCode)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
if(_allSuCode.length <= 0){
|
|
|
|
this.Loading.tableLoading = false
|
|
|
|
return
|
|
|
|
}
|
|
|
|
allSupplierByCodes(_allSuCode).then(res => {
|
|
|
|
let _all = []
|
|
|
|
res.forEach(item=>{
|
|
|
|
_all[item.code] = item
|
|
|
|
})
|
|
|
|
this.tableData.forEach(item=>{
|
|
|
|
if(_all[item.supplierCode]){
|
|
|
|
this.$set(item,"supplierName", _all[item.supplierCode].name)
|
|
|
|
this.$set(item,"supplierAddress", _all[item.supplierCode].address)
|
|
|
|
this.$set(item,"supplierShortName", _all[item.supplierCode].shortName)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
this.Loading.tableLoading = false
|
|
|
|
}).catch(err => {
|
|
|
|
console.log(err)
|
|
|
|
this.Loading.tableLoading = false
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}else{
|
|
|
|
this.Loading.tableLoading = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
//
|
|
|
|
/**
|
|
|
|
* 获取物品信息-逐条过滤到主表或者明细表
|
|
|
|
* 明细或者主表单行数据添加所需要的值
|
|
|
|
* @param {*} type 是更改主表(table)还是明细表(detail)
|
|
|
|
* 要追加的值取showTableBaseFromFE(主表)、showDetailBaseFromFE(明细),参数是基础表的参数,如code,而不是itemCode
|
|
|
|
* 添加到表头的格式为item+追加的参数+FromFE (例如:item_desc2FromFE)
|
|
|
|
*/
|
|
|
|
getItemInfoByItemCodeHandle(type) {
|
|
|
|
let _data = {
|
|
|
|
condition: {filters: []},
|
|
|
|
Sorting: "",
|
|
|
|
SkipCount: 0,
|
|
|
|
MaxResultCount: 1000
|
|
|
|
}
|
|
|
|
// 主表
|
|
|
|
let _mainData = type == 'table' ? this.tableData : this.propsData.details
|
|
|
|
let _arrFromFE = type == 'table' ? this.showTableBaseFromFE : this.showDetailBaseFromFE
|
|
|
|
_mainData.forEach((item)=>{
|
|
|
|
let _filt = {
|
|
|
|
logic: 'Or',
|
|
|
|
column: "code",
|
|
|
|
action: "==",
|
|
|
|
value: item.itemCode
|
|
|
|
}
|
|
|
|
_data.condition.filters.push(_filt)
|
|
|
|
})
|
|
|
|
getPageList(_data, 'basedata/item-basic').then(res => {
|
|
|
|
_mainData.forEach(item=>{
|
|
|
|
let _config = res.items.filter(base=>{
|
|
|
|
return base.code == item.itemCode
|
|
|
|
})
|
|
|
|
if(_config && _config.length > 0){
|
|
|
|
_arrFromFE.forEach(fe=>{
|
|
|
|
this.$set(item,"item_"+fe+"FromFE", _config[0][fe])
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
this.$forceUpdate()
|
|
|
|
this.Loading.DrawerLoading = false
|
|
|
|
}).catch(err => {
|
|
|
|
this.Loading.DrawerLoading = false
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 获取供应商信息过滤propsData
|
|
|
|
getSupplierByCodesHandle_props() {
|
|
|
|
for(let i=0;i<this.tabsDesTions.length;i++){
|
|
|
|
if(!this.propsData.supplierCode){
|
|
|
|
this.Loading.DrawerLoading = false
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if(this.tabsDesTions[i].prop == 'supplierName' || this.tabsDesTions[i].prop == "supplierAddress"){
|
|
|
|
let _allSuCode = [this.propsData.supplierCode]
|
|
|
|
this.Loading.DrawerLoading = true
|
|
|
|
allSupplierByCodes(_allSuCode).then(res => {
|
|
|
|
this.Loading.DrawerLoading = false
|
|
|
|
if(res.length > 0){
|
|
|
|
this.$set(this.propsData,"supplierName", res[0].name)
|
|
|
|
this.$set(this.propsData,"supplierAddress", res[0].address)
|
|
|
|
this.$set(this.propsData,"supplierShortName", res[0].shortName)
|
|
|
|
}
|
|
|
|
}).catch(err => {
|
|
|
|
console.log(err)
|
|
|
|
this.Loading.DrawerLoading = false
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}else{
|
|
|
|
this.Loading.DrawerLoading = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 主列表操作列按钮执行方法
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {*} row 当前行数据
|
|
|
|
* @param {*} label 按钮name
|
|
|
|
*/
|
|
|
|
buttonOperationClick(row, label) {
|
|
|
|
// 获取当前行数据,赋值给 propsData
|
|
|
|
this.propsData = row
|
|
|
|
|
|
|
|
if (label == "edit") {
|
|
|
|
this.formTitle = this.$route.meta.title + "编辑";
|
|
|
|
this.formReveal = false
|
|
|
|
this.theEvent = "edit"
|
|
|
|
const listAssign = (arr1, arr2) => {
|
|
|
|
Object.keys(arr1).forEach(item => {
|
|
|
|
arr1[item] = arr2[item]
|
|
|
|
})
|
|
|
|
}
|
|
|
|
listAssign(this.editFormData, row)
|
|
|
|
if(this.$route.name == 'CustomerItem'){
|
|
|
|
this.editFormData.beginTime = new Date(row.beginTime)
|
|
|
|
this.editFormData.endTime = new Date(row.endTime)
|
|
|
|
}
|
|
|
|
this.displayDialog.editDialog = true
|
|
|
|
}
|
|
|
|
if (label == 'delete') {
|
|
|
|
this.$confirm('此操作将永久删除该消息, 是否继续?', '提示', {
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
type: 'warning'
|
|
|
|
}).then(() => {
|
|
|
|
this.Loading.appMainLoading = true
|
|
|
|
this.displayDialog.detailsDialog = false
|
|
|
|
postDelete(row.id, this.URL).then(res => {
|
|
|
|
this.$successMsg('删除成功!')
|
|
|
|
this.Loading.appMainLoading = false
|
|
|
|
this.paging()
|
|
|
|
}).catch(err => {
|
|
|
|
this.Loading.appMainLoading = false
|
|
|
|
})
|
|
|
|
}).catch(() => {
|
|
|
|
this.Loading.appMainLoading = false
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 主列表更新后全局通用操作
|
|
|
|
pagingCallback(callback){
|
|
|
|
this.Loading.tableLoading = false
|
|
|
|
// 如果业务页面设置showTableBaseFromFE,tableColumns.js别忘了添加配置项
|
|
|
|
if(this.showTableBaseFromFE && this.showTableBaseFromFE.length > 0){
|
|
|
|
this.getItemInfoByItemCodeHandle('table')
|
|
|
|
}
|
|
|
|
if(callback)callback()
|
|
|
|
// this.getSupplierByCodesHandle_table()
|
|
|
|
},
|
|
|
|
// 点击抽屉,获取明细后全局通用操作
|
|
|
|
inlineDialogCallback(){
|
|
|
|
if(this.inlineDialogCallbackUser){this.inlineDialogCallbackUser()}
|
|
|
|
// 如果业务页面设置showDetailBaseFromFE为空,detailsTableColumns.js别忘了删除配置项
|
|
|
|
if(this.showDetailBaseFromFE && this.showDetailBaseFromFE.length > 0){
|
|
|
|
this.getItemInfoByItemCodeHandle('detail')
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
this.Loading.DrawerLoading = false
|
|
|
|
}
|
|
|
|
// this.getSupplierByCodesHandle_props()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|