Commit 4c322e84 authored by renjintao's avatar renjintao

import

parent 16e2557d
......@@ -22,7 +22,6 @@
</Form>
</slot>
</div>
<div class="searchBack">
<slot name="searchBack"></slot>
</div>
......
import Api from '@/plugins/request'
import { getJSON } from 'js-cookie';
export default {
index: `${systemUrl}/importcenter/paged`,
paged(params) {
......@@ -22,5 +23,6 @@ export default {
},
deletes(params) {
return Api.post(`${systemUrl}/importcenter/batchdelete`, params);
}
},
}
......@@ -132,7 +132,7 @@ export default {
title: this.l("status"),
align: "center",
high: true,
code: "mes.import_center.Status",
code: "mimprot.im.status",
width:"150",
},
{
......@@ -162,7 +162,7 @@ export default {
"op",
{
attrs: { oprate: "edit" },
on: { click: () => this.process(params.row.id) },
on: { click: () => this.process(params.row) },
},
"处理"
),
......@@ -214,9 +214,9 @@ export default {
this.detail = () => import("./edit");
this.modal = true;
},
process(id) {
this.curId = id;
this.title = "处理";
process(row) {
this.curId = row.id;
this.title = "处理文件:"+row.name;
this.full=true;
this.detail = () => import("./process");
this.modal = true;
......
......@@ -10,23 +10,47 @@
>
<template slot="easySearch">
<Form inline>
<FormItem><dictionary code="plan.order.taskType" style="width:240px"></dictionary></FormItem>
<FormItem><Button type="primary" >预览</Button></FormItem>
<FormItem>
<span>导入到</span>
</FormItem>
<FormItem>
<dictionary code="import.im.page" style="width:160px"></dictionary>
</FormItem>
<FormItem>
<div class="tip mr20">{{excelData.length}}条数据</div>
</FormItem>
<FormItem>
<Button type="primary">导入</Button>
</FormItem>
</Form>
</template>
<template slot="searchBack">
<Upload action :before-upload="beforeUpload" ref="uploadfile" :format="formatList">
<Button icon="ios-cloud-upload-outline">重新上传</Button>
</Upload>
<template slot="buttons">
<Form inline>
<FormItem>
<Button>下载文件</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">重新上传</Button>
</Upload>
</div>
</FormItem>
<FormItem>
<Button>粘贴excel</Button>
</FormItem>
</Form>
</template>
</DataGrid>
<p class="tr pt10">
<span v-if="excelData.length>0">共 {{excelData.length}} 条数据</span>
<Button @click="cancelExcel">取消</Button>
<Button type="primary">确定导入</Button>
</p>
<FooterToolbar v-if="excelData.length>0&&sheetNames.length>1">
<Form inline>
<FormItem>
<Tabs :animated="false" :value="0" @on-click="sheetClick">
<TabPane :label="item" v-for="(item,index) in sheetNames"></TabPane>
</Tabs>
</FormItem>
</Form>
</FooterToolbar>
</div>
</template>
<script>
......@@ -38,13 +62,6 @@ export default {
return {
disabled: false,
columns: [
// {
// title: '序号',
// type: 'index',
// width: 80,
// align: 'center'
// },
{ key: "id", title: this.l("id"), hide: true, align: "left" },
{
key: "userName",
title: this.l("userName"),
......@@ -272,17 +289,196 @@ export default {
},
},
],
excelData: [],
columns1: [
{
key: "userName",
title: this.l("userName"),
align: "left",
easy: true,
high: true,
render: (h, params) => {
return h("div", { class: "action" }, [
h(
"op",
{
attrs: { oprate: "detail" },
on: { click: () => this.detail(params.row.id) },
},
params.row.userName
),
]);
},
},
{
key: "status",
title: this.l("status"),
align: "center",
high: true,
code: "User.base.status",
},
{
key: "departmentId",
title: this.l("departmentId"),
align: "right",
easy: true,
high: true,
},
{
key: "departmentTitle",
title: this.l("departmentTitle"),
align: "left",
easy: true,
high: true,
},
{
key: "roleTitles",
title: this.l("roleTitles"),
align: "left",
easy: true,
high: true,
hide: true,
render: (h, params) => {
return h("div", { class: "action" }, [
h(
"op",
{
attrs: {
oprate: "detail",
class:
params.row.roleTitles == null ||
params.row.roleTitles == ""
? "empower"
: "detail",
},
on: { click: () => this.authorize(params.row.id) },
},
params.row.roleTitles == null || params.row.roleTitles == ""
? "授权"
: params.row.roleTitles
),
]);
},
},
{
key: "accountId",
title: this.l("accountId"),
hide: true,
align: "left",
},
// {
// key: 'userType',
// title: this.l('userType'),
// hide: true,
// align: 'left'
// },
{
key: "phone",
title: this.l("phone"),
align: "left",
easy: true,
high: true,
},
{
key: "email",
title: this.l("email"),
align: "left",
easy: true,
high: true,
},
{
key: "licensedToWork",
title: this.l("licensedToWork"),
align: "left",
},
{
key: "positionId",
title: this.l("positionId"),
align: "left",
high: true,
code: "User.base.position",
},
{
key: "titleId",
title: this.l("titleId"),
align: "left",
high: true,
code: "User.base.jobtitle",
},
],
excelData: [
{
userName: "测试人员001",
cardNo: "",
gender: "0",
birthday: "1990-09-26 00:00:00",
degreeId: "3",
status: "1",
departmentId: "197",
departmentTitle: "整备",
creatorUserId: "",
creationTime: "2020-08-19 11:43:33",
lastModifierUserId: "",
lastModificationTime: "",
phone: "13745781247",
email: "LZ@outlook.com",
licensedToWork: "3",
positionId: "2",
titleId: "1",
},
{
userName: "测试人员002",
cardNo: "11011",
gender: "1",
birthday: "1981-07-17 00:00:00",
degreeId: "3",
status: "1",
departmentId: "196",
departmentTitle: "乘务",
creatorUserId: "",
creationTime: "2020-08-19 11:43:33",
lastModifierUserId: "",
lastModificationTime: "",
phone: "14761586449",
email: "1594289563@qq.com",
licensedToWork: "3",
positionId: "3",
titleId: "4",
},
{
userName: "测试人员003",
cardNo: "11012",
gender: "0",
birthday: "1996-07-01 00:00:00",
degreeId: "3",
status: "1",
departmentId: "198",
departmentTitle: "物料库房",
creatorUserId: "",
creationTime: "2020-08-19 11:43:33",
lastModifierUserId: "",
lastModificationTime: "",
phone: "19254832512",
email: "1228562934@qq.com",
licensedToWork: "3",
positionId: "1",
titleId: "1",
},
],
formatList: ["xlsx"],
columnsImport: [],
departArr: [], //部门list
sheetNames: [], //excel的表明
workBook: {},
};
},
props: {
eid: Number,
},
created() {
this.tdHeightExcel = window.innerHeight - 240;
this.tdHeightExcel = window.innerHeight - 180;
//导出对列表头进行预加载start
let tempCol = this.$u.clone(this.columns);
tempCol.forEach((ele, index) => {
......@@ -336,17 +532,27 @@ export default {
},
//导入excel文件
async beforeUpload(file) {
this.excelData = [];
this.workBook = {};
this.$refs.uploadfile.clearFiles(); //清除上一次上传文件列表
//上传成功后的读取到excel信息
this.workBook = await this.$u.readXLSX(file);
this.sheetNames = this.workBook.SheetNames; //execel里的表明
this.dealSheet(0); //默认显示excel第一张表
//console.log(workbook);
return false;
},
dealSheet(index) {
//对表信息进行处理
this.excelData = [];
var tempColums = this.$u.clone(this.columnsImport);
const workbook = await this.$u.readXLSX(file);
const sheet2JSONOpts = {
defval: "", //给defval赋值为空的字符串
};
var csv = XLSX.utils.sheet_to_csv(
workbook.Sheets[workbook.SheetNames[0]],
this.workBook.Sheets[this.workBook.SheetNames[index]],
sheet2JSONOpts
);
var lines = csv.split("\n"); //第一行标题
var headers = lines[0].split(",");
var arrTi = [];
......@@ -416,8 +622,10 @@ export default {
});
});
this.excelData = result;
//console.log(workbook);
return false;
},
//切换sheet表重新加载
sheetClick(val) {
this.dealSheet(val);
},
handleClose() {
this.$emit("on-close");
......@@ -441,3 +649,17 @@ export default {
},
};
</script>
<style lang="less">
.content {
.table-footer {
line-height: 45px;
background: #f5f5f5;
}
.ivu-footer-toolbar {
text-align: left;
.ivu-footer-toolbar-right {
float: left;
}
}
}
</style>
{
"name": "admin",
"version": "1.0.0",
"description": "this is init project",
"author": "zhouyx",
"private": true
}
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