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.
274 lines
10 KiB
274 lines
10 KiB
import {
|
|
postImportDown,
|
|
postImport,
|
|
} from '@/api/wms-api'
|
|
import * as allUrlOption from '@/utils/baseData/urlOption'
|
|
import { getLoginName } from "@/utils/auth"
|
|
|
|
export const mixins = {
|
|
data() {
|
|
return {
|
|
allUrlOption:allUrlOption,
|
|
// 当前路由配置
|
|
URLOption:allUrlOption[this.$route.name],
|
|
//主表-列表
|
|
URLOption_base:allUrlOption[this.$route.name].baseURL,
|
|
//主表-明细
|
|
URLOption_detail:allUrlOption[this.$route.name].detailURL,
|
|
//明细-列表
|
|
URLOption_detailList:allUrlOption[this.$route.name].detailListURL,
|
|
// 导出
|
|
URLOption_export:allUrlOption[this.$route.name].exportURL,
|
|
// 新增
|
|
URLOption_add:allUrlOption[this.$route.name].addURL,
|
|
// 编辑
|
|
URLOption_edit:allUrlOption[this.$route.name].editURL,
|
|
//明细-查看主表
|
|
URLOption_parent:allUrlOption[this.$route.name].parentURL ? allUrlOption[this.$route.name].parentURL : allUrlOption[this.$route.name].detailURL,
|
|
//明细-查看主表的连接id
|
|
URLOption_masterId:allUrlOption[this.$route.name].masterId || allUrlOption.defalutMasterId || 'masterId',
|
|
//明细-查看主表的连接title名称
|
|
URLOption_masterName:allUrlOption[this.$route.name].masterName,
|
|
// 列表-明细-查看详情标题名称
|
|
URLOption_detailInfoName:allUrlOption[this.$route.name].detailInfoName,
|
|
|
|
//Dialog标题
|
|
formTitle: "",
|
|
editOptions: {
|
|
options: [], //autoComplete显示数据|| select显示数据(拉取)
|
|
// whetherOrNot: this.$staticOptions.WhetherOrNot(),
|
|
// whetherOrNot: this.$staticOptions.WhetherOrNot(),
|
|
// QtyUom: this.$staticOptions.QtyUom(),
|
|
},
|
|
//表头 从本地缓存获取字段设置,如果没有,从js中获取 todo:优化数据
|
|
tableColumns: this.initTableColumns(),
|
|
//明细表头数据
|
|
detailsTableColumns: this.$isDetailsTableColumns[this.$route.name],
|
|
//明细表头数据——汇总
|
|
summaryTableColumns: this.$isSummaryTableColumns[this.$route.name],
|
|
|
|
//详情数据
|
|
tabsDesTions: this.$isTabsDesTions[this.$route.name],
|
|
|
|
// 主表查询-快速搜索数据配置
|
|
quicklySearchOption: this.$isQuicklySearchOption[this.$route.name],
|
|
|
|
// 主表查询-初级搜索数据配置
|
|
primarySearchOption: this.$isPrimarySearchOption[this.$route.name],
|
|
|
|
//当前操作
|
|
theEvent: "",
|
|
editHandle: [{
|
|
label: "取消",
|
|
name: "cancel"
|
|
},
|
|
{
|
|
label: "确定",
|
|
type: "primary",
|
|
name: "determine"
|
|
},
|
|
],
|
|
addEditApiType: null,//Api新增编辑方式(add,edit)
|
|
editFromApiRowData:null,//Api编辑方式的默认值
|
|
}
|
|
},
|
|
methods: {
|
|
// 结合默认及缓存中的列表tableColumns数据做初始化
|
|
initTableColumns(columnsData,type){
|
|
let _list_defalut = columnsData ? columnsData : this.$isTableColumns[this.$route.name]
|
|
let _type = type ? type : 'list_api'
|
|
if(!_list_defalut)return
|
|
let _local = localStorage.getItem('file_Columns_' + _type + '_' + getLoginName() + '_' + this.$route.name)
|
|
let _list_local = JSON.parse(localStorage.getItem('file_Columns_' + _type + '_' + getLoginName() + '_' + this.$route.name))
|
|
let _new_list = [] //格式化后的数据
|
|
// 如果没有缓存则直接为默认值
|
|
if(!_local){
|
|
_list_defalut.forEach((defalutItem,index) => {
|
|
defalutItem.istrue = true
|
|
_new_list.push(defalutItem)
|
|
})
|
|
}
|
|
// 如果有缓存:默认中已经删除掉的,本地中缓存中也不显示,新增字段,缓存中也显示(默认为眼睛关闭)
|
|
else{
|
|
// 先处理缓存数据,设置索引
|
|
let _locals = {}
|
|
if(_list_local){
|
|
_list_local.forEach((localItem,index) => {
|
|
localItem.itemIndex = index
|
|
if(localItem.showProp && typeof localItem.showProp == 'string'){
|
|
_locals[localItem.showProp] = localItem
|
|
}else{
|
|
_locals[localItem.prop] = localItem
|
|
}
|
|
})
|
|
}
|
|
// 将缓存与默认设置合并,索引同步
|
|
let _number = 0
|
|
_list_defalut.forEach((defalutItem) => {
|
|
if(_locals[defalutItem.showProp]){
|
|
defalutItem.istrue = _locals[defalutItem.showProp].istrue
|
|
defalutItem.itemIndex = _locals[defalutItem.showProp].itemIndex
|
|
}else if(_locals[defalutItem.prop]){
|
|
defalutItem.istrue = _locals[defalutItem.prop].istrue
|
|
defalutItem.itemIndex = _locals[defalutItem.prop].itemIndex
|
|
}else{
|
|
defalutItem.istrue = false
|
|
defalutItem.itemIndex = _number
|
|
}
|
|
_number ++
|
|
_new_list.push(defalutItem)
|
|
})
|
|
// 按索引排序
|
|
function compare(property) {
|
|
return function (a, b) {
|
|
var value1 = a[property];
|
|
var value2 = b[property];
|
|
return value1 - value2;
|
|
}
|
|
}
|
|
_new_list.sort(compare("itemIndex"))
|
|
}
|
|
return _new_list
|
|
},
|
|
//添加子表
|
|
openAddNew() {
|
|
let data = JSON.parse(JSON.stringify(...this.childTableData))
|
|
if (data.number != undefined) { //判断是否有number字段
|
|
data.number = this.CreateFormData.number
|
|
}
|
|
if (this.formReveal) {
|
|
this.CreateFormData.details.push(data)
|
|
} else {
|
|
// data.poLine = Number(this.editFormData.details[this.editFormData.details.length - 1].poLine) + 1
|
|
this.editFormData.details.push(data)
|
|
}
|
|
// this.displayDialog.AddNewDialog = true
|
|
},
|
|
//步骤新增OR编辑结束退出
|
|
stepsClose(val) {
|
|
// this.FormRemove(val[0]);
|
|
this.CreateFormData = val[0]
|
|
if (val[1] == 1) {
|
|
this.oldSkipCount = 1;
|
|
this.paging();
|
|
}
|
|
this.displayDialog.newDialog = false;
|
|
},
|
|
//步骤新增OR编辑第一步
|
|
stepsHandelOne() {
|
|
return new Promise((resolve, reject) => {
|
|
resolve()
|
|
})
|
|
},
|
|
//导出存储-新
|
|
blob(res, fileName) {
|
|
let blob = new Blob([res], {
|
|
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8',
|
|
})
|
|
const href = URL.createObjectURL(blob) //创建新的URL表示指定的blob对象
|
|
const a = document.createElement('a') //创建a标签
|
|
a.style.display = 'none'
|
|
a.href = href // 指定下载链接
|
|
a.download = fileName //指定下载文件名
|
|
a.click() //触发下载
|
|
URL.revokeObjectURL(a.href) //释放URL对象
|
|
},
|
|
//导入文件-新
|
|
postImportMergeClick(val) {
|
|
let that = this
|
|
let menuName = this.$route.meta.title
|
|
if (val[0][0] == 0) {
|
|
that.FormRemove(val[0]);
|
|
that.displayDialog.importDialog = false;
|
|
} else {
|
|
val[0][1].validate((valid) => {
|
|
if (valid) {
|
|
that.Loading.importLoading = true;
|
|
let {
|
|
formFile
|
|
} = val[1]
|
|
|
|
// 特殊导入接口判断
|
|
let _uploadURL = that.importUploadURL || that.URLOption_base
|
|
let _isSpecial = that.importUploadURL ? true : false
|
|
|
|
let fd = new FormData();
|
|
fd.append("fileType", 1) //文件类型 固定1
|
|
let methodVal = ''
|
|
if (val[1].method == '0') {
|
|
methodVal = 'Update'
|
|
} else if (val[1].method == '1') {
|
|
methodVal = 'Append'
|
|
} else if (val[1].method == '2') {
|
|
methodVal = 'Replace'
|
|
}
|
|
fd.append("method", methodVal) //导入方式 0 更新 1 追加 2 覆盖
|
|
fd.append("isAllowPartImport", val[1].isAllowPartImport=='0'?true:false) //是否部分错误导入
|
|
fd.append("route", _isSpecial ? _uploadURL : _uploadURL + '/import') //路由
|
|
fd.append("function", menuName) //菜单名
|
|
fd.append("blobName", menuName)
|
|
fd.append("file", formFile[0])
|
|
|
|
postImport(fd, _uploadURL, _isSpecial).then(res => {
|
|
const headers = JSON.parse(res.headers)
|
|
// 判断是否有错误记录
|
|
if (headers.result.ErrorNum > 0) {
|
|
that.$alert('发现导入错误数据共:' + headers.result.ErrorNum + '条', '错误报告', {
|
|
confirmButtonText: '下载错误报告',
|
|
callback: action => {
|
|
if (action == 'confirm') {
|
|
that.blob(res, menuName + '错误报告')
|
|
}
|
|
}
|
|
})
|
|
} else if (headers.result.ExceptionMessage != null) {
|
|
that.$alert('错误信息:' + headers.result.ExceptionMessage, '错误', {
|
|
confirmButtonText: '确定',
|
|
callback: action => {
|
|
}
|
|
})
|
|
} else {
|
|
that.$alert('全部导入成功,是否下载导入报告', '导入报告', {
|
|
confirmButtonText: '下载导入报告',
|
|
cancelButtonText: '取消',
|
|
callback: action => {
|
|
if (action == 'confirm') {
|
|
that.blob(res, menuName + '导入报告')
|
|
}
|
|
}
|
|
})
|
|
}
|
|
that.Loading.importLoading = false
|
|
that.FormRemove(val[0]);
|
|
that.displayDialog.importDialog = false;
|
|
that.paging()
|
|
}).catch(err => {
|
|
console.log('请联系管理员',err)
|
|
that.$errorMsg('导入过程中发生错误!请联系管理员!')
|
|
that.Loading.importLoading = false
|
|
that.FormRemove(val[0]);
|
|
that.displayDialog.importDialog = false;
|
|
that.paging()
|
|
})
|
|
} else {
|
|
that.$errorMsg('请按照提示继续操作')
|
|
that.displayDialog.importDialog = false;
|
|
return false;
|
|
}
|
|
});
|
|
}
|
|
},
|
|
//导入模板下载
|
|
importDown(url) {
|
|
let _url = url ? url : this.URLOption_base
|
|
postImportDown(_url).then(res => {
|
|
let menuName = this.$route.meta.title
|
|
this.blob(res,menuName + '导入模板')
|
|
})
|
|
},
|
|
//重置表单
|
|
FormRemove(val) {
|
|
val[1].resetFields();
|
|
},
|
|
}
|
|
}
|