Commit d5cdcd17 authored by renjintao's avatar renjintao

Merge branch 'master' of git.mes123.com:zhouyx/mes-ui into product-rjt

parents fb26967f 65efb352
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
<span v-else v-text="placeholder"> </span> <span v-else v-text="placeholder"> </span>
</div> </div>
</DatePicker> </DatePicker>
<div class="time-view" v-else-if="!edit && startDate && endDate"> <div class="time-view" v-else-if="!edit &&( startDate || endDate)">
<span>{{ startDate }}</span> <span>{{ startDate }}</span>
<span class="jian-tou">{{ jg }} {{ unit }}</span> <span class="jian-tou">{{ jg }} {{ unit }}</span>
<span>{{ endDate }}</span> <span>{{ endDate }}</span>
......
...@@ -85,7 +85,13 @@ export default { ...@@ -85,7 +85,13 @@ export default {
}, },
listSlecet() { listSlecet() {
let data = { let data = {
conditions: [], conditions: [
{
fieldName: "userId",
fieldValue: this.$store.state.userInfo.id,
conditionalType: "Equal",
},
],
sortBy: "id", sortBy: "id",
isDesc: false, isDesc: false,
}; };
...@@ -93,15 +99,14 @@ export default { ...@@ -93,15 +99,14 @@ export default {
if (r.result) { if (r.result) {
this.projectList = r.result; this.projectList = r.result;
if (this.curId) { if (this.curId) {
this.projectList.map(u=>{ this.projectList.map((u) => {
if(u.id==this.curId){ if (u.id == this.curId) {
this.downName = u.title; this.downName = u.title;
} }
}) });
} else { } else {
this.downName = this.projectList[0].title; this.downName = this.projectList[0].title;
this.curdId = this.projectList[0].id; this.curdId = this.projectList[0].id;
} }
this.loadTree(this.curId); this.loadTree(this.curId);
} }
...@@ -115,6 +120,11 @@ export default { ...@@ -115,6 +120,11 @@ export default {
fieldValue: this.curdId, fieldValue: this.curdId,
conditionalType: "Equal", conditionalType: "Equal",
}, },
{
fieldName: "userId",
fieldValue: this.$store.state.userInfo.id,
conditionalType: "Equal",
},
], ],
}; };
this.$api.post(`${material}/projectplan/list`, params).then((r) => { this.$api.post(`${material}/projectplan/list`, params).then((r) => {
......
...@@ -122,7 +122,7 @@ export default { ...@@ -122,7 +122,7 @@ export default {
{ {
id: 4, id: 4,
label: "计划开始时间", label: "计划开始时间",
// value: 'startDate', value: 'startDate',
value: (task) => dayjs(task.startDate).format("YYYY-MM-DD"), value: (task) => dayjs(task.startDate).format("YYYY-MM-DD"),
width: 160, width: 160,
}, },
......
...@@ -22,11 +22,11 @@ ...@@ -22,11 +22,11 @@
<Filed :span="24" :name="l('userIds')"> <Filed :span="24" :name="l('userIds')">
<User v-for="(li,i) in entity.userIds" :value="li" :key="i" class="ml10" /> <User v-for="(li,i) in entity.userIds" :value="li" :key="i" class="ml10" />
</Filed> </Filed>
<Filed :span="12" :name="l('startDate')"> <Filed :span="12" name="计划日期">
<DateRange :value="entity"></DateRange> <DateRange :value="entity"></DateRange>
</Filed> </Filed>
<Filed :span="12" :name="l('plansToStartDate')"> <Filed :span="12" name="执行日期">
<DateRange :value="entity" start="plansToStartDate" end="plansToEndTime"></DateRange> <DateRange :value="entity" start="runStartDate" end="runEndTime"></DateRange>
</Filed> </Filed>
<Filed :span="24" :name="l('note')"> <Filed :span="24" :name="l('note')">
<div v-html="entity.note"></div> <div v-html="entity.note"></div>
...@@ -173,6 +173,13 @@ export default { ...@@ -173,6 +173,13 @@ export default {
id: this.eid, id: this.eid,
status: this.status, status: this.status,
}; };
if(this.status==1){
params.runStartDate="";
}else if(this.status==2){
params.runEndDate="";
}else if(this.status==3){
params.runEndDate="";
}
Api.updatepart(params).then((r) => { Api.updatepart(params).then((r) => {
if (r.success) { if (r.success) {
this.$Message.success("任务状态汇报成功"); this.$Message.success("任务状态汇报成功");
......
<template> <template>
<Layout class="full"> <Layout class="full">
<Sider hide-trigger v-if="showMenu" class="menu_side" width="300"> <Sider hide-trigger v-if="showMenu" class="menu_side" width="300">
<ProjectTaskTree :curId="projectId" @on-hide="onHide" @on-select="productSearch" /> <ProjectTaskTree
:curId="projectId"
@on-hide="onHide"
@on-select="productSearch"
/>
</Sider> </Sider>
<div v-if="!showMenu" class="show_menu"> <div v-if="!showMenu" class="show_menu">
<a class="menu_play fr" @click="showMenuFn" title="展开"> <a class="menu_play fr" @click="showMenuFn" title="展开">
<Icon type="ios-arrow-forward" size="24" /> <Icon type="ios-arrow-forward" size="24" />
</a> </a>
</div> </div>
<Content class="content" :class="!showMenu?'con_bord':''"> <Content class="content" :class="!showMenu ? 'con_bord' : ''">
<DataGrid :columns="columns" ref="grid" :action="action" :conditions="easySearch" :lazy="true"> <DataGrid
<template slot="easySearch"> :columns="columns"
<Form ref="formInline" inline> ref="grid"
<FormItem> :action="action"
<div class="taskMenu"> :conditions="easySearch"
<Menu mode="horizontal" active-name="1" @on-select="onSelect"> :lazy="true"
<MenuItem name="1"> >
所有 <template slot="easySearch">
</MenuItem> <Form ref="formInline" inline>
<MenuItem name="2"> <FormItem>
待确认 <div class="taskMenu">
</MenuItem> <Menu mode="horizontal" active-name="-1" @on-select="onSelect">
<MenuItem name="3"> <MenuItem name="-1"> 所有 </MenuItem>
工作中 <MenuItem name="0"> 待确认 </MenuItem>
</MenuItem> <MenuItem name="1"> 工作中 </MenuItem>
<MenuItem name="4"> <MenuItem name="2"> 已完成 </MenuItem>
已完成 <MenuItem name="3"> 已冻结 </MenuItem>
</MenuItem> <!--
<MenuItem name="5">
已冻结
</MenuItem>
<!--
<Submenu name="6"> <Submenu name="6">
<template slot="title"> <template slot="title">
更多 更多
...@@ -42,500 +42,566 @@ ...@@ -42,500 +42,566 @@
</MenuGroup> </MenuGroup>
</Submenu> </Submenu>
--> -->
</Menu> </Menu>
</div> </div>
</FormItem> </FormItem>
<FormItem prop="keys"><Input placeholder="请输入项目标题/计划名称/任务标题" v-model="easySearch.keys.value" v-width="240" /> </FormItem> <FormItem prop="keys"
<FormItem><Button type="primary" @click="search">查询</Button></FormItem> ><Input
<!-- placeholder="请输入项目标题/计划名称/任务标题"
v-model="easySearch.keys.value"
v-width="240"
/>
</FormItem>
<FormItem
><Button type="primary" @click="search">查询</Button></FormItem
>
<!--
<FormItem> <FormItem>
<Button @click="highSearch" type="text"> <Button @click="highSearch" type="text">
<Icon type="md-search" />高级 <Icon type="md-search" />高级
</Button> </Button>
</FormItem> </FormItem>
--> -->
</Form> </Form>
</template> </template>
<template slot="buttons"> <template slot="buttons">
<Button type="primary" @click="add" v-if="planId!=''">新增</Button> <Button type="primary" @click="add" v-if="planId != ''">新增</Button>
</template> </template>
</DataGrid> </DataGrid>
<Modal v-model="modal" :title="title" width="1200" :fullscreen="fullScreen" footer-hide> <Modal
<component :is="detail" :eid="curId" :pid="planId" :projectId="projectId" :row="rowObj" @on-close="cancel" @on-ok="ok" /> v-model="modal"
</Modal> :title="title"
width="1200"
:fullscreen="fullScreen"
footer-hide
>
<component
:is="detail"
:eid="curId"
:pid="planId"
:projectId="projectId"
:row="rowObj"
@on-close="cancel"
@on-ok="ok"
/>
</Modal>
</Content> </Content>
</Layout> </Layout>
</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: { head: {
title: "", title: "",
author: "henq", author: "henq",
description: "project_task 10/20/2020 9:27:58 AM", description: "project_task 10/20/2020 9:27:58 AM",
}, },
data() { data() {
return { return {
action: Api.index, action: Api.index,
showMenu: true, showMenu: true,
easySearch: { easySearch: {
keys: { keys: {
op: "title", op: "title",
value: null value: null,
},
projectId: {
op: "Equal",
value: ''
},
planId: {
op: "In",
value: []
},
status: {
op: "In",
value: []
}
},
theme1: 'light',
modal: false,
title: "新增",
detail: null,
rowObj: null,
curId: '',
fullScreen: false,
projectId: this.eid,
columns: [
// {
// key: "selection",
// type: "selection",
// width: 50,
// align: "center"
// },
{
key: "id",
title: this.$t("id"),
align: "left",
high: true,
hide: true,
},
{
key: "title",
title: this.l("title"),
align: "left",
easy: true,
high: true,
render: (h, params) => {
return h('a', {
attrs: {
oprate: 'detail'
},
on: {
click: () => this.viewRecord(params.row.id, params.row.status)
}
}, params.row.title)
}
},
{
key: "level",
title: this.l("level"),
align: "center",
high: true,
width: 80,
code: 'project.task.level'
},
{
key: "status",
title: this.l("status"),
align: "center",
high: true,
width: 100,
code: 'project.task.status'
},
{
key: "userId",
title: this.l("userId"),
align: "left",
high: true,
type: 'user'
},
{
key: "startDate",
title: '计划日期',
align: "center",
high: true,
width: 280,
render: (h, params) => {
return h('DateRange', {
props: {
value: params.row,
start: 'plansToStartDate',
end: 'plansToEndTime',
}
})
}
},
{
key: "startDate",
title: '执行日期',
align: "center",
high: true,
width: 280,
render: (h, params) => {
return h('DateRange', {
props: {
value: params.row,
start: "runStartDate",
end: "runEndDate",
}
})
}
},
{
key: "workHour",
title: this.l("workHour"),
align: "right",
high: true,
width: 80,
render: (h, params) => {
return h('a', {
attrs: {
oprate: 'detail'
},
on: {
click: () => this.viewWork(params.row.id)
}
}, params.row.workHour)
}
},
{
key: "note",
title: this.l("note"),
align: "left",
high: true,
hide: true
},
{
key: "creatorUserId",
title: this.l("creatorUserId"),
align: "left",
high: true,
type: 'user'
},
{
key: "creationTime",
title: this.l("creationTime"),
align: "center",
high: true,
width: 150,
},
{
title: '操作',
key: 'action',
width: 200,
align: 'center',
render: (h, params) => {
return h('div', {
class: "action"
}, [
h('op', {
attrs: {
icon: "md-arrow-dropright-circle",
type: "icon",
oprate: "edit",
title: "开始",
disable: params.row.status == 0 ? false : true
},
on: {
click: () => this.updatepart(params.row.id, 1)
}
}),
h('op', {
attrs: {
icon: "ios-alarm",
type: "icon",
oprate: "edit",
title: "汇报工作",
disable: params.row.status == 1 || params.row.status == 3 ? false : true
},
on: {
click: () => this.viewRecord(params.row.id, params.row.status)
}
}),
h('op', {
attrs: {
icon: "md-add",
type: "icon",
oprate: "add",
title: "新增记录",
disable: params.row.status == 1 ? false : true
},
on: {
click: () => this.addRecord(params.row)
}
}),
h('op', {
attrs: {
icon: "md-create",
type: "icon",
oprate: "edit",
title: "修改",
disable: params.row.status == 0 ? false : true
},
on: {
click: () => this.edit(params.row.id)
}
}),
h('op', {
attrs: {
icon: "md-trash",
type: "icon",
title: "删除",
oprate: 'delete',
disable: params.row.status == 0 ? false : true
},
on: {
click: () => this.remove(params.row.id)
}
})
])
}
},
],
data1: [{
id: 1,
title: '测试title'
}],
data: [],
planId: '', //当前计划Id
planIdsCur: []
}
},
props: {
eid: String
},
async fetch({
store,
params
}) {
await store.dispatch('loadDictionary') // 加载数据字典
},
created() {
if (this.eid != '') {
this.projectId = this.eid
this.easySearch.projectId.value = this.eid
}
this.treeHeight = window.innerHeight - 150;
},
mounted() {
if (this.eid != "") {
this.easySearch.projectId.value = this.eid
this.$refs.grid.reload(this.easySearch);
}
},
methods: {
ok() {
this.$refs.grid.load()
this.modal = false
this.curId = '';
}, },
search() { projectId: {
this.easySearch.planId.value = this.planIdsCur op: "Equal",
this.$refs.grid.reload(this.easySearch) value: "",
}, },
add() { planId: {
this.curId = this.projectId; op: "In",
this.title = "新增"; value: [],
this.fullScreen = false;
this.detail = () => import('./add')
this.modal = true;
}, },
highSearch() { status: {
this.curId = 0; op: "In",
this.title = "高级搜索"; value: [],
this.fullScreen = false;
this.detail = () => import('./search')
this.modal = true;
}, },
copy(id) { userId: {
this.curId = id; op: "Equal",
this.title = "克隆"; value: this.$store.state.userInfo.id,
this.fullScreen = false;
this.detail = () => import('./add')
this.modal = true;
}, },
view(id) { },
this.curId = id; theme1: "light",
this.title = "详情"; modal: false,
this.fullScreen = false; title: "新增",
this.detail = () => import('./detail') detail: null,
this.modal = true; rowObj: null,
curId: "",
fullScreen: false,
projectId: this.eid,
columns: [
// {
// key: "selection",
// type: "selection",
// width: 50,
// align: "center"
// },
{
key: "id",
title: this.$t("id"),
align: "left",
high: true,
hide: true,
}, },
edit(id) { {
this.curId = id; key: "title",
this.title = "编辑"; title: this.l("title"),
this.fullScreen = false; align: "left",
this.detail = () => import('./edit') easy: true,
this.modal = true; high: true,
render: (h, params) => {
return h(
"a",
{
attrs: {
oprate: "detail",
},
on: {
click: () =>
this.viewRecord(params.row.id, params.row.status),
},
},
params.row.title
);
},
}, },
remove(id) { {
Api.delete(id).then((r) => { key: "level",
if (r.success) { title: this.l("level"),
this.$refs.grid.load(); align: "center",
this.$Message.success('删除成功') high: true,
} width: 80,
}) code: "project.task.level",
}, },
cancel() { {
this.curId = ''; key: "status",
this.modal = false title: this.l("status"),
align: "center",
high: true,
width: 100,
code: "project.task.status",
},
{
key: "userId",
title: this.l("userId"),
align: "left",
high: true,
type: "user",
}, },
onHide() { {
// this.$Message.info("收起左侧树") key: "startDate",
this.showMenu = false; title: "计划日期",
align: "center",
high: true,
width: 280,
render: (h, params) => {
return h("DateRange", {
props: {
value: params.row
},
});
},
}, },
showMenuFn() { {
//this.$Message.info("展开左侧树") key: "runStartDate",
this.showMenu = true; title: "执行日期",
align: "center",
high: true,
width: 280,
render: (h, params) => {
return h("DateRange", {
props: {
value: params.row,
start: "runStartDate",
end: "runEndDate",
},
});
},
}, },
productSearch(id, item, planIds) { {
this.planId = item.selected ? id : ''; key: "workHour",
this.projectId=item.projectId; title: this.l("workHour"),
this.planIdsCur = item.selected ? planIds : [] align: "right",
let where = { high: true,
planId: { width: 80,
op: "In", render: (h, params) => {
value: item.selected ? planIds : [] return h(
"a",
{
attrs: {
oprate: "detail",
}, },
projectId: { on: {
op: "Equal", click: () => this.viewWork(params.row.id),
value: item.projectId
}, },
}; },
this.curId= params.row.workHour
this.$refs.grid.reload(where); );
},
}, },
updatepart(valId, valStatus) { {
let params = { key: "note",
id: valId, title: this.l("note"),
status: valStatus align: "left",
} high: true,
if (valStatus == 1) { hide: true,
params.startDate = ''
}
if (valStatus == 2) {
params.endDate = ''
}
Api.updatepart(params).then(r => {
if (r.success) {
this.$refs.grid.load();
this.$Message.success('操作成功')
} else {
this.$Message.error('操作失败')
}
}).catch(err => {
this.disabled = false;
this.$Message.error('操作失败')
console.warn(err)
})
}, },
onSelect(val) { {
this.$refs.grid.reload(this.easySearch) key: "creatorUserId",
title: this.l("creatorUserId"),
align: "left",
high: true,
type: "user",
}, },
viewRecord(id, status) { {
this.curId = id; key: "creationTime",
this.tastkStatus = status; title: this.l("creationTime"),
this.title = "查看记录"; align: "center",
this.fullScreen = true; high: true,
this.detail = () => import('./detail') width: 150,
this.modal = true;
}, },
viewWork(id) { {
this.curId = id; title: "操作",
this.title = "查看工时"; key: "action",
this.fullScreen = false; width: 200,
this.detail = () => import('../record') align: "center",
this.modal = true; render: (h, params) => {
return h(
"div",
{
class: "action",
},
[
h("op", {
attrs: {
icon: "md-arrow-dropright-circle",
type: "icon",
oprate: "edit",
title: "开始",
disable: params.row.status == 0 ? false : true,
},
on: {
click: () => this.updatepart(params.row.id, 1),
},
}),
h("op", {
attrs: {
icon: "ios-alarm",
type: "icon",
oprate: "edit",
title: "汇报工作",
disable:
params.row.status == 1 || params.row.status == 3
? false
: true,
},
on: {
click: () =>
this.viewRecord(params.row.id, params.row.status),
},
}),
h("op", {
attrs: {
icon: "md-add",
type: "icon",
oprate: "add",
title: "新增记录",
disable: params.row.status == 1 ? false : true,
},
on: {
click: () => this.addRecord(params.row),
},
}),
h("op", {
attrs: {
icon: "md-create",
type: "icon",
oprate: "edit",
title: "修改",
disable: params.row.status == 0 ? false : true,
},
on: {
click: () => this.edit(params.row.id),
},
}),
h("op", {
attrs: {
icon: "md-trash",
type: "icon",
title: "删除",
oprate: "delete",
disable: params.row.status == 0 ? false : true,
},
on: {
click: () => this.remove(params.row.id),
},
}),
]
);
},
}, },
addRecord(row) { ],
this.curId = row.id; data1: [
this.rowObj = row {
this.title = "新增记录"; id: 1,
this.fullScreen = false; title: "测试title",
this.detail = () => import('../record/add')
this.modal = true;
}, },
l(key) { ],
let vkey = "project_task" + "." + key; data: [],
return this.$t(vkey) || key planId: "", //当前计划Id
} planIdsCur: [],
};
},
props: {
eid: String,
},
async fetch({ store, params }) {
await store.dispatch("loadDictionary"); // 加载数据字典
},
created() {
if (this.eid != "") {
this.projectId = this.eid;
this.easySearch.projectId.value = this.eid;
}
this.treeHeight = window.innerHeight - 150;
},
mounted() {
if (this.eid != "") {
this.easySearch.projectId.value = this.eid;
this.$refs.grid.reload(this.easySearch);
}
},
methods: {
ok() {
this.$refs.grid.load();
this.modal = false;
this.curId = "";
},
search() {
this.easySearch.planId.value = this.planIdsCur;
this.$refs.grid.reload(this.easySearch);
},
add() {
this.curId = this.projectId;
this.title = "新增";
this.fullScreen = false;
this.detail = () => import("./add");
this.modal = true;
},
highSearch() {
this.curId = 0;
this.title = "高级搜索";
this.fullScreen = false;
this.detail = () => import("./search");
this.modal = true;
},
copy(id) {
this.curId = id;
this.title = "克隆";
this.fullScreen = false;
this.detail = () => import("./add");
this.modal = true;
},
view(id) {
this.curId = id;
this.title = "详情";
this.fullScreen = false;
this.detail = () => import("./detail");
this.modal = true;
},
edit(id) {
this.curId = id;
this.title = "编辑";
this.fullScreen = false;
this.detail = () => import("./edit");
this.modal = true;
}, },
watch: { remove(id) {
eid(v) { Api.delete(id).then((r) => {
if (v != "") { if (r.success) {
this.eid = v this.$refs.grid.load();
} this.$Message.success("删除成功");
} }
} });
} },
cancel() {
this.curId = "";
this.modal = false;
},
onHide() {
// this.$Message.info("收起左侧树")
this.showMenu = false;
},
showMenuFn() {
//this.$Message.info("展开左侧树")
this.showMenu = true;
},
productSearch(id, item, planIds) {
this.planId = item.selected ? id : "";
this.projectId = item.projectId;
this.planIdsCur = item.selected ? planIds : [];
let where = {
planId: {
op: "In",
value: item.selected ? planIds : [],
},
projectId: {
op: "Equal",
value: item.projectId,
},
};
this.curId = this.$refs.grid.reload(where);
},
updatepart(valId, valStatus) {
let params = {
id: valId,
status: valStatus,
};
if (valStatus == 1) {
params.runStartDate = "";
}
if (valStatus == 2) {
params.runEndDate = "";
}
Api.updatepart(params)
.then((r) => {
if (r.success) {
this.$refs.grid.load();
this.$Message.success("操作成功");
} else {
this.$Message.error("操作失败");
}
})
.catch((err) => {
this.disabled = false;
this.$Message.error("操作失败");
console.warn(err);
});
},
onSelect(val) {
if (val == -1) {
this.easySearch = {
keys: {
op: "title",
value: null,
},
projectId: {
op: "Equal",
value: "",
},
planId: {
op: "In",
value: [],
},
status: {
op: "In",
value: [],
},
userId: {
op: "Equal",
value: this.$store.state.userInfo.id,
},
};
} else {
this.easySearch.status.value = [val];
}
this.$refs.grid.reload(this.easySearch);
},
viewRecord(id, status) {
this.curId = id;
this.tastkStatus = status;
this.title = "查看记录";
this.fullScreen = true;
this.detail = () => import("./detail");
this.modal = true;
},
viewWork(id) {
this.curId = id;
this.title = "查看工时";
this.fullScreen = false;
this.detail = () => import("../record");
this.modal = true;
},
addRecord(row) {
this.curId = row.id;
this.rowObj = row;
this.title = "新增记录";
this.fullScreen = false;
this.detail = () => import("../record/add");
this.modal = true;
},
l(key) {
let vkey = "project_task" + "." + key;
return this.$t(vkey) || key;
},
},
watch: {
eid(v) {
if (v != "") {
this.eid = v;
}
},
},
};
</script> </script>
<style lang="less"> <style lang="less">
.full { .full {
margin-top: 0; margin-top: 0;
.content { .content {
margin-top: 10px; margin-top: 10px;
.ivu-icon-ios-add:before { .ivu-icon-ios-add:before {
content: "\f341"; content: "\f341";
} }
.ivu-icon-ios-remove:before { .ivu-icon-ios-remove:before {
content: "\f33d"; content: "\f33d";
}
} }
}
} }
.taskTab .ivu-tabs-bar { .taskTab .ivu-tabs-bar {
border-bottom: 1px solid #fff; border-bottom: 1px solid #fff;
margin-bottom: 2px; margin-bottom: 2px;
} }
.taskMenu { .taskMenu {
font-size: 12px; font-size: 12px;
.ivu-menu-horizontal { .ivu-menu-horizontal {
height: 30px; height: 30px;
line-height: 30px; line-height: 30px;
} }
.ivu-menu-light { .ivu-menu-light {
&:after { &:after {
height: 0px !important; height: 0px !important;
}
} }
}
} }
.actionCur { .actionCur {
a { a {
span { span {
padding: 4px; padding: 4px;
} }
i { i {
padding: 4px; padding: 4px;
border-radius: 3px; border-radius: 3px;
font-weight: bold; font-weight: bold;
font-size: 18px; font-size: 18px;
}
} }
}
} }
</style> </style>
...@@ -3,7 +3,7 @@ import Api from '@/plugins/request' ...@@ -3,7 +3,7 @@ import Api from '@/plugins/request'
// import Mock from 'mockjs' // import Mock from 'mockjs'
export const state = () => ({ export const state = () => ({
counter: 0, counter: 0,
dictionary: new Map(), //所有字典项 dictionary: [], //所有字典项
userMap: new Map(), //所有用户缓存; userMap: new Map(), //所有用户缓存;
userNameMap: new Map(), //所有用户名称缓存; userNameMap: new Map(), //所有用户名称缓存;
departmentsMap: new Map(), //部门缓存; departmentsMap: new Map(), //部门缓存;
...@@ -25,10 +25,11 @@ export const getters = { ...@@ -25,10 +25,11 @@ export const getters = {
dictionaryByKey: (state) => (key) => { dictionaryByKey: (state) => (key) => {
let result = []; let result = [];
if (state && state.dictionary) { if (state && state.dictionary) {
let items = state.dictionary.get(key); let items = state.dictionary.filter(u=>{
if (items) { return u.code===key
// console.info("items",items) });
return items; if (items.length>0) {
return items[0].items;
} }
} }
...@@ -36,12 +37,11 @@ export const getters = { ...@@ -36,12 +37,11 @@ export const getters = {
}, },
dictionaryByCode: (state) => (key, code) => { dictionaryByCode: (state) => (key, code) => {
let result = null; let result = null;
let items = state.dictionary.get(key); let items = state.dictionary.filter(u=>{
if (items) { return u.code===key
// console.info("items",items) });
return items.filter(u => { if (items.length>0) {
return u.code == code return items[0];
})[0];
} }
return result; return result;
}, },
...@@ -167,18 +167,12 @@ export const actions = { ...@@ -167,18 +167,12 @@ export const actions = {
async loadDictionary({ async loadDictionary({
commit commit
}) { }) {
let url = `${systemUrl}/Dictionary/GetAll` let url = `${systemUrl}/Dictionary/getallanditems`
let { let {
result result
} = await Api.get(url); } = await Api.get(url);
var map = new Map();
commit("setDictionary", result);
for (const key in result) {
if (result.hasOwnProperty(key)) {
map.set(key, result[key])
}
}
commit("setDictionary", map);
let r = await Api.get(`${systemUrl}/user/getuserlist`); let r = await Api.get(`${systemUrl}/user/getuserlist`);
var umap = new Map(); var umap = new Map();
......
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