import { getPageList, postExport, } from "@/api/wms-api" export const TableHeaderMixins = { data() { return { //筛选(旧版,使用conditionFilters组件) screenData: { filters: [{ logic: "", column: "", action: "", value: "" }] }, // 是否添加到body中,(旧版,使用conditionFilters组件) modalAppendToBody: false, //新增/编辑预览数据 previewFormData: {}, // 全面搜索:当前列表数据请求接口的筛选条件 httpOverallSearchData:null, filterForDetailShow:false,//明细筛选弹窗页面显隐控制 } }, methods: { // 关闭导出弹窗 closeExportDrop(){ this.displayDialog.exportDialog = false }, // 关闭主表新增编辑api closeAddEditApiPop(){ this.addEditApiType = null this.editFromApiRowData = null this.displayDialog.addEditApiDialog = false }, // 导出功能 exportDropSubmit(type,form){ const name = this.$route.meta.title let _params = { isRedundance:Boolean(form.isRedundance), isDetailExport:Boolean(form.isDetail), userId:this.$store.getters.currentUserInfo.id } let _exportUrl = this.URLOption_export ? this.URLOption_export : this.URLOption_base; let _special = this.URLOption_export ? true : false let _data = JSON.parse(JSON.stringify(this.PageListParams)) // 全部导出处理 if(type && type == 'all'){ _data.MaxResultCount = this.totalCount} this.closeExportDrop() this.Loading.appMainLoading = true postExport(_params,_data, _exportUrl, _special).then(res => { this.blob(res, name)//使用前端导出名称 this.Loading.appMainLoading = false }).catch(err => { this.Loading.appMainLoading = false }) }, // 点击常用按钮 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; } // Api新增(参数配置从api获取) else if (val == 'addFromApi') { this.addEditApiType = 'add' this.displayDialog.addEditApiDialog = 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') { this.displayDialog.exportDialog = true } // 导入 else if (val == 'import') { this.displayDialog.importDialog = true } // 明细筛选按钮 else if (val == 'filterForDetail'){ this.changeFilterForDetailShow(true) } // 自定义按钮 // 批量打印 ; 不合格转合格 else if(val == 'custom'){ item.customHandle() } }, // 明细筛选弹窗页面显隐控制 changeFilterForDetailShow(data){ this.filterForDetailShow = data }, // 快速搜索按钮 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.URLOption_base).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.URLOption_base).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 }); } }, /** * 表头字段设置 * @param {*} data 数据 * @param {*} type 设置来源 * list_api: 表头来自api的列表 detail_api: 表头来自api列表的明细 detailPage_api表头来自api的明细页面列表 * list: 表头固定的列表 detail: 表头固定列表的明细 */ rowDrop(data,type) { if(!type || type == 'list_api'){ this.apiColumns_Table = data } if(type && type == 'detail_api'){ this.apiColumns_DetailsTable = data } // if(type && type == 'detailPage_api'){ this.apiColumns_DetailsPage = data } if(type && type == 'list'){ this.tableColumns = data } if(type && type == 'detail'){ this.detailsTableColumns = data } } } }