Commit 56e60186 authored by 骆瑛's avatar 骆瑛

增加拓展属性

parent 6a484716
...@@ -53,14 +53,13 @@ ...@@ -53,14 +53,13 @@
<Input v-model="entity.level"> </Input> </FormItem <Input v-model="entity.level"> </Input> </FormItem
></Col> --> ></Col> -->
<Col :span="12" <Col :span="12">
>
<!-- <FormItem :label="l('type')" prop="type">
<Input v-model="entity.type"> </Input> </FormItem
> -->
<FormItem :label="l('type')" prop="type"> <FormItem :label="l('type')" prop="type">
<Dictionary code="base.project_atom.type" v-model="entity.type" ></Dictionary> <Dictionary
</FormItem > code="base.project_atom.type"
v-model="entity.type"
></Dictionary>
</FormItem>
</Col> </Col>
<Col :span="12" <Col :span="12"
><FormItem :label="l('englishFullName')" prop="englishFullName"> ><FormItem :label="l('englishFullName')" prop="englishFullName">
...@@ -71,18 +70,18 @@ ...@@ -71,18 +70,18 @@
<Input v-model="entity.englishName"> </Input> </FormItem <Input v-model="entity.englishName"> </Input> </FormItem
></Col> ></Col>
<Col :span="12"> <Col :span="12">
<!-- <FormItem :label="l('status')" prop="status">
<Input v-model="entity.status"> </Input> </FormItem
> -->
<FormItem :label="l('status')" prop="status"> <FormItem :label="l('status')" prop="status">
<Dictionary code="base.project_atom.status" v-model="entity.status" ></Dictionary> <Dictionary
</FormItem > code="base.project_atom.status"
v-model="entity.status"
></Dictionary>
</FormItem>
</Col> </Col>
<Col :span="12" <!-- <Col :span="12"
><FormItem :label="l('content')" prop="content"> ><FormItem :label="l('content')" prop="content">
<Input v-model="entity.content"> </Input> </FormItem <Input v-model="entity.content"> </Input> </FormItem
></Col> ></Col> -->
<Col :span="12" <Col :span="12"
><FormItem :label="l('code')" prop="code"> ><FormItem :label="l('code')" prop="code">
<Input v-model="entity.code"> </Input> </FormItem <Input v-model="entity.code"> </Input> </FormItem
...@@ -122,13 +121,103 @@ ...@@ -122,13 +121,103 @@
:rows="5" :rows="5"
></Input> </FormItem ></Input> </FormItem
></Col> ></Col>
</Row>
<FormItem> <Col :span="12" v-if="eid != 0">
<Button type="primary" @click="handleSubmit" :disabled="disabled" <FormItem label="扩展属性" prop="inheritCategoryId">
>保存</Button <!-- <Checkbox v-model="entity.inheritCategoryId"></Checkbox> -->
<RadioGroup v-model="inherit">
<Radio label="1">继承</Radio>
<Radio label="0">自定义</Radio>
</RadioGroup>
</FormItem>
</Col>
<Col :span="24" v-if="inherit == '0'">
<Divider orientation="left">扩展属性</Divider>
<Table :columns="columns" :data="checkList" border>
<template slot-scope="{ row, index }" slot="title">
<div v-if="row.fieldType == 1 || row.fieldType == 2">
{{ row.title }}
</div>
<Input
v-model="row.title"
placeholder="请输入名称"
@on-blur="setRow(row, index)"
v-if="row.fieldType == 3"
/>
</template>
<template slot-scope="{ row, index }" slot="note">
<!-- <Input v-if="row.dataType==3" v-model="row.note" placeholder="请输入字典编码" @on-blur="setRow(row,index)" /> -->
<Select
v-if="row.dataType == 3"
v-model="row.note"
clearable
transfer
@on-change="setRow(row, index)"
>
<Option
v-for="item in codeList"
:value="item.code"
:key="item.code"
>{{ item.name }}</Option
> >
</Select>
<span v-else>{{ row.note }}</span>
</template>
<template slot-scope="{ row, index }" slot="dataType">
<Dictionary
@on-change="setRow(row, index)"
v-model="row.dataType"
code="materail.category.dataType"
type="select"
:value="row.dataType"
:key="row.dataType"
></Dictionary>
</template>
<template slot-scope="{ row, index }" slot="unitName">
<Dictionary
v-if="row.dataType == 1 || row.dataType == 2"
@on-change="setRow(row, index)"
v-model="row.unitName"
code="material.main.unitName"
type="select"
placeholder="请选择单位"
:value="row.unitName"
:key="row.unitName"
></Dictionary>
</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">
<a
@click="remove(index, row)"
style="color: #ff7a8b"
v-if="row.fieldType > 1"
>删除</a
>
</template>
</Table>
<Button type="dashed" long @click="addNew" class="mt10"
>新增属性</Button
>
</Col>
<Col :span="24" class="tr mt10">
<FormItem>
<Button type="primary" @click="handleSubmit" :disabled="disabled">保存</Button>
<Button @click="handleClose" class="ml20">取消</Button> <Button @click="handleClose" class="ml20">取消</Button>
</FormItem> </FormItem>
</Col>
</Row>
</Form> </Form>
</template> </template>
<script> <script>
...@@ -137,6 +226,128 @@ export default { ...@@ -137,6 +226,128 @@ export default {
name: "Add", name: "Add",
data() { data() {
return { return {
codeList: [],
checkList: [
{
field: "code",
title: "编号",
note: "",
dataType: 0,
unitName: "",
required: false,
isunique: false,
fieldType: 1,
categoryId: 0,
action: 1,
add: 0, //新增标识
},
{
field: "version",
title: "版本",
note: "",
dataType: 0,
unitName: "",
required: true,
isunique: false,
fieldType: 1,
categoryId: 0,
action: 1,
add: 0, //新增标识
},
{
field: "secret",
title: "密级",
note: "",
dataType: 3,
unitName: "",
required: true,
isunique: false,
fieldType: 1,
categoryId: 0,
action: 1,
add: 0, //新增标识
},
{
field: "name",
title: "标题",
note: "",
dataType: 0,
unitName: "",
required: true,
isunique: false,
fieldType: 1, //共有属性(不能删除)
categoryId: 0,
action: 1,
add: 0, //新增标识
},
{
field: "description",
title: "文档详细说明",
note: "",
dataType: 8,
unitName: "",
required: true,
isunique: false,
fieldType: 1, //共有属性(不能删除)
categoryId: 0,
action: 1,
add: 0, //新增标识
},
],
columns: [
{
title: "序号",
type: "index",
width: 80,
align: "center",
},
{
title: "属性名称",
key: "title",
slot: "title",
},
{
title: "属性类型",
key: "dataType",
align: "center",
slot: "dataType",
width: 200,
},
{
title: "设置",
key: "note",
align: "center",
slot: "note",
},
{
title: "单位",
key: "unitName",
align: "center",
slot: "unitName",
width: "150",
},
{
title: "必填",
key: "required",
align: "center",
slot: "required",
width: 80,
},
{
title: "唯一",
key: "isUnique",
align: "center",
slot: "isUnique",
width: 80,
},
{
width: 80,
title: "操作",
slot: "action",
align: "center",
},
],
inherit: this.eid ? "1" : "0",
disabled: false, disabled: false,
entity: { entity: {
// creationTime: null, // creationTime: null,
...@@ -155,7 +366,7 @@ export default { ...@@ -155,7 +366,7 @@ export default {
englishName: "", englishName: "",
status: null, status: null,
description: "", description: "",
content: "", content: [],
inheritCategoryId: null, inheritCategoryId: null,
code: "", code: "",
module: "", module: "",
...@@ -177,10 +388,48 @@ export default { ...@@ -177,10 +388,48 @@ export default {
} }
}, },
methods: { methods: {
remove(index, row) {
if (row.add == 0) {
//新增的删除,直接删
this.checkList.splice(index, 1);
} else {
row.action = 2; //返回的默认删除,删除后保存在arr数组中,添加标识action = 2,然后点击保存的时候,一起传给后台
this.$set(this.checkList, index, row);
this.arr.push(row);
this.checkList.splice(index, 1);
}
},
setRow(row, index) {
this.$set(this.checkList, index, row);
},
addNew() {
let maxId = 0;
this.checkList.map((u) => {
if (u.mid > maxId) {
maxId = u.mid;
}
});
let obj = {
mid: maxId + 1,
field: "c" + maxId,
title: "",
note: "",
unitName: "",
dataType: 0,
required: false,
isunique: false,
fieldType: 3,
categoryId: 0,
action: 1,
add: 0, //新增标识
};
this.checkList.push(obj);
},
handleSubmit() { handleSubmit() {
this.$refs.form.validate((v) => { this.$refs.form.validate((v) => {
if (v) { if (v) {
this.disabled = true; this.disabled = true;
this.entity.content=JSON.stringify(this.checkList);
Api.create(this.entity) Api.create(this.entity)
.then((r) => { .then((r) => {
this.disabled = false; this.disabled = false;
......
...@@ -52,14 +52,16 @@ ...@@ -52,14 +52,16 @@
<Input v-model="entity.level"> </Input> </FormItem <Input v-model="entity.level"> </Input> </FormItem
></Col> ></Col>
<Col :span="12" <Col :span="12">
>
<!-- <FormItem :label="l('type')" prop="type"> <!-- <FormItem :label="l('type')" prop="type">
<Input v-model="entity.type"> </Input> </FormItem <Input v-model="entity.type"> </Input> </FormItem
> --> > -->
<FormItem :label="l('type')" prop="type"> <FormItem :label="l('type')" prop="type">
<Dictionary code="base.project_atom.type" v-model="entity.type" ></Dictionary> <Dictionary
</FormItem > code="base.project_atom.type"
v-model="entity.type"
></Dictionary>
</FormItem>
</Col> </Col>
<Col :span="12" <Col :span="12"
><FormItem :label="l('englishFullName')" prop="englishFullName"> ><FormItem :label="l('englishFullName')" prop="englishFullName">
...@@ -69,20 +71,22 @@ ...@@ -69,20 +71,22 @@
><FormItem :label="l('englishName')" prop="englishName"> ><FormItem :label="l('englishName')" prop="englishName">
<Input v-model="entity.englishName"> </Input> </FormItem <Input v-model="entity.englishName"> </Input> </FormItem
></Col> ></Col>
<Col :span="12" <Col :span="12">
>
<!-- <FormItem :label="l('status')" prop="status"> <!-- <FormItem :label="l('status')" prop="status">
<Input v-model="entity.status"> </Input> </FormItem <Input v-model="entity.status"> </Input> </FormItem
> --> > -->
<FormItem :label="l('status')" prop="status"> <FormItem :label="l('status')" prop="status">
<Dictionary code="base.project_atom.status" v-model="entity.status" ></Dictionary> <Dictionary
</FormItem > code="base.project_atom.status"
v-model="entity.status"
></Dictionary>
</FormItem>
</Col> </Col>
<Col :span="12" <!-- <Col :span="12"
><FormItem :label="l('content')" prop="content"> ><FormItem :label="l('content')" prop="content">
<Input v-model="entity.content"> </Input> </FormItem <Input v-model="entity.content"> </Input> </FormItem
></Col> ></Col> -->
<Col :span="12" <Col :span="12"
><FormItem :label="l('code')" prop="code"> ><FormItem :label="l('code')" prop="code">
<Input v-model="entity.code"> </Input> </FormItem <Input v-model="entity.code"> </Input> </FormItem
...@@ -122,6 +126,95 @@ ...@@ -122,6 +126,95 @@
:rows="5" :rows="5"
></Input> </FormItem ></Input> </FormItem
></Col> ></Col>
<Col :span="12" v-if="eid != 0">
<FormItem label="扩展属性" prop="inheritCategoryId">
<!-- <Checkbox v-model="entity.inheritCategoryId"></Checkbox> -->
<RadioGroup v-model="inherit">
<Radio label="1">继承</Radio>
<Radio label="0">自定义</Radio>
</RadioGroup>
</FormItem>
</Col>
<Col :span="24" v-if="inherit == '0'">
<Divider orientation="left">扩展属性</Divider>
<Table :columns="columns" :data="checkList" border>
<template slot-scope="{ row, index }" slot="title">
<div v-if="row.fieldType == 1 || row.fieldType == 2">
{{ row.title }}
</div>
<Input
v-model="row.title"
placeholder="请输入名称"
@on-blur="setRow(row, index)"
v-if="row.fieldType == 3"
/>
</template>
<template slot-scope="{ row, index }" slot="note">
<!-- <Input v-if="row.dataType==3" v-model="row.note" placeholder="请输入字典编码" @on-blur="setRow(row,index)" /> -->
<Select
v-if="row.dataType == 3"
v-model="row.note"
clearable
transfer
@on-change="setRow(row, index)"
>
<Option
v-for="item in codeList"
:value="item.code"
:key="item.code"
>{{ item.name }}</Option
>
</Select>
<span v-else>{{ row.note }}</span>
</template>
<template slot-scope="{ row, index }" slot="dataType">
<Dictionary
@on-change="setRow(row, index)"
v-model="row.dataType"
code="materail.category.dataType"
type="select"
:value="row.dataType"
:key="row.dataType"
></Dictionary>
</template>
<template slot-scope="{ row, index }" slot="unitName">
<Dictionary
v-if="row.dataType == 1 || row.dataType == 2"
@on-change="setRow(row, index)"
v-model="row.unitName"
code="material.main.unitName"
type="select"
placeholder="请选择单位"
:value="row.unitName"
:key="row.unitName"
></Dictionary>
</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">
<a
@click="remove(index, row)"
style="color: #ff7a8b"
v-if="row.fieldType > 1"
>删除</a
>
</template>
</Table>
<Button type="dashed" long @click="addNew" class="mt10"
>新增属性</Button
>
</Col>
</Row> </Row>
<FormItem> <FormItem>
<Button type="primary" @click="handleSubmit" :disabled="disabled" <Button type="primary" @click="handleSubmit" :disabled="disabled"
...@@ -137,6 +230,128 @@ export default { ...@@ -137,6 +230,128 @@ export default {
name: "Edit", name: "Edit",
data() { data() {
return { return {
codeList: [],
checkList: [
{
field: "code",
title: "编号",
note: "",
dataType: 0,
unitName: "",
required: false,
isunique: false,
fieldType: 1,
categoryId: 0,
action: 1,
add: 0, //新增标识
},
{
field: "version",
title: "版本",
note: "",
dataType: 0,
unitName: "",
required: true,
isunique: false,
fieldType: 1,
categoryId: 0,
action: 1,
add: 0, //新增标识
},
{
field: "secret",
title: "密级",
note: "",
dataType: 3,
unitName: "",
required: true,
isunique: false,
fieldType: 1,
categoryId: 0,
action: 1,
add: 0, //新增标识
},
{
field: "name",
title: "标题",
note: "",
dataType: 0,
unitName: "",
required: true,
isunique: false,
fieldType: 1, //共有属性(不能删除)
categoryId: 0,
action: 1,
add: 0, //新增标识
},
{
field: "description",
title: "文档详细说明",
note: "",
dataType: 8,
unitName: "",
required: true,
isunique: false,
fieldType: 1, //共有属性(不能删除)
categoryId: 0,
action: 1,
add: 0, //新增标识
},
],
columns: [
{
title: "序号",
type: "index",
width: 80,
align: "center",
},
{
title: "属性名称",
key: "title",
slot: "title",
},
{
title: "属性类型",
key: "dataType",
align: "center",
slot: "dataType",
width: 200,
},
{
title: "设置",
key: "note",
align: "center",
slot: "note",
},
{
title: "单位",
key: "unitName",
align: "center",
slot: "unitName",
width: "150",
},
{
title: "必填",
key: "required",
align: "center",
slot: "required",
width: 80,
},
{
title: "唯一",
key: "isUnique",
align: "center",
slot: "isUnique",
width: 80,
},
{
width: 80,
title: "操作",
slot: "action",
align: "center",
},
],
inherit: this.eid ? "1" : "0",
disabled: false, disabled: false,
entity: {}, entity: {},
rules: { rules: {
...@@ -153,6 +368,43 @@ export default { ...@@ -153,6 +368,43 @@ export default {
} }
}, },
methods: { methods: {
remove(index, row) {
if (row.add == 0) {
//新增的删除,直接删
this.checkList.splice(index, 1);
} else {
row.action = 2; //返回的默认删除,删除后保存在arr数组中,添加标识action = 2,然后点击保存的时候,一起传给后台
this.$set(this.checkList, index, row);
this.arr.push(row);
this.checkList.splice(index, 1);
}
},
setRow(row, index) {
this.$set(this.checkList, index, row);
},
addNew() {
let maxId = 0;
this.checkList.map((u) => {
if (u.mid > maxId) {
maxId = u.mid;
}
});
let obj = {
mid: maxId + 1,
field: "c" + maxId,
title: "",
note: "",
unitName: "",
dataType: 0,
required: false,
isunique: false,
fieldType: 3,
categoryId: 0,
action: 1,
add: 0, //新增标识
};
this.checkList.push(obj);
},
load(v) { load(v) {
Api.get({ id: v }).then((r) => { Api.get({ id: v }).then((r) => {
this.entity = r.result; this.entity = r.result;
......
...@@ -52,9 +52,6 @@ ...@@ -52,9 +52,6 @@
<Input v-model="entity.code"> </Input> </FormItem <Input v-model="entity.code"> </Input> </FormItem
></Col> ></Col>
<Col :span="12"> <Col :span="12">
<!-- <FormItem :label="l('type')" prop="type">
<Input v-model="entity.type"> </Input> </FormItem
> -->
<FormItem :label="l('type')" prop="type"> <FormItem :label="l('type')" prop="type">
<Dictionary code="base.project.type" v-model="entity.type" ></Dictionary> <Dictionary code="base.project.type" v-model="entity.type" ></Dictionary>
</FormItem> </FormItem>
...@@ -71,10 +68,8 @@ ...@@ -71,10 +68,8 @@
><FormItem :label="l('englishName')" prop="englishName"> ><FormItem :label="l('englishName')" prop="englishName">
<Input v-model="entity.englishName"> </Input> </FormItem <Input v-model="entity.englishName"> </Input> </FormItem
></Col> ></Col>
<Col :span="12"> <Col :span="12"
<!-- <FormItem :label="l('status')" prop="status"> >
<Input v-model="entity.status"> </Input> </FormItem
> -->
<FormItem :label="l('status')" prop="status"> <FormItem :label="l('status')" prop="status">
<Dictionary code="base.project.status" v-model="entity.status" ></Dictionary> <Dictionary code="base.project.status" v-model="entity.status" ></Dictionary>
</FormItem> </FormItem>
......
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