Commit ad6cfb09 authored by renjintao's avatar renjintao

process

parent 5eb53bc9
......@@ -97,7 +97,8 @@ export default {
noDataText: '暂无数据',
imBtn: true,
columnsIm: this.columns,
ImportModal: this.open
ImportModal: this.open,
batchImportUrl: '',
};
},
props: {
......@@ -145,19 +146,37 @@ export default {
//重新处理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.type == "selection" || ele.key == "ico") {
ele.hide = true;
}
});
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 temColPage = this.$u.clone(columns); //需要显示的页面的表头
......@@ -223,6 +242,9 @@ export default {
});
})
this.dataIm = useData;
let tempData = this.$u.clone(this.dataIm);
this.$emit("on-get-data", tempData)
},
//导入excel文件
......@@ -309,20 +331,36 @@ export default {
this.imBtn = true;
this.loadColum(this.columnsIm);
this.titleInfo = "批量导入";
this.infoModal = true
this.infoModal = true;
} else {
this.imBtn = false;
this.$Message.error("没有可导入的数据!")
}
},
//导入按钮操作
//确定导入按钮操作
importOk() {
this.importUser();
},
//批量导入用户
importUser() {
let tempData = this.$u.clone(this.dataIm);
this.$emit("on-get-data", tempData)
let imData = [];
let imDataError = []
this.dataIm.forEach(ele => {
if (!ele.ico) {
imData.push(ele)
} 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按钮
changeExcel(val) {
......@@ -351,6 +389,11 @@ export default {
cancelModal() {
this.$emit('on-cancel')
},
//主页面里第二次处理数据
deelData(url, columns, formatList) {
this.dataIm = formatList
this.batchImportUrl = url
},
l(key) {
key = "user" + "." + key;
return this.$t(key);
......
<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">
<slot>
<Icon v-if="type=='icon'" :type="icon" />
<span v-else="type=='text'" v-text="text"></span>
</slot>
<slot>
<Icon v-if="type=='icon'" :type="icon" :color="color" />
<span v-else="type=='text'" v-text="text"></span>
</slot>
</a>
</Tooltip>
<a class="op" v-else :class="css" @click="handler">
</Tooltip>
<a class="op" v-else :class="css" @click="handler">
<slot>
<Icon v-if="type=='icon'" :type="icon" />
<span v-else="type=='text'" v-text="text"></span>
<Icon v-if="type=='icon'" :type="icon" :color="color" />
<span v-else="type=='text'" v-text="text"></span>
</slot>
</a>
</a>
</template>
<script>
export default {
name: "op",
props: {
icon: {
type: String
},
oprate: {
type: String
},
type: {
type: String,
default: "text"
name: "op",
props: {
icon: {
type: String
},
oprate: {
type: String
},
type: {
type: String,
default: "text"
},
title: {
type: String,
},
msg: {
type: String,
default: "确认要删除吗?"
},
color: {
type: String
}
},
title: {
type: String,
data() {
return {
text: "",
css: "detail"
};
},
msg: {
type: String,
default: "确认要删除吗?"
}
},
data() {
return {
text: "",
css: "detail"
};
},
created() {
var oprates = {
detail: "查看",
edit: "编辑",
add: "添加",
delete: "删除",
remove: "删除"
};
created() {
var oprates = {
detail: "查看",
edit: "编辑",
add: "添加",
delete: "删除",
remove: "删除"
};
if (oprates[this.oprate]) {
this.text = oprates[this.oprate];
this.css = this.oprate;
} else if (this.oprate) {
this.css = this.oprate;
} else if (this.type == "icon") {
this.css = "icon";
}
},
methods: {
handler() {
if (this.oprate == "delete"||this.oprate == "remove") {
this.$Modal.confirm({
title: this.title,
content: "<p>" + this.msg + "</p>",
onOk: () => {
this.$emit("click", event);
}
});
} else {
this.$emit("click", event);
}
if (oprates[this.oprate]) {
this.text = oprates[this.oprate];
this.css = this.oprate;
} else if (this.oprate) {
this.css = this.oprate;
} else if (this.type == "icon") {
this.css = "icon";
}
},
methods: {
handler() {
if (this.oprate == "delete" || this.oprate == "remove") {
this.$Modal.confirm({
title: this.title,
content: "<p>" + this.msg + "</p>",
onOk: () => {
this.$emit("click", event);
}
});
} else {
this.$emit("click", event);
}
}
}
}
};
</script>
<style lang="less">
a.op {
display: inline;
margin: 0 3px;
display: inline;
margin: 0 3px;
}
</style>
\ No newline at end of file
</style>
......@@ -11753,7 +11753,7 @@
"dependencies": {
"source-map": {
"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=",
"dev": true,
"optional": true
......
......@@ -38,7 +38,7 @@
<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" />
</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>
</Layout>
</template>
......@@ -89,7 +89,6 @@ export default {
align: "left",
sortable: true,
},
{
key: "ico",
title: " ",
......@@ -113,7 +112,6 @@ export default {
]);
},
},
{
key: "resourceCode",
title: this.l("resourceId"),
......@@ -507,55 +505,35 @@ export default {
this.ModalIm = false
},
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))
//this.$refs.grid.closeImport()
//this.$refs.grid.closeImport(url, coloums, format, ok);
this.$refs.importExcel.deelData(url, coloums, format, ok)
//根据页面二次处理数据
formatMethod(val) {
let tempData = this.$u.clone(val);
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);
// }
// });
tempList = tempData
if (tempList.length == 0) {
this.$Message.error("所有导入的数据均不合法!");
} else {
let parms = {
list: tempList,
tempData.forEach((ele) => {
let obj = {
nameOfResource: ele.nameOfResource,
resourceCode: ele.resourceCode,
code: ele.code,
totalNum: ele.totalNum,
storeTitle: ele.storeTitle,
storeId: ele.storeId,
state: 1,
numberAvailable: ele.numberAvailable,
json: {}
};
alert(JSON.stringify(tempList))
//Api.import(parms).then((res) => {
//if (res.success) {
//this.$Message.success("成功批量导入用户管理成功模块 " + tempList.length + " 条数据");
//this.imBtn = false;
//this.$refs.grid.closeImport()
// } else {
// this.$Message.error("批量导入用户管理失败!");
//}
//});
}
if (ele.nameOfResource && ele.nameOfResource != '' && ele.code && ele.code != '' && ele.resourceCode && ele.resourceCode != '') {
obj.ico = false
} else {
obj.ico = true
}
tempList.push(obj);
});
return tempList
},
//批量导入end
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