Commit 2e4f3489 authored by renjintao's avatar renjintao

process

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