|
|
|
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',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
//渲染数据
|
|
|
|
paging(callback) {
|
|
|
|
this.Loading.tableLoading = true;
|
|
|
|
this.PageListParams.SkipCount = (this.oldSkipCount - 1) * this.PageListParams.MaxResultCount,
|
|
|
|
getPageList(this.PageListParams, this.URL).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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 获取供应商信息过滤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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 明细-获取物品信息【配置(configuration)】参数
|
|
|
|
// 此方法暂时仅仅支持1000条以内的数据,如果有需要1000以外,需要优化
|
|
|
|
getConfigByItemHandle_props() {
|
|
|
|
let _data = {
|
|
|
|
condition: {filters: []},
|
|
|
|
Sorting: "",
|
|
|
|
SkipCount: 0,
|
|
|
|
MaxResultCount: 1000
|
|
|
|
}
|
|
|
|
this.propsData.details.forEach((item)=>{
|
|
|
|
let _filt = {
|
|
|
|
logic: 'Or',
|
|
|
|
column: "code",
|
|
|
|
action: "==",
|
|
|
|
value: item.itemCode
|
|
|
|
}
|
|
|
|
_data.condition.filters.push(_filt)
|
|
|
|
})
|
|
|
|
getPageList(_data, 'basedata/item-basic').then(res => {
|
|
|
|
console.log(items)
|
|
|
|
this.propsData.details.forEach(item=>{
|
|
|
|
let _config = res.items.filters(base=>{
|
|
|
|
return base.code == item.itemCode
|
|
|
|
})
|
|
|
|
console.log(225,_config)
|
|
|
|
})
|
|
|
|
this.Loading.DrawerLoading = false
|
|
|
|
}).catch(err => {
|
|
|
|
this.Loading.DrawerLoading = false
|
|
|
|
})
|
|
|
|
// 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) {
|
|
|
|
console.log(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
|
|
|
|
if(callback)callback()
|
|
|
|
// this.getSupplierByCodesHandle_table()
|
|
|
|
},
|
|
|
|
// 点击抽屉,获取明细后全局通用操作
|
|
|
|
inlineDialogCallback(){
|
|
|
|
// 插入配置数据
|
|
|
|
if(this.showConfiguration){
|
|
|
|
// this.getConfigByItemHandle_props()
|
|
|
|
}else{
|
|
|
|
this.Loading.DrawerLoading = false
|
|
|
|
}
|
|
|
|
// this.getSupplierByCodesHandle_props()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|