Commit 780421a2 authored by renjintao's avatar renjintao

editGrid

parent 39bec43f
......@@ -653,7 +653,7 @@ export default {
// );
// });
tempCol.forEach((elem) => {
if (e[elem.key] && e[elem.key] != "" && e[elem.key] != null) {
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];
......
<template>
<div class="table-content1">
<div class="table-content1">
<div class="table-tools">
<div class="table-search">
<slot name="easySearch"></slot>
</div>
<div class="btns">
<slot name="buttons"></slot>
<!-- <Button @click="config=!config">
<div class="table-search">
<slot name="easySearch"></slot>
</div>
<div class="btns">
<slot name="buttons"></slot>
<!-- <Button @click="config=!config">
<Icon type="md-build" class="table-set" size="14" title="列设置" />
</Button>-->
</div>
</div>
</div>
<div class="table-main" ref="main">
<div>
<table class="table-head">
<thead>
<tr>
<th
v-for="(column, index) in columns"
:key="index"
:style="tdStyle(column)"
>
<label v-if="column.type === 'selection'">
<Checkbox
v-model="checkAll"
@on-change="checked"
:indeterminate="indeterminate"
></Checkbox>
</label>
<label v-else>
{{ renderHeader(column, index) }}
<span class="ivu-table-sort" v-if="column.sortable">
<Icon
type="arrow-up-b"
:class="{ on: column._sortType === 'asc' }"
@click.native="handleSort(index, 'asc')"
/>
<Icon
type="arrow-down-b"
:class="{ on: column._sortType === 'desc' }"
@click.native="handleSort(index, 'desc')"
/>
</span>
</label>
</th>
</tr>
</thead>
<tbody>
<tr
v-for="(item, index) in trs"
:key="item.id"
class="treetr"
:id="'tr' + index"
v-show="show(item)"
:draggable="drag && !item._drag"
@dragstart="dragstart($event, index, item)"
@drop="dragdrop($event, index, item)"
@dragenter="dragenter($event, index, item)"
@dragover="dragover($event, index, item)"
@dragleave="dragleave($event, index, item)"
>
<!-- -->
<td
v-for="(column, snum) in columns"
: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"
></Checkbox>
</label>
<div>
<table class="table-head">
<thead>
<tr>
<th v-for="(column, index) in columns" :key="index" :style="tdStyle(column)">
<label v-if="column.type === 'selection'">
<Checkbox v-model="checkAll" @on-change="checked" :indeterminate="indeterminate"></Checkbox>
</label>
<label v-else>
{{ renderHeader(column, index) }}
<span class="ivu-table-sort" v-if="column.sortable">
<Icon type="arrow-up-b" :class="{ on: column._sortType === 'asc' }" @click.native="handleSort(index, 'asc')" />
<Icon type="arrow-down-b" :class="{ on: column._sortType === 'desc' }" @click.native="handleSort(index, 'desc')" />
</span>
</label>
</th>
</tr>
</thead>
<tbody>
<tr v-for="(item, index) in trs" :key="item.id" class="treetr" :id="'tr' + index" v-show="show(item)" :draggable="drag && !item._drag" @dragstart="dragstart($event, index, item)" @drop="dragdrop($event, index, item)" @dragenter="dragenter($event, index, item)" @dragover="dragover($event, index, item)" @dragleave="dragleave($event, index, item)">
<!-- -->
<td v-for="(column, snum) in columns" :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"></Checkbox>
</label>
<Icon
v-if="column.type === 'drag'"
type="md-more"
class="drag"
/>
<DTSpan
v-if="column.type == 'date'"
:value="item[column.key]"
/>
<div v-if="column.type == 'user'">
<User :value="item[column.key]" />
</div>
<div
v-if="
<Icon v-if="column.type === 'drag'" type="md-more" class="drag" />
<DTSpan v-if="column.type == 'date'" :value="item[column.key]" />
<User v-if="column.type == 'user'" :value="item[column.key]" />
<div v-if="
column.type == 'users' &&
item[column.key] &&
item[column.key].length > 0
"
>
<User
v-for="li in item[column.key]"
:value="li"
:key="li"
class="ml10"
/>
</div>
<state
v-if="column.code"
:code="column.code"
:value="item[column.key]"
/>
<!-- 树图标 -->
<span @click="toggle(index, item)" v-if="snum == treeColumn()">
<span class="ib" v-width="spaceWidth * item._level"></span>
<a v-if="item._count > 0" class="expand"
><Icon
:type="!item._expanded ? 'ios-add' : 'ios-remove'"
/> </a
><i v-else class="ms-tree-space"></i>
</span>
<!-- 菜单名称、排序、请求地址 -->
<label
v-if="
">
<User v-for="li in item[column.key]" :value="li" :key="li" class="ml10" />
</div>
<state v-if="column.code" :code="column.code" :value="item[column.key]" />
<!-- 树图标 -->
<span @click="toggle(index, item)" v-if="snum == treeColumn()">
<span class="ib" v-width="spaceWidth * item._level"></span>
<a v-if="item._count > 0" class="expand">
<Icon :type="!item._expanded ? 'ios-add' : 'ios-remove'" />
</a><i v-else class="ms-tree-space"></i>
</span>
<!-- 菜单名称、排序、请求地址 -->
<label v-if="
!column.type &&
!column.code &&
!column.render &&
!column.slot
"
>
{{ renderBody(item, column) }}
</label>
<table-expand
v-if="column.render && !column.type && !column.solt"
:row="item"
:column="column"
:index="snum"
:render="column.render"
></table-expand>
<column-slot
v-if="column.slot"
:row="item"
:column="column"
:index="snum"
></column-slot>
</td>
</tr>
</tbody>
</table>
</div>
">
{{ renderBody(item, column) }}
</label>
<table-expand v-if="column.render && !column.type && !column.solt" :row="item" :column="column" :index="snum" :render="column.render"></table-expand>
<column-slot v-if="column.slot" :row="item" :column="column" :index="snum"></column-slot>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="table-footer">
<slot name="footer"></slot>
<Page
v-if="page"
:total="search.total"
:current="search.page"
class="fr"
show-total
size="small"
show-elevator
show-sizer
:page-size="search.pageSize"
:page-size-opts="pageSizeOpts"
@on-change="pageChange"
@on-page-size-change="pageSizeChange"
/>
<slot name="footer"></slot>
<Page v-if="page" :total="search.total" :current="search.page" class="fr" show-total size="small" show-elevator show-sizer :page-size="search.pageSize" :page-size-opts="pageSizeOpts" @on-change="pageChange" @on-page-size-change="pageSizeChange" />
</div>
<Modal
v-if="high"
v-model="modalSearch"
title="高级搜索"
draggable
width="800"
ref="search"
>
<slot name="searchForm"></slot>
<div slot="footer">
<Button @click="modalSearch = false" class="mr20">取消</Button>
<Button @click="complexSearch" type="primary" class="mr20">查询</Button>
</div>
<Modal v-if="high" v-model="modalSearch" title="高级搜索" draggable width="800" ref="search">
<slot name="searchForm"></slot>
<div slot="footer">
<Button @click="modalSearch = false" class="mr20">取消</Button>
<Button @click="complexSearch" type="primary" class="mr20">查询</Button>
</div>
</Modal>
<Drawer
title="列设置"
v-if="set"
v-model="config"
:scrollable="true"
placement="left"
:mask="false"
>
<div slot="header">
列设置
<a @click="undoConfig" class="ml50">
<Icon type="md-refresh" title="恢复初始设置" />
</a>
</div>
<ul class="table-columns">
<li
v-for="(li, index) in columnsCur"
:key="index"
v-dragging="{ item: li, list: columnsCur, group: 'li' }"
>
<label @click="columnChange(li, index)" :class="{ dis: li.hide }">
<Icon
:type="li.hide ? 'md-eye-off' : 'md-eye'"
size="16"
class="mr10"
/>
<span>{{ li.title }}</span>
</label>
<Icon type="ios-move" class="move" size="18" />
</li>
</ul>
<Drawer title="列设置" v-if="set" v-model="config" :scrollable="true" placement="left" :mask="false">
<div slot="header">
列设置
<a @click="undoConfig" class="ml50">
<Icon type="md-refresh" title="恢复初始设置" />
</a>
</div>
<ul class="table-columns">
<li v-for="(li, index) in columnsCur" :key="index" v-dragging="{ item: li, list: columnsCur, group: 'li' }">
<label @click="columnChange(li, index)" :class="{ dis: li.hide }">
<Icon :type="li.hide ? 'md-eye-off' : 'md-eye'" size="16" class="mr10" />
<span>{{ li.title }}</span>
</label>
<Icon type="ios-move" class="move" size="18" />
</li>
</ul>
</Drawer>
<FooterToolbar v-if="batch" v-show="footerToolbar" class="ftball">
<div class="tip">已选{{ selectItems.length }}</div>
<slot name="batch"></slot>
<Button @click="cancelBatch">取消</Button>
<div class="tip">已选{{ selectItems.length }}</div>
<slot name="batch"></slot>
<Button @click="cancelBatch">取消</Button>
</FooterToolbar>
</div>
</div>
</template>
<script>
import TableExpand from "./expand";
import ColumnSlot from "./columnSolt";
export default {
name: "treeGrid",
components: { TableExpand, ColumnSlot },
props: {
mode: {
type: [String, Number],
default: 0,
validator: (v) => {
var modes = ["read", "column", "row"];
if (/^\d+/.test(v)) {
return v >= 0 && v < modes.length;
}
return modes.indexOf(v) > -1;
},
},
border: {
//是否显示边框
type: Boolean,
default: true,
},
batch: {
//是否批量操作
type: Boolean,
default: true,
},
format: {
type: Function,
default: null,
},
initsearch: {
type: Function,
default: null,
},
lazy: {
//懒加载设置,设置为真时候,默认不加载数据。
type: Boolean,
default: false,
},
placeholder: {
type: String,
default: "请输入关键字",
},
height: {
type: Number,
default: 0,
},
tool: {
//是否显示工具栏
type: Boolean,
default: true,
},
easy: {
//是否显示简单搜索
type: Boolean,
default: true,
},
high: {
//是否显示高级搜索
type: Boolean,
default: true,
},
draggable: {
//是否可以拖拽
type: Boolean,
default: false,
},
set: {
//是否显示列设置
type: Boolean,
default: true,
},
page: {
//是否分页
type: Boolean,
default: false,
},
columns: Array,
items: {
//接收树形数据
type: Array,
default() {
return [];
},
},
data: {
//接收UpId型数据
type: Array,
default() {
return [];
},
},
keyname: {
//默认行主键
type: [String],
default: "id",
},
upname: {
// 父级字段名称
type: String,
default: "upId",
},
root: {
// 根级UpId的值.
type: [String, Number],
default: 0,
},
action: {
//接口地址
type: String,
default: "",
},
conditions: {
//查询条件
type: Object,
default: function () {
return {
keys: {
op: "name",
value: "",
name: "treeGrid",
components: {
TableExpand,
ColumnSlot
},
props: {
mode: {
type: [String, Number],
default: 0,
validator: (v) => {
var modes = ["read", "column", "row"];
if (/^\d+/.test(v)) {
return v >= 0 && v < modes.length;
}
return modes.indexOf(v) > -1;
},
},
border: {
//是否显示边框
type: Boolean,
default: true,
},
batch: {
//是否批量操作
type: Boolean,
default: true,
},
format: {
type: Function,
default: null,
},
initsearch: {
type: Function,
default: null,
},
lazy: {
//懒加载设置,设置为真时候,默认不加载数据。
type: Boolean,
default: false,
},
placeholder: {
type: String,
default: "请输入关键字",
},
height: {
type: Number,
default: 0,
},
tool: {
//是否显示工具栏
type: Boolean,
default: true,
},
easy: {
//是否显示简单搜索
type: Boolean,
default: true,
},
high: {
//是否显示高级搜索
type: Boolean,
default: true,
},
draggable: {
//是否可以拖拽
type: Boolean,
default: false,
},
set: {
//是否显示列设置
type: Boolean,
default: true,
},
},
page: {
//是否分页
type: Boolean,
default: false,
},
columns: Array,
items: {
//接收树形数据
type: Array,
default () {
return [];
},
},
data: {
//接收UpId型数据
type: Array,
default () {
return [];
},
},
keyname: {
//默认行主键
type: [String],
default: "id",
},
upname: {
// 父级字段名称
type: String,
default: "upId",
},
root: {
// 根级UpId的值.
type: [String, Number],
default: 0,
},
action: {
//接口地址
type: String,
default: "",
},
conditions: {
//查询条件
type: Object,
default: function () {
return {
keys: {
op: "name",
value: "",
default: true,
},
};
},
},
iconName: false,
drag: {
//拖拽
type: Boolean,
default: false,
},
spaceWidth: {
//树形表格缩进距离
type: Number,
default: 20,
},
exportTitle: {
type: String,
default: "",
},
},
provide() {
return {
tableRoot: this.slots,
};
},
},
iconName: false,
drag: {
//拖拽
type: Boolean,
default: false,
},
spaceWidth: {
//树形表格缩进距离
type: Number,
default: 20,
},
exportTitle: {
type: String,
default: "",
},
},
provide() {
return {
tableRoot: this.slots,
};
},
data() {
return {
color: "#19be6b",
checkAll: false,
keys: "",
selectItems: [],
modalSearch: false,
footerToolbar: false,
search: {
pageIndex: 1,
pageSize: 20,
sortBy: "id",
isDesc: true,
conditions: [],
},
searchConditions: this.search,
pageSizeOpts: [20, 50, 100],
tableHeight: 0,
firstY: 0,
config: false,
logs: [],
trs: [], // 处理后数据数组
columnsCur: [], // 处理后的表头数据
checkGroup: [], // 复选框数组
checks: false, // 全选
tdsWidth: 0, // td总宽
timer: false, // 控制监听时长
dataLength: 0, // 树形数据长度
dragIndex: -1, //拖拽开始的序号
};
},
computed: {
indeterminate() {
var checkeds = this.trs.filter((u) => {
return u._checked;
}).length;
return 0 < checkeds && checkeds < this.trs.length;
data() {
return {
color: "#19be6b",
checkAll: false,
keys: "",
selectItems: [],
modalSearch: false,
footerToolbar: false,
search: {
pageIndex: 1,
pageSize: 20,
sortBy: "id",
isDesc: true,
conditions: [],
},
searchConditions: this.search,
pageSizeOpts: [20, 50, 100],
tableHeight: 0,
firstY: 0,
config: false,
logs: [],
trs: [], // 处理后数据数组
columnsCur: [], // 处理后的表头数据
checkGroup: [], // 复选框数组
checks: false, // 全选
tdsWidth: 0, // td总宽
timer: false, // 控制监听时长
dataLength: 0, // 树形数据长度
dragIndex: -1, //拖拽开始的序号
allUser: [], //所有user
};
},
},
watch: {
items() {
if (this.items) {
this.trs = this.treeToList(this.items);
this.checkGroup = this.renderCheck(this.items);
if (this.checkGroup.length == this.dataLength) {
this.checks = true;
} else {
this.checks = false;
computed: {
indeterminate() {
var checkeds = this.trs.filter((u) => {
return u._checked;
}).length;
return 0 < checkeds && checkeds < this.trs.length;
},
},
watch: {
items() {
if (this.items) {
this.trs = this.treeToList(this.items);
this.checkGroup = this.renderCheck(this.items);
if (this.checkGroup.length == this.dataLength) {
this.checks = true;
} else {
this.checks = false;
}
}
},
data(v) {},
columns: {
handler() {
this.columnsCur = this.makeColumns();
},
deep: true,
},
checkGroup(data) {
this.checkAllGroupChange(data);
},
exportTitle(v) {
this.exportTitle = v
}
}
},
data(v) {},
columns: {
handler() {
this.columnsCur = this.makeColumns();
},
deep: true,
},
checkGroup(data) {
this.checkAllGroupChange(data);
},
},
mounted() {
if (this.items && this.items.length > 0) {
this.trs = this.treeToList(this.items);
this.columnsCur = this.makeColumns();
this.checkGroup = this.renderCheck(this.items);
if (this.checkGroup.length == this.dataLength) {
this.checks = true;
} else {
this.checks = false;
}
}
},
methods: {
load() {},
complexSearch() {
var search = this.$refs.search.$children.filter((u) => {
return u.condition;
});
if (search) {
var conditions = search[0].condition;
this.reload(conditions);
}
},
slots() {
return this.$scopedSlots;
},
//拖拽开始
dragstart(e, index, row) {
this.dragIndex = index;
console.log(index);
},
//进入
dragenter(e, index, row) {
var tr = document.getElementById("tr" + index);
if (this.dragIndex > index) {
tr.className += " move";
} else if (this.dragIndex < index) {
tr.className += " sort";
}
},
// 悬浮
dragover(e, index, row) {
e.preventDefault();
// 鼠标Y
var my = e.offsetY;
var h = e.toElement.clientHeight;
var tr = document.getElementById("tr" + index);
if (this.dragIndex > index && my / h < 0.5) {
tr.className = tr.className.replace(" move", " sort");
}
if (this.dragIndex < index && my / h > 0.5) {
tr.className = tr.className.replace(" sort", " move");
}
},
// 离开
dragleave(e, index, row) {
var tr = document.getElementById("tr" + index);
tr.className = tr.className.replace(" move", "").replace(" sort", "");
},
//放下
dragdrop(e, index, row) {
event.preventDefault();
var tr = document.getElementById("tr" + index);
tr.className = tr.className.replace(" move", "").replace(" sort", "");
if (index != this.dragIndex) {
this.$emit("on-drag-drop", this.dragIndex, index, this.trs, e);
}
},
/**
* @dragover="dragover($event, index, item)"
@dragleave="dragleave($event,index,item)"
*/
// 有无多选框折叠位置优化
treeColumn() {
var num = 0;
for (let i = 0, len = this.columns.length; i < len; i++) {
if (this.columns[i].tree) {
num = i;
mounted() {
this.getAllUser(); //获取所有用户
if (this.items && this.items.length > 0) {
this.trs = this.treeToList(this.items);
this.columnsCur = this.makeColumns();
this.checkGroup = this.renderCheck(this.items);
if (this.checkGroup.length == this.dataLength) {
this.checks = true;
} else {
this.checks = false;
}
}
}
return num;
},
methods: {
load() {},
complexSearch() {
var search = this.$refs.search.$children.filter((u) => {
return u.condition;
});
if (search) {
var conditions = search[0].condition;
this.reload(conditions);
}
},
slots() {
return this.$scopedSlots;
},
//拖拽开始
dragstart(e, index, row) {
this.dragIndex = index;
console.log(index);
},
//进入
dragenter(e, index, row) {
var tr = document.getElementById("tr" + index);
if (this.dragIndex > index) {
tr.className += " move";
} else if (this.dragIndex < index) {
tr.className += " sort";
}
},
// 悬浮
dragover(e, index, row) {
e.preventDefault();
// 鼠标Y
var my = e.offsetY;
var h = e.toElement.clientHeight;
var tr = document.getElementById("tr" + index);
if (this.dragIndex > index && my / h < 0.5) {
tr.className = tr.className.replace(" move", " sort");
}
if (this.dragIndex < index && my / h > 0.5) {
tr.className = tr.className.replace(" sort", " move");
}
},
// 离开
dragleave(e, index, row) {
var tr = document.getElementById("tr" + index);
tr.className = tr.className.replace(" move", "").replace(" sort", "");
},
//放下
dragdrop(e, index, row) {
event.preventDefault();
var tr = document.getElementById("tr" + index);
tr.className = tr.className.replace(" move", "").replace(" sort", "");
if (index != this.dragIndex) {
this.$emit("on-drag-drop", this.dragIndex, index, this.trs, e);
}
},
/**
* @dragover="dragover($event, index, item)"
@dragleave="dragleave($event,index,item)"
*/
// 有无多选框折叠位置优化
treeColumn() {
var num = 0;
for (let i = 0, len = this.columns.length; i < len; i++) {
if (this.columns[i].tree) {
num = i;
}
}
return num;
},
// 设置td宽度,td的align
tdStyle(column) {
const style = {};
if (column.align) {
style["text-align"] = column.align;
}
if (column.width) {
style["width"] = `${column.width}px`;
}
return style;
},
// 排序事件
handleSort(index, type) {
this.columnsCur.forEach((col) => (col._sortType = "normal"));
if (this.columnsCur[index]._sortType === type) {
this.columnsCur[index]._sortType = "normal";
} else {
this.columnsCur[index]._sortType = type;
}
this.$emit(
"on-sort-change",
this.columnsCur[index].key,
this.columnsCur[index]._sortType
);
},
// 点击某一行事件
RowClick(data, event, index, text) {
this.$emit("on-row-click", data, event, index, text);
},
// 点击事件 返回数据处理
// 处理表头数据
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;
},
// // 隐藏显示
toggle(index, item) {
if (item._count > 0) {
this.$set(this.trs[index], "_expanded", !item._expanded);
this.trs.forEach((u, i) => {
if (u[this.upname] === item.id) {
this.$set(this.trs[i], "_show", !item._expanded);
}
});
}
console.warn(index, item._expanded, item);
},
show(item) {
if (item._level == 0) {
return true;
} else {
var parents = this.getRoots(item);
return (
parents.filter((u) => {
return !u._expanded;
}).length == 0
);
}
},
getRoots(item) {
var parents = [];
var root = this.trs.filter((u) => {
return u[this.keyname] == item[this.upname];
});
while (root.length == 1) {
parents.push(root[0]);
root = this.trs.filter((u) => {
return u[this.keyname] === root[0][this.upname];
});
}
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) {
var boys = this.getChildrens(data);
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.checkAll =
this.trs.length >
this.trs.filter((u) => {
return !u._checked;
}).length;
},
getChildrens(data) {
var childrens = [];
var that = this;
getChildren(data);
function getChildren(f) {
that.trs.forEach((u) => {
if (u[that.upname] == f[that.keyname]) {
childrens.push(u);
getChildren(u);
}
});
}
return childrens;
},
// checkbox 全选 选择事件
checked(v) {
this.trs.forEach((u, i) => {
this.$set(this.trs[i], "_checked", v);
});
// this.$emit('on-selection-change', this.checkGroup)
},
// 数组去重
getArray(a) {
const hash = {};
const len = a.length;
const result = [];
for (let i = 0; i < len; i++) {
if (!hash[a[i]]) {
hash[a[i]] = true;
result.push(a[i]);
}
}
return result;
},
checkAllGroupChange(data) {
if (this.dataLength > 0 && data.length === this.dataLength) {
this.checks = true;
} else {
this.checks = false;
}
this.$emit("on-selection-change", this.checkGroup);
},
All(data) {
let arr = [];
data.forEach((item) => {
arr.push(item.id);
if (item.children && item.children.length > 0) {
arr = arr.concat(this.All(item.children));
}
});
return arr;
},
// 设置td宽度,td的align
tdStyle(column) {
const style = {};
if (column.align) {
style["text-align"] = column.align;
}
if (column.width) {
style["width"] = `${column.width}px`;
}
if (column.hide) {
style["display"] = `none`;
}
return style;
},
// 排序事件
handleSort(index, type) {
this.columnsCur.forEach((col) => (col._sortType = "normal"));
if (this.columnsCur[index]._sortType === type) {
this.columnsCur[index]._sortType = "normal";
} else {
this.columnsCur[index]._sortType = type;
}
this.$emit(
"on-sort-change",
this.columnsCur[index].key,
this.columnsCur[index]._sortType
);
},
// 点击某一行事件
RowClick(data, event, index, text) {
this.$emit("on-row-click", data, event, index, text);
},
// 点击事件 返回数据处理
// 处理表头数据
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;
},
// // 隐藏显示
// 返回表头
renderHeader(column, $index) {
if ("renderHeader" in this.columns[$index]) {
return this.columns[$index].renderHeader(column, $index);
}
return column.title || "#";
},
treeToList(tree) {
var that = this;
let list = [];
function treeToList(data, level) {
data.map((u) => {
let copy = that.$u.clone(u);
copy._count = 0;
copy._level = level;
copy._expanded = copy._expanded || that.level > level;
copy._show = true;
copy._indeterminate = false;
copy._checked = copy._checked || false;
list.push(copy);
if (u.children) {
treeToList(u.children, level + 1);
copy._count = u.children.length;
delete copy.children;
}
});
}
treeToList(tree, 0);
return list;
},
toggle(index, item) {
if (item._count > 0) {
this.$set(this.trs[index], "_expanded", !item._expanded);
this.trs.forEach((u, i) => {
if (u[this.upname] === item.id) {
this.$set(this.trs[i], "_show", !item._expanded);
}
});
}
console.warn(index, item._expanded, item);
},
show(item) {
if (item._level == 0) {
return true;
} else {
var parents = this.getRoots(item);
return (
parents.filter((u) => {
return !u._expanded;
}).length == 0
);
}
},
getRoots(item) {
var parents = [];
var root = this.trs.filter((u) => {
return u[this.keyname] == item[this.upname];
});
while (root.length == 1) {
parents.push(root[0]);
root = this.trs.filter((u) => {
return u[this.keyname] === root[0][this.upname];
});
}
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) {
var boys = this.getChildrens(data);
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.checkAll =
this.trs.length >
this.trs.filter((u) => {
return !u._checked;
}).length;
},
getChildrens(data) {
var childrens = [];
var that = this;
getChildren(data);
// 返回内容
renderBody(row, column, index) {
return row[column.key];
},
// 默认选中
renderCheck(data) {
let arr = [];
data.forEach((item) => {
if (item._checked) {
arr.push(item.id);
}
if (item.children && item.children.length > 0) {
arr = arr.concat(this.renderCheck(item.children));
}
});
return arr;
},
//分页选择
pageChange(page) {
this.search.page = page;
this.search.pageIndex = page;
this.load();
},
pageSizeChange(size) {
this.search.pageSize = size;
this.search.pageIndex = 1;
this.load();
},
columnChange(item, i) {
item.hide = !item.hide;
this.$set(this.columnsCur, item, i);
this.saveUserconfig();
},
selectionChange(items) {
this.$emit("on-selection-change", items);
this.selectItems = items;
this.footerToolbar = items.length > 0;
},
onSelect(rows, row) {
this.$emit("on-change", rows, row);
},
allChange(items) {
this.$emit("all-change", items);
},
undoConfig() {
//列设置恢复初始化
this.columnsCur = this.$u.clone(this.columns);
// this.saveUserconfig();
},
function getChildren(f) {
that.trs.forEach((u) => {
if (u[that.upname] == f[that.keyname]) {
childrens.push(u);
getChildren(u);
}
});
}
return childrens;
},
// checkbox 全选 选择事件
checked(v) {
this.trs.forEach((u, i) => {
this.$set(this.trs[i], "_checked", v);
});
// this.$emit('on-selection-change', this.checkGroup)
},
// 数组去重
getArray(a) {
const hash = {};
const len = a.length;
const result = [];
for (let i = 0; i < len; i++) {
if (!hash[a[i]]) {
hash[a[i]] = true;
result.push(a[i]);
}
}
return result;
},
checkAllGroupChange(data) {
if (this.dataLength > 0 && data.length === this.dataLength) {
this.checks = true;
} else {
this.checks = false;
}
this.$emit("on-selection-change", this.checkGroup);
},
All(data) {
let arr = [];
data.forEach((item) => {
arr.push(item.id);
if (item.children && item.children.length > 0) {
arr = arr.concat(this.All(item.children));
}
});
return arr;
},
// 返回表头
renderHeader(column, $index) {
if ("renderHeader" in this.columns[$index]) {
return this.columns[$index].renderHeader(column, $index);
}
return column.title || "#";
},
treeToList(tree) {
var that = this;
let list = [];
function treeToList(data, level) {
data.map((u) => {
let copy = that.$u.clone(u);
copy._count = 0;
copy._level = level;
copy._expanded = copy._expanded || that.level > level;
copy._show = true;
copy._indeterminate = false;
copy._checked = copy._checked || false;
list.push(copy);
if (u.children) {
treeToList(u.children, level + 1);
copy._count = u.children.length;
delete copy.children;
}
});
}
treeToList(tree, 0);
return list;
},
// 返回内容
renderBody(row, column, index) {
return row[column.key];
},
// 默认选中
renderCheck(data) {
let arr = [];
data.forEach((item) => {
if (item._checked) {
arr.push(item.id);
}
if (item.children && item.children.length > 0) {
arr = arr.concat(this.renderCheck(item.children));
}
});
return arr;
},
//分页选择
pageChange(page) {
this.search.page = page;
this.search.pageIndex = page;
this.load();
},
pageSizeChange(size) {
this.search.pageSize = size;
this.search.pageIndex = 1;
this.load();
},
columnChange(item, i) {
item.hide = !item.hide;
this.$set(this.columnsCur, item, i);
this.saveUserconfig();
},
selectionChange(items) {
this.$emit("on-selection-change", items);
this.selectItems = items;
this.footerToolbar = items.length > 0;
},
onSelect(rows, row) {
this.$emit("on-change", rows, row);
},
allChange(items) {
this.$emit("all-change", items);
},
undoConfig() {
//列设置恢复初始化
this.columnsCur = this.$u.clone(this.columns);
// this.saveUserconfig();
},
//批量取消
cancelBatch() {
this.footerToolbar = false;
this.$refs.table.selectAll(false);
},
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)
}
});
});
},
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);
});
}
});
},
getUserName(id) {
let name = "";
this.allUser.forEach((ele) => {
if (id == ele.userId) {
name = ele.name;
}
});
return name;
},
},
};
</script>
<style lang="less">
@import "../../../assets/css/custom.less";
@table_theme: #2680eb;
......@@ -779,103 +860,120 @@ export default {
@table_line_height: 50px;
@table_hover: #f2f8fe;
@table_border: #accef7;
.table-content1 {
position: relative;
height: 100%;
display: flex;
flex-direction: column;
.table-tools {
line-height: 40px;
background: @right-header-bg;
.table-search {
float: left;
line-height: 40px;
min-width: 300px;
}
.btns {
float: right;
line-height: 40px;
}
tr:hover {
background: #f7f7f7;
}
}
.icon-set {
font-size: 17px;
margin-left: 5px;
display: inline-block;
}
.icon-set .ivu-icon {
cursor: pointer;
}
table {
border-spacing: 0;
border-collapse: collapse;
margin: 0 auto;
width: 100%;
border: 1px solid @table_border;
th {
background: @table_head;
position: relative;
height: 100%;
display: flex;
flex-direction: column;
.table-tools {
line-height: 40px;
background: @right-header-bg;
.table-search {
float: left;
line-height: 40px;
min-width: 300px;
}
.btns {
float: right;
line-height: 40px;
}
tr:hover {
background: #f7f7f7;
}
}
td,
th {
border-left: @table_border solid 1px;
border-right: @table_border solid 1px;
border-bottom: #e8e9eb solid 1px;
line-height: 50px;
padding: 0 5px;
.drag:hover {
cursor: move;
}
.expand {
width: 18px;
height: 18px;
border: 1px solid @table_border;
text-align: center;
padding: 0 1px;
font-size: 14px;
font-weight: bold;
}
.expand:hover {
background: @table_theme;
color: white;
}
.ib {
.icon-set {
font-size: 17px;
margin-left: 5px;
display: inline-block;
}
}
th {
border-top: @table_border solid 1px;
}
tr.treetr:hover td {
background: @table_hover;
}
tr.move {
td {
background-color: #d3e6fb;
}
}
tr.sort {
td {
border-top: 2px solid #3b8ded;
}
}
tbody {
border-bottom: @table_border solid 1px;
.icon-set .ivu-icon {
cursor: pointer;
}
.ms-tree-space {
position: relative;
top: 1px;
display: inline-block;
font-style: normal;
font-weight: 400;
line-height: 1;
width: 14px;
height: 14px;
table {
border-spacing: 0;
border-collapse: collapse;
margin: 0 auto;
width: 100%;
border: 1px solid @table_border;
th {
background: @table_head;
}
td,
th {
border-left: @table_border solid 1px;
border-right: @table_border solid 1px;
border-bottom: #e8e9eb solid 1px;
line-height: 50px;
padding: 0 5px;
.drag:hover {
cursor: move;
}
.expand {
width: 18px;
height: 18px;
border: 1px solid @table_border;
text-align: center;
padding: 0 1px;
font-size: 14px;
font-weight: bold;
}
.expand:hover {
background: @table_theme;
color: white;
}
.ib {
display: inline-block;
}
}
th {
border-top: @table_border solid 1px;
}
tr.treetr:hover td {
background: @table_hover;
}
tr.move {
td {
background-color: #d3e6fb;
}
}
tr.sort {
td {
border-top: 2px solid #3b8ded;
}
}
tbody {
border-bottom: @table_border solid 1px;
}
.ms-tree-space {
position: relative;
top: 1px;
display: inline-block;
font-style: normal;
font-weight: 400;
line-height: 1;
width: 14px;
height: 14px;
}
}
}
}
</style>
<template>
<div>
<div>
<Card>
<EditGrid
:columns="columns"
ref="grid"
:items="list"
:level="8"
:drag="true"
>
<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" :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">
<Search />
</template> -->
<template slot="buttons">
<Button type="primary" @click="add(null)">新增</Button>
<Dropdown @on-click="show">
<Button shape="circle" icon="md-settings"></Button>
<DropdownMenu slot="list">
<DropdownItem name="saveTemplate">存为模版</DropdownItem>
<DropdownItem name="useTemplate">导入模版</DropdownItem>
<DropdownItem name="down" disabled>
<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>
<Dropdown @on-click="show">
<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>
</Card>
<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>
</div>
</div>
</template>
<script>
import Api from "./api";
import Search from "./search";
export default {
name: "list",
components: {
Search,
},
head: {
title: "项目计划",
author: "henq",
description: "project_plan 10/19/2020 10:23:07 AM",
},
props: {
eid: {
type: String,
name: "list",
components: {
Search,
},
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: {
type: Object,
default: () => {
data() {
return {
id: "33930562-a9f7-bd95-88ab-d01eb1c4c369",
title: "示例项目",
entity: {},
row: {},
action: Api.index,
easySearch: {
keys: {
op: "title",
value: null
},
},
modal: false,
title: "新增",
exportTl: '项目目录',
detail: null,
curId: null,
list: [],
columns: [{
key: "drag",
type: "drag",
width: 50,
align: 'center'
},
{
key: "upId",
width: 50,
type: "selection",
align: 'center'
},
{
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)
},
}),
]);
},
},
],
};
},
},
},
data() {
return {
entity: {},
row: {},
action: Api.index,
easySearch: {
keys: { op: "title", value: null },
},
modal: false,
title: "新增",
detail: null,
curId: null,
list: [],
columns: [
// { key:"id",title:this.$t("id") ,hide:true ,align:"left" ,high:true },
// { key:"creationTime",title:this.l("creationTime") ,align:"left" ,high:true },
// { key:"creatorUserId",title:this.l("creatorUserId") ,align:"left" ,high:true },
// { key:"lastModificationTime",title:this.l("lastModificationTime") ,align:"left" ,high:true },
// { key:"lastModifierUserId",title:this.l("lastModifierUserId") ,align:"left" ,high:true },
// { key:"isDeleted",title:this.l("isDeleted") ,align:"left" ,high:true },
// { key:"deletionTime",title:this.l("deletionTime") ,align:"left" ,high:true },
// { key:"deleterUserId",title:this.l("deleterUserId") ,align:"left" ,high:true },
// { key:"projectId",title:this.l("projectId") ,align:"left" ,high:true },
// { key:"upId",title:this.l("upId") ,align:"left" ,high:true },
// { type: "selection", width: 80, align: "center" },
{
key:"drag",
type:"drag",
width:50,
align:'center'
mounted() {
console.log(this);
this.search();
},
async fetch({
store,
params
}) {
await store.dispatch("loadDictionary"); // 加载数据字典
},
methods: {
ok() {
this.search();
this.modal = false;
this.curId = null;
},
{
key: "upId",
width: 50,
type:"selection",
align:'center'
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;
});
},
{
key: "title",
title: this.l("title"),
align: "left",
tree: true,
easy: true,
high: true,
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: "type",
width: 90,
title: this.l("type"),
align: "center",
high: true,
code: "mes.project_plan.Type",
attr: {
type: "icon",
},
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: "direction",
title: this.l("direction"),
align: "center",
code: "mes.project_plan.direction",
width: 80,
easy: true,
high: true,
copy(id) {
this.curId = id;
this.title = "克隆";
this.detail = () => import("./add");
this.modal = true;
},
{
key: "status",
title: this.l("status"),
align: "center",
width: 80,
high: true,
code: "mes.project_plan.Status",
view(id) {
this.curId = id;
this.title = "详情";
this.detail = () => import("./detail");
this.modal = true;
},
// {
// key: "startDate",
// title: this.l("startDate"),
// align: "left",
// high: true
// ,type:"date"
// },
// { key: "endDate", title: this.l("endDate"), align: "left", high: true,type:"date" },
{
key: "endDate",
width: 250,
title: "计划日期",
align: "center",
render(h, param) {
return h("DateRange", {
attrs: {
value: param.row,
},
});
},
edit(row) {
this.curId = row.id;
this.row = row;
this.title = "编辑";
this.detail = () => import("./edit");
this.modal = true;
},
// {
// key: "attachment",
// title: this.l("attachment"),
// align: "left",
// high: true,
// },
{
key: "executor",
title: this.l("executor"),
align: "left",
high: true,
type: "users",
remove(id) {
Api.delete(id).then((r) => {
if (r.success) {
this.search();
this.$Message.success("删除成功");
}
});
},
{
key: "deliverable",
title: this.l("deliverable"),
code: "mes.project_plan.deliverable",
width: 80,
align: "center",
easy: true,
high: true,
cancel() {
this.curId = null;
this.modal = false;
},
{
title: "操作",
key: "action",
width: 150,
align: "center",
// render:(h,params)=>{
// return h("Actions"
// ,{
// attrs:{
// row:params,
// },
// on:{
// 'on-click':this.rowclick
// }
// }
// )
// }
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",
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;
},
on: { click: () => this.add(params.row) },
}),
h("op", {
attrs: {
icon: "md-create",
type: "icon",
title: "编辑",
oprate: "edit",
disable: params.row.status !== 0,
useTemplate(name) {
that.curId = that.eid;
that.row = that.data;
that.title = "导入模版";
that.detail = () => import("./importTemplate");
that.modal = true;
},
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) },
}),
]);
},
},
],
};
},
mounted() {
console.log(this);
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;
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,
};
}
}
if (name == 'down') {
this.exportTl = '项目目录-' + this.data.title;
this.$refs.grid.export2Excel()
}
m[name] && m[name](name);
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;
},
useTemplate(name){
that.curId = that.eid;
that.row = that.data;
that.title = "导入模版";
that.detail = () => import("./importTemplate");
that.modal = true;
}
}
m[name]&&m[name](name);
},
l(key) {
let vkey = "project_plan" + "." + key;
return this.$t(vkey) || key;
l(key) {
let vkey = "project_plan" + "." + key;
return this.$t(vkey) || key;
},
},
},
};
</script>
<style lang="less">
</style>
\ No newline at end of file
</style>
......@@ -7,7 +7,7 @@
</div>
<div class="mt50 pl10">
<h2>Bmenu</h2>
<div @contextmenu="showBmenu" class="tc" style="width:120px;height:40px;line-height:40px;background:#f5f5f5;border:#ccc solid 1px; border-radius: 5px;">{{message}}</div>
<div @contextmenu="onCon" class="tc" style="width:120px;height:40px;line-height:40px;background:#f5f5f5;border:#ccc solid 1px; border-radius: 5px;">{{message}}</div>
</div>
</div>
</template>
......
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