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.
307 lines
11 KiB
307 lines
11 KiB
import {
|
|
getPageList,
|
|
postExport,
|
|
postUpdateAvailableCapacity,
|
|
fileStorage
|
|
}
|
|
from "@/api/wms-api"
|
|
export const TableHeaderMixins = {
|
|
data() {
|
|
return {
|
|
//筛选(旧版,使用conditionFilters组件)
|
|
screenData: {
|
|
filters: [{
|
|
logic: "",
|
|
column: "",
|
|
action: "",
|
|
value: ""
|
|
}]
|
|
},
|
|
// 是否添加到body中,(旧版,使用conditionFilters组件)
|
|
modalAppendToBody: false,
|
|
//新增/编辑预览数据
|
|
previewFormData: {},
|
|
// 全面搜索:当前列表数据请求接口的筛选条件
|
|
httpOverallSearchData:null,
|
|
}
|
|
},
|
|
methods: {
|
|
// 点击常用按钮
|
|
topbutton(val,item) {
|
|
// 更新
|
|
if (val == 'refresh') {
|
|
this.oldSkipCount = 1
|
|
this.paging()
|
|
// this.$store.dispatch("app/appMainLoading", true)
|
|
}
|
|
// 新增
|
|
else if (val == 'newly') {
|
|
this.formTitle = "新增" + this.$route.meta.title;
|
|
this.formReveal = true
|
|
this.theEvent = "newly"
|
|
this.displayDialog.newDialog = true;
|
|
}
|
|
// 筛选(旧版,使用conditionFilters组件)
|
|
// else if (val == 'filter') {
|
|
// this.displayDialog.screenDialog = true
|
|
// if (this.PageListParams.condition.filters.length != 0) {
|
|
// this.screenData.filters = []
|
|
// this.screenData.filters.push(...this.PageListParams.condition.filters)
|
|
// } else {
|
|
// let data = [{
|
|
// logic: "And",
|
|
// column: "",
|
|
// action: "==",
|
|
// value: ""
|
|
// }]
|
|
// this.screenData.filters = data
|
|
// }
|
|
// }
|
|
// 导出
|
|
else if (val == 'export') {
|
|
const name = this.$route.meta.title
|
|
this.$confirm('您将进行导出操作, 是否继续?', '提示', {
|
|
confirmButtonText: '本页导出',
|
|
cancelButtonText: '全部导出',
|
|
distinguishCancelAndClose: true,
|
|
closeOnClickModal: false,
|
|
closeOnPressEscape: false,
|
|
type: 'warning'
|
|
}).then(() => {
|
|
// 本页导出
|
|
this.Loading.appMainLoading = true
|
|
this.PageListParams.company = window.SITE_CONFIG['company']
|
|
this.PageListParams.function = name
|
|
//自定义导出url
|
|
this.PageListParams.route = item.url ? item.url : this.URL + '/export';
|
|
let _exportUrl = item.url ? item.url : this.URL;
|
|
let _special = (item.url && item.url.length > 0) ? true : false
|
|
postExport(this.PageListParams, _exportUrl, _special).then(res => {
|
|
this.blob(res, name)//使用前端导出名称
|
|
this.Loading.appMainLoading = false
|
|
}).catch(err => {
|
|
this.Loading.appMainLoading = false
|
|
})
|
|
}).catch((action) => {
|
|
if (action === 'cancel') {
|
|
// 全部导出
|
|
this.Loading.appMainLoading = true
|
|
let params = JSON.parse(JSON.stringify(this.PageListParams))
|
|
params.MaxResultCount = this.totalCount
|
|
this.Loading.appMainLoading = true
|
|
params.company = window.SITE_CONFIG['company']
|
|
params.route = this.URL + '/export'
|
|
params.function = name
|
|
postExport(params, this.URL).then(res => {
|
|
this.blob(res, name)//使用前端导出名称
|
|
this.Loading.appMainLoading = false
|
|
}).catch(err => {
|
|
this.Loading.appMainLoading = false
|
|
})
|
|
}
|
|
});
|
|
}
|
|
// 导入
|
|
else if (val == 'import') {
|
|
this.displayDialog.importDialog = true
|
|
}
|
|
//更新可用容量
|
|
else if (val == 'refresh-capacity') {
|
|
this.Loading.appMainLoading = true
|
|
let count = 0
|
|
this.tableData.forEach(element => {
|
|
postUpdateAvailableCapacity({
|
|
locationCode: element.locationCode
|
|
}, this.URL).then(res => {
|
|
count += 1
|
|
if (count == this.tableData.length) {
|
|
this.Loading.appMainLoading = false
|
|
this.paging()
|
|
}
|
|
}).catch(err => {
|
|
count += 1
|
|
if (count == this.tableData.length) {
|
|
this.Loading.appMainLoading = false
|
|
this.paging()
|
|
}
|
|
})
|
|
})
|
|
}
|
|
// 自定义按钮 // 批量打印 ; 不合格转合格
|
|
else if(val == 'custom'){
|
|
item.customHandle()
|
|
}
|
|
},
|
|
// 快速搜索按钮
|
|
quicklySearchClick(val,option,searchOverallRef){
|
|
this.oldSkipCount = 1
|
|
this.Loading.tableLoading = true;
|
|
this.PageListParams.SkipCount = (this.oldSkipCount - 1) * this.PageListParams.MaxResultCount;
|
|
this.PageListParams.condition = {filters: []}
|
|
if(option && val && val.length > 0){
|
|
this.PageListParams.condition.filters.push({
|
|
action:option.action || '==',
|
|
column: option.prop,
|
|
logic: "And",
|
|
value: val,
|
|
})
|
|
}
|
|
// todo:使用paging(callback)如204行
|
|
getPageList(this.PageListParams, this.URL).then(res => {
|
|
this.tableData = res.items
|
|
this.totalCount = res.totalCount
|
|
this.httpOverallSearchData = null //清空全面筛选的回显数据
|
|
if(searchOverallRef)searchOverallRef.changeMoreListShow(false)//关闭高级筛选
|
|
this.pagingCallback()
|
|
}).catch(err => {
|
|
this.Loading.tableLoading = false
|
|
})
|
|
},
|
|
// 快速搜索按钮清除搜索
|
|
quicklySearchClear(val,option,searchOverallRef,hasSearch){
|
|
// 如果没有全面筛选,点击快速清除时候 直接调用接口
|
|
// if(!hasSearch)this.quicklySearchClick(val,option,searchOverallRef)
|
|
// 不管有没有全面筛选都直接调用接口
|
|
this.quicklySearchClick(val,option,searchOverallRef)
|
|
},
|
|
|
|
// 全面筛选组件重新获取页面数据操作 20230215
|
|
overallSearchGetPageHandle(options){
|
|
let _data_primary = options.data_primary,
|
|
_data_moreList = options.data_moreList,
|
|
_option_primary = options.option_primary,
|
|
_vm_quickly = options.vm_quickly,
|
|
_vm_moreList = options.vm_moreList
|
|
|
|
//普通筛选数据集合
|
|
let _primary_filters = []
|
|
_option_primary.forEach(item=>{
|
|
if(_data_primary[item.prop] && String(_data_primary[item.prop]).length > 0){
|
|
let _item = {
|
|
action:item.action || '==',
|
|
column:item.prop,
|
|
logic:'And',
|
|
value:String(_data_primary[item.prop])
|
|
}
|
|
_primary_filters.push(_item)
|
|
}
|
|
})
|
|
//高级筛选数据集合
|
|
let _moreList_filters = []
|
|
_data_moreList.filters.forEach(item=>{
|
|
if(String(item.column).length > 0 && String(item.value).length > 0){
|
|
_moreList_filters.push(item)
|
|
}
|
|
})
|
|
// 全部筛选数据集合
|
|
let _all_filters = []
|
|
_all_filters = _primary_filters.concat(_moreList_filters)
|
|
// 调用接口数据配置
|
|
this.oldSkipCount = 1
|
|
this.Loading.tableLoading = true;
|
|
this.PageListParams.SkipCount = (this.oldSkipCount - 1) * this.PageListParams.MaxResultCount;
|
|
this.PageListParams.condition = {filters:_all_filters}
|
|
this.paging(()=>{
|
|
//快速搜索清空
|
|
if(_vm_quickly){_vm_quickly.searchNormalClear(true)}
|
|
//关闭高级筛选
|
|
if(_vm_moreList){_vm_moreList.changeMoreListShow(false)}
|
|
// 同步当前列表数据请求接口的筛选条件
|
|
this.httpOverallSearchData = {}
|
|
this.httpOverallSearchData.params = JSON.parse(JSON.stringify(_data_primary))
|
|
this.httpOverallSearchData.moreList = JSON.parse(JSON.stringify(_data_moreList))
|
|
})
|
|
// getPageList(this.PageListParams, this.URL).then(res => {
|
|
// this.tableData = res.items
|
|
// this.totalCount = res.totalCount
|
|
// //快速搜索清空
|
|
// if(_vm_quickly){_vm_quickly.searchNormalClear(true)}
|
|
// //关闭高级筛选
|
|
// if(_vm_moreList){_vm_moreList.changeMoreListShow(false)}
|
|
// // 同步当前列表数据请求接口的筛选条件
|
|
// this.httpOverallSearchData = {}
|
|
// this.httpOverallSearchData.params = JSON.parse(JSON.stringify(_data_primary))
|
|
// this.httpOverallSearchData.moreList = JSON.parse(JSON.stringify(_data_moreList))
|
|
// this.pagingCallback()
|
|
// }).catch(err => {
|
|
// this.Loading.tableLoading = false
|
|
// })
|
|
},
|
|
// 全面筛选所有按钮操作集 20230215
|
|
overallSearchFormClick(options){
|
|
let _item = options.item;
|
|
// 普通搜索 + 高级搜索 + 普通重置 + 高级重置
|
|
if(
|
|
_item.name == 'search' || _item.name == 'moreList-search' ||
|
|
_item.name == 'reset' || _item.name == 'moreList-reset'
|
|
){
|
|
this.overallSearchGetPageHandle(options)
|
|
}
|
|
},
|
|
|
|
// 以下为旧版,暂时保留(使用conditionFilters组件)
|
|
//筛选(旧版,使用conditionFilters组件)
|
|
screenFormClick(val) {
|
|
if (val[0] == 0) {
|
|
this.PageListParams.condition.filters = []
|
|
this.oldSkipCount = 1
|
|
this.paging()
|
|
this.displayDialog.screenDialog = false;
|
|
} else if (val[0] == 1) {
|
|
val[1].clearValidate()
|
|
this.displayDialog.screenDialog = false;
|
|
} else {
|
|
val[1].validate((valid) => {
|
|
if (valid) {
|
|
this.PageListParams.condition.filters = []
|
|
// for (let item in this.screenData.filters) {
|
|
this.PageListParams.condition.filters.push(...this.screenData.filters)
|
|
// }
|
|
this.oldSkipCount = 1
|
|
this.paging()
|
|
this.displayDialog.screenDialog = false;
|
|
} else {
|
|
this.$errorMsg('请按照提示继续操作')
|
|
return false;
|
|
}
|
|
});
|
|
}
|
|
},
|
|
//添加筛选条件(旧版,使用conditionFilters组件)
|
|
screenPush() {
|
|
let data = {
|
|
logic: "And",
|
|
column: "",
|
|
action: "==",
|
|
value: ""
|
|
}
|
|
// if (this.screenData.filters.length <= this.tableColumns.length) {
|
|
this.screenData.filters.push(data)
|
|
// } else {
|
|
// this.$errorMsg('筛选条件数不足!')
|
|
// }
|
|
},
|
|
//删除筛选条件(旧版,使用conditionFilters组件)
|
|
screenDelete(val) {
|
|
if (this.screenData.filters.length == 1) {
|
|
this.$warningMsg('必须保留一条筛选条件!')
|
|
} else {
|
|
this.modalAppendToBody = true
|
|
this.$confirm('您确定删除吗, 是否继续?', '提示', {
|
|
confirmButtonText: '确定',
|
|
cancelButtonText: '取消',
|
|
type: 'warning'
|
|
}).then(() => {
|
|
this.screenData.filters.splice(val, 1)
|
|
// this.modalAppendToBody = false
|
|
}).catch(() => {
|
|
// this.modalAppendToBody = false
|
|
});
|
|
}
|
|
},
|
|
// 表头字段设置
|
|
rowDrop(data) {
|
|
this.tableColumns = data
|
|
}
|
|
}
|
|
}
|
|
|