Commit e574be65 authored by renjintao's avatar renjintao

人员管理 导入/导出人员信息

parent 4f9a1bda
/* eslint-disable */
/* Blob.js
* A Blob implementation.
* 2014-05-27
*
* By Eli Grey, http://eligrey.com
* By Devin Samarin, https://github.com/eboyjr
* License: X11/MIT
* See LICENSE.md
*/
/*global self, unescape */
/*jslint bitwise: true, regexp: true, confusion: true, es5: true, vars: true, white: true,
plusplus: true */
/*! @source http://purl.eligrey.com/github/Blob.js/blob/master/Blob.js */
(function (view) {
"use strict";
view.URL = view.URL || view.webkitURL;
if (view.Blob && view.URL) {
try {
new Blob;
return;
} catch (e) {}
}
// Internally we use a BlobBuilder implementation to base Blob off of
// in order to support older browsers that only have BlobBuilder
var BlobBuilder = view.BlobBuilder || view.WebKitBlobBuilder || view.MozBlobBuilder || (function(view) {
var
get_class = function(object) {
return Object.prototype.toString.call(object).match(/^\[object\s(.*)\]$/)[1];
}
, FakeBlobBuilder = function BlobBuilder() {
this.data = [];
}
, FakeBlob = function Blob(data, type, encoding) {
this.data = data;
this.size = data.length;
this.type = type;
this.encoding = encoding;
}
, FBB_proto = FakeBlobBuilder.prototype
, FB_proto = FakeBlob.prototype
, FileReaderSync = view.FileReaderSync
, FileException = function(type) {
this.code = this[this.name = type];
}
, file_ex_codes = (
"NOT_FOUND_ERR SECURITY_ERR ABORT_ERR NOT_READABLE_ERR ENCODING_ERR "
+ "NO_MODIFICATION_ALLOWED_ERR INVALID_STATE_ERR SYNTAX_ERR"
).split(" ")
, file_ex_code = file_ex_codes.length
, real_URL = view.URL || view.webkitURL || view
, real_create_object_URL = real_URL.createObjectURL
, real_revoke_object_URL = real_URL.revokeObjectURL
, URL = real_URL
, btoa = view.btoa
, atob = view.atob
, ArrayBuffer = view.ArrayBuffer
, Uint8Array = view.Uint8Array
;
FakeBlob.fake = FB_proto.fake = true;
while (file_ex_code--) {
FileException.prototype[file_ex_codes[file_ex_code]] = file_ex_code + 1;
}
if (!real_URL.createObjectURL) {
URL = view.URL = {};
}
URL.createObjectURL = function(blob) {
var
type = blob.type
, data_URI_header
;
if (type === null) {
type = "application/octet-stream";
}
if (blob instanceof FakeBlob) {
data_URI_header = "data:" + type;
if (blob.encoding === "base64") {
return data_URI_header + ";base64," + blob.data;
} else if (blob.encoding === "URI") {
return data_URI_header + "," + decodeURIComponent(blob.data);
} if (btoa) {
return data_URI_header + ";base64," + btoa(blob.data);
} else {
return data_URI_header + "," + encodeURIComponent(blob.data);
}
} else if (real_create_object_URL) {
return real_create_object_URL.call(real_URL, blob);
}
};
URL.revokeObjectURL = function(object_URL) {
if (object_URL.substring(0, 5) !== "data:" && real_revoke_object_URL) {
real_revoke_object_URL.call(real_URL, object_URL);
}
};
FBB_proto.append = function(data/*, endings*/) {
var bb = this.data;
// decode data to a binary string
if (Uint8Array && (data instanceof ArrayBuffer || data instanceof Uint8Array)) {
var
str = ""
, buf = new Uint8Array(data)
, i = 0
, buf_len = buf.length
;
for (; i < buf_len; i++) {
str += String.fromCharCode(buf[i]);
}
bb.push(str);
} else if (get_class(data) === "Blob" || get_class(data) === "File") {
if (FileReaderSync) {
var fr = new FileReaderSync;
bb.push(fr.readAsBinaryString(data));
} else {
// async FileReader won't work as BlobBuilder is sync
throw new FileException("NOT_READABLE_ERR");
}
} else if (data instanceof FakeBlob) {
if (data.encoding === "base64" && atob) {
bb.push(atob(data.data));
} else if (data.encoding === "URI") {
bb.push(decodeURIComponent(data.data));
} else if (data.encoding === "raw") {
bb.push(data.data);
}
} else {
if (typeof data !== "string") {
data += ""; // convert unsupported types to strings
}
// decode UTF-16 to binary string
bb.push(unescape(encodeURIComponent(data)));
}
};
FBB_proto.getBlob = function(type) {
if (!arguments.length) {
type = null;
}
return new FakeBlob(this.data.join(""), type, "raw");
};
FBB_proto.toString = function() {
return "[object BlobBuilder]";
};
FB_proto.slice = function(start, end, type) {
var args = arguments.length;
if (args < 3) {
type = null;
}
return new FakeBlob(
this.data.slice(start, args > 1 ? end : this.data.length)
, type
, this.encoding
);
};
FB_proto.toString = function() {
return "[object Blob]";
};
FB_proto.close = function() {
this.size = this.data.length = 0;
};
return FakeBlobBuilder;
}(view));
view.Blob = function Blob(blobParts, options) {
var type = options ? (options.type || "") : "";
var builder = new BlobBuilder();
if (blobParts) {
for (var i = 0, len = blobParts.length; i < len; i++) {
builder.append(blobParts[i]);
}
}
return builder.getBlob(type);
};
}(typeof self !== "undefined" && self || typeof window !== "undefined" && window || this.content || this));
/* eslint-disable */
require('script-loader!file-saver');
require('./Blob.js');
require('script-loader!xlsx/dist/xlsx.core.min');
function generateArray(table) {
var out = [];
var rows = table.querySelectorAll('tr');
var ranges = [];
for (var R = 0; R < rows.length; ++R) {
var outRow = [];
var row = rows[R];
var columns = row.querySelectorAll('td');
for (var C = 0; C < columns.length; ++C) {
var cell = columns[C];
var colspan = cell.getAttribute('colspan');
var rowspan = cell.getAttribute('rowspan');
var cellValue = cell.innerText;
if (cellValue !== "" && cellValue == +cellValue) cellValue = +cellValue;
//Skip ranges
ranges.forEach(function (range) {
if (R >= range.s.r && R <= range.e.r && outRow.length >= range.s.c && outRow.length <= range.e.c) {
for (var i = 0; i <= range.e.c - range.s.c; ++i) outRow.push(null);
}
});
//Handle Row Span
if (rowspan || colspan) {
rowspan = rowspan || 1;
colspan = colspan || 1;
ranges.push({s: {r: R, c: outRow.length}, e: {r: R + rowspan - 1, c: outRow.length + colspan - 1}});
}
;
//Handle Value
outRow.push(cellValue !== "" ? cellValue : null);
//Handle Colspan
if (colspan) for (var k = 0; k < colspan - 1; ++k) outRow.push(null);
}
out.push(outRow);
}
return [out, ranges];
};
function datenum(v, date1904) {
if (date1904) v += 1462;
var epoch = Date.parse(v);
return (epoch - new Date(Date.UTC(1899, 11, 30))) / (24 * 60 * 60 * 1000);
}
function sheet_from_array_of_arrays(data, opts) {
var ws = {};
var range = {s: {c: 10000000, r: 10000000}, e: {c: 0, r: 0}};
for (var R = 0; R != data.length; ++R) {
for (var C = 0; C != data[R].length; ++C) {
if (range.s.r > R) range.s.r = R;
if (range.s.c > C) range.s.c = C;
if (range.e.r < R) range.e.r = R;
if (range.e.c < C) range.e.c = C;
var cell = {v: data[R][C]};
if (cell.v == null) continue;
var cell_ref = XLSX.utils.encode_cell({c: C, r: R});
if (typeof cell.v === 'number') cell.t = 'n';
else if (typeof cell.v === 'boolean') cell.t = 'b';
else if (cell.v instanceof Date) {
cell.t = 'n';
cell.z = XLSX.SSF._table[14];
cell.v = datenum(cell.v);
}
else cell.t = 's';
ws[cell_ref] = cell;
}
}
if (range.s.c < 10000000) ws['!ref'] = XLSX.utils.encode_range(range);
return ws;
}
function Workbook() {
if (!(this instanceof Workbook)) return new Workbook();
this.SheetNames = [];
this.Sheets = {};
}
function s2ab(s) {
var buf = new ArrayBuffer(s.length);
var view = new Uint8Array(buf);
for (var i = 0; i != s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
return buf;
}
export function export_table_to_excel(id) {
var theTable = document.getElementById(id);
console.log('a')
var oo = generateArray(theTable);
var ranges = oo[1];
/* original data */
var data = oo[0];
var ws_name = "SheetJS";
console.log(data);
var wb = new Workbook(), ws = sheet_from_array_of_arrays(data);
/* add ranges to worksheet */
// ws['!cols'] = ['apple', 'banan'];
ws['!merges'] = ranges;
/* add worksheet to workbook */
wb.SheetNames.push(ws_name);
wb.Sheets[ws_name] = ws;
var wbout = XLSX.write(wb, {bookType: 'xlsx', bookSST: false, type: 'binary'});
saveAs(new Blob([s2ab(wbout)], {type: "application/octet-stream"}), "test.xlsx")
}
function formatJson(jsonData) {
console.log(jsonData)
}
export function export_json_to_excel(th, jsonData, defaultTitle) {
/* original data */
var data = jsonData;
data.unshift(th);
var ws_name = "SheetJS";
var wb = new Workbook(), ws = sheet_from_array_of_arrays(data);
/* add worksheet to workbook */
wb.SheetNames.push(ws_name);
wb.Sheets[ws_name] = ws;
var wbout = XLSX.write(wb, {bookType: 'xlsx', bookSST: false, type: 'binary'});
var title = defaultTitle || '列表'
saveAs(new Blob([s2ab(wbout)], {type: "application/octet-stream"}), title + ".xlsx")
}
import {
head
} from "lodash";
import XLSX from 'xlsx';
let henq = {}; let henq = {};
let pdfInfo = '' let pdfInfo = ''
henq.clone = (obj) => { henq.clone = (obj) => {
...@@ -43,12 +47,12 @@ henq.isArray = u => { ...@@ -43,12 +47,12 @@ henq.isArray = u => {
return Object.prototype.toString.call(u) == '[object Array]'; return Object.prototype.toString.call(u) == '[object Array]';
} }
henq.toIntArray = u => { henq.toIntArray = u => {
if(henq.isNull(u)){ if (henq.isNull(u)) {
return []; return [];
} }
var arrs=u.split(',') var arrs = u.split(',')
var result=[]; var result = [];
arrs.map(p=>{ arrs.map(p => {
result.push(parseInt(p)); result.push(parseInt(p));
}) })
return result; return result;
...@@ -119,19 +123,20 @@ henq.toTree = (list, rootId, format, parentFiledName) => { ...@@ -119,19 +123,20 @@ henq.toTree = (list, rootId, format, parentFiledName) => {
return toTree(list, rootId, i) return toTree(list, rootId, i)
} }
henq.treeToList = (tree) => { henq.treeToList = (tree) => {
let list=[]; let list = [];
function treeToList(data) { function treeToList(data) {
data.map(u=>{ data.map(u => {
if(u.children){ if (u.children) {
treeToList(u.children,u) treeToList(u.children, u)
} }
let copy=henq.clone(u); let copy = henq.clone(u);
delete copy.delete; delete copy.delete;
copy.parent=u; copy.parent = u;
list.push(copy); list.push(copy);
}) })
} }
treeToList(tree,null) treeToList(tree, null)
return list; return list;
} }
//导出pdf //导出pdf
...@@ -158,4 +163,86 @@ henq.outPdf = (ele, fileName) => { ...@@ -158,4 +163,86 @@ henq.outPdf = (ele, fileName) => {
window.open("/static/pdf.html", '_blank'); window.open("/static/pdf.html", '_blank');
}, 1000) }, 1000)
} }
//导出json为excel
henq.outExcel = (fileName, title, key, outdata) => {
var that = henq
require.ensure([], () => {
const {
export_json_to_excel
} = require("@/excel/Export2Excel");
const tHeader = title; // 设置Excel的表格第一行的标题
const filterVal = key; //list里对象的属性
const list = outdata; //把data里的tableData存到list
const data = that.formatJson(filterVal, list);
export_json_to_excel(tHeader, data, fileName); //导出Excel 文件名
})
}
henq.formatJson = (filterVal, jsonData) => {
return jsonData.map((v) => filterVal.map((j) => v[j]));
}
//获取当前年月日时分秒
henq.getNowTime = () => {
var myDate = new Date();
let year = myDate.getFullYear().toString();
let month = (myDate.getMonth() + 1).toString();
if (month.length == 1) {
month = "0" + month;
}
let date = myDate.getDate().toString();
if (date.length == 1) {
date = "0" + date;
}
let hours = myDate.getHours().toString();
if (hours.length == 1) {
hours = "0" + hours;
}
let minutes = myDate.getMinutes().toString();
if (minutes.length == 1) {
minutes = "0" + minutes;
}
let seconds = myDate.getSeconds().toString();
if (seconds.length == 1) {
seconds = "0" + seconds;
}
return year + month + date + hours + minutes + seconds;
}
//读取本地excel
henq.readXLSX=(file)=>{
let nameSplit = file.name.split(".");
let format = nameSplit[nameSplit.length - 1];
if (!["xlsx", "csv"].includes(format)) {
return false;
}
return new Promise((resolve, reject) => {
let reader = new FileReader();
reader.readAsBinaryString(file);
reader.onload = function (evt) {
let data = evt.target.result; // 读到的数据
var workbook = XLSX.read(data, { type: "binary" });
resolve(workbook);
};
});
}
//得到根据value得到对应数据字典的name
henq.dirName=(code,v)=>{
var items=""
code.forEach(ele => {
if(ele.code==v)
{
items=ele.name
}
});
return items
}
//得到根据name得到对应数据字典的code
henq.dirCode=(code,v)=>{
var items=""
code.forEach(ele => {
if(ele.name==v)
{
items=ele.code
}
});
return items
}
export default henq; export default henq;
...@@ -2627,7 +2627,7 @@ ...@@ -2627,7 +2627,7 @@
}, },
"adler-32": { "adler-32": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/adler-32/-/adler-32-1.2.0.tgz", "resolved": "https://registry.npm.taobao.org/adler-32/download/adler-32-1.2.0.tgz",
"integrity": "sha1-aj5r8KY5ALoVZSgIyxXGgT0aXyU=", "integrity": "sha1-aj5r8KY5ALoVZSgIyxXGgT0aXyU=",
"requires": { "requires": {
"exit-on-epipe": "~1.0.1", "exit-on-epipe": "~1.0.1",
...@@ -4131,12 +4131,11 @@ ...@@ -4131,12 +4131,11 @@
"integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw="
}, },
"cfb": { "cfb": {
"version": "1.1.4", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/cfb/-/cfb-1.1.4.tgz", "resolved": "https://registry.npm.taobao.org/cfb/download/cfb-1.2.0.tgz",
"integrity": "sha512-rwFkl3aFO3f+ljR27YINwC0x8vPjyiEVbYbrTCKzspEf7Q++3THdfHVgJYNUbxNcupJECrLX+L40Mjm9hm/Bgw==", "integrity": "sha1-ak0IcrUl7WA0nh71H7Swv3Psqag=",
"requires": { "requires": {
"adler-32": "~1.2.0", "adler-32": "~1.2.0",
"commander": "^2.16.0",
"crc-32": "~1.2.0", "crc-32": "~1.2.0",
"printj": "~1.1.2" "printj": "~1.1.2"
} }
...@@ -4775,7 +4774,7 @@ ...@@ -4775,7 +4774,7 @@
}, },
"codepage": { "codepage": {
"version": "1.14.0", "version": "1.14.0",
"resolved": "https://registry.npmjs.org/codepage/-/codepage-1.14.0.tgz", "resolved": "https://registry.npm.taobao.org/codepage/download/codepage-1.14.0.tgz",
"integrity": "sha1-jL4lSBMjVZ19MHVxsP/5HnodL5k=", "integrity": "sha1-jL4lSBMjVZ19MHVxsP/5HnodL5k=",
"requires": { "requires": {
"commander": "~2.14.1", "commander": "~2.14.1",
...@@ -4784,8 +4783,8 @@ ...@@ -4784,8 +4783,8 @@
"dependencies": { "dependencies": {
"commander": { "commander": {
"version": "2.14.1", "version": "2.14.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.14.1.tgz", "resolved": "https://registry.npm.taobao.org/commander/download/commander-2.14.1.tgz?cache=0&sync_timestamp=1595168224685&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcommander%2Fdownload%2Fcommander-2.14.1.tgz",
"integrity": "sha512-+YR16o3rK53SmWHU3rEM3tPAh2rwb1yPcQX5irVn7mb0gXbwuCCrnkbV5+PBfETdfg1vui07nM6PCG1zndcjQw==" "integrity": "sha1-IjUSPjevjKPGXfRbAm29NXsBuao="
} }
} }
}, },
...@@ -5341,8 +5340,8 @@ ...@@ -5341,8 +5340,8 @@
}, },
"crc-32": { "crc-32": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.0.tgz", "resolved": "https://registry.npm.taobao.org/crc-32/download/crc-32-1.2.0.tgz",
"integrity": "sha512-1uBwHxF+Y/4yF5G48fwnKq6QsIXheor3ZLPT80yGBV1oEUwpPojlEhQbWKVw1VwcTQyMGHK1/XMmTjmlsmTTGA==", "integrity": "sha1-yy224puIUI4y2d0OwWk+e0Ghggg=",
"requires": { "requires": {
"exit-on-epipe": "~1.0.1", "exit-on-epipe": "~1.0.1",
"printj": "~1.1.0" "printj": "~1.1.0"
...@@ -6226,11 +6225,11 @@ ...@@ -6226,11 +6225,11 @@
} }
}, },
"echarts": { "echarts": {
"version": "4.7.0", "version": "4.8.0",
"resolved": "https://registry.npmjs.org/echarts/-/echarts-4.7.0.tgz", "resolved": "https://registry.npm.taobao.org/echarts/download/echarts-4.8.0.tgz?cache=0&sync_timestamp=1596215792462&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fecharts%2Fdownload%2Fecharts-4.8.0.tgz",
"integrity": "sha512-NlOTdUcAsIyCCG+N4uh0ZEvXtrPW2jvcuqf03RyqYeCKzyPbiOQ4I3MdKXMhxG3lBdqQNdNXVT71SB4KTQjN0A==", "integrity": "sha1-ssHPuSKbE9No7hBPyO6mALV01MQ=",
"requires": { "requires": {
"zrender": "4.3.0" "zrender": "4.3.1"
} }
}, },
"echarts-liquidfill": { "echarts-liquidfill": {
...@@ -7128,8 +7127,8 @@ ...@@ -7128,8 +7127,8 @@
}, },
"exit-on-epipe": { "exit-on-epipe": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/exit-on-epipe/-/exit-on-epipe-1.0.1.tgz", "resolved": "https://registry.npm.taobao.org/exit-on-epipe/download/exit-on-epipe-1.0.1.tgz",
"integrity": "sha512-h2z5mrROTxce56S+pnvAV890uu7ls7f1kEvVGJbw1OlFH3/mlJ5bkXu0KRyW94v37zzHPiUd55iLn3DA7TjWpw==" "integrity": "sha1-C92S6H1ShdJn2qgXHQ6wYVlolpI="
}, },
"expand-brackets": { "expand-brackets": {
"version": "2.1.4", "version": "2.1.4",
...@@ -7583,6 +7582,11 @@ ...@@ -7583,6 +7582,11 @@
"schema-utils": "^2.5.0" "schema-utils": "^2.5.0"
} }
}, },
"file-saver": {
"version": "2.0.2",
"resolved": "https://registry.npm.taobao.org/file-saver/download/file-saver-2.0.2.tgz",
"integrity": "sha1-BtbnKKnqLfLM4vjZ6E383DOOwXo="
},
"file-uri-to-path": { "file-uri-to-path": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
...@@ -7810,8 +7814,8 @@ ...@@ -7810,8 +7814,8 @@
}, },
"frac": { "frac": {
"version": "1.1.2", "version": "1.1.2",
"resolved": "https://registry.npmjs.org/frac/-/frac-1.1.2.tgz", "resolved": "https://registry.npm.taobao.org/frac/download/frac-1.1.2.tgz",
"integrity": "sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA==" "integrity": "sha1-PXT39keMiKG1AgMG10fcYxPHTQs="
}, },
"fragment-cache": { "fragment-cache": {
"version": "0.2.1", "version": "0.2.1",
...@@ -14415,8 +14419,8 @@ ...@@ -14415,8 +14419,8 @@
}, },
"printj": { "printj": {
"version": "1.1.2", "version": "1.1.2",
"resolved": "https://registry.npmjs.org/printj/-/printj-1.1.2.tgz", "resolved": "https://registry.npm.taobao.org/printj/download/printj-1.1.2.tgz",
"integrity": "sha512-zA2SmoLaxZyArQTOPj5LXecR+RagfPSU5Kw1qP+jkWeNlrq+eJZyY2oS68SU1Z/7/myXM4lo9716laOFAVStCQ==" "integrity": "sha1-2Q3rKXWoufYA+zoclOP0xTx4oiI="
}, },
"private": { "private": {
"version": "0.1.8", "version": "0.1.8",
...@@ -15889,8 +15893,8 @@ ...@@ -15889,8 +15893,8 @@
}, },
"script-loader": { "script-loader": {
"version": "0.7.2", "version": "0.7.2",
"resolved": "https://registry.npmjs.org/script-loader/-/script-loader-0.7.2.tgz", "resolved": "https://registry.npm.taobao.org/script-loader/download/script-loader-0.7.2.tgz",
"integrity": "sha512-UMNLEvgOAQuzK8ji8qIscM3GIrRCWN6MmMXGD4SD5l6cSycgGsCo0tX5xRnfQcoghqct0tjHjcykgI1PyBE2aA==", "integrity": "sha1-IBbbb4byX1z1baOJFdgzeLsWa6c=",
"dev": true, "dev": true,
"requires": { "requires": {
"raw-loader": "~0.5.1" "raw-loader": "~0.5.1"
...@@ -16469,8 +16473,8 @@ ...@@ -16469,8 +16473,8 @@
}, },
"ssf": { "ssf": {
"version": "0.10.3", "version": "0.10.3",
"resolved": "https://registry.npmjs.org/ssf/-/ssf-0.10.3.tgz", "resolved": "https://registry.npm.taobao.org/ssf/download/ssf-0.10.3.tgz",
"integrity": "sha512-pRuUdW0WwyB2doSqqjWyzwCD6PkfxpHAHdZp39K3dp/Hq7f+xfMwNAWIi16DyrRg4gg9c/RvLYkJTSawTPTm1w==", "integrity": "sha1-jq4fwpyQpVLnkhII+BiS1vd6yys=",
"requires": { "requires": {
"frac": "~1.1.2" "frac": "~1.1.2"
} }
...@@ -20192,8 +20196,8 @@ ...@@ -20192,8 +20196,8 @@
}, },
"wmf": { "wmf": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/wmf/-/wmf-1.0.2.tgz", "resolved": "https://registry.npm.taobao.org/wmf/download/wmf-1.0.2.tgz",
"integrity": "sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw==" "integrity": "sha1-fRnWIQcaCMK9xrfmiKnENSmMwto="
}, },
"word-wrap": { "word-wrap": {
"version": "1.2.3", "version": "1.2.3",
...@@ -20311,8 +20315,8 @@ ...@@ -20311,8 +20315,8 @@
}, },
"xlsx": { "xlsx": {
"version": "0.15.6", "version": "0.15.6",
"resolved": "https://registry.npmjs.org/xlsx/-/xlsx-0.15.6.tgz", "resolved": "https://registry.npm.taobao.org/xlsx/download/xlsx-0.15.6.tgz?cache=0&sync_timestamp=1597272342311&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fxlsx%2Fdownload%2Fxlsx-0.15.6.tgz",
"integrity": "sha512-7vD9eutyLs65iDjNFimVN+gk/oDkfkCgpQUjdE82QgzJCrBHC4bGPH7fzKVyy0UPp3gyFVQTQEFJaWaAvZCShQ==", "integrity": "sha1-Rh+EHW2eoag3XizSRr8jrs4IodU=",
"requires": { "requires": {
"adler-32": "~1.2.0", "adler-32": "~1.2.0",
"cfb": "^1.1.4", "cfb": "^1.1.4",
...@@ -20326,8 +20330,8 @@ ...@@ -20326,8 +20330,8 @@
"dependencies": { "dependencies": {
"commander": { "commander": {
"version": "2.17.1", "version": "2.17.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.17.1.tgz", "resolved": "https://registry.npm.taobao.org/commander/download/commander-2.17.1.tgz?cache=0&sync_timestamp=1595168224685&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcommander%2Fdownload%2Fcommander-2.17.1.tgz",
"integrity": "sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==" "integrity": "sha1-vXerfebelCBc6sxy8XFtKfIKd78="
} }
} }
}, },
...@@ -20593,9 +20597,9 @@ ...@@ -20593,9 +20597,9 @@
} }
}, },
"zrender": { "zrender": {
"version": "4.3.0", "version": "4.3.1",
"resolved": "https://registry.npmjs.org/zrender/-/zrender-4.3.0.tgz", "resolved": "https://registry.npm.taobao.org/zrender/download/zrender-4.3.1.tgz?cache=0&sync_timestamp=1596718989769&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fzrender%2Fdownload%2Fzrender-4.3.1.tgz",
"integrity": "sha512-Dii6j2bDsPkxQayuVf2DXJeruIB/mKVxxcGRZQ9GExiBd4c3w7+oBuvo1O/JGHeFeA1nCmSDVDs/S7yKZG1nrA==" "integrity": "sha1-uviqbcgYei+BlpLX1fm+36K5D6M="
} }
} }
} }
...@@ -19,8 +19,9 @@ ...@@ -19,8 +19,9 @@
"better-scroll": "^1.12.1", "better-scroll": "^1.12.1",
"cross-env": "^5.2.0", "cross-env": "^5.2.0",
"dayjs": "^1.8.22", "dayjs": "^1.8.22",
"echarts": "^4.7.0", "echarts": "^4.8.0",
"echarts-liquidfill": "^2.0.5", "echarts-liquidfill": "^2.0.5",
"file-saver": "^2.0.2",
"gojs": "^2.1.10", "gojs": "^2.1.10",
"iview-loader": "^1.3.0", "iview-loader": "^1.3.0",
"iview-pro": "file:./iview-pro", "iview-pro": "file:./iview-pro",
...@@ -49,7 +50,7 @@ ...@@ -49,7 +50,7 @@
"vue2-editor": "^2.10.2", "vue2-editor": "^2.10.2",
"vuedraggable": "^2.23.0", "vuedraggable": "^2.23.0",
"vuex-along": "^1.2.10", "vuex-along": "^1.2.10",
"xlsx": "^0.15.1" "xlsx": "^0.15.6"
}, },
"devDependencies": { "devDependencies": {
"@babel/plugin-transform-runtime": "^7.2.0", "@babel/plugin-transform-runtime": "^7.2.0",
...@@ -66,9 +67,9 @@ ...@@ -66,9 +67,9 @@
"less": "^2.7.3", "less": "^2.7.3",
"less-loader": "^4.1.0", "less-loader": "^4.1.0",
"lint-staged": "^7.2.0", "lint-staged": "^7.2.0",
"script-loader": "^0.7.2",
"svg-sprite-loader": "^3.8.0", "svg-sprite-loader": "^3.8.0",
"text-loader": "0.0.1", "text-loader": "0.0.1",
"vue-template-compiler": "^2.6.11", "vue-template-compiler": "^2.6.11"
"script-loader": "^0.7.2"
} }
} }
...@@ -52,4 +52,9 @@ export default { ...@@ -52,4 +52,9 @@ export default {
accountreset(params) { accountreset(params) {
return Api.post(`${systemUrl}/user/accountreset`, params); return Api.post(`${systemUrl}/user/accountreset`, params);
}, },
//批量导入用户
accountreset(params) {
return Api.post(`${systemUrl}/userimportservice/import`, params);
},
} }
\ No newline at end of file
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
</template> </template>
<template slot="buttons"> <template slot="buttons">
<Button type="primary" @click="addModal=true">新增</Button> <Button type="primary" @click="addModal=true">新增</Button>
<Button @click="import2Excel">导入</Button>
<Button @click="export2Excel">导出</Button>
</template> </template>
</DataGrid> </DataGrid>
<Modal v-model="addModal" title="新增" footer-hide width="800"> <Modal v-model="addModal" title="新增" footer-hide width="800">
...@@ -116,24 +118,45 @@ ...@@ -116,24 +118,45 @@
<Modal v-model="syncAccountModal" title="同步账户" @on-ok="syncAccountOk" @on-cancel="cancel"> <Modal v-model="syncAccountModal" title="同步账户" @on-ok="syncAccountOk" @on-cancel="cancel">
<p>确定同步账户?</p> <p>确定同步账户?</p>
</Modal> </Modal>
<Modal v-model="modalImport" title="导入excel" fullscreen hidefooter>
<Upload action :before-upload="beforeUpload" ref="uploadfile">
<Button icon="ios-cloud-upload-outline">上传Excel文件</Button>
</Upload>
<DataGrid
border
:height="tdHeightExcel"
:columns="columnImport"
:data="excelData"
:tool="false"
:page="false"
></DataGrid>
<div slot="footer">
<Button @click="cancelExcel">取消</Button>
<Button type="primary" @click="importOk">确定导入</Button>
</div>
</Modal>
</Content> </Content>
</Layout> </Layout>
</template> </template>
<script> <script>
import Api from "./api"; import Api from "./api";
import ApiDepart from "../department/api";
import Add from "./add"; import Add from "./add";
import Edit from "./edit"; import Edit from "./edit";
import Detail from "./detail"; import Detail from "./detail";
import Search from "./search"; import Search from "./search";
import service from "@/plugins/request"; import service from "@/plugins/request";
import util from '@/libs/util'; import util from "@/libs/util";
import { Time } from "view-design";
import XLSX from "xlsx";
export default { export default {
name: "list", name: "list",
components: { components: {
Add, Add,
Edit, Edit,
Detail, Detail,
Search Search,
}, },
data() { data() {
return { return {
...@@ -143,12 +166,13 @@ export default { ...@@ -143,12 +166,13 @@ export default {
op: op:
"userName,cardNo,national,phone,email,enableEquip,jobNo,remark,departmentTitle,roleTitles", "userName,cardNo,national,phone,email,enableEquip,jobNo,remark,departmentTitle,roleTitles",
value: null, value: null,
default: true default: true,
}, },
departmentId: { op: "In", value: "" } departmentId: { op: "In", value: "" },
}, },
treeData: [], treeData: [],
tdHeight: "", tdHeight: "",
tdHeightExcel: "",
treeInputSearch: "", treeInputSearch: "",
treeHeight: "", treeHeight: "",
tableHeight: "", tableHeight: "",
...@@ -184,12 +208,12 @@ export default { ...@@ -184,12 +208,12 @@ export default {
"op", "op",
{ {
attrs: { oprate: "detail" }, attrs: { oprate: "detail" },
on: { click: () => this.detail(params.row.id) } on: { click: () => this.detail(params.row.id) },
}, },
params.row.userName params.row.userName
) ),
]); ]);
} },
}, },
// { // {
// key: 'cardTypeId', // key: 'cardTypeId',
...@@ -203,14 +227,14 @@ export default { ...@@ -203,14 +227,14 @@ export default {
title: this.l("cardNo"), title: this.l("cardNo"),
align: "left", align: "left",
easy: true, easy: true,
high: true high: true,
}, },
{ {
key: "gender", key: "gender",
title: this.l("gender"), title: this.l("gender"),
align: "center", align: "center",
high: true, high: true,
code: "User.base.gender" code: "User.base.gender",
}, },
{ {
key: "birthday", key: "birthday",
...@@ -218,7 +242,7 @@ export default { ...@@ -218,7 +242,7 @@ export default {
align: "center", align: "center",
high: true, high: true,
hide: true, hide: true,
type: "date" type: "date",
}, },
{ {
key: "degreeId", key: "degreeId",
...@@ -226,22 +250,30 @@ export default { ...@@ -226,22 +250,30 @@ export default {
align: "left", align: "left",
high: true, high: true,
code: "User.base.degree", code: "User.base.degree",
hide: true hide: true,
}, },
{ {
key: "status", key: "status",
title: this.l("status"), title: this.l("status"),
align: "center", align: "center",
high: true, high: true,
code: "User.base.status" code: "User.base.status",
},
{
key: "departmentId",
title: this.l("departmentId"),
align: "right",
easy: true,
high: true,
}, },
{ {
key: "departmentTitle", key: "departmentTitle",
title: this.l("departmentTitle"), title: this.l("departmentTitle"),
align: "left", align: "left",
easy: true, easy: true,
high: true high: true,
}, },
{ {
key: "roleTitles", key: "roleTitles",
title: this.l("roleTitles"), title: this.l("roleTitles"),
...@@ -259,46 +291,46 @@ export default { ...@@ -259,46 +291,46 @@ export default {
params.row.roleTitles == null || params.row.roleTitles == null ||
params.row.roleTitles == "" params.row.roleTitles == ""
? "empower" ? "empower"
: "detail" : "detail",
}, },
on: { click: () => this.authorize(params.row.id) } on: { click: () => this.authorize(params.row.id) },
}, },
params.row.roleTitles == null || params.row.roleTitles == "" params.row.roleTitles == null || params.row.roleTitles == ""
? "授权" ? "授权"
: params.row.roleTitles : params.row.roleTitles
) ),
]); ]);
} },
}, },
{ {
key: "creatorUserId", key: "creatorUserId",
title: this.l("creatorUserId"), title: this.l("creatorUserId"),
hide: true, hide: true,
align: "left" align: "left",
}, },
{ {
key: "creationTime", key: "creationTime",
title: this.l("creationTime"), title: this.l("creationTime"),
hide: true, hide: true,
align: "left" align: "left",
}, },
{ {
key: "lastModifierUserId", key: "lastModifierUserId",
title: this.l("lastModifierUserId"), title: this.l("lastModifierUserId"),
hide: true, hide: true,
align: "left" align: "left",
}, },
{ {
key: "lastModificationTime", key: "lastModificationTime",
title: this.l("lastModificationTime"), title: this.l("lastModificationTime"),
hide: true, hide: true,
align: "left" align: "left",
}, },
{ {
key: "accountId", key: "accountId",
title: this.l("accountId"), title: this.l("accountId"),
hide: true, hide: true,
align: "left" align: "left",
}, },
// { // {
// key: 'userType', // key: 'userType',
...@@ -311,7 +343,7 @@ export default { ...@@ -311,7 +343,7 @@ export default {
title: this.l("phone"), title: this.l("phone"),
align: "left", align: "left",
easy: true, easy: true,
high: true high: true,
}, },
{ {
key: "email", key: "email",
...@@ -319,13 +351,13 @@ export default { ...@@ -319,13 +351,13 @@ export default {
align: "left", align: "left",
easy: true, easy: true,
high: true, high: true,
hide: true hide: true,
}, },
{ {
key: "licensedToWork", key: "licensedToWork",
title: this.l("licensedToWork"), title: this.l("licensedToWork"),
align: "left", align: "left",
hide: true hide: true,
}, },
{ {
key: "positionId", key: "positionId",
...@@ -333,7 +365,7 @@ export default { ...@@ -333,7 +365,7 @@ export default {
align: "left", align: "left",
high: true, high: true,
code: "User.base.position", code: "User.base.position",
hide: true hide: true,
}, },
{ {
key: "titleId", key: "titleId",
...@@ -341,9 +373,8 @@ export default { ...@@ -341,9 +373,8 @@ export default {
align: "left", align: "left",
high: true, high: true,
code: "User.base.jobtitle", code: "User.base.jobtitle",
hide: true hide: true,
}, },
{ {
title: "操作", title: "操作",
key: "action", key: "action",
...@@ -356,9 +387,9 @@ export default { ...@@ -356,9 +387,9 @@ export default {
{ {
attrs: { attrs: {
oprate: "detail", oprate: "detail",
class: "empower" class: "empower",
}, },
on: { click: () => this.syncAccount(params.row) } on: { click: () => this.syncAccount(params.row) },
}, },
params.row.accountId == 0 ? "同步" : "" params.row.accountId == 0 ? "同步" : ""
), ),
...@@ -366,7 +397,7 @@ export default { ...@@ -366,7 +397,7 @@ export default {
"op", "op",
{ {
attrs: { oprate: "edit" }, attrs: { oprate: "edit" },
on: { click: () => this.edit(params.row.id) } on: { click: () => this.edit(params.row.id) },
}, },
"编辑" "编辑"
), ),
...@@ -374,7 +405,7 @@ export default { ...@@ -374,7 +405,7 @@ export default {
"op", "op",
{ {
attrs: { oprate: "remove" }, attrs: { oprate: "remove" },
on: { click: () => this.remove(params.row) } on: { click: () => this.remove(params.row) },
}, },
"删除" "删除"
), ),
...@@ -382,35 +413,173 @@ export default { ...@@ -382,35 +413,173 @@ export default {
"op", "op",
{ {
attrs: { attrs: {
oprate: "detail" oprate: "detail",
}, },
on: { click: () => this.openReset(params.row) } on: { click: () => this.openReset(params.row) },
}, },
"重置密码" "重置密码"
) ),
]); ]);
} },
} },
], ],
selectRow: {} //删除时选中的行数据 selectRow: {}, //删除时选中的行数据
//导入导出时使用
searchs: {
pageIndex: 1,
pageSize: 1000,
conditions: [],
},
list: [],
modalImport: false,
excelData: [],
columnImport: [
{
key: "userName",
title: this.l("userName"),
align: "left",
easy: true,
high: true,
},
{
key: "cardNo",
title: this.l("cardNo"),
align: "left",
easy: true,
high: true,
},
{
key: "gender",
title: this.l("gender"),
align: "center",
high: true,
code: "User.base.gender",
},
{
key: "birthday",
title: this.l("birthday"),
align: "center",
high: true,
type: "date",
},
{
key: "degreeId",
title: this.l("degreeId"),
align: "left",
high: true,
code: "User.base.degree",
},
{
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,
},
{
key: "accountId",
title: this.l("accountId"),
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",
},
{
key: "creatorUserId",
title: this.l("creatorUserId"),
align: "left",
type: "user",
},
{
key: "creationTime",
title: this.l("creationTime"),
align: "left",
},
{
key: "lastModifierUserId",
title: this.l("lastModifierUserId"),
align: "left",
type: "user",
},
{
key: "lastModificationTime",
title: this.l("lastModificationTime"),
align: "left",
},
],
departArr: [], //部门list
}; };
}, },
created() { created() {
this.treeHeight = window.innerHeight - 150 this.treeHeight = window.innerHeight - 150;
this.tdHeight = window.innerHeight - 240 this.tdHeight = window.innerHeight - 240;
this.tdHeightExcel = window.innerHeight - 240;
}, },
mounted() { mounted() {
window.onresize = () => { window.onresize = () => {
///浏览器窗口大小变化 ///浏览器窗口大小变化
return (() => { return (() => {
window.screenHeight = window.innerHeight window.screenHeight = window.innerHeight;
this.treeHeight = window.screenHeight - 150 this.treeHeight = window.screenHeight - 150;
this.tdHeight = window.screenHeight - 240 this.tdHeight = window.screenHeight - 240;
this.tdHeightExcel = window.innerHeight - 240;
})(); })();
} };
this.initTree() this.initTree();
this.loadrole(0) this.loadrole(0);
this.loadrole(1) this.loadrole(1);
}, },
async fetch({ store, params }) { async fetch({ store, params }) {
await store.dispatch("loadDictionary"); // 加载数据字典 await store.dispatch("loadDictionary"); // 加载数据字典
...@@ -443,7 +612,7 @@ export default { ...@@ -443,7 +612,7 @@ export default {
this.selectRow = row; this.selectRow = row;
}, },
removeOk() { removeOk() {
Api.delete({ id: this.curId }).then(r => { Api.delete({ id: this.curId }).then((r) => {
if (r.success) { if (r.success) {
this.$refs.grid.load(); this.$refs.grid.load();
this.deletelModal = false; this.deletelModal = false;
...@@ -452,11 +621,11 @@ export default { ...@@ -452,11 +621,11 @@ export default {
let parms = { let parms = {
userId: this.curId, userId: this.curId,
accountId: this.selectRow.accountId, accountId: this.selectRow.accountId,
tanantCode: util.cookies.get('tanantCode'), tanantCode: util.cookies.get("tanantCode"),
isDeleted: true, isDeleted: true,
name:this.selectRow.userName name: this.selectRow.userName,
}; };
Api.authAccount(parms).then(res => { Api.authAccount(parms).then((res) => {
if (res.success) { if (res.success) {
this.$Message.success("账户同步成功"); this.$Message.success("账户同步成功");
} }
...@@ -524,9 +693,9 @@ export default { ...@@ -524,9 +693,9 @@ export default {
reset() { reset() {
let parms = { let parms = {
userId: this.curId, userId: this.curId,
accountId: this.selectRow.accountId accountId: this.selectRow.accountId,
}; };
Api.authResetpassword(parms).then(res => { Api.authResetpassword(parms).then((res) => {
if (res.success) { if (res.success) {
this.$Message.success("重置成功!"); this.$Message.success("重置成功!");
} else { } else {
...@@ -538,7 +707,7 @@ export default { ...@@ -538,7 +707,7 @@ export default {
loadrole(type) { loadrole(type) {
var url = `${systemUrl}/MyRole/GetRolesAsync`; var url = `${systemUrl}/MyRole/GetRolesAsync`;
var data = []; var data = [];
service.get(`${url}`, { role_type: type } ).then(response => { service.get(`${url}`, { role_type: type }).then((response) => {
data = response.result.items; data = response.result.items;
if (type == 1) { if (type == 1) {
this.authList = data; this.authList = data;
...@@ -555,12 +724,12 @@ export default { ...@@ -555,12 +724,12 @@ export default {
this.curId = id; this.curId = id;
this.show3 = true; this.show3 = true;
var url = `${systemUrl}/MyUserRole/GetPaged`; var url = `${systemUrl}/MyUserRole/GetPaged`;
service.get(`${url}`, { userId: id }).then(response => { service.get(`${url}`, { userId: id }).then((response) => {
var data = response.result.items; var data = response.result.items;
var dt1 = data.filter(function(ite) { var dt1 = data.filter(function (ite) {
return ite.role_type == 0; return ite.role_type == 0;
}); });
var dt2 = data.filter(function(ite) { var dt2 = data.filter(function (ite) {
return ite.role_type == 1; return ite.role_type == 1;
}); });
dt1.forEach((item, i) => { dt1.forEach((item, i) => {
...@@ -574,14 +743,13 @@ export default { ...@@ -574,14 +743,13 @@ export default {
authOk() { authOk() {
var url = `${systemUrl}/MyUserRole/CreateOrUpdate`; var url = `${systemUrl}/MyUserRole/CreateOrUpdate`;
service service
.post( .post(`${url}`, {
`${url}`,{
myUserRole: { myUserRole: {
userId: this.curId, userId: this.curId,
RoleIds: this.allChecked.join(",") RoleIds: this.allChecked.join(","),
} },
}) })
.then(response => { .then((response) => {
if (response.success) { if (response.success) {
this.$Message.success("保存成功"); this.$Message.success("保存成功");
this.authModel.extra = []; this.authModel.extra = [];
...@@ -589,7 +757,7 @@ export default { ...@@ -589,7 +757,7 @@ export default {
this.$refs.grid.easySearch(); this.$refs.grid.easySearch();
} }
}) })
.catch(error => { .catch((error) => {
this.$Message.error("保存失败"); this.$Message.error("保存失败");
}); });
}, },
...@@ -604,18 +772,18 @@ export default { ...@@ -604,18 +772,18 @@ export default {
userId: this.selectRow.id, userId: this.selectRow.id,
loginName: this.selectRow.phone, loginName: this.selectRow.phone,
status: this.selectRow.status, status: this.selectRow.status,
tanantCode:util.cookies.get('tanantCode'), tanantCode: util.cookies.get("tanantCode"),
name:this.selectRow.userName name: this.selectRow.userName,
}; };
if (this.selectRow.phone && this.selectRow.phone != "") { if (this.selectRow.phone && this.selectRow.phone != "") {
Api.authAccount(parms).then(res => { Api.authAccount(parms).then((res) => {
if (res.success) { if (res.success) {
this.$Message.success("账户同步成功"); this.$Message.success("账户同步成功");
let parms1 = { let parms1 = {
userId: parms.userId, userId: parms.userId,
accountId: res.result accountId: res.result,
}; };
Api.updateAccount(parms1).then(res1 => { Api.updateAccount(parms1).then((res1) => {
if (res1.success) { if (res1.success) {
this.$Message.success("操作成功"); this.$Message.success("操作成功");
this.$refs.grid.easySearch(); this.$refs.grid.easySearch();
...@@ -628,8 +796,196 @@ export default { ...@@ -628,8 +796,196 @@ export default {
} else { } else {
this.$Message.error("请完善个人电话信息"); this.$Message.error("请完善个人电话信息");
} }
} },
//同步账户end //同步账户end
//导出excel
export2Excel() {
var where = [];
var conditions = this.easySearch;
if (conditions) {
Object.keys(conditions).forEach((u) => {
let v = conditions[u].value;
let op = conditions[u].op;
if (!this.$u.isNull(v)) {
if (op == "Range") {
let times = [];
v.map((u) => {
if (!this.$u.isNull(u)) {
times.push(this.$u.toTime(u));
}
});
v = times.join(",");
} else if (op.indexOf("In") > -1) {
v = v.join(",");
}
if (!this.$u.isNull(v)) {
where.push({
fieldName: u,
fieldValue: v,
conditionalType: op,
});
}
}
});
}
this.searchs.pageIndex = 1;
this.searchs.conditions = where;
this.searchs.pageSize = 1000;
this.$api.post(this.action, this.searchs).then((r) => {
this.list = r.result.items;
const tHeader = []; // 设置Excel的表格第一行的标题
const filterVal = []; //list里对象的属性
var tempCol = [];
var columnsCur = this.$refs.grid.columnsCur; //导出列信息
columnsCur.forEach((el) => {
if (!el.hide && el.key != "action") {
if (el.code) {
tHeader.push(el.key + "DirName");
filterVal.push(el.key + "DirName");
tempCol.push({ key: el.key + "DirName", code: el.code }); //临时存放code数据字典的字段及对应的数据字典code
}
tHeader.push(el.key);
filterVal.push(el.key);
}
});
this.list.forEach((e) => {
//给导出数据增加数据字典对应的name
tempCol.forEach((ele) => {
e[ele.key] = this.$u.dirName(
this.$store.getters.dictionaryByKey(ele.code),
e[ele.key.substring(0, ele.key.length - 7)]
);
});
});
let nowDate = this.$u.getNowTime(); //年月日时分秒yyyyMMddhhmmss
//获取导出数据结束
this.$u.outExcel(
"用户管理(" + nowDate + ")",
tHeader,
filterVal,
this.list
);
});
},
//导入excel
import2Excel() {
this.modalImport = true;
this.excelData = [];
this.$refs.uploadfile.clearFiles();
ApiDepart.getpaged().then((r) => {
this.departArr = r.result.items;
});
},
async beforeUpload(file) {
this.excelData = [];
const workbook = await this.$u.readXLSX(file);
const sheet2JSONOpts = {
defval: "", //给defval赋值为空的字符串
};
var tempList = XLSX.utils.sheet_to_json(
workbook.Sheets[workbook.SheetNames[0]],
sheet2JSONOpts
);
this.$refs.uploadfile.clearFiles();//清除上一次上传文件列表
//对读取的excel文件数据进行处理
var tempColums = tempList[0]; //必须保证excel第一行数据行DirName有数据值,否则取不到所有的标题
var arrTitle = Object.keys(tempColums);
var arrTitleUse = []; //使用数据字典的字段
arrTitle.forEach((el) => {
if (el.indexOf("DirName") != -1) {
arrTitleUse.push({ name: el, val: el.substring(0, el.length - 7) });
}
});
tempList.forEach((ele) => {
//如果导入文件没有departmentid,但存在departmentTitle的话,通过title获取id
if (
ele.departmentTitle &&
ele.departmentTitle != "" &&
(!ele.departmentId || ele.departmentId == "")
) {
this.departArr.forEach((e) => {
if (ele.departmentTitle && ele.departmentTitle == e.name) {
ele.departmentId = e.id;
}
});
} else if (//如果导入文件没有departmentTitle,但存在departmentid的话,通过id获取departmentTitle
ele.departmentId &&
ele.departmentId + "" != "" &&
(!ele.departmentTitle || ele.departmentTitle == "")
) {
this.departArr.forEach((e) => {
if (ele.departmentId && ele.departmentId == e.id) {
ele.departmentTitle = e.name;
}
});
}
//对列表里的数据字典项进行处理
arrTitleUse.forEach((elem) => {
if (!ele[elem.val] || ele[elem.val] == "" || ele[elem.val] == null) {
this.columnImport.forEach((co) => {
if (co.key == elem.val) {
if (ele[elem.name]) {
//如果数据字典项对应的DirName字段存在,通过name查询到对应的code,然后赋值
ele[elem.val] = this.$u.dirCode(
this.$store.getters.dictionaryByKey(co.code),
ele[elem.name]
);
} else {
//如果对应的DirName不存在,则赋值此字段对应的数据字典项对应的第一个默认值
ele[elem.val] = this.$store.getters.dictionaryByKey(
co.code
)[0].code;
}
}
});
}
});
});
this.excelData = tempList;
//console.log(workbook);
return false;
},
importOk() {
//确定批量导入
let tempData = this.$u.clone(this.excelData);
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,
};
tempList.push(obj);
});
let parms = {
list: tempList,
};
Api.accountreset(parms).then((res) => {
if (res.success) {
this.$Message.success("批量导入成功!");
this.$refs.grid.load();
this.cancelExcel();
} else {
this.$Message.error("批量导入失败!");
}
});
},
cancelExcel() {
this.modalImport = false;
this.excelData = [];
this.$refs.uploadfile.clearFiles();
},
}, },
computed: { computed: {
searchList() { searchList() {
...@@ -652,10 +1008,10 @@ export default { ...@@ -652,10 +1008,10 @@ export default {
} }
return newNodeList; return newNodeList;
}, },
allChecked: function() { allChecked: function () {
return [...this.authModel.extra, ...this.authModel.default]; return [...this.authModel.extra, ...this.authModel.default];
} },
} },
}; };
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
......
...@@ -2,6 +2,7 @@ import Vue from 'vue' ...@@ -2,6 +2,7 @@ import Vue from 'vue'
import ViewUI from 'view-design' import ViewUI from 'view-design'
import VueI18n from 'vue-i18n'; import VueI18n from 'vue-i18n';
import Languages from '@/i18n/locale'; import Languages from '@/i18n/locale';
import XLSX from 'xlsx'
import VueParticles from 'vue-particles' import VueParticles from 'vue-particles'
// 插件 // 插件
...@@ -68,7 +69,7 @@ import iLink from '@/components/link'; ...@@ -68,7 +69,7 @@ import iLink from '@/components/link';
import OrgTree from 'v-org-tree' import OrgTree from 'v-org-tree'
import 'v-org-tree/dist/v-org-tree.css' import 'v-org-tree/dist/v-org-tree.css'
Vue.use(OrgTree) Vue.use(OrgTree)
Vue.use(XLSX)
Vue.component("iLink", iLink) Vue.component("iLink", iLink)
Vue.prototype.$echarts = echarts Vue.prototype.$echarts = echarts
......
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