Commit 7eed0ff4 authored by renjintao's avatar renjintao

store

parent dbe0e802
...@@ -13,12 +13,18 @@ ...@@ -13,12 +13,18 @@
</Col> </Col>
<Col :span="12"> <Col :span="12">
<FormItem :label="l('description')" prop="description"> <FormItem :label="l('description')" prop="description">
<Input v-model="entity.description" ></Input> <Input v-model="entity.description"></Input>
</FormItem> </FormItem>
</Col> </Col>
<Col :span="12"> <Col :span="12" v-if="user">
<FormItem :label="l('userName')" prop="userName"> <FormItem :label="l('userName')" prop="userName">
<Input v-model="entity.userName"></Input> <UserSelect
ref="userSelected"
:roleTitle="roleTitle"
v-model="entity.userIds"
:multiple="true"
@on-change="userChange"
/>
</FormItem> </FormItem>
</Col> </Col>
</Row> </Row>
...@@ -35,6 +41,7 @@ export default { ...@@ -35,6 +41,7 @@ export default {
data() { data() {
return { return {
disabled: false, disabled: false,
roleTitle: "库管员",
entity: { entity: {
creationTime: null, creationTime: null,
creatorUserId: null, creatorUserId: null,
...@@ -61,20 +68,37 @@ export default { ...@@ -61,20 +68,37 @@ export default {
props: { props: {
v: Object, v: Object,
eid: Number, eid: Number,
level:Number, level: Number,
upId:Number, upId: Number,
}, user: {
mounted() { type: Boolean,
if (this.eid > 0) { default: true
this.load(this.eid);
} }
}, },
mounted() {},
methods: { methods: {
handleSubmit() { handleSubmit() {
this.$refs.form.validate(v => { this.$refs.form.validate(v => {
if (v) { if (v) {
this.disabled = true; this.disabled = true;
Api.create(this.entity) let userNam = "";
let userId = "";
if (this.user) {
userId = this.entity.userIds.join(",");
userNam = this.$refs.userSelected.getSelectNames().join(",");
}
let paramsdata = {
id: this.entity.id,
upId: this.entity.upId,
title: this.entity.title, //库位名称
code: this.entity.code, //库位编号
description: this.entity.description, //位置
level: this.entity.level,
userName: userNam, //库管员
userIds: userId //库管员id
};
Api.create(paramsdata)
.then(r => { .then(r => {
this.disabled = false; this.disabled = false;
if (r.success) { if (r.success) {
...@@ -101,6 +125,7 @@ export default { ...@@ -101,6 +125,7 @@ export default {
this.entity.id = 0; this.entity.id = 0;
}); });
}, },
userChange(val) {},
l(key) { l(key) {
key = "store_room_location" + "." + key; key = "store_room_location" + "." + key;
return this.$t(key); return this.$t(key);
...@@ -110,10 +135,8 @@ export default { ...@@ -110,10 +135,8 @@ export default {
v() { v() {
this.entity = this.$u.clone(this.v); this.entity = this.$u.clone(this.v);
}, },
eid(v) { user(v) {
if (v > 0) { this.user = v;
this.load(v);
}
} }
} }
}; };
......
<template> <template>
<div class="detail"> <div class="detail">
<Row> <Row>
<Filed :span="12" :name="l('creationTime')">{{entity.creationTime}}</Filed>
<Filed :span="12" :name="l('creatorUserId')">{{entity.creatorUserId}}</Filed>
<Filed :span="12" :name="l('lastModificationTime')">{{entity.lastModificationTime}}</Filed>
<Filed :span="12" :name="l('lastModifierUserId')">{{entity.lastModifierUserId}}</Filed>
<Filed :span="12" :name="l('isDeleted')">{{entity.isDeleted}}</Filed>
<Filed :span="12" :name="l('deleterUserId')">{{entity.deleterUserId}}</Filed>
<Filed :span="12" :name="l('deletionTime')">{{entity.deletionTime}}</Filed>
<Filed :span="12" :name="l('upId')">{{entity.upId}}</Filed>
<Filed :span="12" :name="l('materialType')">{{entity.materialType}}</Filed>
<Filed :span="12" :name="l('title')">{{entity.title}}</Filed> <Filed :span="12" :name="l('title')">{{entity.title}}</Filed>
<Filed :span="12" :name="l('code')">{{entity.code}}</Filed> <Filed :span="12" :name="l('code')">{{entity.code}}</Filed>
<Filed :span="12" :name="l('status')">{{entity.status}}</Filed> <Filed :span="12" :name="l('description')">{{entity.description}}</Filed>
<Filed :span="24" :name="l('description')">{{entity.description}}</Filed> <Filed :span="12" :name="l('level')"><state code="store.level" :value="entity.level+''" type="text"></state> </Filed>
<Filed :span="12" :name="l('level')">{{entity.level}}</Filed>
<Filed :span="24" :name="l('userName')">{{entity.userName}}</Filed> <Filed :span="24" :name="l('userName')">{{entity.userName}}</Filed>
<Filed :span="24" :name="l('userIds')">{{entity.userIds}}</Filed> <Filed :span="12" :name="l('creatorUserId')"><User :value="entity.creatorUserId" /></Filed>
<Filed :span="12" :name="l('creationTime')">{{entity.creationTime}}</Filed>
<Filed :span="12" :name="l('lastModifierUserId')"> <User :value="entity.lastModifierUserId" /></Filed>
<Filed :span="12" :name="l('lastModificationTime')">{{entity.lastModificationTime}}</Filed>
</Row> </Row>
</div> </div>
</template> </template>
......
<template> <template>
<Form ref="form" :model="entity" :rules="rules" :label-width="90"> <Form ref="form" :model="entity" :rules="rules" :label-width="90">
<Row> <Row>
<Col :span="12">
<FormItem :label="l('creationTime')" prop="creationTime">
<DatePicker type="date" v-model="entity.creationTime"></DatePicker>
</FormItem>
</Col>
<Col :span="12">
<FormItem :label="l('creatorUserId')" prop="creatorUserId">
<InputNumber v-model="entity.creatorUserId"></InputNumber>
</FormItem>
</Col>
<Col :span="12">
<FormItem :label="l('lastModificationTime')" prop="lastModificationTime">
<DatePicker type="date" v-model="entity.lastModificationTime"></DatePicker>
</FormItem>
</Col>
<Col :span="12">
<FormItem :label="l('lastModifierUserId')" prop="lastModifierUserId">
<InputNumber v-model="entity.lastModifierUserId"></InputNumber>
</FormItem>
</Col>
<Col :span="12">
<FormItem :label="l('isDeleted')" prop="isDeleted">
<Input v-model="entity.isDeleted"></Input>
</FormItem>
</Col>
<Col :span="12">
<FormItem :label="l('deleterUserId')" prop="deleterUserId">
<InputNumber v-model="entity.deleterUserId"></InputNumber>
</FormItem>
</Col>
<Col :span="12">
<FormItem :label="l('deletionTime')" prop="deletionTime">
<DatePicker type="date" v-model="entity.deletionTime"></DatePicker>
</FormItem>
</Col>
<Col :span="12">
<FormItem :label="l('upId')" prop="upId">
<InputNumber v-model="entity.upId"></InputNumber>
</FormItem>
</Col>
<Col :span="12">
<FormItem :label="l('materialType')" prop="materialType">
<Input v-model="entity.materialType"></Input>
</FormItem>
</Col>
<Col :span="12"> <Col :span="12">
<FormItem :label="l('title')" prop="title"> <FormItem :label="l('title')" prop="title">
<Input v-model="entity.title"></Input> <Input v-model="entity.title"></Input>
...@@ -57,28 +12,18 @@ ...@@ -57,28 +12,18 @@
</FormItem> </FormItem>
</Col> </Col>
<Col :span="12"> <Col :span="12">
<FormItem :label="l('status')" prop="status">
<InputNumber v-model="entity.status"></InputNumber>
</FormItem>
</Col>
<Col :span="24">
<FormItem :label="l('description')" prop="description"> <FormItem :label="l('description')" prop="description">
<Input v-model="entity.description" type="textarea" :rows="5"></Input> <Input v-model="entity.description"></Input>
</FormItem> </FormItem>
</Col> </Col>
<Col :span="12"> <Col :span="12" v-if="user">
<FormItem :label="l('level')" prop="level">
<InputNumber v-model="entity.level"></InputNumber>
</FormItem>
</Col>
<Col :span="24">
<FormItem :label="l('userName')" prop="userName"> <FormItem :label="l('userName')" prop="userName">
<Input v-model="entity.userName" type="textarea" :rows="5"></Input> <UserSelect
</FormItem> ref="userSelected"
</Col> :roleTitle="roleTitle"
<Col :span="24"> v-model="entity.userIds"
<FormItem :label="l('userIds')" prop="userIds"> :multiple="true"
<Input v-model="entity.userIds" type="textarea" :rows="5"></Input> />
</FormItem> </FormItem>
</Col> </Col>
</Row> </Row>
...@@ -95,6 +40,7 @@ export default { ...@@ -95,6 +40,7 @@ export default {
data() { data() {
return { return {
disabled: false, disabled: false,
roleTitle: "库管",
entity: {}, entity: {},
rules: { rules: {
name: [{ required: true, message: "必填", trigger: "blur" }] name: [{ required: true, message: "必填", trigger: "blur" }]
...@@ -102,7 +48,14 @@ export default { ...@@ -102,7 +48,14 @@ export default {
}; };
}, },
props: { props: {
eid: Number v: Object,
eid: Number,
level: Number,
upId: Number,
user: {
type: Boolean,
default: true
}
}, },
mounted() { mounted() {
if (this.eid > 0) { if (this.eid > 0) {
...@@ -112,6 +65,7 @@ export default { ...@@ -112,6 +65,7 @@ export default {
methods: { methods: {
load(v) { load(v) {
Api.get({ id: v }).then(r => { Api.get({ id: v }).then(r => {
r.result.userIds = this.$u.toIntArray(r.result.userIds);
this.entity = r.result; this.entity = r.result;
}); });
}, },
...@@ -119,7 +73,27 @@ export default { ...@@ -119,7 +73,27 @@ export default {
this.$refs.form.validate(v => { this.$refs.form.validate(v => {
if (v) { if (v) {
this.disabled = true; this.disabled = true;
Api.update(this.entity)
let userNam = "";
let userId = "";
if (this.user) {
userId = this.entity.userIds.join(",");
userNam = this.$refs.userSelected.getSelectNames().join(",");
}
let paramsdata = {
id: this.entity.id,
upId: this.entity.upId,
title: this.entity.title, //库位名称
code: this.entity.code, //库位编号
description: this.entity.description, //位置
level: this.entity.level,
userName: userNam, //库管员
userIds: userId, //库管员id
creationTime: this.entity.creationTime,
creatorUserId: this.entity.creatorUserId
};
Api.update(paramsdata)
.then(r => { .then(r => {
this.disabled = false; this.disabled = false;
if (r.success) { if (r.success) {
...@@ -150,6 +124,9 @@ export default { ...@@ -150,6 +124,9 @@ export default {
if (v != 0) { if (v != 0) {
this.load(v); this.load(v);
} }
},
user(v) {
this.user = v;
} }
} }
}; };
......
...@@ -2,18 +2,19 @@ ...@@ -2,18 +2,19 @@
<div> <div>
<div class="mb10 pt5"> <div class="mb10 pt5">
<Input v-model="searchValue" placeholder="请输入库位名称" clearable style="width: 240px" /> <Input v-model="searchValue" placeholder="请输入库位名称" clearable style="width: 240px" />
<Button type="primary" class @click="searchData">查询</Button> <Button type="primary" class @click="handleSearch">查询</Button>
<div class="fr"> <div class="fr">
<Button type="primary" @click="add()">新增库位</Button> <Button type="primary" @click="add()">新增库位</Button>
</div> </div>
</div> </div>
<TreeGrid :columns="columns" :items="treeData"></TreeGrid> <TreeGrid :columns="columns" :items="treeData"></TreeGrid>
<Modal v-model="modal" :title="title" width="1200" footer-hide> <Modal v-model="modal" :title="title" width="1000" footer-hide>
<component <component
:is="detail" :is="detail"
:eid="curId" :eid="curId"
:level="level" :level="level"
:upId="upId" :upId="upId"
:user="user"
@on-close="cancel" @on-close="cancel"
@on-ok="ok" @on-ok="ok"
/> />
...@@ -46,41 +47,51 @@ export default { ...@@ -46,41 +47,51 @@ export default {
curId: 0, curId: 0,
level: null, level: null,
upId: null, upId: null,
user: true,
treeData: [], treeData: [],
treeDataOld: [],
columns: [ columns: [
{ {
key: "title", key: "title",
title: this.l("title"), title: this.l("title"),
align: "left", align: "left"
}, },
{ {
key: "code", key: "code",
title: this.l("code"), title: this.l("code"),
align: "left", align: "left"
}, },
{ {
key: "description", key: "description",
title: this.l("description"), title: this.l("description"),
align: "left", align: "left"
}, },
{ {
key: "level", key: "level",
title: this.l("level"), title: this.l("level"),
align: "left", align: "left",
code:'store.level' code: "store.level"
}, },
{ {
key: "userName", key: "userName",
title: this.l("userName"), title: this.l("userName"),
align: "left", align: "left"
}, },
{ {
title: "操作", title: "操作",
key: "action", key: "action",
width: 140, width: 300,
align: "center", align: "center",
render: (h, params) => { render: (h, params) => {
return h("div", { class: "action" }, [ return h("div", { class: "action" }, [
h(
"op",
{
attrs: { oprate: "add" },
on: { click: () => this.addrow(params.row) }
},
"新增"
),
h( h(
"op", "op",
{ {
...@@ -94,7 +105,7 @@ export default { ...@@ -94,7 +105,7 @@ export default {
"op", "op",
{ {
attrs: { oprate: "edit" }, attrs: { oprate: "edit" },
on: { click: () => this.edit(params.row.id) } on: { click: () => this.edit(params.row) }
}, },
"编辑" "编辑"
), ),
...@@ -108,63 +119,41 @@ export default { ...@@ -108,63 +119,41 @@ export default {
) )
]); ]);
} }
},
{
title: '操作',
key: 'id',
align: 'left',
render: (h, params) => {
let actions = [
h(
'op',
{
attrs: { oprate: 'add' },
on: { click: () => this.addrow(params.row) }
},
'新增'
),
h(
'op',
{
attrs: { oprate: 'edit' },
on: { click: () => this.edit(params.row.id,params.row.up_id) }
},
'编辑'
)
]
if (params.row.children.length == 0) {
actions.push(
h(
'op',
{
attrs: { oprate: 'delete' },
on: { click: () => this.remove(params.row.id) }
},
'删除'
)
)
}
return h('div', { class: 'action' }, actions)
}
} }
] ]
}; };
}, },
mounted() { mounted() {
this.laodaction(this.keys) this.laodaction(this.keys);
}, },
async fetch({ store, params }) { async fetch({ store, params }) {
await store.dispatch("loadDictionary"); // 加载数据字典 await store.dispatch("loadDictionary"); // 加载数据字典
}, },
methods: { methods: {
laodaction(name) { laodaction(name) {
let params = { title: name }; let params = {
Api.getList(params).then(r => { conditions: [
this.treeData = r.result; {
this.treeData.forEach(data=>{ fieldName: "title",
data.children=[] fieldValue: name,
}) conditionalType: "Like"
alert(JSON.stringify(this.treeData)) }
]
};
Api.paged(params).then(r => {
let res = r.result.items;
var data = this.$u.toTree(
res,
0,
u => {
u.expand = true;
u.selected = false;
u.checked = false;
},
"upId"
);
this.treeData = this.$u.clone(data);
this.treeDataOld = this.$u.clone(data);
}); });
}, },
//查询 //查询
...@@ -172,28 +161,78 @@ export default { ...@@ -172,28 +161,78 @@ export default {
var name = this.searchValue; var name = this.searchValue;
this.laodaction(name); this.laodaction(name);
}, },
handleSearch() {
let tree = this.$u.clone(this.treeDataOld);
let value = this.searchValue;
if (value.trim() == "") {
this.treeData = this.$u.clone(this.treeDataOld);
} else {
//不满足搜索条件的待删除元素索引数组
let removeArr = [];
for (let i = 0; i < tree.length; i++) {
let node = tree[i];
this.searchTree(node, i, value, removeArr);
}
//遍历删除不满足条件的节点
for (let j = removeArr.length - 1; j >= 0; j--) {
tree.splice(removeArr[j], 1);
}
this.treeData = tree;
}
},
searchTree(node, index, value, removeArr) {
let children = node.children;
//针对非叶子节点,需要递归其children节点
if (children && children.length > 0) {
let innderArr = [];
for (let i = 0; i < children.length; i++) {
this.searchTree(children[i], i, value, innderArr);
}
if (node.title.indexOf(value) === -1) {
for (let j = innderArr.length - 1; j >= 0; j--) {
children.splice(innderArr[j], 1);
}
if (node.children.length === 0) {
removeArr.push(index);
}
}
} else {
//叶子节点,直接进行匹配
if (node.title.indexOf(value) === -1) {
removeArr.push(index);
} else {
//将满足条件内容做标记显示
// node.title = node.title.replace(regExp, replaceStr);
}
}
},
addOk() { addOk() {
this.laodaction(); var name = this.searchValue;
this.addModal = false; this.laodaction(name);
this.editModal = false; this.modal = false;
this.addrowModal = false;
// this.curId = 0 // this.curId = 0
}, },
ok() { ok() {
this.$refs.grid.load(); var name = this.searchValue;
this.laodaction(name);
this.modal = false; this.modal = false;
this.curId = 0; this.curId = 0;
}, },
search() {
this.$refs.grid.reload(this.easySearch);
},
add() { add() {
this.curId = 0; this.curId = 0;
this.level = 1; this.level = 1;
this.user = true;
(this.upId = 0), (this.title = "新增"); (this.upId = 0), (this.title = "新增");
this.detail = () => import("./add"); this.detail = () => import("./add");
this.modal = true; this.modal = true;
}, },
addrow(params) {
this.curId = 0;
this.user = false;
(this.upId = params.id), (this.title = "新增");
this.detail = () => import("./add");
this.modal = true;
},
copy(id) { copy(id) {
this.curId = id; this.curId = id;
this.title = "克隆"; this.title = "克隆";
...@@ -206,17 +245,23 @@ export default { ...@@ -206,17 +245,23 @@ export default {
this.detail = () => import("./detail"); this.detail = () => import("./detail");
this.modal = true; this.modal = true;
}, },
edit(id) { edit(row) {
this.curId = id; this.curId = row.id;
this.title = "编辑"; this.title = "编辑";
if (row.upId == 0) {
this.user = true;
} else {
this.user = false;
}
this.detail = () => import("./edit"); this.detail = () => import("./edit");
this.modal = true; this.modal = true;
}, },
remove(id) { remove(id) {
Api.delete(id).then(r => { Api.delete(id).then(r => {
if (r.success) { if (r.success) {
this.$refs.grid.load();
this.$Message.success("删除成功"); this.$Message.success("删除成功");
var name = this.searchValue;
this.laodaction(name);
} }
}); });
}, },
......
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