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

批量设置

parent cb7db6a0
<template> <template>
<div>
<Select <Select
:placeholder="placeholder" :placeholder="placeholder"
v-model="name" v-model="name"
...@@ -7,7 +6,6 @@ ...@@ -7,7 +6,6 @@
:multiple="multiple" :multiple="multiple"
clearable clearable
filterable filterable
transfer
> >
<Option <Option
v-for="item in users" v-for="item in users"
...@@ -30,7 +28,6 @@ ...@@ -30,7 +28,6 @@
</div> </div>
</Option> </Option>
</Select> </Select>
</div>
</template> </template>
<script> <script>
......
...@@ -142,7 +142,7 @@ export default { ...@@ -142,7 +142,7 @@ export default {
}).then((r) => { }).then((r) => {
if (r.success) { if (r.success) {
this.$Message.success("导入成功"); this.$Message.success("导入成功");
this.$emit("on-load"); this.$emit("on-ok");
} }
}); });
}, },
......
<template> <template>
<div> <div>
<Card> <Card>
<EditGrid :columns="columns" ref="grid" :batch="true" :items="list" :level="8" :drag="true" :exportTitle="exportTl" @on-selection-change="batchChange"> <EditGrid
<template slot="easySearch"> :columns="columns"
<Form ref="formInline" :model="easySearch" inline> ref="grid"
<FormItem prop="keys"><Input placeholder="请输入关键字标题" v-model="easySearch.keys.value" /> :batch="true"
</FormItem> :items="list"
<FormItem><Button type="primary" @click="search">查询</Button> :level="8"
</FormItem> :drag="true"
</Form> :exportTitle="exportTl"
</template> @on-selection-change="batchChange"
<!-- <template slot="searchForm"> >
<template slot="easySearch">
<Form ref="formInline" :model="easySearch" inline>
<FormItem prop="keys"
><Input
placeholder="请输入关键字标题"
v-model="easySearch.keys.value"
/>
</FormItem>
<FormItem
><Button type="primary" @click="search">查询</Button>
</FormItem>
</Form>
</template>
<!-- <template slot="searchForm">
<Search /> <Search />
</template> --> </template> -->
<template slot="buttons"> <template slot="buttons">
<Button type="primary" @click="add(null)">新增</Button> <Button type="primary" @click="add(null)">新增</Button>
<Button @mouseenter.native="showBm" ref="showBtn" shape="circle" icon="md-settings"></Button> <Button
<Dropdown @on-click="show" v-if="false"> @mouseenter.native="showBm"
<Button shape="circle" icon="md-settings"></Button> ref="showBtn"
<DropdownMenu slot="list"> shape="circle"
<DropdownItem name="saveTemplate">存为模版</DropdownItem> icon="md-settings"
<DropdownItem name="useTemplate">导入模版</DropdownItem> ></Button>
<DropdownItem name="down"> <Dropdown @on-click="show" v-if="false">
<Icon type="md-cloud-download" class="mr10" />导出Excel <Button shape="circle" icon="md-settings"></Button>
</DropdownItem> <DropdownMenu slot="list">
<DropdownItem name="importExcel" disabled> <DropdownItem name="saveTemplate">存为模版</DropdownItem>
<Icon type="md-cloud-upload" class="mr10" />导入Excel <DropdownItem name="useTemplate">导入模版</DropdownItem>
</DropdownItem> <DropdownItem name="down">
</DropdownMenu> <Icon type="md-cloud-download" class="mr10" />导出Excel
</Dropdown> </DropdownItem>
</template> <DropdownItem name="importExcel" disabled>
<template slot="batch"> <Icon type="md-cloud-upload" class="mr10" />导入Excel
<Button type="primary" @click="bacthRemove()">批量删除</Button> </DropdownItem>
</template> </DropdownMenu>
</EditGrid> </Dropdown>
</template>
<template slot="batch">
<span v-width="300" style="color:#333">
<DateRange v-model="dateEntity" edit v-width="260"></DateRange>
<Button type="primary">设置2计划日期</Button>
</span>
<span>
<UserGroup
v-model="executors"
multiple
:projectId="eid"
v-width="300"
></UserGroup>
<Button type="primary">设置执行人</Button>
</span>
<Button type="primary" @click="bacthRemove()">批量删除</Button>
</template>
</EditGrid>
</Card> </Card>
<Submenus :show="showStatu" :data="tempItems" :params="params"></Submenus> <Submenus :show="showStatu" :data="tempItems" :params="params"></Submenus>
<Modal v-model="modal" :title="title" width="1200" footer-hide> <Modal v-model="modal" :title="title" width="1200" footer-hide>
<component :is="detail" :eid="curId" :v="row" @on-close="cancel" @on-ok="ok" /> <component
:is="detail"
:eid="curId"
:v="row"
@on-close="cancel"
@on-ok="ok"
/>
</Modal> </Modal>
<ImportExcel ref="importExcel" @on-get-data="getData" :modalTitle="temTitle" :columns="columns" :open="ModalIm" @on-cancel="ModalImCancel" @on-ok="ok" /> <ImportExcel
</div> ref="importExcel"
@on-get-data="getData"
:modalTitle="temTitle"
:columns="columns"
:open="ModalIm"
@on-cancel="ModalImCancel"
@on-ok="ok"
/>
</div>
</template> </template>
<script> <script>
import Api from "./api"; import Api from "./api";
import Search from "./search"; import Search from "./search";
export default { export default {
name: "list", name: "list",
components: { components: {
Search, Search,
},
head: {
title: "项目计划",
author: "henq",
description: "project_plan 10/19/2020 10:23:07 AM",
},
props: {
eid: {
type: String,
}, },
head: { data: {
title: "项目计划", type: Object,
author: "henq", default: () => {
description: "project_plan 10/19/2020 10:23:07 AM",
},
props: {
eid: {
type: String,
},
data: {
type: Object,
default: () => {
return {
id: "33930562-a9f7-bd95-88ab-d01eb1c4c369",
title: "示例项目",
};
},
},
},
data() {
return { return {
entity: {}, id: "33930562-a9f7-bd95-88ab-d01eb1c4c369",
batchItems:[], title: "示例项目",
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: "项目目录",
}; };
},
}, },
mounted() { },
this.search(); data() {
}, return {
async fetch({ entity: {},
store, executors: [],
params dateEntity: {
}) { startDate: null,
await store.dispatch("loadDictionary"); // 加载数据字典 endDate: null,
}, },
methods: { batchItems: [],
ok() { row: {},
this.search(); action: Api.index,
this.modal = false; easySearch: {
this.curId = null; keys: {
op: "title",
value: null,
}, },
search() { },
// this.$refs.grid.reload(this.easySearch); modal: false,
var params = { title: "新增",
conditions: [{ detail: null,
fieldName: "projectId", curId: null,
conditionalType: "Equal", list: [],
fieldValue: this.eid, rootList: [],
}, ], columns: [
// conditions: [] {
}; key: "drag",
Api.list(params).then((r) => { type: "drag",
let res = r.result; width: 50,
this.rootList = this.$u.clone(r.result) align: "center",
var data = this.$u.toTree( title: "移动",
res,
null,
(u) => {
// console.log(u);
u.expanded = true;
u.selected = false;
u.checked = false;
},
"upId"
);
this.list = data;
});
}, },
add(row) { {
if (row) { key: "upId",
this.curId = row.id; width: 50,
this.row = row; type: "selection",
} else { align: "center",
this.curId = null; title: "选择",
this.row = {
projectId: this.data.id,
};
}
this.title = "新增";
this.detail = () => import("./add");
this.modal = true;
}, },
send(row) { {
console.log(row); key: "upTitle",
if (!row.startDate) { title: this.l("upTitle"),
this.$Message.error("未设置开始时间"); hide: true,
return; export: true,
}
if (!row.endDate) {
this.$Message.error("未设置结束时间");
return;
}
if (row.executor.length == 0) {
this.$Message.error("请设置执行人");
return;
}
delete row.chlidren;
delete row.parent;
console.warn(row);
row.status = 1;
Api.sendtask({
id: row.id,
status: 1,
}).then((r) => {
if (r.success) {
this.$Message.info("任务派发成功!");
this.search();
}
});
}, },
copy(id) { {
this.curId = id; key: "title",
this.title = "克隆"; title: this.l("title"),
this.detail = () => import("./add"); align: "left",
this.modal = true; tree: true,
easy: true,
high: true,
export: true,
}, },
view(id) { {
this.curId = id; key: "type",
this.title = "详情"; width: 90,
this.detail = () => import("./detail"); title: this.l("type"),
this.modal = true; align: "center",
high: true,
code: "mes.project_plan.Type",
attr: {
type: "icon",
},
export: true,
}, },
edit(row) { {
this.curId = row.id; key: "direction",
this.row = row; title: this.l("direction"),
this.title = "编辑"; align: "center",
this.detail = () => import("./edit"); code: "mes.project_plan.direction",
this.modal = true; width: 80,
easy: true,
high: true,
export: true,
}, },
remove(id) { {
Api.delete(id).then((r) => { key: "status",
if (r.success) { title: this.l("status"),
this.search(); align: "center",
this.$Message.success("删除成功"); width: 80,
} high: true,
}); code: "mes.project_plan.Status",
export: true,
}, },
cancel() { {
this.curId = null; key: "startDate",
this.modal = false; title: "计划开始日期",
hide: true,
export: true,
}, },
show(name) { {
var that = this; key: "endDate",
var m = { title: "计划结束日期",
saveTemplate(name) { hide: true,
that.curId = that.eid; export: true,
that.row = that.data;
that.title = "保存模版";
that.detail = () => import("./saveTemplate");
that.modal = true;
},
useTemplate(name) {
that.curId = that.eid;
that.row = that.data;
that.title = "导入模版";
that.detail = () => import("./importTemplate");
that.modal = true;
},
}
//导出excel
if (name == 'down') {
this.exportTl = '项目目录-' + this.data.title;
// this.$refs.grid.export2Excel()
this.$u.export2excel(this.exportTl, this.columns, this.list)
}
if (name == 'importExcel') {
this.openModalIm()
}
m[name] && m[name](name);
}, },
saveTemplate() { {
var that = this; key: "dateRange",
that.curId = that.eid; width: 250,
that.row = that.data; title: "计划日期",
that.title = "保存模版"; align: "center",
that.detail = () => import("./saveTemplate"); render(h, param) {
that.modal = true; return h("DateRange", {
attrs: {
value: param.row,
},
});
},
}, },
useTemplate() { {
var that = this; key: "executor",
that.curId = that.eid; title: this.l("executor"),
that.row = that.data; align: "left",
that.title = "导入模版"; high: true,
that.detail = () => import("./importTemplate"); type: "users",
that.modal = true; export: true,
}, },
down() { {
this.exportTl = '项目目录-' + this.data.title; key: "deliverable",
this.$u.export2excel(this.exportTl, this.columns, this.rootList, this.$store) title: this.l("deliverable"),
//this.$refs.grid.export2Excel() code: "mes.project_plan.deliverable",
width: 80,
align: "center",
easy: true,
high: true,
export: true,
}, },
importExcel() { {
this.openModalIm() title: "操作",
key: "action",
width: 150,
align: "center",
render: (h, params) => {
return h(
"div",
{
class: "action",
},
[
h("op", {
attrs: {
icon: "md-arrow-dropright-circle",
type: "icon",
title: "派发",
oprate: "edit",
disable: params.row.status != 0,
},
on: {
click: () => this.send(params.row),
},
}),
h("op", {
attrs: {
icon: "md-add",
type: "icon",
title: "新增子任务",
disable: params.row.status > 1,
oprate: "edit",
},
on: {
click: () => this.add(params.row),
},
}),
h("op", {
attrs: {
icon: "md-create",
type: "icon",
title: "编辑",
oprate: "edit",
disable: params.row.status !== 0,
},
on: {
click: () => this.edit(params.row),
},
}),
h("op", {
attrs: {
icon: "ios-trash",
type: "icon",
title: "删除",
oprate: "delete",
disable: params.row.status !== 0,
msg: "确认要删除吗?",
},
on: {
click: () => this.remove(params.row.id),
},
}),
]
);
},
}, },
showBm(event) { ],
let obj = event.target //setButon
let objSet = obj.getBoundingClientRect() showStatu: false, //控件是否显示
this.showStatu = true; tempItems: [], //控件数据
this.params = { params: {}, //控件坐标位置
x: objSet.x, //导出导入
y: objSet.bottom exportTl: "项目目录",
}; ModalIm: false,
console.log(event) temTitle: "项目目录",
this.tempItems = [{ };
label: "存为模版", },
onClick: () => { mounted() {
this.saveTemplate() this.search();
}, },
}, { async fetch({ store, params }) {
label: "导入模版", await store.dispatch("loadDictionary"); // 加载数据字典
divided: true, },
onClick: () => { methods: {
this.useTemplate() ok() {
}, this.search();
}, this.modal = false;
{ this.curId = null;
label: "导出Excel", },
icon: "md-cloud-download", search() {
onClick: () => { // this.$refs.grid.reload(this.easySearch);
this.down() var params = {
}, conditions: [
}, {
{ fieldName: "projectId",
label: "导入Excel", conditionalType: "Equal",
icon: "md-cloud-upload", fieldValue: this.eid,
onClick: () => { },
this.importExcel() ],
}, // conditions: []
} };
]; Api.list(params).then((r) => {
let res = r.result;
this.rootList = this.$u.clone(r.result);
var data = this.$u.toTree(
res,
null,
(u) => {
// console.log(u);
u.expanded = true;
u.selected = false;
u.checked = false;
},
"upId"
);
this.list = data;
});
},
add(row) {
if (row) {
this.curId = row.id;
this.row = row;
} else {
this.curId = null;
this.row = {
projectId: this.data.id,
};
}
this.title = "新增";
this.detail = () => import("./add");
this.modal = true;
},
send(row) {
console.log(row);
if (!row.startDate) {
this.$Message.error("未设置开始时间");
return;
}
if (!row.endDate) {
this.$Message.error("未设置结束时间");
return;
}
if (row.executor.length == 0) {
this.$Message.error("请设置执行人");
return;
}
delete row.chlidren;
delete row.parent;
console.warn(row);
row.status = 1;
Api.sendtask({
id: row.id,
status: 1,
}).then((r) => {
if (r.success) {
this.$Message.info("任务派发成功!");
this.search();
}
});
},
copy(id) {
this.curId = id;
this.title = "克隆";
this.detail = () => import("./add");
this.modal = true;
},
view(id) {
this.curId = id;
this.title = "详情";
this.detail = () => import("./detail");
this.modal = true;
},
edit(row) {
this.curId = row.id;
this.row = row;
this.title = "编辑";
this.detail = () => import("./edit");
this.modal = true;
},
remove(id) {
Api.delete(id).then((r) => {
if (r.success) {
this.search();
this.$Message.success("删除成功");
}
});
},
cancel() {
this.curId = null;
this.modal = false;
},
show(name) {
var that = this;
var m = {
saveTemplate(name) {
that.curId = that.eid;
that.row = that.data;
that.title = "保存模版";
that.detail = () => import("./saveTemplate");
that.modal = true;
}, },
batchChange(items,list){ useTemplate(name) {
this.batchItems=items; that.curId = that.eid;
that.row = that.data;
that.title = "导入模版";
that.detail = () => import("./importTemplate");
that.modal = true;
}, },
bacthRemove(){ };
var ids=this.batchItems.map(u=>{ //导出excel
return u.id; if (name == "down") {
}) this.exportTl = "项目目录-" + this.data.title;
if(ids.length>0){ // this.$refs.grid.export2Excel()
Api.batch(ids).then(r=>{ this.$u.export2excel(this.exportTl, this.columns, this.list);
if(r.success){ }
this.search(); 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 {
//导入功能 label: "导入模版",
openModalIm() { divided: true,
this.ModalIm = true onClick: () => {
this.useTemplate();
},
}, },
ModalImCancel() { {
this.ModalIm = false label: "导出Excel",
icon: "md-cloud-download",
onClick: () => {
this.down();
},
}, },
getData(val) { {
let url = `${material}/projectplan/importplans`; label: "导入Excel",
this.$refs.importExcel.deelData(url, this.columns, this.formatMethod(val)) icon: "md-cloud-upload",
onClick: () => {
this.importExcel();
},
}, },
//根据页面二次处理数据 ];
formatMethod(val) { },
let tempData = this.$u.clone(val); batchChange(items, list) {
let tempList = []; this.batchItems = items;
tempData.forEach((ele) => { },
let obj = { bacthRemove() {
projectId: this.eid, var ids = this.batchItems.map((u) => {
upTitle: ele.upTitle ? ele.upTitle : null, return u.id;
title: ele.title ? ele.title : '', });
status: 0, if (ids.length > 0) {
type: ele.type ? ele.type : 0, //? this.$Modal.confirm({
startDate: ele.startDate ? ele.startDate : "", //? title: "确认",
endDate: ele.endDate ? ele.endDate : "", //? content: "确认删除?",
direction: ele.direction ? ele.direction : 0, onOk: () => {
executor: ele.executor ? ele.executor : [], //? Api.batch(ids).then((r) => {
deliverable: ele.deliverable ? ele.deliverable : 0 if (r.success) {
this.search();
}; this.$Message.success("删除成功!");
if (ele.title && ele.title != '') { } else {
obj.ico = false this.$Message.error("出现异常");
} else { }
obj.ico = true
}
tempList.push(obj);
}); });
return tempList },
}, });
//批量导入end }
l(key) { },
let vkey = "project_plan" + "." + key; //批量导入start
return this.$t(vkey) || key; //导入功能
}, openModalIm() {
this.ModalIm = true;
},
ModalImCancel() {
this.ModalIm = false;
},
getData(val) {
let url = `${material}/projectplan/importplans`;
this.$refs.importExcel.deelData(
url,
this.columns,
this.formatMethod(val)
);
},
//根据页面二次处理数据
formatMethod(val) {
let tempData = this.$u.clone(val);
let tempList = [];
tempData.forEach((ele) => {
let obj = {
projectId: this.eid,
upTitle: ele.upTitle ? ele.upTitle : null,
title: ele.title ? ele.title : "",
status: 0,
type: ele.type ? ele.type : 0, //?
startDate: ele.startDate ? ele.startDate : "", //?
endDate: ele.endDate ? ele.endDate : "", //?
direction: ele.direction ? ele.direction : 0,
executor: ele.executor ? ele.executor : [], //?
deliverable: ele.deliverable ? ele.deliverable : 0,
};
if (ele.title && ele.title != "") {
obj.ico = false;
} else {
obj.ico = true;
}
tempList.push(obj);
});
return tempList;
},
//批量导入end
l(key) {
let vkey = "project_plan" + "." + key;
return this.$t(vkey) || key;
}, },
},
}; };
</script> </script>
......
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