Commit c0b6424e authored by 周远喜's avatar 周远喜

批量设置

parent cb7db6a0
<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>
......
......@@ -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" @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">
<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>
<template slot="batch">
<Button type="primary" @click="bacthRemove()">批量删除</Button>
</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: {},
batchItems:[],
row: {},
action: Api.index,
easySearch: {
keys: {
op: "title",
value: null
},
},
modal: false,
title: "新增",
detail: null,
curId: null,
list: [],
rootList: [],
columns: [{
key: "drag",
type: "drag",
width: 50,
align: 'center',
title: '移动',
},
{
key: "upId",
width: 50,
type: "selection",
align: 'center',
title: '选择',
},
{
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() {
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;
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;
});
},
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()
this.$u.export2excel(this.exportTl, this.columns, this.list)
}
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.$u.export2excel(this.exportTl, this.columns, this.rootList, this.$store)
//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;
},
batchChange(items,list){
this.batchItems=items;
useTemplate(name) {
that.curId = that.eid;
that.row = that.data;
that.title = "导入模版";
that.detail = () => import("./importTemplate");
that.modal = true;
},
bacthRemove(){
var ids=this.batchItems.map(u=>{
return u.id;
})
if(ids.length>0){
Api.batch(ids).then(r=>{
if(r.success){
this.search();
}
})
}
};
//导出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();
},
},
//批量导入start
//导入功能
openModalIm() {
this.ModalIm = true
{
label: "导入模版",
divided: true,
onClick: () => {
this.useTemplate();
},
},
ModalImCancel() {
this.ModalIm = false
{
label: "导出Excel",
icon: "md-cloud-download",
onClick: () => {
this.down();
},
},
getData(val) {
let url = `${material}/projectplan/importplans`;
this.$refs.importExcel.deelData(url, this.columns, this.formatMethod(val))
{
label: "导入Excel",
icon: "md-cloud-upload",
onClick: () => {
this.importExcel();
},
},
//根据页面二次处理数据
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);
];
},
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("出现异常");
}
});
return tempList
},
//批量导入end
l(key) {
let vkey = "project_plan" + "." + key;
return this.$t(vkey) || key;
},
},
});
}
},
//批量导入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>
......
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