Commit 6bcd208b authored by 仇晓婷's avatar 仇晓婷

物料主数据

parent d4efdb51
...@@ -70,30 +70,30 @@ export default { ...@@ -70,30 +70,30 @@ export default {
// this.tableData(); // this.tableData();
}, },
methods: { methods: {
tableData() { // tableData() {
let conditions = [ // let conditions = [
{ // {
conditionalType: "In", // conditionalType: "In",
fieldName: "fieldType", // fieldName: "fieldType",
fieldValue: "1,2" // fieldValue: "1,2"
}, // },
{ // {
conditionalType: "Equal", // conditionalType: "Equal",
fieldName: "categoryId", // fieldName: "categoryId",
fieldValue: "0" // fieldValue: "0"
} // }
]; // ];
Api.listTable({ conditions: conditions }).then(r => { // Api.listTable({ conditions: conditions }).then(r => {
if (r.result) { // if (r.result) {
var arr = r.result; // var arr = r.result;
this.checkList = arr.filter(function(item) { // this.checkList = arr.filter(function(item) {
delete item["id"]; // delete item["id"];
return item; // return item;
}); // });
} // }
}); // });
}, // },
remove(index, row) { remove(index, row) {
if (row.add == 0) { if (row.add == 0) {
//新增的删除,直接删 //新增的删除,直接删
......
<template> <template>
<div class="maseter">
<div class="come-back" @click="back">
<Icon type="ios-undo-outline" />返回
</div>
<Layout class="data-details"> <Layout class="data-details">
<Sider hide-trigger class="left-detail" width="300"> <Sider hide-trigger class="left-detail" width="300">
<h4 class="bt">标题</h4> <h4 class="bt">标题</h4>
...@@ -47,6 +51,7 @@ ...@@ -47,6 +51,7 @@
</div> </div>
</Content> </Content>
</Layout> </Layout>
</div>
</template> </template>
<script> <script>
export default { export default {
...@@ -73,6 +78,11 @@ export default { ...@@ -73,6 +78,11 @@ export default {
}; };
}, },
methods: { methods: {
back() {
this.$router.push({
path: "/materiel/masterData"
});
},
everyItem(li, i) { everyItem(li, i) {
this.isactive = i; this.isactive = i;
}, },
...@@ -83,7 +93,21 @@ export default { ...@@ -83,7 +93,21 @@ export default {
} }
}; };
</script> </script>
<style lang="less"> <style lang="less" >
.maseter {
.come-back {
margin: 5px;
color: #2680eb;
.ivu-icon {
font-size: 20px;
}
}
.come-back:hover {
font-weight: bold;
cursor: pointer;
}
}
.ivu-layout { .ivu-layout {
background-color: #f5f7f9 !important; background-color: #f5f7f9 !important;
} }
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
<div> <div>
<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"> <Col :span="12">
<FormItem label="编码" prop="code"> <FormItem label="编码" prop="code">
<Input v-model="entity.code" placeholder="请输入" disabled></Input> <Input v-model="entity.code" placeholder="请输入" disabled></Input>
</FormItem> </FormItem>
</Col>--> </Col>
<Col :span="12"> <Col :span="12">
<FormItem label="名称" prop="name"> <FormItem label="名称" prop="name">
<Input v-model="entity.name" placeholder="请输入"></Input> <Input v-model="entity.name" placeholder="请输入"></Input>
...@@ -23,61 +23,16 @@ ...@@ -23,61 +23,16 @@
></Dictionary> ></Dictionary>
</FormItem> </FormItem>
</Col> </Col>
<Col :span="12">
<FormItem label="版本" prop="version">
<Input v-model="entity.version" placeholder="请输入"></Input>
</FormItem>
</Col>
<Col :span="24"> <Col :span="24">
<FormItem label="描述" prop="description"> <FormItem label="描述" prop="description">
<Input v-model="entity.description" type="textarea" placeholder="请输入..."></Input> <Input v-model="entity.description" type="textarea" placeholder="请输入..."></Input>
</FormItem> </FormItem>
</Col> </Col>
<Col :span="24">
<h4>属性配置</h4>
</Col>
<Col :span="24" style="padding:20px 0 0px 10px;margin-bottom:10px;" class="table-solt">
<!--fieldType 1.固有,2.默认,3自定义; -->
<Table border :columns="columns" :data="checkList" class="tableCommon" height="300">
<template slot-scope="{ row, index }" slot="title">
<div v-if="row.fieldType==1||row.fieldType==2">{{row.title}}</div>
<Input v-else v-model="row.title" placeholder="请输入" @on-blur="setRow(row,index)" />
</template>
<template slot-scope="{ row, index }" slot="note">
<div v-if="row.fieldType==1">{{row.note}}</div>
<Input v-model="row.note" placeholder="请输入" @on-blur="setRow(row,index)" v-else />
</template>
<template slot-scope="{ row, index }" slot="dataType">
<state
v-if="row.fieldType==1"
code="materail.category.dataType"
:value="row.dataType"
type="text"
></state>
<Dictionary
v-else
code="materail.category.dataType"
type="select"
:value="row.dataType"
:key="row.dataType"
></Dictionary>
</template>
<!-- <template slot-scope="{ row, index }" slot="result">
<Input v-model="row.result" placeholder="请输入" @on-blur="setRow(row,index)" />
</template>-->
<template slot-scope="{ row, index }" slot="required">
<Checkbox v-model="row.required" @on-change="setRow(row,index)"></Checkbox>
</template>
<template slot-scope="{ row, index }" slot="isUnique">
<Checkbox v-model="row.isUnique" @on-change="setRow(row,index)"></Checkbox>
</template>
<template
slot-scope="{ row, index }"
slot="action"
v-if="row.fieldType==2||row.fieldType==3"
>
<a @click="remove(index,row)" style="color:#FF7A8B">删除</a>
</template>
</Table>
</Col>
<Col :span="24" style="margin-bottom:20px;">
<Button type="primary" long @click="addNew" class="mt10">添加</Button>
</Col>
<Col :span="24" style="text-align: right;"> <Col :span="24" style="text-align: right;">
<FormItem> <FormItem>
<Button type="primary" @click="handleSubmit" :disabled="disabled">保存</Button> <Button type="primary" @click="handleSubmit" :disabled="disabled">保存</Button>
...@@ -94,69 +49,20 @@ export default { ...@@ -94,69 +49,20 @@ export default {
props: ["nodeInfo"], props: ["nodeInfo"],
data() { data() {
return { return {
arr: [],
entity: { entity: {
upId: 0, id: this.nodeInfo.id,
code: 0 code: 0,
categoryId: this.nodeInfo.categoryId, //左侧树点击的id
customProperties: {},
rootCategoryId: this.nodeInfo.rootCategoryId //左侧树点击的数据的最顶层id
}, },
arr: [],
disabled: false, disabled: false,
columns: [
{
title: "序号",
type: "index",
width: 80,
align: "center"
},
{
title: "属性名称",
key: "title",
align: "center",
slot: "title"
},
{
title: "备注",
key: "note",
align: "center",
slot: "note"
},
{
title: "属性类型",
key: "dataType",
align: "center",
slot: "dataType"
},
// {
// title: "是否显示",
// key: "result",
// align: "center",
// slot: "result"
// },
{
title: "是否必填",
key: "required",
align: "center",
slot: "required"
},
{
title: "是否唯一属性",
key: "isunique",
align: "center",
slot: "isunique"
},
{
title: "操作",
slot: "action",
width: 100,
align: "center"
}
],
checkList: [],
rules: { rules: {
name: [{ required: true, message: "必填", trigger: "blur" }] name: [{ required: true, message: "必填", trigger: "blur" }]
} }
}; };
}, },
async fetch({ store, params }) { async fetch({ store, params }) {
await store.dispatch("loadDictionary"); // 加载数据字典 await store.dispatch("loadDictionary"); // 加载数据字典
}, },
...@@ -168,71 +74,42 @@ export default { ...@@ -168,71 +74,42 @@ export default {
Api.get({ id: this.nodeInfo.id }).then(r => { Api.get({ id: this.nodeInfo.id }).then(r => {
if (r.result) { if (r.result) {
this.entity = r.result; this.entity = r.result;
this.tableData();
}
});
},
tableData() {
let conditions = [
{
conditionalType: "Equal",
fieldName: "categoryId",
fieldValue: this.nodeInfo.id
}
];
Api.listTable({ conditions: conditions }).then(r => {
if (r.result) {
console.log(r);
this.checkList = r.result;
} }
}); });
}, },
remove(index, row) { remove(index, row) {
if (row.add == 0) { if (row.add == 0) {
//新增的删除,直接删
this.checkList.splice(index, 1); this.checkList.splice(index, 1);
} else { } else {
row.action = 2; row.action = 2; //返回的默认删除,删除后保存在arr数组中,添加标识action = 2,然后点击保存的时候,一起传给后台
this.$set(this.checkList, index, row); this.$set(this.checkList, index, row);
this.arr.push(row); this.arr.push(row);
this.checkList.splice(index, 1); this.checkList.splice(index, 1);
} }
}, },
setRow(row,index) { setRow(row, index) {
this.$set(this.checkList, index, row); this.$set(this.checkList, index, row);
}, },
addNew() {
let arr = this.$u.clone(this.checkList);
let obj = {
title: "",
note: "",
dataType: "",
required: false,
isunique: false,
fieldType: 3,
categoryId: 0,
action: 1,
add: 0
};
arr.push(obj);
this.checkList = arr;
},
handleSubmit() { handleSubmit() {
this.$refs.form.validate(v => { this.$refs.form.validate(v => {
if (v) { if (v) {
let categoryDto = this.entity; // let categoryDto = this.entity;
let pro = this.checkList.concat(this.arr); // let pro = this.checkList.concat(this.arr);
Api.update({ categoryDto: categoryDto, pro: pro }) Api.update(this.entity)
.then(r => { .then(r => {
if (r.success) { if (r.success) {
this.$Message.success("保存成功"); this.$Message.success("保存成功");
this.$emit("on-ok"); this.$emit("on-ok");
} else { } else {
this.$Message.error("保存失败"); this.$Message.error(r.error.message);
} }
}) })
.catch(err => { .catch(err => {
this.disabled = false; this.disabled = false;
this.$Message.error("保存失败"); this.$Message.error(r.error.message);
}); });
} }
}); });
......
<template> <template>
<div class="master-data"> <div class="master-data">
{{nodeInfo}}
<DataGrid :columns="columns" ref="grid" :action="action" :initsearch="sets" :high="false"> <DataGrid :columns="columns" ref="grid" :action="action" :initsearch="sets" :high="false">
<template slot="easySearch"> <template slot="easySearch">
<Form ref="formInline" :model="easySearch" inline> <Form ref="formInline" :model="easySearch" inline>
...@@ -57,7 +56,7 @@ export default { ...@@ -57,7 +56,7 @@ export default {
v.rootCategoryId = this.nodeInfo.rootCategoryId; v.rootCategoryId = this.nodeInfo.rootCategoryId;
}, },
easySearch: { easySearch: {
keys: { op: "Code,Name", value: null }, keys: { op: "Code,Name", value: null }
// categoryId: { // categoryId: {
// op: "In", // op: "In",
// value: this.nodeInfo.categoryId // value: this.nodeInfo.categoryId
...@@ -77,7 +76,19 @@ export default { ...@@ -77,7 +76,19 @@ export default {
{ {
key: "Code", key: "Code",
title: "编码", title: "编码",
align: "left" align: "left",
render: (h, params) => {
return h(
"a",
{
props: {},
on: {
click: () => this.details(params.row)
}
},
params.row.Code
);
}
}, },
{ {
key: "Name", key: "Name",
...@@ -151,7 +162,12 @@ export default { ...@@ -151,7 +162,12 @@ export default {
this.detail = () => import("./add"); this.detail = () => import("./add");
this.modal = true; this.modal = true;
}, },
edit(row) {}, edit(row) {
this.nodeInfo.id = row.Id;
this.title = "编辑";
this.detail = () => import("./edit");
this.modal = true;
},
remove(id) { remove(id) {
this.$Modal.confirm({ this.$Modal.confirm({
title: "删除", title: "删除",
...@@ -169,6 +185,11 @@ export default { ...@@ -169,6 +185,11 @@ export default {
} }
}); });
}, },
details() {
this.$router.push({
path: "/materiel/masterData/details"
});
},
ok() { ok() {
this.$refs.grid.reload(this.easySearch); this.$refs.grid.reload(this.easySearch);
this.modal = false; this.modal = false;
......
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