Commit 0e19d11e authored by 仇晓婷's avatar 仇晓婷

Merge branch 'master' of http://git.mes123.com/zhouyx/mes-ui

parents c25fd74e c0b6424e
...@@ -21,9 +21,7 @@ ul, ...@@ -21,9 +21,7 @@ ul,
li { li {
list-style: none; list-style: none;
} }
.ivu-drawer-wrap{
z-index: 12000;
}
div::-webkit-scrollbar { div::-webkit-scrollbar {
width: 10px; width: 10px;
height: 10px; height: 10px;
......
...@@ -23,6 +23,9 @@ ...@@ -23,6 +23,9 @@
background-color: @primary-color; background-color: @primary-color;
border-color: @primary-color; border-color: @primary-color;
} }
.ivu-drawer-wrap,.tree-drawer{
z-index: 12000;
}
.ivu-btn-group:not(.ivu-btn-group-vertical) .ivu-btn-primary:first-child:not(:last-child) { .ivu-btn-group:not(.ivu-btn-group-vertical) .ivu-btn-primary:first-child:not(:last-child) {
border-right-color: @primary-color; border-right-color: @primary-color;
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
<Table :border="true" :columns="columnsImport" :data="excelData" :height="tdHeightExcel" :no-data-text="noDataText" ref="table" class="tableCommon" v-if="tableImport"></Table> <Table :border="true" :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" /> <component :is="detailExcel" ref="comExcel" @on-datalength="datalength" />
</div> </div>
<FooterToolbar v-if="sheetNames.length>1&&tableImport"> <FooterToolbar v-if="sheetNames.length>1&&tableImport" class="footer">
<Form inline> <Form inline>
<FormItem> <FormItem>
<Tabs :animated="false" :value="0" @on-click="sheetClick"> <Tabs :animated="false" :value="0" @on-click="sheetClick">
...@@ -79,11 +79,10 @@ export default { ...@@ -79,11 +79,10 @@ export default {
tableImport: true, tableImport: true,
tdHeightExcel: "", tdHeightExcel: "",
excelData: [], excelData: [],
excelDataBack: [], //临时存储原始数据 excelDataBack: [], //临时存储原始数据,
formatList: ["xlsx"], formatList: ["xlsx"],
columnsImport: [], columnsImport: [],
departArr: [], //部门list departArr: [], //部门list
usersArr: [],
sheetNames: [], //excel的表明 sheetNames: [], //excel的表明
workBook: {}, workBook: {},
openDatas: [], openDatas: [],
...@@ -105,7 +104,7 @@ export default { ...@@ -105,7 +104,7 @@ export default {
props: { props: {
eid: Number, eid: Number,
data: { data: {
// 当作table使用,直接显示数据 // 当作table使用,直接显示数据,数据里不能用英文逗号',',因为将excel转为数据后是用','分解的
type: Array, type: Array,
default: function () { default: function () {
return []; return [];
...@@ -131,12 +130,6 @@ export default { ...@@ -131,12 +130,6 @@ export default {
this.$api.get(`${systemUrl}/Department/GetDepartments`).then((r) => { this.$api.get(`${systemUrl}/Department/GetDepartments`).then((r) => {
this.departArr = r.result.items; this.departArr = r.result.items;
}); });
this.$api.get(`${systemUrl}/user/getuserlist`)
.then((r) => {
if (r.success) {
this.usersArr = r.result
}
})
//导出对列表头进行预加载end //导出对列表头进行预加载end
}, },
async fetch({ async fetch({
...@@ -279,25 +272,28 @@ export default { ...@@ -279,25 +272,28 @@ export default {
//人员名称转换为userid,如果查不到此人员,则为空 //人员名称转换为userid,如果查不到此人员,则为空
arrUseName.forEach((euser) => { arrUseName.forEach((euser) => {
if (eles[euser.key] && eles[euser.key] != "" && eles[euser.key] != null) { if (eles[euser.key] && eles[euser.key] != "" && eles[euser.key] != null) {
this.usersArr.forEach(eluser => { if (this.$store.state.userNameMap.get(eles[euser.key])) {
if (eles[euser.key] == eluser.name) { eles[euser.key] = this.$store.state.userNameMap.get(eles[euser.key]).id
eles[euser.key] = eluser.id } else {
} eles[euser.key] = null
}) }
} }
}); });
//多个名称转换为数组 //多个名称转换为数组
arrUseNames.forEach((eusers) => { arrUseNames.forEach((eusers) => {
if (eles[eusers.key] && eles[eusers.key] != "" && eles[eusers.key] != null) { if (eles[eusers.key] && eles[eusers.key] != "" && eles[eusers.key] != null) {
let arruserstemp = this.$u.clone(eles[eusers.key].split(',') || eles[eusers.key].split(',')) var arruserstemp = []
if (eles[eusers.key].indexOf(',') > -1) {
arruserstemp = eles[eusers.key].split(',')
} else {
arruserstemp = [eles[eusers.key]]
}
let tempUserIds = [] let tempUserIds = []
arruserstemp.forEach(eltempUsers => { arruserstemp.forEach(eltempUsers => {
if (this.$store.state.userNameMap.get(eltempUsers)) {
tempUserIds.push(this.$store.state.userNameMap.get(eltempUsers).id)
}
this.usersArr.forEach(elusers => {
if (eltempUsers == elusers.name) {
tempUserIds.push(elusers.id)
}
})
}) })
eles[eusers.key] = tempUserIds eles[eusers.key] = tempUserIds
} }
...@@ -567,5 +563,17 @@ export default { ...@@ -567,5 +563,17 @@ export default {
text-align: right; text-align: right;
} }
} }
.footer {
.ivu-tabs-tab {
color: #aaa;
}
.ivu-tabs-tab-active,
.ivu-tabs-tab-focused {
color: #fff;
}
}
} }
</style> </style>
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<thead> <thead>
<tr> <tr>
<th <th
v-for="(column, index) in columns" v-for="(column, index) in columnNow"
:key="index" :key="index"
:style="tdStyle(column)" :style="tdStyle(column)"
> >
...@@ -62,20 +62,19 @@ ...@@ -62,20 +62,19 @@
> >
<!-- --> <!-- -->
<td <td
v-for="(column, snum) in columns" v-for="(column, snum) in columnNow"
:key="column.key" :key="column.key"
:style="tdStyle(column)" :style="tdStyle(column)"
> >
<!-- 多选 --> <!-- 多选 -->
<label <label
v-if="column.type === 'selection'" v-if="column.type === 'selection'"
@click="rowChecked(item, index, $event)"
> >
<Checkbox <Checkbox
v-model="item._checked" v-model="item._checked"
:indeterminate="item._indeterminate" @on-change="rowChecked($event,item, index,)"
:indeterminate="indeterminateBoys(item)"
></Checkbox> ></Checkbox>
{{ item._checked }}
</label> </label>
<Icon <Icon
...@@ -148,7 +147,6 @@ ...@@ -148,7 +147,6 @@
</table> </table>
</div> </div>
</div> </div>
<div class="table-footer"> <div class="table-footer">
<slot name="footer"></slot> <slot name="footer"></slot>
<Page <Page
...@@ -190,9 +188,9 @@ ...@@ -190,9 +188,9 @@
> >
<div slot="header"> <div slot="header">
列设置 列设置
<a @click="undoConfig" class="ml50"> <!-- <a @click="undoConfig" class="ml50">
<Icon type="md-refresh" title="恢复初始设置" /> <Icon type="md-refresh" title="恢复初始设置" />
</a> </a> -->
</div> </div>
<ul class="table-columns"> <ul class="table-columns">
<li <li
...@@ -212,7 +210,7 @@ ...@@ -212,7 +210,7 @@
</li> </li>
</ul> </ul>
</Drawer> </Drawer>
<FooterToolbar v-if="batch" v-show="footerToolbar" class="ftball"> <FooterToolbar v-if="batch" v-show="footerToolbar&&selectItems.length>0" class="ftball">
<div class="ib">已选{{ selectItems.length }}</div> <div class="ib">已选{{ selectItems.length }}</div>
<slot name="batch"></slot> <slot name="batch"></slot>
<Button @click="cancelBatch">取消</Button> <Button @click="cancelBatch">取消</Button>
...@@ -359,7 +357,7 @@ export default { ...@@ -359,7 +357,7 @@ export default {
spaceWidth: { spaceWidth: {
//树形表格缩进距离 //树形表格缩进距离
type: Number, type: Number,
default: 20, default: 35,
}, },
exportTitle: { exportTitle: {
type: String, type: String,
...@@ -386,6 +384,7 @@ export default { ...@@ -386,6 +384,7 @@ export default {
isDesc: true, isDesc: true,
conditions: [], conditions: [],
}, },
level:1,
searchConditions: this.search, searchConditions: this.search,
pageSizeOpts: [20, 50, 100], pageSizeOpts: [20, 50, 100],
tableHeight: 0, tableHeight: 0,
...@@ -396,11 +395,12 @@ export default { ...@@ -396,11 +395,12 @@ export default {
columnsCur: [], // 处理后的表头数据 columnsCur: [], // 处理后的表头数据
checkGroup: [], // 复选框数组 checkGroup: [], // 复选框数组
checks: false, // 全选 checks: false, // 全选
tdsWidth: 0, // td总宽
timer: false, // 控制监听时长 timer: false, // 控制监听时长
dataLength: 0, // 树形数据长度 dataLength: 0, // 树形数据长度
dragIndex: -1, //拖拽开始的序号 dragIndex: -1, //拖拽开始的序号
allUser: [], //所有user allUser: [], //所有user
userConfig: null,
userId: this.$store.state.userInfo.userId,
}; };
}, },
computed: { computed: {
...@@ -410,9 +410,18 @@ export default { ...@@ -410,9 +410,18 @@ export default {
}).length; }).length;
return 0 < checkeds && checkeds < this.trs.length; return 0 < checkeds && checkeds < this.trs.length;
}, },
columnNow() {
// return this.columnsCur;
var now=this.columnsCur.filter((u) => {
return !u.hide||u.hide==false;
});
console.log("cols",now,this.columnsCur,this.columns)
return now;
},
}, },
watch: { watch: {
items() { items() {
this.selectItems=[];
if (this.items) { if (this.items) {
this.trs = this.treeToList(this.items); this.trs = this.treeToList(this.items);
} }
...@@ -428,11 +437,12 @@ export default { ...@@ -428,11 +437,12 @@ export default {
this.exportTitle = v; this.exportTitle = v;
}, },
}, },
created(){
this.columnsCur = this.makeColumns();
},
mounted() { mounted() {
this.getAllUser(); //获取所有用户
if (this.items && this.items.length > 0) { if (this.items && this.items.length > 0) {
this.trs = this.treeToList(this.items); this.trs = this.treeToList(this.items);
this.columnsCur = this.makeColumns();
} }
}, },
methods: { methods: {
...@@ -498,8 +508,8 @@ export default { ...@@ -498,8 +508,8 @@ export default {
// 有无多选框折叠位置优化 // 有无多选框折叠位置优化
treeColumn() { treeColumn() {
var num = 0; var num = 0;
for (let i = 0, len = this.columns.length; i < len; i++) { for (let i = 0, len = this.columnNow.length; i < len; i++) {
if (this.columns[i].tree) { if (this.columnNow[i].tree) {
num = i; num = i;
} }
} }
...@@ -542,13 +552,6 @@ export default { ...@@ -542,13 +552,6 @@ export default {
// 处理表头数据 // 处理表头数据
makeColumns() { makeColumns() {
const columns = this.$u.clone(this.columns); const columns = this.$u.clone(this.columns);
this.tdsWidth = 0;
columns.forEach((column, index) => {
column._index = index;
column._width = column.width ? column.width : "";
column._sortType = "normal";
this.tdsWidth += column.width ? parseFloat(column.width) : 0;
});
return columns; return columns;
}, },
// // 隐藏显示 // // 隐藏显示
...@@ -588,42 +591,20 @@ export default { ...@@ -588,42 +591,20 @@ export default {
} }
return parents; return parents;
}, },
open(index, item) {
if (item.children) {
item.children.forEach((child, childIndex) => {
child.isShow = true;
if (child.children && child.expanded) {
this.open(index + childIndex + 1, child);
}
});
}
},
close(index, item) {
if (item.children) {
item.children.forEach((child, childIndex) => {
child.isShow = false;
child.expanded = false;
if (child.children) {
this.close(index + childIndex + 1, child);
}
});
}
},
// 点击check勾选框,判断是否有children节点 如果有就一并勾选 // 点击check勾选框,判断是否有children节点 如果有就一并勾选
rowChecked(data, index, event) { rowChecked(event,data, index, ) {
// this.$set(this.trs, index, data); this.trs[index]._checked=data._checked;
var boys = this.getChildrens(data); var boys = this.getChildrens(data);
if(boys.length){ if (boys.length>0) {
this.trs.forEach((u, i) => {
}
this.trs.forEach((u, i) => {
var items = boys.filter((b) => { var items = boys.filter((b) => {
return b[this.keyname] == u[this.keyname]; return b[this.keyname] == u[this.keyname];
}); });
if (items.length == 1) { if (items.length == 1) {
this.$set(this.trs[i], "_checked", !data._checked); this.$set(this.trs[i], "_checked", data._checked);
} }
}); });
}
this.checkAll = this.checkAll =
this.trs.length > this.trs.length >
this.trs.filter((u) => { this.trs.filter((u) => {
...@@ -633,6 +614,14 @@ export default { ...@@ -633,6 +614,14 @@ export default {
this.selectionChange(); this.selectionChange();
}); });
}, },
indeterminateBoys(item){
var boys = this.getChildrens(item);
if(boys.length==0){
return false;
}else{
return boys.filter(u=>{return u._checked===item._checked}).length<boys.length;
}
},
getChildrens(data) { getChildrens(data) {
var childrens = []; var childrens = [];
var that = this; var that = this;
...@@ -658,12 +647,12 @@ export default { ...@@ -658,12 +647,12 @@ export default {
}, },
selectionChange() { selectionChange() {
var items = this.trs.filter((u) => { var items = this.trs.filter((u) => {
return u._checked === true; return u._checked;
}); });
this.selectItems = items; this.selectItems = items;
this.$emit("on-selection-change", items, this.trs); this.$emit("on-selection-change", items, this.trs);
this.footerToolbar = items.length > 0; this.footerToolbar = items.length > 0;
console.log("footerToolbar", items, this.trs); console.log("footerToolbar", items);
}, },
// 数组去重 // 数组去重
getArray(a) { getArray(a) {
...@@ -740,205 +729,42 @@ export default { ...@@ -740,205 +729,42 @@ export default {
columnChange(item, i) { columnChange(item, i) {
item.hide = !item.hide; item.hide = !item.hide;
this.$set(this.columnsCur, item, i); this.$set(this.columnsCur, item, i);
this.saveUserconfig(); // this.saveUserconfig();
},
onSelect(rows, row) {
this.$emit("on-change", rows, row);
},
allChange(items) {
this.$emit("all-change", items);
}, },
undoConfig() { undoConfig() {
//列设置恢复初始化 //列设置恢复初始化
this.columnsCur = this.$u.clone(this.columns); this.columnsCur = this.$u.clone(this.columns);
// this.saveUserconfig(); // this.saveUserconfig();
}, },
//批量取消 saveUserconfig() {
cancelBatch() { let url = `${window.systemUrl}/config/update`;
this.footerToolbar = false; var content = [];
// this.$refs.table.selectAll(false); this.columnsCur.map((u) => {
}, content.push({
//导出excel key: u.key,
export2Excel() { hide: u.hide,
//当前显示数据
let list = [];
list = this.trs;
const tHeader = []; // 设置Excel的表格第一行的标题
const filterVal = []; //list里对象的属性
var tempCol = [];
var tempCol1 = []; //存放物料相关表头
var tempCol2 = []; //存放工艺规程相关表头
var tempColUser = []; //存放type=user的表头
var tempColUsers = []; //存放type=users的表头
var columnsCur = this.$u.clone(this.columns); //导出列标题信息griddata this.$refs.grid.columnsCur
columnsCur.forEach((el) => {
if (el.export) {
if (el.code) {
tempCol.push({
key: el.key,
code: el.code,
}); //临时存放code数据字典的字段及对应的数据字典code
}
if (el.materialKey) {
tempCol1.push({
key: el.key,
code: el.materialKey,
}); //临时存放物料管理大类和子类列表
}
if (el.techKey) {
tempCol2.push({
key: el.key,
code: el.techKey,
}); //临时存放工艺规程相关转换
}
if (el.type && el.type == "user") {
tempColUser.push({
key: el.key,
code: el.type,
}); //临时存放user列
}
if (el.type && el.type == "users") {
tempColUsers.push({
key: el.key,
code: el.type,
}); //临时存放user列
}
tHeader.push(el.title);
filterVal.push(el.key);
}
});
list.forEach((e) => {
tempCol.forEach((elem) => {
if (
(e[elem.key] && e[elem.key] != "" && e[elem.key] != null) ||
e[elem.key] == 0
) {
//如果数据字典项对应的DirName字段存在,通过name查询到对应的code,然后赋值。
let codeArr = [];
let keyValue = e[elem.key];
if (
keyValue.length > 0 &&
(keyValue.indexOf(",") > -1 || keyValue.indexOf(",") > -1)
) {
//如果对应的数据包含多个数据字典项,比如包含“,”或“,”
if (keyValue.indexOf(",") > -1) {
codeArr = keyValue.split(",");
}
if (keyValue.indexOf > -1) {
codeArr = keyValue.split(",");
}
}
if (codeArr.length <= 1) {
//对应的数据包含一个数据字典项
e[elem.key] = this.$u.dirName(
this.$store.getters.dictionaryByKey(elem.code),
e[elem.key]
);
} else {
//对应的数据包含多个数据字典项
let codeInfo = "";
codeArr.forEach((el) => {
codeInfo =
codeInfo +
this.$u.dirName(
this.$store.getters.dictionaryByKey(elem.code),
el
) +
",";
});
e[elem.key] = codeInfo.substr(0, codeInfo.length - 1);
}
}
});
//导出数据增加对应的物料管理信息 code: 1【rootCategoryId 大类】 2【categoryId 大类】 3【codeRuleId 编码名称】
tempCol1.forEach((elcol1) => {
if (elcol1.code == 1) {
e[elcol1.key] = this.getType1(e[elcol1.key]);
} else if (elcol1.code == 2) {
e[elcol1.key] = this.getType2(e[elcol1.key]);
} else if (elcol1.code == 3) {
e[elcol1.key] = this.getType3(e[elcol1.key]);
}
});
//导出工艺规程相关转换表头信息
tempCol2.forEach((elcol2) => {
if (elcol2.code == 1) {
e[elcol2.key] = this.getRoutingHeaderName(e[elcol2.key]);
}
});
//导出username相关信息
tempColUser.forEach((eluser) => {
if (Array.isArray(e[eluser.key]) && e[eluser.key].length > 0) {
let temUsers = this.$u.clone(e[eluser.key]);
let temUserName = "";
temUsers.forEach((u) => {
temUserName = temUserName + this.getUserName(u);
});
e[eluser.key] = temUserName;
}
if (
e[eluser.key] &&
typeof e[eluser.key] == "string" &&
e[eluser.key] != "" &&
e[eluser.key] != null
) {
e[eluser.key] = this.getUserName(e[eluser.key]);
}
});
tempColUsers.forEach((elusers) => {
if (e[elusers.key].length > 0) {
let temUsers = this.$u.clone(e[elusers.key]);
let temUserName = "";
temUsers.forEach((u) => {
temUserName = temUserName + this.getUserName(u) + ",";
});
e[elusers.key] = temUserName.substr(0, temUserName.length - 1);
}
}); });
}); });
if (!this.userConfig) {
let nowDate = this.$u.getNowTime(); //年月日时分秒yyyyMMddhhmmss url = `${window.systemUrl}/config/create`;
//获取导出数据结束 var data = {
page: window.location.pathname,
this.$nextTick(() => { component: "Grid",
this.$u.outExcel( key: this.$u.guid(),
this.exportTitle + "(" + nowDate + ")", content: JSON.stringify(content),
tHeader, };
filterVal, this.$api.post(url, data).then((r) => {
list this.loadUserConfig();
);
});
},
//获取所有用户信息
getAllUser() {
this.$api
.post(`${systemUrl}/user/paged`, {
conditions: [],
pageIndex: 1,
pageSize: 100000,
})
.then((r) => {
if (r.success) {
let tempUserInfo = r.result.items;
tempUserInfo.forEach((ele) => {
let temObj = {
userId: ele.id,
name: ele.userName,
};
this.allUser.push(temObj);
});
}
}); });
} else {
this.userConfig.content = JSON.stringify(content);
this.$api.post(url, this.userConfig);
}
}, },
getUserName(id) { //批量取消
let name = ""; cancelBatch() {
this.allUser.forEach((ele) => { this.footerToolbar = false;
if (id == ele.userId) { // this.$refs.table.selectAll(false);
name = ele.name;
}
});
return name;
}, },
}, },
}; };
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
<Button @click="complexSearch" type="primary" style="margin-left: 10px">查询</Button> <Button @click="complexSearch" type="primary" style="margin-left: 10px">查询</Button>
</div> </div>
</Modal> </Modal>
<Drawer title="列设置" v-if="set" v-model="config" :scrollable="true" placement="left" :mask="false"> <Drawer title="列设置" v-if="set" v-model="config" :scrollable="true" placement="left" :mask="false" class-name="tree-drawer">
<div slot="header"> <div slot="header">
列设置 列设置
<a @click="undoConfig" class="ml50"> <a @click="undoConfig" class="ml50">
......
<template> <template>
<div>
<Select <Select
:placeholder="placeholder" :placeholder="placeholder"
v-model="name" v-model="name"
...@@ -7,7 +6,6 @@ ...@@ -7,7 +6,6 @@
:multiple="multiple" :multiple="multiple"
clearable clearable
filterable filterable
transfer
> >
<Option <Option
v-for="item in users" v-for="item in users"
...@@ -30,7 +28,6 @@ ...@@ -30,7 +28,6 @@
</div> </div>
</Option> </Option>
</Select> </Select>
</div>
</template> </template>
<script> <script>
......
import XLSX from 'xlsx'; import XLSX from 'xlsx';
import Api from '@/plugins/request'
let henq = {}; let henq = {};
let pdfInfo = '' let pdfInfo = ''
henq.clone = (data)=> { henq.clone = (data)=> {
...@@ -133,7 +132,7 @@ henq.toTree = (list, rootId, format, parentFiledName) => { ...@@ -133,7 +132,7 @@ henq.toTree = (list, rootId, format, parentFiledName) => {
function toTree(data, parentId, level) { function toTree(data, parentId, level) {
let parents = data.filter(u => { let parents = data.filter(u => {
if(u[upId]=='') if(u[upId]==='')
{ {
u[upId]=null u[upId]=null
} }
...@@ -337,18 +336,19 @@ henq.readXLSX = (file) => { ...@@ -337,18 +336,19 @@ henq.readXLSX = (file) => {
} }
//得到根据value得到对应数据字典的name //得到根据value得到对应数据字典的name
henq.dirName = (code, v) => { henq.dirName = (code, v) => {
var items = "" var items = ""
let i = 0 let i = 0
code.forEach(ele => { code.forEach(ele => {
if (ele.code == v) { if (ele.code == v) {
items = ele.name items = ele.name
i++ i++
}
});
if (i == 0) { //如果没查到对应的name,则返回默认name
items = code[0].name
} }
}); return items
if (i == 0) { //如果没查到对应的name,则返回默认name
items = code[0].name
}
return items
} }
//得到根据name得到对应数据字典的code //得到根据name得到对应数据字典的code
henq.dirCode = (code, v) => { henq.dirCode = (code, v) => {
...@@ -628,6 +628,122 @@ henq.getCurMonth = (val) => { ...@@ -628,6 +628,122 @@ henq.getCurMonth = (val) => {
} }
return m_year + '-' + m_month return m_year + '-' + m_month
} }
//获取当天、明天、昨天、本周、上周、本月、上月的日期 end //获取当天、明天、昨天、本周、上周、本月、上月的日期 end
//导出excel
henq.export2excel=(exTitle,columns,datalist,store)=>{
//当前显示数据
let list = henq.clone(datalist);
const tHeader = []; // 设置Excel的表格第一行的标题
const filterVal = []; //list里对象的属性
var tempCol = [];
var tempColUser = []; //存放type=user的表头
var tempColUsers = []; //存放type=users的表头
var columnsCur = henq.clone(columns); //导出列标题信息griddata this.$refs.grid.columnsCur
columnsCur.forEach((el) => {
if (el.export) {
if (el.code) {
tempCol.push({
key: el.key,
code: el.code,
}); //临时存放code数据字典的字段及对应的数据字典code
}
if (el.type && el.type == "user") {
tempColUser.push({
key: el.key,
code: el.type,
}); //临时存放user列
}
if (el.type && el.type == "users") {
tempColUsers.push({
key: el.key,
code: el.type,
}); //临时存放user列
}
tHeader.push(el.title);
filterVal.push(el.key);
}
});
list.forEach((e) => {
tempCol.forEach((elem) => {
if (
(e[elem.key] && e[elem.key] != "" && e[elem.key] != null) ||
e[elem.key] == 0
) {
//如果数据字典项对应的DirName字段存在,通过name查询到对应的code,然后赋值。
let codeArr = [];
let keyValue = e[elem.key];
if (
keyValue.length > 0 &&
(keyValue.indexOf(",") > -1 || keyValue.indexOf(",") > -1)
) {
//如果对应的数据包含多个数据字典项,比如包含“,”或“,”
if (keyValue.indexOf(",") > -1) {
codeArr = keyValue.split(",");
}
if (keyValue.indexOf > -1) {
codeArr = keyValue.split(",");
}
}
if (codeArr.length <= 1) {
//对应的数据包含一个数据字典项
e[elem.key] = henq.dirName(store.getters.dictionaryByKey(elem.code),e[elem.key]);
} else {
//对应的数据包含多个数据字典项
let codeInfo = "";
codeArr.forEach((el) => {
codeInfo =
codeInfo +
henq.dirName(
store.getters.dictionaryByKey(elem.code),
el
) +
",";
});
e[elem.key] = codeInfo.substr(0, codeInfo.length - 1);
}
}
});
//导出username相关信息
tempColUser.forEach((eluser) => {
if (Array.isArray(e[eluser.key]) && e[eluser.key].length > 0) {
let temUsers = henq.clone(e[eluser.key]);
let temUserName = "";
temUsers.forEach((u) => {
temUserName = temUserName + store.getters.getUser(u).name;
});
e[eluser.key] = temUserName;
}
if (
e[eluser.key] &&
typeof e[eluser.key] == "string" &&
e[eluser.key] != "" &&
e[eluser.key] != null
) {
e[eluser.key] = store.getters.getUser(e[eluser.key]).name;
}
});
tempColUsers.forEach((elusers) => {
if (e[elusers.key].length > 0) {
let temUsers = henq.clone(e[elusers.key]);
let temUserName = "";
temUsers.forEach((u) => {
temUserName = temUserName + store.getters.getUser(u).name + ",";
});
e[elusers.key] = temUserName.substr(0, temUserName.length - 1);
}
});
});
let nowDate = henq.getNowTime(); //年月日时分秒yyyyMMddhhmmss
//获取导出数据结束
henq.outExcel(
exTitle + "(" + nowDate + ")",
tHeader,
filterVal,
list
);
}
export default henq; export default henq;
...@@ -26,6 +26,9 @@ export default { ...@@ -26,6 +26,9 @@ export default {
} }
}); });
}, },
batch(ids) {
return Api.post(`${material}/projectplan/batchdelete`,ids);
},
///projecttemplate/list ///projecttemplate/list
templates(params){ templates(params){
return Api.post(`${material}/projecttemplate/list`,params) return Api.post(`${material}/projecttemplate/list`,params)
......
...@@ -142,7 +142,7 @@ export default { ...@@ -142,7 +142,7 @@ export default {
}).then((r) => { }).then((r) => {
if (r.success) { if (r.success) {
this.$Message.success("导入成功"); this.$Message.success("导入成功");
this.$emit("on-load"); this.$emit("on-ok");
} }
}); });
}, },
......
<template> <template>
<div> <div>
<Card> <Card>
<EditGrid :columns="columns" ref="grid" :batch="true" :items="list" :level="8" :drag="true" :exportTitle="exportTl"> <EditGrid
<template slot="easySearch"> :columns="columns"
<Form ref="formInline" :model="easySearch" inline> ref="grid"
<FormItem prop="keys"><Input placeholder="请输入关键字标题" v-model="easySearch.keys.value" /> :batch="true"
</FormItem> :items="list"
<FormItem><Button type="primary" @click="search">查询</Button> :level="8"
</FormItem> :drag="true"
</Form> :exportTitle="exportTl"
</template> @on-selection-change="batchChange"
<!-- <template slot="searchForm"> >
<template slot="easySearch">
<Form ref="formInline" :model="easySearch" inline>
<FormItem prop="keys"
><Input
placeholder="请输入关键字标题"
v-model="easySearch.keys.value"
/>
</FormItem>
<FormItem
><Button type="primary" @click="search">查询</Button>
</FormItem>
</Form>
</template>
<!-- <template slot="searchForm">
<Search /> <Search />
</template> --> </template> -->
<template slot="buttons"> <template slot="buttons">
<Button type="primary" @click="add(null)">新增</Button> <Button type="primary" @click="add(null)">新增</Button>
<Button @mouseenter.native="showBm" ref="showBtn" shape="circle" icon="md-settings"></Button> <Button
<Dropdown @on-click="show" v-if="false"> @mouseenter.native="showBm"
<Button shape="circle" icon="md-settings"></Button> ref="showBtn"
<DropdownMenu slot="list"> shape="circle"
<DropdownItem name="saveTemplate">存为模版</DropdownItem> icon="md-settings"
<DropdownItem name="useTemplate">导入模版</DropdownItem> ></Button>
<DropdownItem name="down"> <Dropdown @on-click="show" v-if="false">
<Icon type="md-cloud-download" class="mr10" />导出Excel <Button shape="circle" icon="md-settings"></Button>
</DropdownItem> <DropdownMenu slot="list">
<DropdownItem name="importExcel" disabled> <DropdownItem name="saveTemplate">存为模版</DropdownItem>
<Icon type="md-cloud-upload" class="mr10" />导入Excel <DropdownItem name="useTemplate">导入模版</DropdownItem>
</DropdownItem> <DropdownItem name="down">
</DropdownMenu> <Icon type="md-cloud-download" class="mr10" />导出Excel
</Dropdown> </DropdownItem>
</template> <DropdownItem name="importExcel" disabled>
</EditGrid> <Icon type="md-cloud-upload" class="mr10" />导入Excel
</DropdownItem>
</DropdownMenu>
</Dropdown>
</template>
<template slot="batch">
<span v-width="300" style="color:#333">
<DateRange v-model="dateEntity" edit v-width="260"></DateRange>
<Button type="primary">设置2计划日期</Button>
</span>
<span>
<UserGroup
v-model="executors"
multiple
:projectId="eid"
v-width="300"
></UserGroup>
<Button type="primary">设置执行人</Button>
</span>
<Button type="primary" @click="bacthRemove()">批量删除</Button>
</template>
</EditGrid>
</Card> </Card>
<Submenus :show="showStatu" :data="tempItems" :params="params"></Submenus> <Submenus :show="showStatu" :data="tempItems" :params="params"></Submenus>
<Modal v-model="modal" :title="title" width="1200" footer-hide> <Modal v-model="modal" :title="title" width="1200" footer-hide>
<component :is="detail" :eid="curId" :v="row" @on-close="cancel" @on-ok="ok" /> <component
:is="detail"
:eid="curId"
:v="row"
@on-close="cancel"
@on-ok="ok"
/>
</Modal> </Modal>
<ImportExcel ref="importExcel" @on-get-data="getData" :modalTitle="temTitle" :columns="columns" :open="ModalIm" @on-cancel="ModalImCancel" @on-ok="ok" /> <ImportExcel
</div> ref="importExcel"
@on-get-data="getData"
:modalTitle="temTitle"
:columns="columns"
:open="ModalIm"
@on-cancel="ModalImCancel"
@on-ok="ok"
/>
</div>
</template> </template>
<script> <script>
import Api from "./api"; import Api from "./api";
import Search from "./search"; import Search from "./search";
export default { export default {
name: "list", name: "list",
components: { components: {
Search, Search,
},
head: {
title: "项目计划",
author: "henq",
description: "project_plan 10/19/2020 10:23:07 AM",
},
props: {
eid: {
type: String,
}, },
head: { data: {
title: "项目计划", type: Object,
author: "henq", default: () => {
description: "project_plan 10/19/2020 10:23:07 AM",
},
props: {
eid: {
type: String,
},
data: {
type: Object,
default: () => {
return {
id: "33930562-a9f7-bd95-88ab-d01eb1c4c369",
title: "示例项目",
};
},
},
},
data() {
return { return {
entity: {}, id: "33930562-a9f7-bd95-88ab-d01eb1c4c369",
row: {}, title: "示例项目",
action: Api.index,
easySearch: {
keys: {
op: "title",
value: null
},
},
modal: false,
title: "新增",
detail: null,
curId: null,
list: [],
columns: [{
key: "drag",
type: "drag",
width: 50,
align: 'center'
},
{
key: "upId",
width: 50,
type: "selection",
align: 'center'
},
{
key: "upTitle",
title: this.l("upTitle"),
hide: true,
export: true,
},
{
key: "title",
title: this.l("title"),
align: "left",
tree: true,
easy: true,
high: true,
export: true,
},
{
key: "type",
width: 90,
title: this.l("type"),
align: "center",
high: true,
code: "mes.project_plan.Type",
attr: {
type: "icon",
},
export: true,
},
{
key: "direction",
title: this.l("direction"),
align: "center",
code: "mes.project_plan.direction",
width: 80,
easy: true,
high: true,
export: true,
},
{
key: "status",
title: this.l("status"),
align: "center",
width: 80,
high: true,
code: "mes.project_plan.Status",
export: true,
},
{
key: "startDate",
title: "计划开始日期",
hide: true,
export: true,
},
{
key: "endDate",
title: "计划结束日期",
hide: true,
export: true,
},
{
key: "dateRange",
width: 250,
title: "计划日期",
align: "center",
render(h, param) {
return h("DateRange", {
attrs: {
value: param.row,
},
});
},
},
{
key: "executor",
title: this.l("executor"),
align: "left",
high: true,
type: "users",
export: true,
},
{
key: "deliverable",
title: this.l("deliverable"),
code: "mes.project_plan.deliverable",
width: 80,
align: "center",
easy: true,
high: true,
export: true,
},
{
title: "操作",
key: "action",
width: 150,
align: "center",
render: (h, params) => {
return h("div", {
class: "action"
}, [
h("op", {
attrs: {
icon: "md-arrow-dropright-circle",
type: "icon",
title: "派发",
oprate: "edit",
disable: params.row.status != 0,
},
on: {
click: () => this.send(params.row)
},
}),
h("op", {
attrs: {
icon: "md-add",
type: "icon",
title: "新增子任务",
disable: params.row.status > 1,
oprate: "edit",
},
on: {
click: () => this.add(params.row)
},
}),
h("op", {
attrs: {
icon: "md-create",
type: "icon",
title: "编辑",
oprate: "edit",
disable: params.row.status !== 0,
},
on: {
click: () => this.edit(params.row)
},
}),
h("op", {
attrs: {
icon: "ios-trash",
type: "icon",
title: "删除",
oprate: "delete",
disable: params.row.status !== 0,
msg: "确认要删除吗?",
},
on: {
click: () => this.remove(params.row.id)
},
}),
]);
},
},
],
//setButon
showStatu: false, //控件是否显示
tempItems: [], //控件数据
params: {}, //控件坐标位置
//导出导入
exportTl: '项目目录',
ModalIm: false,
temTitle: "项目目录",
}; };
},
}, },
mounted() { },
console.log(this); data() {
this.search(); return {
}, entity: {},
async fetch({ executors: [],
store, dateEntity: {
params startDate: null,
}) { endDate: null,
await store.dispatch("loadDictionary"); // 加载数据字典 },
}, batchItems: [],
methods: { row: {},
ok() { action: Api.index,
this.search(); easySearch: {
this.modal = false; keys: {
this.curId = null; op: "title",
value: null,
}, },
search() { },
// this.$refs.grid.reload(this.easySearch); modal: false,
var params = { title: "新增",
conditions: [{ detail: null,
fieldName: "projectId", curId: null,
conditionalType: "Equal", list: [],
fieldValue: this.eid, rootList: [],
}, ], columns: [
// conditions: [] {
}; key: "drag",
Api.list(params).then((r) => { type: "drag",
let res = r.result; width: 50,
var data = this.$u.toTree( align: "center",
res, title: "移动",
null,
(u) => {
// console.log(u);
u.expanded = true;
u.selected = false;
u.checked = false;
},
"upId"
);
this.list = data;
});
}, },
add(row) { {
if (row) { key: "upId",
this.curId = row.id; width: 50,
this.row = row; type: "selection",
} else { align: "center",
this.curId = null; title: "选择",
this.row = {
projectId: this.data.id,
};
}
this.title = "新增";
this.detail = () => import("./add");
this.modal = true;
}, },
send(row) { {
console.log(row); key: "upTitle",
if (!row.startDate) { title: this.l("upTitle"),
this.$Message.error("未设置开始时间"); hide: true,
return; export: true,
}
if (!row.endDate) {
this.$Message.error("未设置结束时间");
return;
}
if (row.executor.length == 0) {
this.$Message.error("请设置执行人");
return;
}
delete row.chlidren;
delete row.parent;
console.warn(row);
row.status = 1;
Api.sendtask({
id: row.id,
status: 1,
}).then((r) => {
if (r.success) {
this.$Message.info("任务派发成功!");
this.search();
}
});
}, },
copy(id) { {
this.curId = id; key: "title",
this.title = "克隆"; title: this.l("title"),
this.detail = () => import("./add"); align: "left",
this.modal = true; tree: true,
easy: true,
high: true,
export: true,
}, },
view(id) { {
this.curId = id; key: "type",
this.title = "详情"; width: 90,
this.detail = () => import("./detail"); title: this.l("type"),
this.modal = true; align: "center",
high: true,
code: "mes.project_plan.Type",
attr: {
type: "icon",
},
export: true,
}, },
edit(row) { {
this.curId = row.id; key: "direction",
this.row = row; title: this.l("direction"),
this.title = "编辑"; align: "center",
this.detail = () => import("./edit"); code: "mes.project_plan.direction",
this.modal = true; width: 80,
easy: true,
high: true,
export: true,
}, },
remove(id) { {
Api.delete(id).then((r) => { key: "status",
if (r.success) { title: this.l("status"),
this.search(); align: "center",
this.$Message.success("删除成功"); width: 80,
} high: true,
}); code: "mes.project_plan.Status",
export: true,
}, },
cancel() { {
this.curId = null; key: "startDate",
this.modal = false; title: "计划开始日期",
hide: true,
export: true,
}, },
show(name) { {
var that = this; key: "endDate",
var m = { title: "计划结束日期",
saveTemplate(name) { hide: true,
that.curId = that.eid; export: true,
that.row = that.data;
that.title = "保存模版";
that.detail = () => import("./saveTemplate");
that.modal = true;
},
useTemplate(name) {
that.curId = that.eid;
that.row = that.data;
that.title = "导入模版";
that.detail = () => import("./importTemplate");
that.modal = true;
},
}
//导出excel
if (name == 'down') {
this.exportTl = '项目目录-' + this.data.title;
this.$refs.grid.export2Excel()
}
if (name == 'importExcel') {
this.openModalIm()
}
m[name] && m[name](name);
}, },
saveTemplate() { {
var that = this; key: "dateRange",
that.curId = that.eid; width: 250,
that.row = that.data; title: "计划日期",
that.title = "保存模版"; align: "center",
that.detail = () => import("./saveTemplate"); render(h, param) {
that.modal = true; return h("DateRange", {
attrs: {
value: param.row,
},
});
},
}, },
useTemplate() { {
var that = this; key: "executor",
that.curId = that.eid; title: this.l("executor"),
that.row = that.data; align: "left",
that.title = "导入模版"; high: true,
that.detail = () => import("./importTemplate"); type: "users",
that.modal = true; export: true,
}, },
down() { {
this.exportTl = '项目目录-' + this.data.title; key: "deliverable",
this.$refs.grid.export2Excel() title: this.l("deliverable"),
code: "mes.project_plan.deliverable",
width: 80,
align: "center",
easy: true,
high: true,
export: true,
}, },
importExcel() { {
this.openModalIm() title: "操作",
key: "action",
width: 150,
align: "center",
render: (h, params) => {
return h(
"div",
{
class: "action",
},
[
h("op", {
attrs: {
icon: "md-arrow-dropright-circle",
type: "icon",
title: "派发",
oprate: "edit",
disable: params.row.status != 0,
},
on: {
click: () => this.send(params.row),
},
}),
h("op", {
attrs: {
icon: "md-add",
type: "icon",
title: "新增子任务",
disable: params.row.status > 1,
oprate: "edit",
},
on: {
click: () => this.add(params.row),
},
}),
h("op", {
attrs: {
icon: "md-create",
type: "icon",
title: "编辑",
oprate: "edit",
disable: params.row.status !== 0,
},
on: {
click: () => this.edit(params.row),
},
}),
h("op", {
attrs: {
icon: "ios-trash",
type: "icon",
title: "删除",
oprate: "delete",
disable: params.row.status !== 0,
msg: "确认要删除吗?",
},
on: {
click: () => this.remove(params.row.id),
},
}),
]
);
},
}, },
showBm(event) { ],
let obj = event.target //setButon
let objSet = obj.getBoundingClientRect() showStatu: false, //控件是否显示
this.showStatu = true; tempItems: [], //控件数据
this.params = { params: {}, //控件坐标位置
x: objSet.x, //导出导入
y: objSet.bottom exportTl: "项目目录",
}; ModalIm: false,
console.log(event) temTitle: "项目目录",
this.tempItems = [{ };
label: "存为模版", },
onClick: () => { mounted() {
this.saveTemplate() this.search();
}, },
}, { async fetch({ store, params }) {
label: "导入模版", await store.dispatch("loadDictionary"); // 加载数据字典
divided: true, },
onClick: () => { methods: {
this.useTemplate() ok() {
}, this.search();
}, this.modal = false;
{ this.curId = null;
label: "导出Excel", },
icon: "md-cloud-download", search() {
onClick: () => { // this.$refs.grid.reload(this.easySearch);
this.down() var params = {
}, conditions: [
}, {
{ fieldName: "projectId",
label: "导入Excel", conditionalType: "Equal",
icon: "md-cloud-upload", fieldValue: this.eid,
onClick: () => { },
this.importExcel() ],
}, // conditions: []
} };
]; Api.list(params).then((r) => {
let res = r.result;
this.rootList = this.$u.clone(r.result);
var data = this.$u.toTree(
res,
null,
(u) => {
// console.log(u);
u.expanded = true;
u.selected = false;
u.checked = false;
},
"upId"
);
this.list = data;
});
},
add(row) {
if (row) {
this.curId = row.id;
this.row = row;
} else {
this.curId = null;
this.row = {
projectId: this.data.id,
};
}
this.title = "新增";
this.detail = () => import("./add");
this.modal = true;
},
send(row) {
console.log(row);
if (!row.startDate) {
this.$Message.error("未设置开始时间");
return;
}
if (!row.endDate) {
this.$Message.error("未设置结束时间");
return;
}
if (row.executor.length == 0) {
this.$Message.error("请设置执行人");
return;
}
delete row.chlidren;
delete row.parent;
console.warn(row);
row.status = 1;
Api.sendtask({
id: row.id,
status: 1,
}).then((r) => {
if (r.success) {
this.$Message.info("任务派发成功!");
this.search();
}
});
},
copy(id) {
this.curId = id;
this.title = "克隆";
this.detail = () => import("./add");
this.modal = true;
},
view(id) {
this.curId = id;
this.title = "详情";
this.detail = () => import("./detail");
this.modal = true;
},
edit(row) {
this.curId = row.id;
this.row = row;
this.title = "编辑";
this.detail = () => import("./edit");
this.modal = true;
},
remove(id) {
Api.delete(id).then((r) => {
if (r.success) {
this.search();
this.$Message.success("删除成功");
}
});
},
cancel() {
this.curId = null;
this.modal = false;
},
show(name) {
var that = this;
var m = {
saveTemplate(name) {
that.curId = that.eid;
that.row = that.data;
that.title = "保存模版";
that.detail = () => import("./saveTemplate");
that.modal = true;
}, },
//批量导入start useTemplate(name) {
//导入功能 that.curId = that.eid;
openModalIm() { that.row = that.data;
this.ModalIm = true that.title = "导入模版";
that.detail = () => import("./importTemplate");
that.modal = true;
}, },
ModalImCancel() { };
this.ModalIm = false //导出excel
if (name == "down") {
this.exportTl = "项目目录-" + this.data.title;
// this.$refs.grid.export2Excel()
this.$u.export2excel(this.exportTl, this.columns, this.list);
}
if (name == "importExcel") {
this.openModalIm();
}
m[name] && m[name](name);
},
saveTemplate() {
var that = this;
that.curId = that.eid;
that.row = that.data;
that.title = "保存模版";
that.detail = () => import("./saveTemplate");
that.modal = true;
},
useTemplate() {
var that = this;
that.curId = that.eid;
that.row = that.data;
that.title = "导入模版";
that.detail = () => import("./importTemplate");
that.modal = true;
},
down() {
this.exportTl = "项目目录-" + this.data.title;
this.$u.export2excel(
this.exportTl,
this.columns,
this.rootList,
this.$store
);
//this.$refs.grid.export2Excel()
},
importExcel() {
this.openModalIm();
},
showBm(event) {
let obj = event.target;
let objSet = obj.getBoundingClientRect();
this.showStatu = true;
this.params = {
x: objSet.x,
y: objSet.bottom,
};
console.log(event);
this.tempItems = [
{
label: "存为模版",
onClick: () => {
this.saveTemplate();
},
}, },
getData(val) { {
let url = `${material}/projectplan/importplans`; label: "导入模版",
this.$refs.importExcel.deelData(url, this.columns, this.formatMethod(val)) divided: true,
onClick: () => {
this.useTemplate();
},
}, },
//根据页面二次处理数据 {
formatMethod(val) { label: "导出Excel",
let tempData = this.$u.clone(val); icon: "md-cloud-download",
let tempList = []; onClick: () => {
tempData.forEach((ele) => { this.down();
let obj = { },
projectId: this.eid,
upTitle: ele.upTitle ? ele.upTitle : null,
title: ele.title ? ele.title : '',
status: 0,
type: ele.type ? ele.type : 0, //?
startDate: ele.startDate ? ele.startDate : "", //?
endDate: ele.endDate ? ele.endDate : "", //?
direction: ele.direction ? ele.direction : 0,
executor: ele.executor ? ele.executor : [], //?
deliverable: ele.deliverable ? ele.deliverable : 0
};
if (ele.title && ele.title != '') {
obj.ico = false
} else {
obj.ico = true
}
tempList.push(obj);
});
return tempList
}, },
//批量导入end {
l(key) { label: "导入Excel",
let vkey = "project_plan" + "." + key; icon: "md-cloud-upload",
return this.$t(vkey) || key; onClick: () => {
this.importExcel();
},
}, },
];
},
batchChange(items, list) {
this.batchItems = items;
},
bacthRemove() {
var ids = this.batchItems.map((u) => {
return u.id;
});
if (ids.length > 0) {
this.$Modal.confirm({
title: "确认",
content: "确认删除?",
onOk: () => {
Api.batch(ids).then((r) => {
if (r.success) {
this.search();
this.$Message.success("删除成功!");
} else {
this.$Message.error("出现异常");
}
});
},
});
}
},
//批量导入start
//导入功能
openModalIm() {
this.ModalIm = true;
},
ModalImCancel() {
this.ModalIm = false;
},
getData(val) {
let url = `${material}/projectplan/importplans`;
this.$refs.importExcel.deelData(
url,
this.columns,
this.formatMethod(val)
);
},
//根据页面二次处理数据
formatMethod(val) {
let tempData = this.$u.clone(val);
let tempList = [];
tempData.forEach((ele) => {
let obj = {
projectId: this.eid,
upTitle: ele.upTitle ? ele.upTitle : null,
title: ele.title ? ele.title : "",
status: 0,
type: ele.type ? ele.type : 0, //?
startDate: ele.startDate ? ele.startDate : "", //?
endDate: ele.endDate ? ele.endDate : "", //?
direction: ele.direction ? ele.direction : 0,
executor: ele.executor ? ele.executor : [], //?
deliverable: ele.deliverable ? ele.deliverable : 0,
};
if (ele.title && ele.title != "") {
obj.ico = false;
} else {
obj.ico = true;
}
tempList.push(obj);
});
return tempList;
},
//批量导入end
l(key) {
let vkey = "project_plan" + "." + key;
return this.$t(vkey) || key;
}, },
},
}; };
</script> </script>
......
...@@ -5,6 +5,7 @@ export const state = () => ({ ...@@ -5,6 +5,7 @@ export const state = () => ({
counter: 0, counter: 0,
dictionary: new Map(), //所有字典项 dictionary: new Map(), //所有字典项
userMap: new Map(), //所有用户缓存; userMap: new Map(), //所有用户缓存;
userNameMap: new Map(), //所有用户名称缓存;
departmentsMap: new Map(), //部门缓存; departmentsMap: new Map(), //部门缓存;
userInfo: { userInfo: {
userId: 0, userId: 0,
...@@ -69,6 +70,9 @@ export const mutations = { ...@@ -69,6 +70,9 @@ export const mutations = {
setUsers(state, users) { setUsers(state, users) {
state.userMap = users; state.userMap = users;
}, },
setUserNames(state, usersNames) {
state.userNameMap = usersNames;
},
addUser(state, user) { addUser(state, user) {
state.userMap.push(user); state.userMap.push(user);
}, },
...@@ -178,10 +182,14 @@ export const actions = { ...@@ -178,10 +182,14 @@ export const actions = {
let r = await Api.get(`${systemUrl}/user/getuserlist`); let r = await Api.get(`${systemUrl}/user/getuserlist`);
var umap = new Map(); var umap = new Map();
var unamemap=new Map();
r.result.map(u => { r.result.map(u => {
umap.set(u.id, u); umap.set(u.id, u);
unamemap.set(u.name,u)
}); });
commit("setUsers", umap); commit("setUsers", umap);
commit("setUserNames", unamemap);
}, },
async loadDepartments({ async loadDepartments({
commit commit
......
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