Commit ad6cfb09 authored by renjintao's avatar renjintao

process

parent 5eb53bc9
...@@ -97,7 +97,8 @@ export default { ...@@ -97,7 +97,8 @@ export default {
noDataText: '暂无数据', noDataText: '暂无数据',
imBtn: true, imBtn: true,
columnsIm: this.columns, columnsIm: this.columns,
ImportModal: this.open ImportModal: this.open,
batchImportUrl: '',
}; };
}, },
props: { props: {
...@@ -145,19 +146,37 @@ export default { ...@@ -145,19 +146,37 @@ export default {
//重新处理colum //重新处理colum
loadColum(columns) { loadColum(columns) {
let tempCol = this.$u.clone(columns); let tempCol = this.$u.clone(columns);
tempCol.unshift({
type: 'index',
width: 80,
align: 'right',
title: '序号'
})
tempCol.forEach((ele, index) => { tempCol.forEach((ele, index) => {
if (ele.key == "action" || ele.type == "selection" || ele.key == "ico") { if (ele.key == "action" || ele.type == "selection" || ele.key == "ico") {
ele.hide = true; ele.hide = true;
} }
}); });
this.colsIm = tempCol; this.colsIm = tempCol;
this.colsIm.unshift({
type: 'index',
width: 80,
align: 'right',
title: '序号'
}, {
key: "ico",
title: " ",
align: "center",
width: 60,
render: (h, params) => {
return h("div", {
class: ""
}, [
h(params.row.ico ? "op" : "", {
attrs: {
icon: "ios-alert",
type: "icon",
title: "数据不合法",
color: "#ff9900"
}
}),
]);
},
})
//处理原始数据和表头进行对应 //处理原始数据和表头进行对应
let temCol = this.$u.clone(this.colsIm); //原始数据表头 let temCol = this.$u.clone(this.colsIm); //原始数据表头
let temColPage = this.$u.clone(columns); //需要显示的页面的表头 let temColPage = this.$u.clone(columns); //需要显示的页面的表头
...@@ -223,6 +242,9 @@ export default { ...@@ -223,6 +242,9 @@ export default {
}); });
}) })
this.dataIm = useData; this.dataIm = useData;
let tempData = this.$u.clone(this.dataIm);
this.$emit("on-get-data", tempData)
}, },
//导入excel文件 //导入excel文件
...@@ -309,20 +331,36 @@ export default { ...@@ -309,20 +331,36 @@ export default {
this.imBtn = true; this.imBtn = true;
this.loadColum(this.columnsIm); this.loadColum(this.columnsIm);
this.titleInfo = "批量导入"; this.titleInfo = "批量导入";
this.infoModal = true this.infoModal = true;
} else { } else {
this.imBtn = false; this.imBtn = false;
this.$Message.error("没有可导入的数据!") this.$Message.error("没有可导入的数据!")
} }
}, },
//导入按钮操作 //确定导入按钮操作
importOk() { importOk() {
this.importUser(); let imData = [];
}, let imDataError = []
//批量导入用户 this.dataIm.forEach(ele => {
importUser() { if (!ele.ico) {
let tempData = this.$u.clone(this.dataIm); imData.push(ele)
this.$emit("on-get-data", tempData) } else {
imDataError.push(ele)
}
})
this.$api.post(this.batchImportUrl, {
list: imData
}).then((r) => {
if (r.success) {
this.$Message.success("批量导入成功" + imData.length + "条数据")
this.dataIm = imDataError
this.$emit("on-ok")
} else {
this.$Message.error("批量导入失败")
}
}).catch(err => {
this.$Message.error("数据异常!");
});;
}, },
//切换列表和excel按钮 //切换列表和excel按钮
changeExcel(val) { changeExcel(val) {
...@@ -351,6 +389,11 @@ export default { ...@@ -351,6 +389,11 @@ export default {
cancelModal() { cancelModal() {
this.$emit('on-cancel') this.$emit('on-cancel')
}, },
//主页面里第二次处理数据
deelData(url, columns, formatList) {
this.dataIm = formatList
this.batchImportUrl = url
},
l(key) { l(key) {
key = "user" + "." + key; key = "user" + "." + key;
return this.$t(key); return this.$t(key);
......
<template> <template>
<Tooltip trigger="hover" v-if="title" :content="title" placement="top-end"> <Tooltip trigger="hover" v-if="title" :content="title" placement="top-end">
<a class="op" :class="css" @click="handler"> <a class="op" :class="css" @click="handler">
<slot> <slot>
<Icon v-if="type=='icon'" :type="icon" /> <Icon v-if="type=='icon'" :type="icon" :color="color" />
<span v-else="type=='text'" v-text="text"></span> <span v-else="type=='text'" v-text="text"></span>
</slot> </slot>
</a> </a>
</Tooltip> </Tooltip>
<a class="op" v-else :class="css" @click="handler"> <a class="op" v-else :class="css" @click="handler">
<slot> <slot>
<Icon v-if="type=='icon'" :type="icon" /> <Icon v-if="type=='icon'" :type="icon" :color="color" />
<span v-else="type=='text'" v-text="text"></span> <span v-else="type=='text'" v-text="text"></span>
</slot> </slot>
</a> </a>
</template> </template>
<script> <script>
export default { export default {
name: "op", name: "op",
props: { props: {
icon: { icon: {
type: String type: String
}, },
oprate: { oprate: {
type: String type: String
}, },
type: { type: {
type: String, type: String,
default: "text" default: "text"
},
title: {
type: String,
},
msg: {
type: String,
default: "确认要删除吗?"
},
color: {
type: String
}
}, },
title: { data() {
type: String, return {
text: "",
css: "detail"
};
}, },
msg: { created() {
type: String, var oprates = {
default: "确认要删除吗?" detail: "查看",
} edit: "编辑",
}, add: "添加",
data() { delete: "删除",
return { remove: "删除"
text: "", };
css: "detail"
};
},
created() {
var oprates = {
detail: "查看",
edit: "编辑",
add: "添加",
delete: "删除",
remove: "删除"
};
if (oprates[this.oprate]) { if (oprates[this.oprate]) {
this.text = oprates[this.oprate]; this.text = oprates[this.oprate];
this.css = this.oprate; this.css = this.oprate;
} else if (this.oprate) { } else if (this.oprate) {
this.css = this.oprate; this.css = this.oprate;
} else if (this.type == "icon") { } else if (this.type == "icon") {
this.css = "icon"; this.css = "icon";
} }
}, },
methods: { methods: {
handler() { handler() {
if (this.oprate == "delete"||this.oprate == "remove") { if (this.oprate == "delete" || this.oprate == "remove") {
this.$Modal.confirm({ this.$Modal.confirm({
title: this.title, title: this.title,
content: "<p>" + this.msg + "</p>", content: "<p>" + this.msg + "</p>",
onOk: () => { onOk: () => {
this.$emit("click", event); this.$emit("click", event);
} }
}); });
} else { } else {
this.$emit("click", event); this.$emit("click", event);
} }
}
} }
}
}; };
</script> </script>
<style lang="less"> <style lang="less">
a.op { a.op {
display: inline; display: inline;
margin: 0 3px; margin: 0 3px;
} }
</style> </style>
\ No newline at end of file
...@@ -11753,7 +11753,7 @@ ...@@ -11753,7 +11753,7 @@
"dependencies": { "dependencies": {
"source-map": { "source-map": {
"version": "0.6.1", "version": "0.6.1",
"resolved": "https://registry.npm.taobao.org/source-map/download/source-map-0.6.1.tgz", "resolved": "http://r.cnpmjs.org/source-map/download/source-map-0.6.1.tgz",
"integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=",
"dev": true, "dev": true,
"optional": true "optional": true
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
<Modal v-model="modal" :title="title" width="1200" footer-hide :fullscreen="fscreeen"> <Modal v-model="modal" :title="title" width="1200" footer-hide :fullscreen="fscreeen">
<component :is="detail" :eid="curId" :rootName="rootName" :storeTitle="storeTitle" :materialType="materialType" :storeId="storeId" :mcode="mCode" :cartList="this.$u.clone(this.$store.state.cart)" @on-close="cancel" @on-ok="ok" @substr="substr" /> <component :is="detail" :eid="curId" :rootName="rootName" :storeTitle="storeTitle" :materialType="materialType" :storeId="storeId" :mcode="mCode" :cartList="this.$u.clone(this.$store.state.cart)" @on-close="cancel" @on-ok="ok" @substr="substr" />
</Modal> </Modal>
<ImportExcel ref="importExcel" @on-get-data="getData" :columns="columns" :open="ModalIm" @on-cancel="ModalImCancel" /> <ImportExcel ref="importExcel" @on-get-data="getData" :columns="columns" :open="ModalIm" @on-cancel="ModalImCancel" @on-ok="ok" />
</Content> </Content>
</Layout> </Layout>
</template> </template>
...@@ -89,7 +89,6 @@ export default { ...@@ -89,7 +89,6 @@ export default {
align: "left", align: "left",
sortable: true, sortable: true,
}, },
{ {
key: "ico", key: "ico",
title: " ", title: " ",
...@@ -113,7 +112,6 @@ export default { ...@@ -113,7 +112,6 @@ export default {
]); ]);
}, },
}, },
{ {
key: "resourceCode", key: "resourceCode",
title: this.l("resourceId"), title: this.l("resourceId"),
...@@ -507,55 +505,35 @@ export default { ...@@ -507,55 +505,35 @@ export default {
this.ModalIm = false this.ModalIm = false
}, },
getData(val) { getData(val) {
alert(JSON.stringify(val)) let url = `${resourceUrl}/resourceimportservice/import`;
this.$refs.importExcel.deelData(url, this.columns, this.formatMethod(val))
}, },
onImportData(val) { //根据页面二次处理数据
//alert(JSON.stringify(val)) formatMethod(val) {
//this.$refs.grid.closeImport()
//this.$refs.grid.closeImport(url, coloums, format, ok);
this.$refs.importExcel.deelData(url, coloums, format, ok)
let tempData = this.$u.clone(val); let tempData = this.$u.clone(val);
let tempList = []; let tempList = [];
//tempData.forEach((ele) => { tempData.forEach((ele) => {
//let obj = { let obj = {
// userName: ele.userName, nameOfResource: ele.nameOfResource,
//cardNo: ele.cardNo, resourceCode: ele.resourceCode,
// gender: ele.gender, code: ele.code,
//birthday: ele.birthday, totalNum: ele.totalNum,
//degreeId: ele.degreeId, storeTitle: ele.storeTitle,
//departmentId: ele.departmentId, storeId: ele.storeId,
//status: ele.status, state: 1,
//phone: ele.phone, numberAvailable: ele.numberAvailable,
//email: ele.email, json: {}
//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);
// }
// });
tempList = tempData
if (tempList.length == 0) {
this.$Message.error("所有导入的数据均不合法!");
} else {
let parms = {
list: tempList,
}; };
alert(JSON.stringify(tempList)) if (ele.nameOfResource && ele.nameOfResource != '' && ele.code && ele.code != '' && ele.resourceCode && ele.resourceCode != '') {
//Api.import(parms).then((res) => { obj.ico = false
//if (res.success) { } else {
//this.$Message.success("成功批量导入用户管理成功模块 " + tempList.length + " 条数据"); obj.ico = true
//this.imBtn = false; }
//this.$refs.grid.closeImport() tempList.push(obj);
// } else {
// this.$Message.error("批量导入用户管理失败!"); });
//} return tempList
//});
}
}, },
//批量导入end //批量导入end
l(key) { l(key) {
......
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