Commit 2e4f3489 authored by renjintao's avatar renjintao

process

parent 9eddae69
......@@ -135,16 +135,40 @@ export default {
},
columns1() {
let col1 = [{
key: "userName",
title: this.l("userName"),
key: "name",
title: this.l1("name"),
align: "left",
},
{
key: "status",
title: this.l("status"),
align: "center",
code: "User.base.status",
key: "parent_Id",
title: this.l1("parent_Id"),
align: "left",
hide: true,
parentDepart: true,
import: true,
},
{
key: "code",
title: this.l1("code"),
align: "left",
},
{
key: "location",
title: this.l1("location"),
align: "left",
location: true,
import: true,
},
{
key: "property",
title: this.l1("property"),
align: "left",
code: "department.property",
},
{
key: "creationTime",
title: this.l1("creationTime"),
align: "left",
},
]
return col1
......@@ -629,6 +653,10 @@ export default {
key = "user" + "." + key;
return i18n.t(key);
},
l1(key) {
key = "DipartLocation" + "." + key;
return i18n.t(key);
},
l2(key) {
key = "resource" + "." + key;
return i18n.t(key);
......@@ -645,8 +673,7 @@ export default {
key = "product_info" + "." + key;
return i18n.t(key);
},
test()
{
ViewUI.Message.error("terterer")
test() {
ViewUI.Message.error("terterer")
}
}
\ No newline at end of file
<template>
<div class="table-contentProcess">
<div class="table-contentProcess">
<div class="table-tools">
<div class="table-search">
<Form inline>
<FormItem>
<span>导入到</span>
</FormItem>
<FormItem>
<dictionary
code="import.im.page"
style="width:160px"
@on-change="pageChange"
v-model="pageType"
></dictionary>
</FormItem>
<FormItem>
<Button type="primary" @click="openInfoModal" :disabled="btnIm">导入</Button>
</FormItem>
<FormItem>
<div style="height:34px;overflow: hidden;padding:0">
<Upload action :before-upload="beforeUpload" ref="uploadfile" :format="formatList">
<Button icon="ios-cloud-upload-outline" @click="resetParms">重新上传</Button>
</Upload>
</div>
</FormItem>
</Form>
</div>
<div class="btns">
<Form inline>
<FormItem>
<Tooltip content="下载文件">
<a @click="downFile" tooltip="1111">
<Icon type="md-download" />
{{entity.file}}
</a>
</Tooltip>
</FormItem>
<FormItem>
<Tooltip content="预览文件">
<a class="ml10 mr10" @click="resetTable">
<Icon type="md-eye" />预览
</a>
</Tooltip>
</FormItem>
<FormItem>
<RadioGroup v-model="excelType" type="button" @on-change="changeExcel" size="small">
<Tooltip content="文件数据">
<Radio label="0">
<Icon type="ios-list-box-outline" />
</Radio>
</Tooltip>
<Tooltip content="粘贴Excel数据">
<Radio label="1">
<Icon type="ios-copy" />
</Radio>
</Tooltip>
</RadioGroup>
</FormItem>
</Form>
</div>
<div class="table-search">
<Form inline>
<FormItem>
<span>导入到</span>
</FormItem>
<FormItem>
<dictionary code="import.im.page" style="width:160px" @on-change="pageChange" v-model="pageType"></dictionary>
</FormItem>
<FormItem>
<Button type="primary" @click="openInfoModal" :disabled="btnIm">导入</Button>
</FormItem>
<FormItem>
<div style="height:34px;overflow: hidden;padding:0">
<Upload action :before-upload="beforeUpload" ref="uploadfile" :format="formatList">
<Button icon="ios-cloud-upload-outline" @click="resetParms">重新上传</Button>
</Upload>
</div>
</FormItem>
</Form>
</div>
<div class="btns">
<Form inline>
<FormItem>
<Tooltip content="下载文件">
<a @click="downFile" tooltip="1111">
<Icon type="md-download" />
{{entity.file}}
</a>
</Tooltip>
</FormItem>
<FormItem>
<Tooltip content="预览文件">
<a class="ml10 mr10" @click="resetTable">
<Icon type="md-eye" />预览
</a>
</Tooltip>
</FormItem>
<FormItem>
<RadioGroup v-model="excelType" type="button" @on-change="changeExcel" size="small">
<Tooltip content="文件数据">
<Radio label="0">
<Icon type="ios-list-box-outline" />
</Radio>
</Tooltip>
<Tooltip content="粘贴Excel数据">
<Radio label="1">
<Icon type="ios-copy" />
</Radio>
</Tooltip>
</RadioGroup>
</FormItem>
</Form>
</div>
</div>
<div class="table-main" ref="main">
<Table
:border="true"
:columns="columnsImport"
:data="excelData"
:height="tdHeightExcel"
:no-data-text="noDataText"
ref="table"
class="tableCommon"
v-if="tableImport"
></Table>
<component :is="detailExcel" ref="comExcel" @on-datalength="datalength" />
<Table :border="true" :columns="columnsImport" :data="excelData" :height="tdHeightExcel" :no-data-text="noDataText" ref="table" class="tableCommon" v-if="tableImport"></Table>
<component :is="detailExcel" ref="comExcel" @on-datalength="datalength" />
</div>
<FooterToolbar v-if="sheetNames.length>1&&tableImport">
<Form inline>
<FormItem>
<Tabs :animated="false" :value="0" @on-click="sheetClick">
<TabPane :label="item" v-for="(item,index) in sheetNames" :key="index"></TabPane>
</Tabs>
</FormItem>
</Form>
<Form inline>
<FormItem>
<Tabs :animated="false" :value="0" @on-click="sheetClick">
<TabPane :label="item" v-for="(item,index) in sheetNames" :key="index"></TabPane>
</Tabs>
</FormItem>
</Form>
</FooterToolbar>
<Modal v-model="infoModal" :title="titleInfo" fullscreen>
<DataGrid
:tool="false"
:page="false"
:columns="colsIm"
:data="dataIm"
:height="tdHeightExcel+30"
ref="dataImport"
></DataGrid>
<div slot="footer">
<Button @click="infoModal=false">关闭</Button>
<Button type="primary" @click="importOk" v-show="imBtn">确定导入</Button>
</div>
<DataGrid :tool="false" :page="false" :columns="colsIm" :data="dataIm" :height="tdHeightExcel+30" ref="dataImport"></DataGrid>
<div slot="footer">
<Button @click="infoModal=false">关闭</Button>
<Button type="primary" @click="importOk" v-show="imBtn">确定导入</Button>
</div>
</Modal>
</div>
</div>
</template>
<script>
import Api from "./api";
import BaseColums from "./baseColums";
import XLSX from "xlsx";
import { Switch } from "view-design";
import {
Switch
} from "view-design";
export default {
name: "Edit",
data() {
return {
pageType: undefined,
tabVal: 0,
infoModal: false,
entity: {},
downUrl: fileUrlDown,
fileUrlPath: "",
disabled: false,
detailExcel: null,
tableImport: true,
tdHeightExcel: "",
excelData: [],
excelDataBack: [], //临时存储原始数据
formatList: ["xlsx"],
columnsImport: [],
departArr: [], //部门list
sheetNames: [], //excel的表明
workBook: {},
openDatas: [],
dataType: 0,
//new
colsIm: [],
dataIm: [],
excelType: "0",
btnIm: true,
listLength: 0,
titleInfo: "",
noDataText: "暂无数据",
imBtn: true,
//物料管理
treeData: [], //物料管理左侧类别树
codeRuleData: [], //物料编码等信息
routingHeaderData: [], //工艺规程列表信息
};
},
props: {
eid: Number,
},
created() {
this.tdHeightExcel = window.innerHeight - 180;
//导出对列表头进行预加载start
this.$api.get(`${systemUrl}/Department/GetDepartments`).then((r) => {
this.departArr = r.result.items;
});
//导出对列表头进行预加载end
},
mounted() {
if (this.eid > 0) {
this.load(this.eid);
}
//物料加载类型数据
this.getTreeData();
this.getcodeRuleData();
//获取工艺规程信息
this.getRoutingHeaderData();
window.onresize = () => {
///浏览器窗口大小变化
return (() => {
window.screenHeight = window.innerHeight;
this.tdHeightExcel = window.screenHeight - 180;
})();
};
},
methods: {
load(v) {
Api.get({
id: v,
}).then((r) => {
this.entity = r.result || {};
});
this.dataType = 0;
this.sheetNames = [];
this.excelData = [];
this.excelDataBack = [];
Api.openExcel({
id: v,
})
.then((res) => {
if (res.success) {
this.openDatas = res.result || [];
this.dealOpenTable(0);
//获取excel sheetname
if (res.result.length > 0) {
res.result.forEach((el) => {
this.sheetNames.push(el.title);
});
}
}
})
.catch((e) => {
this.noDataText =
"文件无法解析,建议下载原文件后转换为Excel文件格式重新上传!";
});
name: "Edit",
data() {
return {
pageType: undefined,
tabVal: 0,
infoModal: false,
entity: {},
downUrl: fileUrlDown,
fileUrlPath: "",
disabled: false,
detailExcel: null,
tableImport: true,
tdHeightExcel: "",
excelData: [],
excelDataBack: [], //临时存储原始数据
formatList: ["xlsx"],
columnsImport: [],
departArr: [], //部门list
sheetNames: [], //excel的表明
workBook: {},
openDatas: [],
dataType: 0,
//new
colsIm: [],
dataIm: [],
excelType: "0",
btnIm: true,
listLength: 0,
titleInfo: "",
noDataText: "暂无数据",
imBtn: true,
//物料管理
treeData: [], //物料管理左侧类别树
codeRuleData: [], //物料编码等信息
routingHeaderData: [], //工艺规程列表信息
};
},
//加载原文件列表
dealOpenTable(val) {
this.excelData = this.openDatas[val].dataTable;
this.excelDataBack = this.openDatas[val].dataTable;
this.listLength = this.excelData.length;
var tempCos = Object.keys(this.openDatas[val].dataTable[0]); //获取列表标题
this.columnsImport = [];
var headersNow = [];
headersNow.push({
type: "index",
width: 80,
align: "right",
title: "序号",
});
tempCos.forEach((el) => {
let headObj = {};
headObj.title = el;
headObj.key = el;
headersNow.push(headObj);
});
this.columnsImport = headersNow;
props: {
eid: Number,
},
//重新处理colum
loadColum(columns) {
let tempCol = this.$u.clone(columns);
tempCol.unshift({
type: "index",
width: 80,
align: "right",
title: "序号",
});
tempCol.forEach((ele, index) => {
if (ele.key == "action") {
ele.hide = true;
}
});
this.colsIm = tempCol;
//处理原始数据和表头进行对应
let temCol = this.$u.clone(this.colsIm); //原始数据表头
let temColPage = this.$u.clone(columns); //需要显示的页面的表头
//let temData = this.$u.clone(this.excelDataBack); //原始数据
let temData = []; //原始数据
if (this.excelType == "0") {
temData = this.$u.clone(this.excelDataBack);
} else {
temData = this.$u.clone(this.$refs.comExcel.excelData);
}
let arrTitleUse = []; //使用数据字典的字段
let arrTitleUse1 = []; //使用物料编码的字段
temColPage.forEach((elCode) => {
if (elCode.code) {
arrTitleUse.push({
key: elCode.key,
code: elCode.code,
});
}
if (elCode.materialKey) {
//临时存放物料管理大类和子类列表
arrTitleUse1.push({
key: elCode.key,
code: elCode.materialKey,
});
}
});
let useData = []; //重新组织list列表数据
temData.forEach((elData, index) => {
let objTm = {};
temCol.forEach((elTitle) => {
objTm[elTitle.key] = elData[elTitle.title];
created() {
this.tdHeightExcel = window.innerHeight - 180;
//导出对列表头进行预加载start
this.$api.get(`${systemUrl}/Department/GetDepartments`).then((r) => {
this.departArr = r.result.items;
});
useData.push(objTm);
});
//对列表里的部门及数据字典项进行处理
useData.forEach((eles) => {
//如果导入文件没有departmentid,但存在departmentTitle的话,通过title获取id
if (
[
(eles.departmentTitle && eles.departmentTitle != "") ||
(eles.departmentName && eles.departmentName != ""),
] &&
(!eles.departmentId || eles.departmentId == "")
) {
this.departArr.forEach((e) => {
if (
(eles.departmentTitle && eles.departmentTitle == e.name) ||
(eles.departmentName && eles.departmentName == e.name)
) {
eles.departmentId = e.id;
}
});
} else if (
//如果导入文件没有departmentTitle,但存在departmentid的话,通过id获取departmentTitle
eles.departmentId &&
eles.departmentId + "" != "" &&
(!eles.departmentTitle || eles.departmentTitle == "") &&
(!eles.departmentName || eles.departmentName == "")
) {
this.departArr.forEach((e) => {
if (eles.departmentId && eles.departmentId == e.id) {
eles.departmentTitle = e.name;
eles.departmentName = e.name;
}
});
}
arrTitleUse.forEach((elem) => {
if (
eles[elem.key] &&
eles[elem.key] != "" &&
eles[elem.key] != null
) {
//如果数据字典项对应的DirName字段存在,通过name查询到对应的code,然后赋值
eles[elem.key] = this.$u.dirCode(
this.$store.getters.dictionaryByKey(elem.code),
eles[elem.key]
);
}
});
});
this.dataIm = useData;
//导出对列表头进行预加载end
},
//下载原excel文件
downFile() {
let truePath = this.entity.path;
if (truePath.length > 2) {
if (
truePath.substring(0, 7).toLowerCase() == "http://" ||
truePath.substring(0, 8).toLowerCase() == "https://"
) {
window.open(truePath, "_blank");
} else {
this.fileUrlPath = this.downUrl + this.entity.path;
window.open(this.fileUrlPath, "_blank");
mounted() {
if (this.eid > 0) {
this.load(this.eid);
}
}
},
//导入excel文件
//打开传时初始化
resetParms() {
this.pageType = undefined;
this.tdHeightExcel = window.innerHeight - 180;
},
async beforeUpload(file) {
//初始化
this.sheetNames = [];
this.workBook = {};
this.$refs.uploadfile.clearFiles(); //清除上一次上传文件列表
//上传成功后的读取到excel信息
this.workBook = await this.$u.readXLSX(file);
this.sheetNames = this.workBook.SheetNames; //execel里的表明
this.dealSheet(0); //默认显示第一个表
return false;
//物料加载类型数据
this.getTreeData();
this.getcodeRuleData();
//获取工艺规程信息
this.getRoutingHeaderData();
window.onresize = () => {
///浏览器窗口大小变化
return (() => {
window.screenHeight = window.innerHeight;
this.tdHeightExcel = window.screenHeight - 180;
})();
};
},
//对上传的excel表信息进行处理,不对表头进行处理
dealSheet(index) {
this.dataType = 1;
this.columnsImport = [];
this.excelData = [];
this.excelDataBack = [];
const sheet2JSONOpts = {
defval: "", //给defval赋值为空的字符串
};
var csv = XLSX.utils.sheet_to_csv(
this.workBook.Sheets[this.workBook.SheetNames[index]],
sheet2JSONOpts
);
methods: {
load(v) {
Api.get({
id: v,
}).then((r) => {
this.entity = r.result || {};
});
this.dataType = 0;
this.sheetNames = [];
this.excelData = [];
this.excelDataBack = [];
var lines = csv.split("\n"); //第一行标题
var headers = lines[0].split(",");
var headersNow = [];
headersNow.push({
type: "index",
width: 80,
align: "right",
title: "序号",
});
headers.forEach((elHead) => {
let headObj = {};
headObj.title = elHead;
headObj.key = elHead;
headersNow.push(headObj);
});
this.columnsImport = headersNow;
var result = [];
for (var i = 1; i < lines.length - 1; i++) {
var obj = {};
var currentline = lines[i].split(",");
for (var j = 0; j < headers.length; j++) {
obj[headers[j]] = currentline[j];
}
result.push(obj);
}
this.excelData = result;
this.excelDataBack = result;
this.changeExcel(0);
},
//切换sheet表重新加载
sheetClick(val) {
this.tabVal = val;
if (this.dataType == 0) {
this.dealOpenTable(val);
} else {
this.dealSheet(val);
}
if (this.pageType != undefined) {
this.pageChange(this.pageType);
}
},
//选择导入的模块 0:用户管理
pageChange(val) {
this.btnIm = false;
if (val == undefined) {
this.btnIm = true;
} else {
this.btnIm = false;
}
},
handleClose() {
this.$emit("on-close");
},
cancelExcel() {
this.excelData = [];
this.excelDataBack = [];
this.$refs.uploadfile.clearFiles();
let parms = {
status: 1,
id: this.eid,
};
//导入中心列表数据状态更新
Api.updateimportstatus(parms).then((res) => {
if (res.success) {
this.$emit("on-ok");
}
});
this.$emit("on-close");
},
Api.openExcel({
id: v,
})
.then((res) => {
if (res.success) {
this.openDatas = res.result || [];
this.dealOpenTable(0);
//获取excel sheetname
if (res.result.length > 0) {
res.result.forEach((el) => {
this.sheetNames.push(el.title);
});
}
}
})
.catch((e) => {
this.noDataText =
"文件无法解析,建议下载原文件后转换为Excel文件格式重新上传!";
});
},
//加载原文件列表
dealOpenTable(val) {
this.excelData = this.openDatas[val].dataTable;
this.excelDataBack = this.openDatas[val].dataTable;
this.listLength = this.excelData.length;
var tempCos = Object.keys(this.openDatas[val].dataTable[0]); //获取列表标题
this.columnsImport = [];
var headersNow = [];
headersNow.push({
type: "index",
width: 80,
align: "right",
title: "序号",
});
tempCos.forEach((el) => {
let headObj = {};
headObj.title = el;
headObj.key = el;
headersNow.push(headObj);
});
this.columnsImport = headersNow;
},
//重新处理colum
loadColum(columns) {
let tempCol = this.$u.clone(columns);
tempCol.unshift({
type: "index",
width: 80,
align: "right",
title: "序号",
});
tempCol.forEach((ele, index) => {
if (ele.key == "action") {
ele.hide = true;
}
});
this.colsIm = tempCol;
//重新加载excel
resetTable() {
this.pageType = undefined;
this.load(this.eid);
this.tdHeightExcel = window.innerHeight - 180;
if (this.excelType == 1) {
this.changeExcel(0);
}
},
//打开导入数据格式化后的窗口
openInfoModal() {
if (this.excelData.length > 0 && this.pageType != undefined) {
this.imBtn = true;
switch (this.pageType) {
case 0:
this.loadColum(BaseColums.columns0());
break;
case 1:
this.loadColum(BaseColums.columns1());
break;
case 2:
this.loadColum(BaseColums.columns2());
break;
case 3:
this.loadColum(BaseColums.columns3());
break;
case 4:
this.loadColum(BaseColums.columns4());
break;
case 5:
this.loadColum(BaseColums.columns5());
break;
case 6:
this.loadColum(BaseColums.columns6());
break;
default:
this.loadColum(BaseColums.columns0());
}
this.titleInfo =
"批量导入到 【" +
this.$u.dirName(
this.$store.getters.dictionaryByKey("import.im.page"),
this.pageType
) +
"】 模块";
this.infoModal = true;
} else {
this.imBtn = true;
if (this.excelData.length == 0) {
this.$Message.error(
"表【" + this.sheetNames[this.tabVal] + "】没有可导入的数据!"
);
} else if (this.pageType == undefined) {
this.$Message.error("请选择需要批量导入到的模块!");
}
}
},
//导入按钮操作
importOk() {
switch (this.pageType) {
case 0:
this.importUser();
break;
case 2:
this.importResource();
break;
case 3:
this.importMateriel();
break;
case 4:
this.importRountingHeader();
break;
case 5:
this.importRountingBom();
break;
case 6:
this.importProductMix();
break;
default:
//this.loadColum(this.columns1);
}
},
//批量导入用户
importUser() {
let tempData = this.$u.clone(this.dataIm);
let tempList = [];
tempData.forEach((ele) => {
let obj = {
userName: ele.userName,
cardNo: ele.cardNo,
gender: ele.gender,
birthday: ele.birthday,
degreeId: ele.degreeId,
departmentId: ele.departmentId,
status: ele.status,
phone: ele.phone,
email: ele.email,
licensedToWork: ele.licensedToWork,
positionId: ele.positionId,
titleId: ele.titleId,
departmentTitle: ele.departmentTitle,
};
if (
ele.userName &&
ele.userName != "" &&
ele.cardNo &&
ele.cardNo != "" &&
ele.departmentId &&
ele.departmentId != "" &&
ele.phone &&
ele.phone != ""
) {
tempList.push(obj);
}
});
if (tempList.length == 0) {
this.$Message.error("所有导入的数据均不合法!");
} else {
let parms = {
list: tempList,
};
let url = `${systemUrl}/userimportservice/import`;
this.$api.post(url, parms).then((res) => {
if (res.success) {
this.$Message.success(
"成功批量导入用户管理成功模块 " + tempList.length + " 条数据"
//处理原始数据和表头进行对应
let temCol = this.$u.clone(this.colsIm); //原始数据表头
let temColPage = this.$u.clone(columns); //需要显示的页面的表头
//let temData = this.$u.clone(this.excelDataBack); //原始数据
let temData = []; //原始数据
if (this.excelType == "0") {
temData = this.$u.clone(this.excelDataBack);
} else {
temData = this.$u.clone(this.$refs.comExcel.excelData);
}
let arrTitleUse = []; //使用数据字典的字段
let arrTitleUse1 = []; //使用物料编码的字段
temColPage.forEach((elCode) => {
if (elCode.code) {
arrTitleUse.push({
key: elCode.key,
code: elCode.code,
});
}
if (elCode.materialKey) {
//临时存放物料管理大类和子类列表
arrTitleUse1.push({
key: elCode.key,
code: elCode.materialKey,
});
}
});
let useData = []; //重新组织list列表数据
temData.forEach((elData, index) => {
let objTm = {};
temCol.forEach((elTitle) => {
objTm[elTitle.key] = elData[elTitle.title];
});
useData.push(objTm);
});
//对列表里的部门及数据字典项进行处理
useData.forEach((eles) => {
//如果导入文件没有departmentid,但存在departmentTitle的话,通过title获取id
if (
[
(eles.departmentTitle && eles.departmentTitle != "") ||
(eles.departmentName && eles.departmentName != ""),
] &&
(!eles.departmentId || eles.departmentId == "")
) {
this.departArr.forEach((e) => {
if (
(eles.departmentTitle && eles.departmentTitle == e.name) ||
(eles.departmentName && eles.departmentName == e.name)
) {
eles.departmentId = e.id;
}
});
} else if (
//如果导入文件没有departmentTitle,但存在departmentid的话,通过id获取departmentTitle
eles.departmentId &&
eles.departmentId + "" != "" &&
(!eles.departmentTitle || eles.departmentTitle == "") &&
(!eles.departmentName || eles.departmentName == "")
) {
this.departArr.forEach((e) => {
if (eles.departmentId && eles.departmentId == e.id) {
eles.departmentTitle = e.name;
eles.departmentName = e.name;
}
});
}
arrTitleUse.forEach((elem) => {
if (
eles[elem.key] &&
eles[elem.key] != "" &&
eles[elem.key] != null
) {
//如果数据字典项对应的DirName字段存在,通过name查询到对应的code,然后赋值
eles[elem.key] = this.$u.dirCode(
this.$store.getters.dictionaryByKey(elem.code),
eles[elem.key]
);
}
});
});
this.dataIm = useData;
},
//下载原excel文件
downFile() {
let truePath = this.entity.path;
if (truePath.length > 2) {
if (
truePath.substring(0, 7).toLowerCase() == "http://" ||
truePath.substring(0, 8).toLowerCase() == "https://"
) {
window.open(truePath, "_blank");
} else {
this.fileUrlPath = this.downUrl + this.entity.path;
window.open(this.fileUrlPath, "_blank");
}
}
},
//导入excel文件
//打开传时初始化
resetParms() {
this.pageType = undefined;
this.tdHeightExcel = window.innerHeight - 180;
},
async beforeUpload(file) {
//初始化
this.sheetNames = [];
this.workBook = {};
this.$refs.uploadfile.clearFiles(); //清除上一次上传文件列表
//上传成功后的读取到excel信息
this.workBook = await this.$u.readXLSX(file);
this.sheetNames = this.workBook.SheetNames; //execel里的表明
this.dealSheet(0); //默认显示第一个表
return false;
},
//对上传的excel表信息进行处理,不对表头进行处理
dealSheet(index) {
this.dataType = 1;
this.columnsImport = [];
this.excelData = [];
this.excelDataBack = [];
const sheet2JSONOpts = {
defval: "", //给defval赋值为空的字符串
};
var csv = XLSX.utils.sheet_to_csv(
this.workBook.Sheets[this.workBook.SheetNames[index]],
sheet2JSONOpts
);
this.imBtn = false;
this.cancelExcel();
} else {
this.$Message.error("批量导入用户管理失败!");
}
});
}
},
//批量插入制造资源
importResource() {
let tempData = this.$u.clone(this.dataIm);
let tempList = [];
tempData.forEach((ele) => {
let obj = {
nameOfResource: ele.nameOfResource ? ele.nameOfResource : "",
resourceCode: ele.resourceCode ? ele.resourceCode : "",
code: ele.code ? ele.code : "",
totalNum: ele.totalNum ? ele.totalNum : 0,
storeTitle: ele.storeTitle ? ele.storeTitle : "",
storeId: ele.storeId ? ele.storeId : null,
state: 1,
numberAvailable: ele.numberAvailable ? ele.numberAvailable : 0,
json: {},
};
if (
ele.nameOfResource &&
ele.nameOfResource != "" &&
ele.code &&
ele.code != "" &&
ele.resourceCode &&
ele.resourceCode != ""
) {
tempList.push(obj);
}
});
if (tempList.length == 0) {
this.$Message.error("所有导入的数据均不合法!");
} else {
let parms = {
list: tempList,
};
let url = `${resourceUrl}/resourceimportservice/import`;
this.$api
.post(url, parms)
.then((r) => {
if (r.success) {
this.$Message.success(
"成功批量导入制造资源成功模块 " + tempList.length + " 条数据"
);
this.imBtn = false;
this.cancelExcel();
var lines = csv.split("\n"); //第一行标题
var headers = lines[0].split(",");
var headersNow = [];
headersNow.push({
type: "index",
width: 80,
align: "right",
title: "序号",
});
headers.forEach((elHead) => {
let headObj = {};
headObj.title = elHead;
headObj.key = elHead;
headersNow.push(headObj);
});
this.columnsImport = headersNow;
var result = [];
for (var i = 1; i < lines.length - 1; i++) {
var obj = {};
var currentline = lines[i].split(",");
for (var j = 0; j < headers.length; j++) {
obj[headers[j]] = currentline[j];
}
result.push(obj);
}
this.excelData = result;
this.excelDataBack = result;
this.changeExcel(0);
},
//切换sheet表重新加载
sheetClick(val) {
this.tabVal = val;
if (this.dataType == 0) {
this.dealOpenTable(val);
} else {
this.$Message.error("批量导入失败");
this.dealSheet(val);
}
})
.catch((err) => {
this.$Message.error("数据异常!");
});
}
},
//插入物料管理start
importMateriel() {
let tempData = this.$u.clone(this.dataIm);
let tempList = [];
tempData.forEach((ele) => {
let obj = {
name: ele.name ? ele.name : "",
version: ele.version ? Number(ele.version) : "",
drawing: ele.drawing ? ele.drawing : "",
description: ele.description ? ele.description : "",
code: 0,
status: ele.status ? Number(ele.status) : "",
customProperties: {},
categoryId: this.getType2(ele.categoryId)
? this.getType2(ele.categoryId)
: 1, //左侧树点击的id
rootCategoryId: this.getType1(ele.rootCategoryId)
? this.getType1(ele.rootCategoryId)
: 1, //左侧树点击的数据的最顶层id
codeRuleId: this.getType3(ele.codeRuleId)
? this.getType3(ele.codeRuleId)
: 1, //类别编码名称
codeRuleType: ele.codeRuleType ? Number(ele.codeRuleType) : 1, //类别codeType
};
if (
ele.codeRuleId &&
this.getType3(ele.codeRuleId) != "" &&
ele.codeRuleType &&
ele.codeRuleType != "" &&
ele.codeRuleType != null &&
ele.rootCategoryId &&
this.getType1(ele.rootCategoryId) != "" &&
ele.name &&
ele.name != ""
) {
tempList.push(obj);
}
});
if (tempList.length == 0) {
this.$Message.error("所有导入的数据均不合法!");
} else {
let parms = {
list: tempList,
};
let url = `${material}/materialimportservice/import`;
this.$api
.post(url, parms)
.then((r) => {
if (r.success) {
this.$Message.success(
"成功批量导入物料管理模块 " + tempList.length + " 条数据"
);
this.imBtn = false;
this.cancelExcel();
if (this.pageType != undefined) {
this.pageChange(this.pageType);
}
},
//选择导入的模块 0:用户管理
pageChange(val) {
this.btnIm = false;
if (val == undefined) {
this.btnIm = true;
} else {
this.$Message.error("批量导入失败");
this.btnIm = false;
}
})
.catch((err) => {
this.$Message.error("数据异常!");
});
}
},
//物料大类和子类的解析start
getTreeData() {
let data = {
conditions: [],
};
this.$api.post(`${material}/category/list`, data).then((r) => {
if (r.success) {
this.treeData = r.result || [];
}
});
},
getType1(val) {
let tempTreeList = this.$u.clone(this.treeData);
let rootId = "";
if (val && val != "" && val != null) {
tempTreeList.forEach((ele) => {
if (ele.upId == 0 && ele.name == val) {
rootId = ele.id;
}
});
}
return rootId;
},
getType2(val) {
let tempTreeList = this.$u.clone(this.treeData);
let childrenId = "";
if (val && val != "" && val != null) {
tempTreeList.forEach((ele) => {
if (ele.upId > 0 && ele.name == val) {
childrenId = ele.id;
}
});
}
return childrenId;
},
//物料大类和子类的解析end
//获取编码名称等start
getcodeRuleData() {
let data = {
conditions: [],
};
this.$api.post(`${material}/coderule/paged`, data).then((r) => {
if (r.success) {
this.codeRuleData = r.result.items || [];
}
});
},
getType3(val) {
let codeRuleDataList = this.$u.clone(this.codeRuleData);
let codeRuleId = "";
if (val && val != "" && val != null) {
codeRuleDataList.forEach((ele) => {
if (ele.name == val) {
codeRuleId = ele.id;
}
});
}
return codeRuleId;
},
//获取编码名称等end
//插入物料管理end
//插入工艺规程 及工艺相关start
importRountingHeader() {
let tempData = this.$u.clone(this.dataIm);
let tempList = [];
tempData.forEach((ele) => {
let obj = {
classId: null,
unicode: "",
name: ele.name ? ele.name : "",
code: ele.code ? ele.code : "",
productId: ele.productId ? ele.productId : "", //?
productName: ele.productName ? ele.productName : "", //?
productBomId: ele.productBomId ? ele.productBomId : "", //?
drawingNo: ele.drawingNo ? ele.drawingNo : "", //?
version: "",
versionid: ele.versionid ? ele.versionid : "",
author: null,
departmentId: ele.departmentId ? ele.departmentId : null, //?
departmentName: ele.departmentName ? ele.departmentName : "", //?
isMain: 1,
upId: null,
upDetailId: null,
routingType: ele.routingType ? ele.routingType : null,
status: 0,
approvalStatus: 4, //?
remark: "",
approvalStatusRemark: "",
auditUserId1: "",
auditUserId2: "",
platesnum: null,
versionnotes: "",
isSendPpm: 1,
fileId: "",
phase: ele.phase ? ele.phase : null,
isEffect: ele.isEffect ? ele.isEffect : 1,
};
if (ele.name && ele.name != "") {
tempList.push(obj);
}
});
if (tempList.length == 0) {
this.$Message.error("所有导入的数据均不合法!");
} else {
let parms = {
list: tempList,
};
let url = `${technologyUrl}routingheaderimportservice/import`;
this.$api
.post(url, parms)
.then((r) => {
if (r.success) {
this.$Message.success(
"成功批量导入工艺规程模块 " + tempList.length + " 条数据"
);
this.imBtn = false;
this.cancelExcel();
},
handleClose() {
this.$emit("on-close");
},
cancelExcel() {
this.excelData = [];
this.excelDataBack = [];
this.$refs.uploadfile.clearFiles();
let parms = {
status: 1,
id: this.eid,
};
//导入中心列表数据状态更新
Api.updateimportstatus(parms).then((res) => {
if (res.success) {
this.$emit("on-ok");
}
});
this.$emit("on-close");
},
//重新加载excel
resetTable() {
this.pageType = undefined;
this.load(this.eid);
this.tdHeightExcel = window.innerHeight - 180;
if (this.excelType == 1) {
this.changeExcel(0);
}
},
//打开导入数据格式化后的窗口
openInfoModal() {
if (this.excelData.length > 0 && this.pageType != undefined) {
this.imBtn = true;
switch (this.pageType) {
case 0:
this.loadColum(BaseColums.columns0());
break;
case 1:
this.loadColum(BaseColums.columns1());
break;
case 2:
this.loadColum(BaseColums.columns2());
break;
case 3:
this.loadColum(BaseColums.columns3());
break;
case 4:
this.loadColum(BaseColums.columns4());
break;
case 5:
this.loadColum(BaseColums.columns5());
break;
case 6:
this.loadColum(BaseColums.columns6());
break;
default:
this.loadColum(BaseColums.columns0());
}
this.titleInfo =
"批量导入到 【" +
this.$u.dirName(
this.$store.getters.dictionaryByKey("import.im.page"),
this.pageType
) +
"】 模块";
this.infoModal = true;
} else {
this.$Message.error("批量导入失败");
this.imBtn = true;
if (this.excelData.length == 0) {
this.$Message.error(
"表【" + this.sheetNames[this.tabVal] + "】没有可导入的数据!"
);
} else if (this.pageType == undefined) {
this.$Message.error("请选择需要批量导入到的模块!");
}
}
})
.catch((err) => {
this.$Message.error("数据异常!");
});
}
},
//导入工艺bom
importRountingBom() {
let tempData = this.$u.clone(this.dataIm);
let tempList = [];
tempData.forEach((ele) => {
let obj = {
routingHeaderId: Number(this.getRoutingHeaderId(ele.routingHeaderId)),
routingDetailId: ele.routingDetailId
? Number(ele.routingDetailId)
: null,
routingDetailNo: ele.routingDetailNo
? Number(ele.routingDetailNo)
: null,
routingDetailName: ele.routingDetailName ? ele.routingDetailName : "",
routingStepId: 0,
quantity: ele.quantity ? Number(ele.quantity) : 0,
materialId: ele.materialId ? ele.materialId : "",
materialType: ele.materialType ? Number(ele.materialType) : "",
materialNumber: ele.materialNumber ? ele.materialNumber : "",
nameMaterial: ele.nameMaterial ? ele.nameMaterial : "",
brand: ele.brand ? ele.brand : "",
specifications: ele.specifications ? ele.specifications : "",
xhgg: ele.xhgg ? ele.xhgg : "",
texture: ele.texture ? ele.texture : "",
procurementStandards: ele.procurementStandards
? ele.procurementStandards
: "",
qualityGrade: ele.qualityGrade ? ele.qualityGrade : "",
state: null,
extend: "",
remark: "",
drawNum: ele.drawNum ? ele.drawNum : "",
};
if (ele.routingDetailId && ele.routingDetailId != null) {
tempList.push(obj);
}
});
if (tempList.length == 0) {
this.$Message.error("所有导入的数据均不合法!");
} else {
let parms = {
list: tempList,
};
let url = `${technologyUrl}productinfoimportservice/import`;
this.$api
.post(url, parms)
.then((r) => {
if (r.success) {
this.$Message.success(
"成功批量导入工艺Bom模块 " + tempList.length + " 条数据"
);
this.imBtn = false;
this.cancelExcel();
},
//导入按钮操作
importOk() {
switch (this.pageType) {
case 0:
this.importUser();
break;
case 1:
this.importDepart();
break;
case 2:
this.importResource();
break;
case 3:
this.importMateriel();
break;
case 4:
this.importRountingHeader();
break;
case 5:
this.importRountingBom();
break;
case 6:
this.importProductMix();
break;
default:
//this.loadColum(this.columns1);
}
},
//批量导入用户
importUser() {
let tempData = this.$u.clone(this.dataIm);
let tempList = [];
tempData.forEach((ele) => {
let obj = {
userName: ele.userName,
cardNo: ele.cardNo,
gender: ele.gender,
birthday: ele.birthday,
degreeId: ele.degreeId,
departmentId: ele.departmentId,
status: ele.status,
phone: ele.phone,
email: ele.email,
licensedToWork: ele.licensedToWork,
positionId: ele.positionId,
titleId: ele.titleId,
departmentTitle: ele.departmentTitle,
};
if (
ele.userName &&
ele.userName != "" &&
ele.cardNo &&
ele.cardNo != "" &&
ele.departmentId &&
ele.departmentId != "" &&
ele.phone &&
ele.phone != ""
) {
tempList.push(obj);
}
});
if (tempList.length == 0) {
this.$Message.error("所有导入的数据均不合法!");
} else {
this.$Message.error("批量导入失败");
let parms = {
list: tempList,
};
let url = `${systemUrl}/userimportservice/import`;
this.$api.post(url, parms).then((res) => {
if (res.success) {
this.$Message.success(
"成功批量导入用户管理成功模块 " + tempList.length + " 条数据"
);
this.imBtn = false;
this.cancelExcel();
} else {
this.$Message.error("批量导入用户管理失败!");
}
});
}
})
.catch((err) => {
this.$Message.error("数据异常!");
});
}
},
//获取工艺规程列表
getRoutingHeaderData() {
let url = `${technologyUrl}routingheader/list`;
let data = {
conditions: [],
};
},
//批量插入部门
importDepart() {
let tempData = this.$u.clone(this.dataIm);
let tempList = [];
tempData.forEach((ele) => {
let obj = {
parentTitle: ele.parent_Id ? ele.parent_Id : '',
name: ele.name ? ele.name : '', //部门名称
parent_Id: ele.parent_Id ? ele.parent_Id : '', //上级部门 [id]
code: ele.code ? ele.code : '', //部门编号
location: ele.location ? this.getCityValue(ele.location) : '', //省市县
isProduction: 0, //是否生产班组:1是,0否
property: ele.property ? ele.property : '' //属性
};
if (
ele.name &&
ele.name != ""
) {
tempList.push(obj);
}
});
if (tempList.length == 0) {
this.$Message.error("所有导入的数据均不合法!");
} else {
let parms = {
list: tempList,
};
let url = `${systemUrl}/departmentimport/import`;
this.$api.post(url, parms).then((res) => {
if (res.success) {
this.$Message.success(
"成功批量导入部门管理成功模块 " + tempList.length + " 条数据"
);
this.imBtn = false;
this.cancelExcel();
} else {
this.$Message.error("批量导入部门管理失败!");
}
});
}
},
//批量插入制造资源
importResource() {
let tempData = this.$u.clone(this.dataIm);
let tempList = [];
tempData.forEach((ele) => {
let obj = {
nameOfResource: ele.nameOfResource ? ele.nameOfResource : "",
resourceCode: ele.resourceCode ? ele.resourceCode : "",
code: ele.code ? ele.code : "",
totalNum: ele.totalNum ? ele.totalNum : 0,
storeTitle: ele.storeTitle ? ele.storeTitle : "",
storeId: ele.storeId ? ele.storeId : null,
state: 1,
numberAvailable: ele.numberAvailable ? ele.numberAvailable : 0,
json: {},
};
if (
ele.nameOfResource &&
ele.nameOfResource != "" &&
ele.code &&
ele.code != "" &&
ele.resourceCode &&
ele.resourceCode != ""
) {
tempList.push(obj);
}
});
if (tempList.length == 0) {
this.$Message.error("所有导入的数据均不合法!");
} else {
let parms = {
list: tempList,
};
let url = `${resourceUrl}/resourceimportservice/import`;
this.$api
.post(url, parms)
.then((r) => {
if (r.success) {
this.$Message.success(
"成功批量导入制造资源成功模块 " + tempList.length + " 条数据"
);
this.imBtn = false;
this.cancelExcel();
} else {
this.$Message.error("批量导入失败");
}
})
.catch((err) => {
this.$Message.error("数据异常!");
});
}
},
//插入物料管理start
importMateriel() {
let tempData = this.$u.clone(this.dataIm);
let tempList = [];
tempData.forEach((ele) => {
let obj = {
name: ele.name ? ele.name : "",
version: ele.version ? Number(ele.version) : "",
drawing: ele.drawing ? ele.drawing : "",
description: ele.description ? ele.description : "",
code: 0,
status: ele.status ? Number(ele.status) : "",
customProperties: {},
categoryId: this.getType2(ele.categoryId) ?
this.getType2(ele.categoryId) : 1, //左侧树点击的id
rootCategoryId: this.getType1(ele.rootCategoryId) ?
this.getType1(ele.rootCategoryId) : 1, //左侧树点击的数据的最顶层id
codeRuleId: this.getType3(ele.codeRuleId) ?
this.getType3(ele.codeRuleId) : 1, //类别编码名称
codeRuleType: ele.codeRuleType ? Number(ele.codeRuleType) : 1, //类别codeType
};
if (
ele.codeRuleId &&
this.getType3(ele.codeRuleId) != "" &&
ele.codeRuleType &&
ele.codeRuleType != "" &&
ele.codeRuleType != null &&
ele.rootCategoryId &&
this.getType1(ele.rootCategoryId) != "" &&
ele.name &&
ele.name != ""
) {
tempList.push(obj);
}
});
if (tempList.length == 0) {
this.$Message.error("所有导入的数据均不合法!");
} else {
let parms = {
list: tempList,
};
let url = `${material}/materialimportservice/import`;
this.$api
.post(url, parms)
.then((r) => {
if (r.success) {
this.$Message.success(
"成功批量导入物料管理模块 " + tempList.length + " 条数据"
);
this.imBtn = false;
this.cancelExcel();
} else {
this.$Message.error("批量导入失败");
}
})
.catch((err) => {
this.$Message.error("数据异常!");
});
}
},
//物料大类和子类的解析start
getTreeData() {
let data = {
conditions: [],
};
this.$api.post(`${material}/category/list`, data).then((r) => {
if (r.success) {
this.treeData = r.result || [];
}
});
},
getType1(val) {
let tempTreeList = this.$u.clone(this.treeData);
let rootId = "";
if (val && val != "" && val != null) {
tempTreeList.forEach((ele) => {
if (ele.upId == 0 && ele.name == val) {
rootId = ele.id;
}
});
}
return rootId;
},
getType2(val) {
let tempTreeList = this.$u.clone(this.treeData);
let childrenId = "";
if (val && val != "" && val != null) {
tempTreeList.forEach((ele) => {
if (ele.upId > 0 && ele.name == val) {
childrenId = ele.id;
}
});
}
return childrenId;
},
//物料大类和子类的解析end
//获取编码名称等start
getcodeRuleData() {
let data = {
conditions: [],
};
this.$api.post(`${material}/coderule/paged`, data).then((r) => {
if (r.success) {
this.codeRuleData = r.result.items || [];
}
});
},
getType3(val) {
let codeRuleDataList = this.$u.clone(this.codeRuleData);
let codeRuleId = "";
if (val && val != "" && val != null) {
codeRuleDataList.forEach((ele) => {
if (ele.name == val) {
codeRuleId = ele.id;
}
});
}
return codeRuleId;
},
//获取编码名称等end
//插入物料管理end
//插入工艺规程 及工艺相关start
importRountingHeader() {
let tempData = this.$u.clone(this.dataIm);
let tempList = [];
tempData.forEach((ele) => {
let obj = {
classId: null,
unicode: "",
name: ele.name ? ele.name : "",
code: ele.code ? ele.code : "",
productId: ele.productId ? ele.productId : "", //?
productName: ele.productName ? ele.productName : "", //?
productBomId: ele.productBomId ? ele.productBomId : "", //?
drawingNo: ele.drawingNo ? ele.drawingNo : "", //?
version: "",
versionid: ele.versionid ? ele.versionid : "",
author: null,
departmentId: ele.departmentId ? ele.departmentId : null, //?
departmentName: ele.departmentName ? ele.departmentName : "", //?
isMain: 1,
upId: null,
upDetailId: null,
routingType: ele.routingType ? ele.routingType : null,
status: 0,
approvalStatus: 4, //?
remark: "",
approvalStatusRemark: "",
auditUserId1: "",
auditUserId2: "",
platesnum: null,
versionnotes: "",
isSendPpm: 1,
fileId: "",
phase: ele.phase ? ele.phase : null,
isEffect: ele.isEffect ? ele.isEffect : 1,
};
if (ele.name && ele.name != "") {
tempList.push(obj);
}
});
if (tempList.length == 0) {
this.$Message.error("所有导入的数据均不合法!");
} else {
let parms = {
list: tempList,
};
let url = `${technologyUrl}routingheaderimportservice/import`;
this.$api
.post(url, parms)
.then((r) => {
if (r.success) {
this.$Message.success(
"成功批量导入工艺规程模块 " + tempList.length + " 条数据"
);
this.imBtn = false;
this.cancelExcel();
} else {
this.$Message.error("批量导入失败");
}
})
.catch((err) => {
this.$Message.error("数据异常!");
});
}
},
//导入工艺bom
importRountingBom() {
let tempData = this.$u.clone(this.dataIm);
let tempList = [];
tempData.forEach((ele) => {
let obj = {
routingHeaderId: Number(this.getRoutingHeaderId(ele.routingHeaderId)),
routingDetailId: ele.routingDetailId ?
Number(ele.routingDetailId) : null,
routingDetailNo: ele.routingDetailNo ?
Number(ele.routingDetailNo) : null,
routingDetailName: ele.routingDetailName ? ele.routingDetailName : "",
routingStepId: 0,
quantity: ele.quantity ? Number(ele.quantity) : 0,
materialId: ele.materialId ? ele.materialId : "",
materialType: ele.materialType ? Number(ele.materialType) : "",
materialNumber: ele.materialNumber ? ele.materialNumber : "",
nameMaterial: ele.nameMaterial ? ele.nameMaterial : "",
brand: ele.brand ? ele.brand : "",
specifications: ele.specifications ? ele.specifications : "",
xhgg: ele.xhgg ? ele.xhgg : "",
texture: ele.texture ? ele.texture : "",
procurementStandards: ele.procurementStandards ?
ele.procurementStandards : "",
qualityGrade: ele.qualityGrade ? ele.qualityGrade : "",
state: null,
extend: "",
remark: "",
drawNum: ele.drawNum ? ele.drawNum : "",
};
if (ele.routingDetailId && ele.routingDetailId != null) {
tempList.push(obj);
}
});
if (tempList.length == 0) {
this.$Message.error("所有导入的数据均不合法!");
} else {
let parms = {
list: tempList,
};
let url = `${technologyUrl}productinfoimportservice/import`;
this.$api
.post(url, parms)
.then((r) => {
if (r.success) {
this.$Message.success(
"成功批量导入工艺Bom模块 " + tempList.length + " 条数据"
);
this.imBtn = false;
this.cancelExcel();
} else {
this.$Message.error("批量导入失败");
}
})
.catch((err) => {
this.$Message.error("数据异常!");
});
}
},
//获取工艺规程列表
getRoutingHeaderData() {
let url = `${technologyUrl}routingheader/list`;
let data = {
conditions: [],
};
this.$api.post(url, data).then((r) => {
if (r.success) {
this.routingHeaderData = r.result || [];
}
});
},
//根据工艺规程ID获得name
getRoutingHeaderId(val) {
let routingHeaderDataList = this.$u.clone(this.routingHeaderData);
let routingHeaderId = 0;
routingHeaderDataList.forEach((ele) => {
if (ele.name == val) {
routingHeaderId = ele.id;
}
});
return routingHeaderId;
},
//插入工艺规程 及工艺相关end
//插入产品管理start
importProductMix() {
let tempData = this.$u.clone(this.dataIm);
let tempList = [];
tempData.forEach((ele) => {
let obj = {
mmcode: ele.mmcode ? ele.mmcode : "",
drawingNo: ele.drawingNo ? ele.drawingNo : "",
name: ele.name ? ele.name : "",
type: ele.type ? ele.type : 1,
madeCompany: ele.madeCompany ? ele.madeCompany : null,
madeCompanyTitle: ele.madeCompanyTitle ? ele.madeCompanyTitle : "",
version: ele.version ? ele.version : 0,
productUrl: "",
productUrlList: "",
levelId: ele.levelId ? ele.levelId : null,
levelTitle: ele.levelTitle ? ele.levelTitle : "",
materialId: ele.materialId ? ele.materialId : "",
};
if (ele.name && ele.name != "") {
tempList.push(obj);
}
});
if (tempList.length == 0) {
this.$Message.error("所有导入的数据均不合法!");
} else {
let parms = {
list: tempList,
};
let url = `${technologyUrl}productinfoimportservice/import`;
this.$api
.post(url, parms)
.then((r) => {
if (r.success) {
this.$Message.success(
"成功批量导入产品管理模块 " + tempList.length + " 条数据"
);
this.imBtn = false;
this.cancelExcel();
this.$api.post(url, data).then((r) => {
if (r.success) {
this.routingHeaderData = r.result || [];
}
});
},
//根据工艺规程ID获得name
getRoutingHeaderId(val) {
let routingHeaderDataList = this.$u.clone(this.routingHeaderData);
let routingHeaderId = 0;
routingHeaderDataList.forEach((ele) => {
if (ele.name == val) {
routingHeaderId = ele.id;
}
});
return routingHeaderId;
},
//插入工艺规程 及工艺相关end
//插入产品管理start
importProductMix() {
let tempData = this.$u.clone(this.dataIm);
let tempList = [];
tempData.forEach((ele) => {
let obj = {
mmcode: ele.mmcode ? ele.mmcode : "",
drawingNo: ele.drawingNo ? ele.drawingNo : "",
name: ele.name ? ele.name : "",
type: ele.type ? ele.type : 1,
madeCompany: ele.madeCompany ? ele.madeCompany : null,
madeCompanyTitle: ele.madeCompanyTitle ? ele.madeCompanyTitle : "",
version: ele.version ? ele.version : 0,
productUrl: "",
productUrlList: "",
levelId: ele.levelId ? ele.levelId : null,
levelTitle: ele.levelTitle ? ele.levelTitle : "",
materialId: ele.materialId ? ele.materialId : "",
};
if (ele.name && ele.name != "") {
tempList.push(obj);
}
});
if (tempList.length == 0) {
this.$Message.error("所有导入的数据均不合法!");
} else {
this.$Message.error("批量导入失败");
let parms = {
list: tempList,
};
let url = `${technologyUrl}productinfoimportservice/import`;
this.$api
.post(url, parms)
.then((r) => {
if (r.success) {
this.$Message.success(
"成功批量导入产品管理模块 " + tempList.length + " 条数据"
);
this.imBtn = false;
this.cancelExcel();
} else {
this.$Message.error("批量导入失败");
}
})
.catch((err) => {
this.$Message.error("数据异常!");
});
}
})
.catch((err) => {
this.$Message.error("数据异常!");
});
}
},
//插入产品管理end
//切换列表和excel按钮
changeExcel(val) {
if (val == 1) {
this.tableImport = false;
this.detailExcel = () => import("./detailExcel");
this.pageType = undefined;
this.excelType = "1";
} else {
this.detailExcel = null;
this.tableImport = true;
this.pageType = undefined;
this.excelType = "0";
this.listLength = this.excelData.length;
}
},
datalength(val) {
this.listLength = val;
},
//插入产品管理end
//切换列表和excel按钮
changeExcel(val) {
if (val == 1) {
this.tableImport = false;
this.detailExcel = () => import("./detailExcel");
this.pageType = undefined;
this.excelType = "1";
} else {
this.detailExcel = null;
this.tableImport = true;
this.pageType = undefined;
this.excelType = "0";
this.listLength = this.excelData.length;
}
},
datalength(val) {
this.listLength = val;
},
},
},
watch: {
eid(v) {
if (v != 0) {
this.load(v);
}
watch: {
eid(v) {
if (v != 0) {
this.load(v);
}
},
},
},
};
</script>
<style lang="less">
@import "../../assets/css/custom.less";
.table-contentProcess {
position: relative;
height: 100%;
display: flex;
flex-direction: column;
position: relative;
height: 100%;
display: flex;
flex-direction: column;
.tip {
display: inline;
}
.tip {
display: inline;
}
form {
display: inline-block;
form {
display: inline-block;
.ivu-form-item {
margin: 0;
vertical-align: middle;
.ivu-form-item {
margin: 0;
vertical-align: middle;
}
}
}
.table-main {
width: 100%;
text-align: left;
padding: 0;
display: block;
overflow-y: auto;
flex-grow: 1;
.table-main {
width: 100%;
text-align: left;
padding: 0;
display: block;
overflow-y: auto;
flex-grow: 1;
tr td .ivu-table-cell {
padding: 0 5px;
}
tr td .ivu-table-cell {
padding: 0 5px;
overflow-x: hidden;
}
overflow-x: hidden;
}
.table-tools {
display: flex;
line-height: 50px;
background: @right-header-bg;
.table-tools {
display: flex;
line-height: 50px;
background: @right-header-bg;
.table-search {
flex-grow: 1;
}
.table-search {
flex-grow: 1;
}
.btns {
min-width: 200px;
text-align: right;
.btns {
min-width: 200px;
text-align: right;
}
}
}
.table-footer {
line-height: 45px;
background: #f5f5f5;
}
.table-footer {
line-height: 45px;
background: #f5f5f5;
}
.ivu-footer-toolbar {
text-align: left;
.ivu-footer-toolbar {
text-align: left;
// background: #f5f5f5;
.ivu-footer-toolbar-right {
float: left;
// background: #f5f5f5;
.ivu-footer-toolbar-right {
float: left;
}
}
}
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment