Commit 9b6cb7dd authored by 周远喜's avatar 周远喜

动态表单

parent 7667d67e
<template>
<div>
<span v-if="type=='date'">{{value.substr(0,10)}}</span>
<span v-if="type=='date'">
<Tooltip :content="value">
{{value.substr(0,10)}}
</Tooltip>
</span>
<span v-else>{{value.substr(0,19)}}</span>
</div>
</template>
......
......@@ -177,7 +177,7 @@ export default {
async fetch({ store, params }) {
await store.dispatch("loadDictionary"); // 加载数据字典
},
mounted() {
created() {
this.tableData();
},
methods: {
......
......@@ -52,9 +52,9 @@
<Input v-if="li.dataType==8" type="textarea" v-model="entity[li.field]" ></Input>
</FormItem>
</Col>
<Col :span="24">
<!-- <Col :span="24">
<div v-html="entity"></div>
</Col>
</Col> -->
<Col :span="24" style="text-align: right;">
<FormItem>
<Button type="primary" @click="handleSubmit" :disabled="disabled">保存</Button>
......
......@@ -32,13 +32,34 @@
<FormItem label="描述" prop="description">
<Input v-model="entity.description" type="textarea" placeholder="请输入..."></Input>
</FormItem>
</Col>
</Row>
<div>
<h4>扩展属性</h4>
</div>
<Row>
<Col v-for="li in fileds" :key="li.field" :span="li.span">
<FormItem :label="li.title" :prop="li.name">
<Input v-if="li.dataType==0" v-model="entity[li.field]" ></Input>
<InputNumber v-if="li.dataType==1||li.dataType==2" v-model="entity[li.field]" class="w100"></InputNumber>
<Dictionary v-if="li.dataType==3" v-model="entity[li.field]" :code="li.note"></Dictionary>
<Input v-if="li.dataType==4" v-model="entity[li.filed]" ></Input>
<DatePicker v-if="li.dataType==5" v-model="entity[li.field]" type="date" :placeholder="'选择'+li.title" ></DatePicker>
<InputFile v-if="li.dataType==6" v-model="entity[li.field]" ></InputFile>
<!-- <files ref="refFile" :parms="parms" fileFormat :Photos="true" @clickItem="clickData" /> -->
<InputFile v-if="li.dataType==7" v-model="entity[li.field]" ></InputFile>
<Input v-if="li.dataType==8" type="textarea" v-model="entity[li.field]" ></Input>
</FormItem>
</Col>
<!-- <Col :span="24">
<div v-html="entity"></div>
</Col> -->
<Col :span="24" style="text-align: right;">
<FormItem>
<Button type="primary" @click="handleSubmit" :disabled="disabled">保存</Button>
<Button @click="handleClose" class="ml20">取消</Button>
</FormItem>
</Col>
</Col>
</Row>
</Form>
</div>
......@@ -53,11 +74,11 @@ export default {
entity: {
id: this.eid,
code: 0,
codeRuleId:this.nodeInfo.codeRuleId,
categoryId: this.nodeInfo.categoryId, //左侧树点击的id
customProperties: {},
rootCategoryId: this.nodeInfo.rootCategoryId //左侧树点击的数据的最顶层id
},
checkList: [],
disabled: false,
rules: {
name: [{ required: true, message: "必填", trigger: "blur" }]
......@@ -67,10 +88,43 @@ export default {
async fetch({ store, params }) {
await store.dispatch("loadDictionary"); // 加载数据字典
},
created() {
this.initFiled();
},
mounted() {
this.get();
},
methods: {
initFiled() {
let conditions = [
{
conditionalType: "Equal",
fieldName: "categoryId",
fieldValue: this.nodeInfo.rootCategoryId
}
];
Api.listTable({ conditions: conditions ,sortBy:'id',isDesc:false}).then(r => {
if (r.result) {
this.fileds = r.result.filter(function(item) {
item.span=12;
if(item.dataType>4){
item.span=24
}
delete item["id"];
return item.fieldType!=1;
});
this.fileds.map(u=>{
let v='';
if(u.dataType==1||u.dataType==2){
v=0;
}
// this.$set(this.entity.customProperties,u.filed,v)
this.$set(this.entity,u.filed,v)
})
}
});
},
get() {
Api.get({ id: this.eid }).then(r => {
if (r.result) {
......@@ -78,7 +132,35 @@ export default {
}
});
},
tableData() {
let conditions = [
{
conditionalType: "In",
fieldName: "fieldType",
fieldValue: "1,2"
},
{
conditionalType: "Equal",
fieldName: "categoryId",
fieldValue: "0"
}
];
Api.listTable({
conditions: conditions,
sortBy: "id",
isDesc: false
}).then(r => {
if (r.result) {
var arr = r.result;
this.checkList = arr.filter(function(item) {
item.mid=item.id;
delete item["id"]; //删除属性id
return item;
});
}
});
},
remove(index, row) {
// if (row.add == 0) {
......
......@@ -141,7 +141,8 @@ export default {
key: "creationTime",
title: "创建时间",
hide:false,
align: "left"
align: "left",
type:"date"
},
{
key: "creatorUserId",
......
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