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,
li {
list-style: none;
}
.ivu-drawer-wrap{
z-index: 12000;
}
div::-webkit-scrollbar {
width: 10px;
height: 10px;
......
......@@ -23,6 +23,9 @@
background-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) {
border-right-color: @primary-color;
......
......@@ -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>
<component :is="detailExcel" ref="comExcel" @on-datalength="datalength" />
</div>
<FooterToolbar v-if="sheetNames.length>1&&tableImport">
<FooterToolbar v-if="sheetNames.length>1&&tableImport" class="footer">
<Form inline>
<FormItem>
<Tabs :animated="false" :value="0" @on-click="sheetClick">
......@@ -79,11 +79,10 @@ export default {
tableImport: true,
tdHeightExcel: "",
excelData: [],
excelDataBack: [], //临时存储原始数据
excelDataBack: [], //临时存储原始数据,
formatList: ["xlsx"],
columnsImport: [],
departArr: [], //部门list
usersArr: [],
sheetNames: [], //excel的表明
workBook: {},
openDatas: [],
......@@ -105,7 +104,7 @@ export default {
props: {
eid: Number,
data: {
// 当作table使用,直接显示数据
// 当作table使用,直接显示数据,数据里不能用英文逗号',',因为将excel转为数据后是用','分解的
type: Array,
default: function () {
return [];
......@@ -131,12 +130,6 @@ export default {
this.$api.get(`${systemUrl}/Department/GetDepartments`).then((r) => {
this.departArr = r.result.items;
});
this.$api.get(`${systemUrl}/user/getuserlist`)
.then((r) => {
if (r.success) {
this.usersArr = r.result
}
})
//导出对列表头进行预加载end
},
async fetch({
......@@ -279,25 +272,28 @@ export default {
//人员名称转换为userid,如果查不到此人员,则为空
arrUseName.forEach((euser) => {
if (eles[euser.key] && eles[euser.key] != "" && eles[euser.key] != null) {
this.usersArr.forEach(eluser => {
if (eles[euser.key] == eluser.name) {
eles[euser.key] = eluser.id
}
})
if (this.$store.state.userNameMap.get(eles[euser.key])) {
eles[euser.key] = this.$store.state.userNameMap.get(eles[euser.key]).id
} else {
eles[euser.key] = null
}
}
});
//多个名称转换为数组
arrUseNames.forEach((eusers) => {
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 = []
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
}
......@@ -567,5 +563,17 @@ export default {
text-align: right;
}
}
.footer {
.ivu-tabs-tab {
color: #aaa;
}
.ivu-tabs-tab-active,
.ivu-tabs-tab-focused {
color: #fff;
}
}
}
</style>
......@@ -17,7 +17,7 @@
<thead>
<tr>
<th
v-for="(column, index) in columns"
v-for="(column, index) in columnNow"
:key="index"
:style="tdStyle(column)"
>
......@@ -62,20 +62,19 @@
>
<!-- -->
<td
v-for="(column, snum) in columns"
v-for="(column, snum) in columnNow"
:key="column.key"
:style="tdStyle(column)"
>
<!-- 多选 -->
<label
v-if="column.type === 'selection'"
@click="rowChecked(item, index, $event)"
>
<Checkbox
v-model="item._checked"
:indeterminate="item._indeterminate"
@on-change="rowChecked($event,item, index,)"
:indeterminate="indeterminateBoys(item)"
></Checkbox>
{{ item._checked }}
</label>
<Icon
......@@ -148,7 +147,6 @@
</table>
</div>
</div>
<div class="table-footer">
<slot name="footer"></slot>
<Page
......@@ -190,9 +188,9 @@
>
<div slot="header">
列设置
<a @click="undoConfig" class="ml50">
<!-- <a @click="undoConfig" class="ml50">
<Icon type="md-refresh" title="恢复初始设置" />
</a>
</a> -->
</div>
<ul class="table-columns">
<li
......@@ -212,7 +210,7 @@
</li>
</ul>
</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>
<slot name="batch"></slot>
<Button @click="cancelBatch">取消</Button>
......@@ -359,7 +357,7 @@ export default {
spaceWidth: {
//树形表格缩进距离
type: Number,
default: 20,
default: 35,
},
exportTitle: {
type: String,
......@@ -386,6 +384,7 @@ export default {
isDesc: true,
conditions: [],
},
level:1,
searchConditions: this.search,
pageSizeOpts: [20, 50, 100],
tableHeight: 0,
......@@ -396,11 +395,12 @@ export default {
columnsCur: [], // 处理后的表头数据
checkGroup: [], // 复选框数组
checks: false, // 全选
tdsWidth: 0, // td总宽
timer: false, // 控制监听时长
dataLength: 0, // 树形数据长度
dragIndex: -1, //拖拽开始的序号
allUser: [], //所有user
userConfig: null,
userId: this.$store.state.userInfo.userId,
};
},
computed: {
......@@ -410,9 +410,18 @@ export default {
}).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: {
items() {
this.selectItems=[];
if (this.items) {
this.trs = this.treeToList(this.items);
}
......@@ -428,11 +437,12 @@ export default {
this.exportTitle = v;
},
},
created(){
this.columnsCur = this.makeColumns();
},
mounted() {
this.getAllUser(); //获取所有用户
if (this.items && this.items.length > 0) {
this.trs = this.treeToList(this.items);
this.columnsCur = this.makeColumns();
}
},
methods: {
......@@ -498,8 +508,8 @@ export default {
// 有无多选框折叠位置优化
treeColumn() {
var num = 0;
for (let i = 0, len = this.columns.length; i < len; i++) {
if (this.columns[i].tree) {
for (let i = 0, len = this.columnNow.length; i < len; i++) {
if (this.columnNow[i].tree) {
num = i;
}
}
......@@ -542,13 +552,6 @@ export default {
// 处理表头数据
makeColumns() {
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;
},
// // 隐藏显示
......@@ -588,42 +591,20 @@ export default {
}
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节点 如果有就一并勾选
rowChecked(data, index, event) {
// this.$set(this.trs, index, data);
rowChecked(event,data, index, ) {
this.trs[index]._checked=data._checked;
var boys = this.getChildrens(data);
if(boys.length){
}
this.trs.forEach((u, i) => {
if (boys.length>0) {
this.trs.forEach((u, i) => {
var items = boys.filter((b) => {
return b[this.keyname] == u[this.keyname];
});
if (items.length == 1) {
this.$set(this.trs[i], "_checked", !data._checked);
this.$set(this.trs[i], "_checked", data._checked);
}
});
}
this.checkAll =
this.trs.length >
this.trs.filter((u) => {
......@@ -633,6 +614,14 @@ export default {
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) {
var childrens = [];
var that = this;
......@@ -658,12 +647,12 @@ export default {
},
selectionChange() {
var items = this.trs.filter((u) => {
return u._checked === true;
return u._checked;
});
this.selectItems = items;
this.$emit("on-selection-change", items, this.trs);
this.footerToolbar = items.length > 0;
console.log("footerToolbar", items, this.trs);
console.log("footerToolbar", items);
},
// 数组去重
getArray(a) {
......@@ -740,205 +729,42 @@ export default {
columnChange(item, i) {
item.hide = !item.hide;
this.$set(this.columnsCur, item, i);
this.saveUserconfig();
},
onSelect(rows, row) {
this.$emit("on-change", rows, row);
},
allChange(items) {
this.$emit("all-change", items);
// this.saveUserconfig();
},
undoConfig() {
//列设置恢复初始化
this.columnsCur = this.$u.clone(this.columns);
// this.saveUserconfig();
},
//批量取消
cancelBatch() {
this.footerToolbar = false;
// this.$refs.table.selectAll(false);
},
//导出excel
export2Excel() {
//当前显示数据
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);
}
saveUserconfig() {
let url = `${window.systemUrl}/config/update`;
var content = [];
this.columnsCur.map((u) => {
content.push({
key: u.key,
hide: u.hide,
});
});
let nowDate = this.$u.getNowTime(); //年月日时分秒yyyyMMddhhmmss
//获取导出数据结束
this.$nextTick(() => {
this.$u.outExcel(
this.exportTitle + "(" + nowDate + ")",
tHeader,
filterVal,
list
);
});
},
//获取所有用户信息
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);
});
}
if (!this.userConfig) {
url = `${window.systemUrl}/config/create`;
var data = {
page: window.location.pathname,
component: "Grid",
key: this.$u.guid(),
content: JSON.stringify(content),
};
this.$api.post(url, data).then((r) => {
this.loadUserConfig();
});
} else {
this.userConfig.content = JSON.stringify(content);
this.$api.post(url, this.userConfig);
}
},
getUserName(id) {
let name = "";
this.allUser.forEach((ele) => {
if (id == ele.userId) {
name = ele.name;
}
});
return name;
//批量取消
cancelBatch() {
this.footerToolbar = false;
// this.$refs.table.selectAll(false);
},
},
};
......
......@@ -51,7 +51,7 @@
<Button @click="complexSearch" type="primary" style="margin-left: 10px">查询</Button>
</div>
</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">
列设置
<a @click="undoConfig" class="ml50">
......
<template>
<div>
<Select
:placeholder="placeholder"
v-model="name"
......@@ -7,7 +6,6 @@
:multiple="multiple"
clearable
filterable
transfer
>
<Option
v-for="item in users"
......@@ -30,7 +28,6 @@
</div>
</Option>
</Select>
</div>
</template>
<script>
......
import XLSX from 'xlsx';
import Api from '@/plugins/request'
let henq = {};
let pdfInfo = ''
henq.clone = (data)=> {
......@@ -133,7 +132,7 @@ henq.toTree = (list, rootId, format, parentFiledName) => {
function toTree(data, parentId, level) {
let parents = data.filter(u => {
if(u[upId]=='')
if(u[upId]==='')
{
u[upId]=null
}
......@@ -337,18 +336,19 @@ henq.readXLSX = (file) => {
}
//得到根据value得到对应数据字典的name
henq.dirName = (code, v) => {
var items = ""
let i = 0
code.forEach(ele => {
if (ele.code == v) {
items = ele.name
i++
var items = ""
let i = 0
code.forEach(ele => {
if (ele.code == v) {
items = ele.name
i++
}
});
if (i == 0) { //如果没查到对应的name,则返回默认name
items = code[0].name
}
});
if (i == 0) { //如果没查到对应的name,则返回默认name
items = code[0].name
}
return items
return items
}
//得到根据name得到对应数据字典的code
henq.dirCode = (code, v) => {
......@@ -628,6 +628,122 @@ henq.getCurMonth = (val) => {
}
return m_year + '-' + m_month
}
//获取当天、明天、昨天、本周、上周、本月、上月的日期 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;
......@@ -26,6 +26,9 @@ export default {
}
});
},
batch(ids) {
return Api.post(`${material}/projectplan/batchdelete`,ids);
},
///projecttemplate/list
templates(params){
return Api.post(`${material}/projecttemplate/list`,params)
......
......@@ -142,7 +142,7 @@ export default {
}).then((r) => {
if (r.success) {
this.$Message.success("导入成功");
this.$emit("on-load");
this.$emit("on-ok");
}
});
},
......
<template>
<div>
<div>
<Card>
<EditGrid :columns="columns" ref="grid" :batch="true" :items="list" :level="8" :drag="true" :exportTitle="exportTl">
<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">
<EditGrid
:columns="columns"
ref="grid"
:batch="true"
:items="list"
:level="8"
:drag="true"
:exportTitle="exportTl"
@on-selection-change="batchChange"
>
<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 />
</template> -->
<template slot="buttons">
<Button type="primary" @click="add(null)">新增</Button>
<Button @mouseenter.native="showBm" ref="showBtn" shape="circle" icon="md-settings"></Button>
<Dropdown @on-click="show" v-if="false">
<Button shape="circle" icon="md-settings"></Button>
<DropdownMenu slot="list">
<DropdownItem name="saveTemplate">存为模版</DropdownItem>
<DropdownItem name="useTemplate">导入模版</DropdownItem>
<DropdownItem name="down">
<Icon type="md-cloud-download" class="mr10" />导出Excel
</DropdownItem>
<DropdownItem name="importExcel" disabled>
<Icon type="md-cloud-upload" class="mr10" />导入Excel
</DropdownItem>
</DropdownMenu>
</Dropdown>
</template>
</EditGrid>
<template slot="buttons">
<Button type="primary" @click="add(null)">新增</Button>
<Button
@mouseenter.native="showBm"
ref="showBtn"
shape="circle"
icon="md-settings"
></Button>
<Dropdown @on-click="show" v-if="false">
<Button shape="circle" icon="md-settings"></Button>
<DropdownMenu slot="list">
<DropdownItem name="saveTemplate">存为模版</DropdownItem>
<DropdownItem name="useTemplate">导入模版</DropdownItem>
<DropdownItem name="down">
<Icon type="md-cloud-download" class="mr10" />导出Excel
</DropdownItem>
<DropdownItem name="importExcel" disabled>
<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>
<Submenus :show="showStatu" :data="tempItems" :params="params"></Submenus>
<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>
<ImportExcel ref="importExcel" @on-get-data="getData" :modalTitle="temTitle" :columns="columns" :open="ModalIm" @on-cancel="ModalImCancel" @on-ok="ok" />
</div>
<ImportExcel
ref="importExcel"
@on-get-data="getData"
:modalTitle="temTitle"
:columns="columns"
:open="ModalIm"
@on-cancel="ModalImCancel"
@on-ok="ok"
/>
</div>
</template>
<script>
import Api from "./api";
import Search from "./search";
export default {
name: "list",
components: {
Search,
name: "list",
components: {
Search,
},
head: {
title: "项目计划",
author: "henq",
description: "project_plan 10/19/2020 10:23:07 AM",
},
props: {
eid: {
type: String,
},
head: {
title: "项目计划",
author: "henq",
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() {
data: {
type: Object,
default: () => {
return {
entity: {},
row: {},
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: "项目目录",
id: "33930562-a9f7-bd95-88ab-d01eb1c4c369",
title: "示例项目",
};
},
},
mounted() {
console.log(this);
this.search();
},
async fetch({
store,
params
}) {
await store.dispatch("loadDictionary"); // 加载数据字典
},
methods: {
ok() {
this.search();
this.modal = false;
this.curId = null;
},
data() {
return {
entity: {},
executors: [],
dateEntity: {
startDate: null,
endDate: null,
},
batchItems: [],
row: {},
action: Api.index,
easySearch: {
keys: {
op: "title",
value: null,
},
search() {
// this.$refs.grid.reload(this.easySearch);
var params = {
conditions: [{
fieldName: "projectId",
conditionalType: "Equal",
fieldValue: this.eid,
}, ],
// conditions: []
};
Api.list(params).then((r) => {
let res = 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;
});
},
modal: false,
title: "新增",
detail: null,
curId: null,
list: [],
rootList: [],
columns: [
{
key: "drag",
type: "drag",
width: 50,
align: "center",
title: "移动",
},
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;
{
key: "upId",
width: 50,
type: "selection",
align: "center",
title: "选择",
},
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();
}
});
{
key: "upTitle",
title: this.l("upTitle"),
hide: true,
export: true,
},
copy(id) {
this.curId = id;
this.title = "克隆";
this.detail = () => import("./add");
this.modal = true;
{
key: "title",
title: this.l("title"),
align: "left",
tree: true,
easy: true,
high: true,
export: true,
},
view(id) {
this.curId = id;
this.title = "详情";
this.detail = () => import("./detail");
this.modal = true;
{
key: "type",
width: 90,
title: this.l("type"),
align: "center",
high: true,
code: "mes.project_plan.Type",
attr: {
type: "icon",
},
export: true,
},
edit(row) {
this.curId = row.id;
this.row = row;
this.title = "编辑";
this.detail = () => import("./edit");
this.modal = true;
{
key: "direction",
title: this.l("direction"),
align: "center",
code: "mes.project_plan.direction",
width: 80,
easy: true,
high: true,
export: true,
},
remove(id) {
Api.delete(id).then((r) => {
if (r.success) {
this.search();
this.$Message.success("删除成功");
}
});
{
key: "status",
title: this.l("status"),
align: "center",
width: 80,
high: true,
code: "mes.project_plan.Status",
export: true,
},
cancel() {
this.curId = null;
this.modal = false;
{
key: "startDate",
title: "计划开始日期",
hide: true,
export: true,
},
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;
},
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);
{
key: "endDate",
title: "计划结束日期",
hide: true,
export: true,
},
saveTemplate() {
var that = this;
that.curId = that.eid;
that.row = that.data;
that.title = "保存模版";
that.detail = () => import("./saveTemplate");
that.modal = true;
{
key: "dateRange",
width: 250,
title: "计划日期",
align: "center",
render(h, param) {
return h("DateRange", {
attrs: {
value: param.row,
},
});
},
},
useTemplate() {
var that = this;
that.curId = that.eid;
that.row = that.data;
that.title = "导入模版";
that.detail = () => import("./importTemplate");
that.modal = true;
{
key: "executor",
title: this.l("executor"),
align: "left",
high: true,
type: "users",
export: true,
},
down() {
this.exportTl = '项目目录-' + this.data.title;
this.$refs.grid.export2Excel()
{
key: "deliverable",
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
let objSet = obj.getBoundingClientRect()
this.showStatu = true;
this.params = {
x: objSet.x,
y: objSet.bottom
};
console.log(event)
this.tempItems = [{
label: "存为模版",
onClick: () => {
this.saveTemplate()
},
}, {
label: "导入模版",
divided: true,
onClick: () => {
this.useTemplate()
},
},
{
label: "导出Excel",
icon: "md-cloud-download",
onClick: () => {
this.down()
},
},
{
label: "导入Excel",
icon: "md-cloud-upload",
onClick: () => {
this.importExcel()
},
}
];
],
//setButon
showStatu: false, //控件是否显示
tempItems: [], //控件数据
params: {}, //控件坐标位置
//导出导入
exportTl: "项目目录",
ModalIm: false,
temTitle: "项目目录",
};
},
mounted() {
this.search();
},
async fetch({ store, params }) {
await store.dispatch("loadDictionary"); // 加载数据字典
},
methods: {
ok() {
this.search();
this.modal = false;
this.curId = null;
},
search() {
// this.$refs.grid.reload(this.easySearch);
var params = {
conditions: [
{
fieldName: "projectId",
conditionalType: "Equal",
fieldValue: this.eid,
},
],
// 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
//导入功能
openModalIm() {
this.ModalIm = true
useTemplate(name) {
that.curId = that.eid;
that.row = that.data;
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`;
this.$refs.importExcel.deelData(url, this.columns, this.formatMethod(val))
{
label: "导入模版",
divided: true,
onClick: () => {
this.useTemplate();
},
},
//根据页面二次处理数据
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
{
label: "导出Excel",
icon: "md-cloud-download",
onClick: () => {
this.down();
},
},
//批量导入end
l(key) {
let vkey = "project_plan" + "." + key;
return this.$t(vkey) || key;
{
label: "导入Excel",
icon: "md-cloud-upload",
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>
......
......@@ -5,6 +5,7 @@ export const state = () => ({
counter: 0,
dictionary: new Map(), //所有字典项
userMap: new Map(), //所有用户缓存;
userNameMap: new Map(), //所有用户名称缓存;
departmentsMap: new Map(), //部门缓存;
userInfo: {
userId: 0,
......@@ -69,6 +70,9 @@ export const mutations = {
setUsers(state, users) {
state.userMap = users;
},
setUserNames(state, usersNames) {
state.userNameMap = usersNames;
},
addUser(state, user) {
state.userMap.push(user);
},
......@@ -178,10 +182,14 @@ export const actions = {
let r = await Api.get(`${systemUrl}/user/getuserlist`);
var umap = new Map();
var unamemap=new Map();
r.result.map(u => {
umap.set(u.id, u);
unamemap.set(u.name,u)
});
commit("setUsers", umap);
commit("setUserNames", unamemap);
},
async loadDepartments({
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