Commit b40a73e5 authored by 仇晓婷's avatar 仇晓婷

wendang

parent 1034f24d
<template>
<Form ref="form" :model="entity" :rules="rules" :label-width="90">
<Row>
<Col :span="12">
<FormItem :label="l('title')" prop="title">
<Input v-model="entity.title"></Input>
</FormItem>
</Col>
<Col :span="12">
<FormItem :label="l('code')" prop="code">
<Input v-model="entity.code"></Input>
</FormItem>
</Col>
<Col :span="12">
<FormItem :label="l('description')" prop="description">
<Input v-model="entity.description"></Input>
</FormItem>
</Col>
<Col :span="12" v-if="user">
<FormItem :label="l('userName')" prop="userName">
<UserSelect
ref="userSelected"
:roleTitle="roleTitle"
v-model="entity.userIds"
:multiple="true"
@on-change="userChange"
/>
</FormItem>
</Col>
<Col :span="12">
<FormItem label="物料类型" prop="materialType">
<Select v-model="entity.materialType" multiple @on-change="changeVal">
<Option v-for="item in list" :value="item.id" :key="item.id">{{ item.name }}</Option>
</Select>
</FormItem>
</Col>
</Row>
<FormItem>
<Button type="primary" @click="handleSubmit" v-noClick>保存</Button>
<Button @click="handleClose" class="ml20">取消</Button>
</FormItem>
</Form>
</template>
<script>
import Api from "./api";
export default {
name: "Add",
data() {
return {
list: [],
roleTitle: "库管员",
entity: {
creationTime: null,
creatorUserId: null,
lastModificationTime: null,
lastModifierUserId: null,
isDeleted: null,
deleterUserId: null,
deletionTime: null,
upId: this.upId,
materialType: "",
materialTypeName: "",
title: "",
code: "",
status: null,
description: "",
level: this.level,
userName: "",
userIds: "",
codeRuleType: "",
},
rules: {
title: [{ required: true, message: "必填", trigger: "blur" }],
},
};
},
props: {
v: Object,
eid: Number,
level: Number,
upId: Number,
user: {
type: Boolean,
default: true,
},
},
mounted() {
this.getList();
},
methods: {
getList() {
let data = {
conditions: [
{
fieldName: "upId",
fieldValue: 0,
conditionalType: "Equal",
},
],
};
Api.list(data).then((r) => {
this.list = r.result;
// console.log(this.list);
});
},
changeVal(val) {
let code = [];
let type = [];
for (let i = 0; i < this.list.length; i++) {
let obj = this.list[i];
for (let j = 0; j < val.length; j++) {
if (obj.id == val[j]) {
code.push(obj.code);
type.push(obj.codeRuleType);
}
}
}
this.entity.materialTypeName = code.join(",");
this.entity.codeRuleType = type.join(",");
},
handleSubmit() {
this.$refs.form.validate((v) => {
if (v) {
let userNam = "";
let userId = "";
if (this.user) {
userId = this.entity.userIds.join(",");
userNam = this.$refs.userSelected.getSelectNames().join(",");
}
let materialType = this.entity.materialType.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
materialType: materialType, //物料类型
materialTypeName: this.entity.materialTypeName, //物料编码
codeRuleType: this.entity.codeRuleType,
};
Api.create(paramsdata)
.then((r) => {
if (r.success) {
this.$Message.success("保存成功");
this.$emit("on-ok");
} else {
this.$Message.error("保存失败");
}
})
.catch((err) => {
this.$Message.error("保存失败");
console.warn(err);
});
}
});
},
handleClose() {
this.$emit("on-close");
},
load(v) {
Api.get({ id: v }).then((r) => {
this.entity = r.result;
this.entity.id = 0;
});
},
userChange(val) {},
l(key) {
key = "store_room_location" + "." + key;
return this.$t(key);
},
},
watch: {
v() {
this.entity = this.$u.clone(this.v);
},
user(v) {
this.user = v;
},
},
};
</script>
import Api from '@/plugins/request'
export default {
index: `${material}/documentcategory/paged`,
paged(params) {
return Api.post(`${material}/documentcategory/paged`, params);
},
getList(params) {
return Api.post(`${material}/documentcategory/list`, params);
},
get(params) {
return Api.get(`${material}/documentcategory/get`, params);
},
create(params) {
return Api.post(`${material}/documentcategory/create`, params);
},
update(params) {
return Api.post(`${material}/documentcategory/update`, params);
},
delete(id) {
return Api.delete(`${material}/documentcategory/delete`, {
params: {
id: id
}
});
},
list(params) {
return Api.post(`${material}/category/list`, params);//物料类型列表
},
}
<template>
<div class="detail">
<Row>
<Filed :span="12" :name="l('title')">{{entity.title}}</Filed>
<Filed :span="12" :name="l('code')">{{entity.code}}</Filed>
<Filed :span="12" :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('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>
<Filed :span="24" name="物料编号">{{entity.materialTypeName}}</Filed>
<Filed :span="24" :name="l('userName')">{{entity.userName}}</Filed>
</Row>
</div>
</template>
<script>
import Api from "./api";
export default {
name: "Add",
data() {
return {
entity: {},
rules: {
name: [{ required: true, message: "必填", trigger: "blur" }],
code: [{ required: true, message: "必填", trigger: "blur" }],
},
};
},
props: {
eid: Number,
},
mounted() {
if (this.eid > 0) {
this.load(this.eid);
}
},
methods: {
load(v) {
Api.get({ id: v }).then((r) => {
this.entity = r.result;
this.$emit("on-load");
});
},
handleClose() {
this.$emit("on-close");
},
l(key) {
key = "store_room_location" + "." + key;
return this.$t(key);
},
},
watch: {
eid(v) {
if (v > 0) {
this.load(v);
}
},
},
};
</script>
<template>
<Form ref="form" :model="entity" :rules="rules" :label-width="90">
<Row>
<Col :span="12">
<FormItem :label="l('title')" prop="title">
<Input v-model="entity.title"></Input>
</FormItem>
</Col>
<Col :span="12">
<FormItem :label="l('code')" prop="code">
<Input v-model="entity.code"></Input>
</FormItem>
</Col>
<Col :span="12">
<FormItem :label="l('description')" prop="description">
<Input v-model="entity.description"></Input>
</FormItem>
</Col>
<Col :span="12" v-if="user">
<FormItem :label="l('userName')" prop="userName">
<UserSelect
ref="userSelected"
:roleTitle="roleTitle"
v-model="entity.userIds"
:multiple="true"
/>
</FormItem>
</Col>
<Col :span="12">
<FormItem label="物料类型" prop="materialType">
<Select v-model="materialType" multiple @on-change="changeVal">
<Option v-for="item in list" :value="item.id" :key="item.id">{{ item.name }}</Option>
</Select>
</FormItem>
</Col>
</Row>
<FormItem>
<Button type="primary" @click="handleSubmit" v-noClick>保存</Button>
<Button @click="handleClose" class="ml20">取消</Button>
</FormItem>
</Form>
</template>
<script>
import Api from "./api";
export default {
name: "Edit",
data() {
return {
list: [],
roleTitle: "库管",
entity: {
materialType: [],
codeRuleType: "",
},
materialType: [],
rules: {
name: [{ required: true, message: "必填", trigger: "blur" }],
},
};
},
props: {
v: Object,
eid: Number,
level: Number,
upId: Number,
user: {
type: Boolean,
default: true,
},
},
mounted() {
if (this.eid > 0) {
this.load(this.eid);
}
this.getList();
},
methods: {
getList() {
let data = {
conditions: [
{
fieldName: "upId",
fieldValue: 0,
conditionalType: "Equal",
},
],
};
Api.list(data).then((r) => {
this.list = r.result;
});
},
changeVal(val) {
let code = [];
let type = [];
for (let i = 0; i < this.list.length; i++) {
let obj = this.list[i];
for (let j = 0; j < val.length; j++) {
if (obj.id == val[j]) {
code.push(obj.code);
type.push(obj.codeRuleType);
}
}
}
this.entity.materialTypeName = code.join(",");
this.entity.codeRuleType = type.join(",");
},
load(v) {
Api.get({ id: v }).then((r) => {
r.result.userIds = this.$u.toIntArray(r.result.userIds);
this.entity = r.result;
var uids = [];
let ids = [];
ids = r.result.materialType.split(",");
ids.map((u) => {
uids.push(parseInt(u));
});
this.materialType = uids;
});
},
handleSubmit() {
this.$refs.form.validate((v) => {
if (v) {
let materialType = this.materialType.join(",");
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,
materialType: materialType, //物料类型
materialTypeName: this.entity.materialTypeName, //物料编码
codeRuleType: this.entity.codeRuleType,
};
Api.update(paramsdata)
.then((r) => {
if (r.success) {
this.$Message.success("保存成功");
this.$emit("on-ok");
} else {
this.$Message.error("保存失败");
}
})
.catch((err) => {
this.$Message.error("保存失败");
console.warn(err);
});
}
});
},
handleClose() {
this.$emit("on-close");
},
l(key) {
key = "store_room_location" + "." + key;
return this.$t(key);
},
},
watch: {
eid(v) {
if (v != 0) {
this.load(v);
}
},
user(v) {
this.user = v;
},
},
};
</script>
<template>
<div>
<div class="mb10 pt5">
<Input v-model="searchValue" placeholder="请输入库位名称" clearable style="width: 240px" />
<Button type="primary" class @click="handleSearch">查询</Button>
<div class="fr">
<Button type="primary" @click="add()">新增库位</Button>
</div>
</div>
<TreeGrid :columns="columns" :items="treeData"></TreeGrid>
<Modal v-model="modal" :title="title" width="1000" footer-hide>
<component
:is="detail"
:eid="curId"
:level="level"
:upId="upId"
:user="user"
@on-close="cancel"
@on-ok="ok"
/>
</Modal>
</div>
</template>
<script>
import Api from "./api";
import Search from "./search";
export default {
name: "list",
components: {
Search,
},
head: {
title: "库房库位",
author: "henq",
description: "store_room_location 7/10/2020 8:57:03 AM",
},
data() {
return {
easySearch: {
keys: { op: "title,code,userName", value: null },
},
searchValue: "", //搜索库位名称
keys: "",
modal: false,
title: "新增",
detail: null,
curId: 0,
level: null,
upId: null,
user: true,
treeData: [],
treeDataOld: [],
columns: [
{
key: "title",
title: this.l("title"),
align: "left",
},
{
key: "code",
title: this.l("code"),
align: "left",
},
{
key: "description",
title: this.l("description"),
align: "left",
},
{
key: "level",
title: this.l("level"),
align: "left",
code: "store.level",
},
{
key: "materialTypeName",
title: "物料编号",
align: "left",
},
{
key: "userName",
title: this.l("userName"),
align: "left",
},
{
title: "操作",
key: "action",
width: 300,
align: "center",
render: (h, params) => {
return h("div", { class: "action" }, [
h(
"op",
{
attrs: { oprate: "add" },
on: { click: () => this.addrow(params.row) },
},
"新增"
),
h(
"op",
{
attrs: { oprate: "detail" },
on: { click: () => this.view(params.row.id) },
},
"查看"
),
//h('op', { attrs: { oprate: 'copy' }, on: { click: () => this.copy(params.row.id) } }, '克隆'),
h(
"op",
{
attrs: { oprate: "edit" },
on: { click: () => this.edit(params.row) },
},
"编辑"
),
h(
"op",
{
attrs: { oprate: "delete" },
on: { click: () => this.remove(params.row) },
},
"删除"
),
]);
},
},
],
};
},
mounted() {
this.laodaction(this.keys);
},
async fetch({ store, params }) {
await store.dispatch("loadDictionary"); // 加载数据字典
},
methods: {
laodaction(name) {
let params = {
conditions: [
{
fieldName: "title",
fieldValue: name,
conditionalType: "Like",
},
],
};
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);
});
},
//查询
searchData() {
var name = this.searchValue;
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);
}
}
},
addOk() {
var name = this.searchValue;
this.laodaction(name);
this.modal = false;
// this.curId = 0
},
ok() {
var name = this.searchValue;
this.laodaction(name);
this.modal = false;
this.curId = 0;
},
add() {
this.curId = 0;
this.level = 1;
this.user = true;
(this.upId = 0), (this.title = "新增");
this.detail = () => import("./add");
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) {
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.title = "编辑";
if (row.upId == 0) {
this.user = true;
} else {
this.user = false;
}
this.detail = () => import("./edit");
this.modal = true;
},
remove(row) {
if (row.children && row.children.length == 0) {
Api.delete(row.id).then((r) => {
if (r.success) {
this.$Message.success("删除成功");
var name = this.searchValue;
this.laodaction(name);
}
});
} else {
this.$Message.error("此节点有子节点,不能删除!");
return false;
}
},
cancel() {
this.curId = 0;
this.modal = false;
},
l(key) {
let vkey = "store_room_location" + "." + key;
return this.$t(vkey) || key;
},
},
};
</script>
<style lang="less">
</style>
\ No newline at end of file
<template>
<Form ref="form" :model="condition" :label-width="90">
<Row>
<Col :span="12" :v-if="condition.id.show">
<FormItem :label="$t('id')" prop="id">
<Input v-model="condition.id.value"></Input>
</FormItem>
</Col>
<Col :span="12" :v-if="condition.creationTime.show">
<FormItem :label="l('creationTime')" prop="creationTime">
<DatePicker type="daterange" v-model="condition.creationTime.value"></DatePicker>
</FormItem>
</Col>
<Col :span="12" :v-if="condition.creatorUserId.show">
<FormItem :label="l('creatorUserId')" prop="creatorUserId">
<Input v-model="condition.creatorUserId.value"></Input>
</FormItem>
</Col>
<Col :span="12" :v-if="condition.lastModificationTime.show">
<FormItem :label="l('lastModificationTime')" prop="lastModificationTime">
<DatePicker type="daterange" v-model="condition.lastModificationTime.value"></DatePicker>
</FormItem>
</Col>
<Col :span="12" :v-if="condition.lastModifierUserId.show">
<FormItem :label="l('lastModifierUserId')" prop="lastModifierUserId">
<Input v-model="condition.lastModifierUserId.value"></Input>
</FormItem>
</Col>
<Col :span="12" :v-if="condition.deletionTime.show">
<FormItem :label="l('deletionTime')" prop="deletionTime">
<DatePicker type="daterange" v-model="condition.deletionTime.value"></DatePicker>
</FormItem>
</Col>
<Col :span="12" :v-if="condition.upId.show">
<FormItem :label="l('upId')" prop="upId">
<Input v-model="condition.upId.value"></Input>
</FormItem>
</Col>
<Col :span="12" :v-if="condition.materialType.show">
<FormItem :label="l('materialType')" prop="materialType">
<Input v-model="condition.materialType.value"></Input>
</FormItem>
</Col>
<Col :span="12" :v-if="condition.title.show">
<FormItem :label="l('title')" prop="title">
<Input v-model="condition.title.value"></Input>
</FormItem>
</Col>
<Col :span="12" :v-if="condition.code.show">
<FormItem :label="l('code')" prop="code">
<Input v-model="condition.code.value"></Input>
</FormItem>
</Col>
<Col :span="12" :v-if="condition.status.show">
<FormItem :label="l('status')" prop="status">
<Input v-model="condition.status.value"></Input>
</FormItem>
</Col>
<Col :span="24" :v-if="condition.description.show">
<FormItem :label="l('description')" prop="description">
<Input v-model="condition.description.value"></Input>
</FormItem>
</Col>
<Col :span="12" :v-if="condition.level.show">
<FormItem :label="l('level')" prop="level">
<Input v-model="condition.level.value"></Input>
</FormItem>
</Col>
<Col :span="24" :v-if="condition.userName.show">
<FormItem :label="l('userName')" prop="userName">
<Input v-model="condition.userName.value"></Input>
</FormItem>
</Col>
<Col :span="24" :v-if="condition.userIds.show">
<FormItem :label="l('userIds')" prop="userIds">
<Input v-model="condition.userIds.value"></Input>
</FormItem>
</Col>
</Row>
</Form>
</template>
<script>
import Api from "./api";
export default {
name: "Add",
data() {
return {
condition: {
id: { op: "Equal", value: null, show: true },
creationTime: { op: "Range", value: null, show: true },
creatorUserId: { op: "Equal", value: null, show: true },
lastModificationTime: { op: "Range", value: null, show: true },
lastModifierUserId: { op: "Equal", value: null, show: true },
deletionTime: { op: "Range", value: null, show: true },
upId: { op: "Equal", value: null, show: true },
materialType: { op: "Equal", value: null, show: true },
title: { op: "Equal", value: null, show: true },
code: { op: "Equal", value: null, show: true },
status: { op: "Equal", value: null, show: true },
description: { op: "Equal", value: null, show: true },
level: { op: "Equal", value: null, show: true },
userName: { op: "Equal", value: null, show: true },
userIds: { op: "Equal", value: null, show: true }
}
};
},
methods: {
handleClose() {
this.$emit("on-close");
},
l(key) {
key = "store_room_location" + "." + key;
return this.$t(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