|
@@ -1,20 +1,12 @@
|
|
<template>
|
|
<template>
|
|
- <a-card
|
|
|
|
- :tab-list="tabList"
|
|
|
|
- size="small"
|
|
|
|
- style="min-height:600px"
|
|
|
|
- :active-tab-key="selectKey"
|
|
|
|
- @tabChange="onTabChange">
|
|
|
|
- <a-form
|
|
|
|
- v-show="model.id"
|
|
|
|
- size="small"
|
|
|
|
- v-if="selectKey === '0'">
|
|
|
|
|
|
+ <a-card :tab-list="tabList" size="small" style="min-height:600px" :active-tab-key="selectKey" @tabChange="onTabChange">
|
|
|
|
+ <a-form v-show="model.id" size="small" v-if="selectKey === '0'">
|
|
<a-form-item label="标题">
|
|
<a-form-item label="标题">
|
|
<a-input v-model="model.label" />
|
|
<a-input v-model="model.label" />
|
|
</a-form-item>
|
|
</a-form-item>
|
|
<template v-if="model.type!=='divider'">
|
|
<template v-if="model.type!=='divider'">
|
|
<a-form-item label="字段名称">
|
|
<a-form-item label="字段名称">
|
|
- <a-input v-model="model.value" />
|
|
|
|
|
|
+ <a-input v-model="model.value" @blur="valueChange" />
|
|
</a-form-item>
|
|
</a-form-item>
|
|
<a-form-item label="是否必填">
|
|
<a-form-item label="是否必填">
|
|
<a-switch v-model="model.required" />
|
|
<a-switch v-model="model.required" />
|
|
@@ -53,16 +45,8 @@
|
|
<!-- 下拉框 -->
|
|
<!-- 下拉框 -->
|
|
<template v-if="model.type === 'select'">
|
|
<template v-if="model.type === 'select'">
|
|
<a-form-item label="选项">
|
|
<a-form-item label="选项">
|
|
- <VueDraggable
|
|
|
|
- v-model="model.attrs.options"
|
|
|
|
- :animation="150"
|
|
|
|
- handle=".handle"
|
|
|
|
- >
|
|
|
|
- <div
|
|
|
|
- v-for="(item, index) in model.attrs.options"
|
|
|
|
- :key="index"
|
|
|
|
- class="options"
|
|
|
|
- >
|
|
|
|
|
|
+ <VueDraggable v-model="model.attrs.options" :animation="150" handle=".handle">
|
|
|
|
+ <div v-for="(item, index) in model.attrs.options" :key="index" class="options">
|
|
<a-space>
|
|
<a-space>
|
|
<a-icon class="handle cursor-move" type="unordered-list" />
|
|
<a-icon class="handle cursor-move" type="unordered-list" />
|
|
<a-input-group compact>
|
|
<a-input-group compact>
|
|
@@ -82,7 +66,7 @@
|
|
<a-switch v-model="model.attrs.showTime" />
|
|
<a-switch v-model="model.attrs.showTime" />
|
|
</a-form-item>
|
|
</a-form-item>
|
|
<a-form-item label="时间格式">
|
|
<a-form-item label="时间格式">
|
|
- <a-input placeholder="YYYY-MM-DD HH:mm:ss" v-model="model.attrs.format" ></a-input>
|
|
|
|
|
|
+ <a-input placeholder="YYYY-MM-DD HH:mm:ss" v-model="model.attrs.format"></a-input>
|
|
</a-form-item>
|
|
</a-form-item>
|
|
</template>
|
|
</template>
|
|
<!-- 上传 -->
|
|
<!-- 上传 -->
|
|
@@ -123,18 +107,11 @@
|
|
<a-button type="primary" @click="addForm()">添加到表单</a-button>
|
|
<a-button type="primary" @click="addForm()">添加到表单</a-button>
|
|
</a-form-item> -->
|
|
</a-form-item> -->
|
|
</template>
|
|
</template>
|
|
- <a-popconfirm
|
|
|
|
- title="确定删除该组件?"
|
|
|
|
- ok-text="确定"
|
|
|
|
- cancel-text="取消"
|
|
|
|
- @confirm="deleteModel"
|
|
|
|
- >
|
|
|
|
|
|
+ <a-popconfirm title="确定删除该组件?" ok-text="确定" cancel-text="取消" @confirm="deleteModel">
|
|
<a-button type="danger" style="width:100%">删除</a-button>
|
|
<a-button type="danger" style="width:100%">删除</a-button>
|
|
</a-popconfirm>
|
|
</a-popconfirm>
|
|
</a-form>
|
|
</a-form>
|
|
- <a-form
|
|
|
|
- size="small"
|
|
|
|
- v-if="selectKey === '1'">
|
|
|
|
|
|
+ <a-form size="small" v-if="selectKey === '1'">
|
|
<a-form-item label="布局">
|
|
<a-form-item label="布局">
|
|
<a-radio-group name="radioGroup" v-model="config.layout">
|
|
<a-radio-group name="radioGroup" v-model="config.layout">
|
|
<a-radio :value="1">
|
|
<a-radio :value="1">
|
|
@@ -154,105 +131,111 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
-
|
|
|
|
import { VueDraggable } from 'vue-draggable-plus'
|
|
import { VueDraggable } from 'vue-draggable-plus'
|
|
import { getTableInfos } from '@/api/custom/form'
|
|
import { getTableInfos } from '@/api/custom/form'
|
|
import BindTable from './BindTable.vue'
|
|
import BindTable from './BindTable.vue'
|
|
export default {
|
|
export default {
|
|
components: {
|
|
components: {
|
|
VueDraggable,
|
|
VueDraggable,
|
|
- BindTable
|
|
|
|
|
|
+ BindTable,
|
|
},
|
|
},
|
|
- data () {
|
|
|
|
|
|
+ data() {
|
|
return {
|
|
return {
|
|
model: {
|
|
model: {
|
|
attrs: {
|
|
attrs: {
|
|
- placeholder: ''
|
|
|
|
- }
|
|
|
|
|
|
+ placeholder: '',
|
|
|
|
+ },
|
|
},
|
|
},
|
|
config: {},
|
|
config: {},
|
|
selectKey: '0',
|
|
selectKey: '0',
|
|
tabList: [
|
|
tabList: [
|
|
{
|
|
{
|
|
key: '0',
|
|
key: '0',
|
|
- tab: '字段属性'
|
|
|
|
|
|
+ tab: '字段属性',
|
|
},
|
|
},
|
|
{
|
|
{
|
|
key: '1',
|
|
key: '1',
|
|
- tab: '表单属性'
|
|
|
|
- }
|
|
|
|
|
|
+ tab: '表单属性',
|
|
|
|
+ },
|
|
],
|
|
],
|
|
tableList: [],
|
|
tableList: [],
|
|
- additionalField: []
|
|
|
|
|
|
+ additionalField: [],
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- created () {
|
|
|
|
- },
|
|
|
|
|
|
+ created() {},
|
|
methods: {
|
|
methods: {
|
|
- base (val, config) {
|
|
|
|
|
|
+ base(val, config) {
|
|
this.model = val
|
|
this.model = val
|
|
this.config = config
|
|
this.config = config
|
|
if (this.model.attrs.dict !== undefined && this.model.attrs.dict !== '') {
|
|
if (this.model.attrs.dict !== undefined && this.model.attrs.dict !== '') {
|
|
this.dictChange(this.model.attrs.dict)
|
|
this.dictChange(this.model.attrs.dict)
|
|
}
|
|
}
|
|
- this.additionalField = val.attrs.connect && val.attrs.connect.length > 1 ? val.attrs.connect.slice(1, val.attrs.connect.length).map(item => item.columnName) : []
|
|
|
|
|
|
+ this.additionalField =
|
|
|
|
+ val.attrs.connect && val.attrs.connect.length > 1
|
|
|
|
+ ? val.attrs.connect.slice(1, val.attrs.connect.length).map((item) => item.columnName)
|
|
|
|
+ : []
|
|
},
|
|
},
|
|
- addOption () {
|
|
|
|
|
|
+ addOption() {
|
|
this.model.attrs.options.push({
|
|
this.model.attrs.options.push({
|
|
label: '选项' + (this.model.attrs.options.length + 1),
|
|
label: '选项' + (this.model.attrs.options.length + 1),
|
|
- value: 'newValue' + (this.model.attrs.options.length + 1)
|
|
|
|
|
|
+ value: 'newValue' + (this.model.attrs.options.length + 1),
|
|
})
|
|
})
|
|
},
|
|
},
|
|
- deleteOption (i) {
|
|
|
|
|
|
+ deleteOption(i) {
|
|
this.model.attrs.options.splice(i, 1)
|
|
this.model.attrs.options.splice(i, 1)
|
|
},
|
|
},
|
|
- deleteModel () {
|
|
|
|
|
|
+ deleteModel() {
|
|
this.$emit('delete', this.model)
|
|
this.$emit('delete', this.model)
|
|
},
|
|
},
|
|
- dictChange (tableName) {
|
|
|
|
- getTableInfos({ tableName }).then(res => {
|
|
|
|
|
|
+ dictChange(tableName) {
|
|
|
|
+ getTableInfos({ tableName }).then((res) => {
|
|
this.tableList = res.data
|
|
this.tableList = res.data
|
|
if (this.model.attrs.connect.length === 0) {
|
|
if (this.model.attrs.connect.length === 0) {
|
|
this.model.attrs.connect.push({
|
|
this.model.attrs.connect.push({
|
|
- bind: 'id',
|
|
|
|
|
|
+ bind: this.model.value,
|
|
columnName: 'id',
|
|
columnName: 'id',
|
|
- columnComment: 'id'
|
|
|
|
|
|
+ columnComment: 'id',
|
|
})
|
|
})
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
- selectTypeChange () {
|
|
|
|
|
|
+ valueChange() {
|
|
|
|
+ if (this.model.type === 'dataSelect' && this.model.attrs.connect.length > 0) {
|
|
|
|
+ this.model.attrs.connect[0].bind = this.model.value
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ selectTypeChange() {
|
|
this.model.attrs.connect.splice(1)
|
|
this.model.attrs.connect.splice(1)
|
|
this.additionalField = []
|
|
this.additionalField = []
|
|
},
|
|
},
|
|
- additionalFieldChange (val, e) {
|
|
|
|
- const arr = e.map(item => {
|
|
|
|
|
|
+ additionalFieldChange(val, e) {
|
|
|
|
+ const arr = e.map((item) => {
|
|
return {
|
|
return {
|
|
bind: item.key,
|
|
bind: item.key,
|
|
columnName: item.key,
|
|
columnName: item.key,
|
|
- columnComment: item.componentOptions.propsData.label
|
|
|
|
|
|
+ columnComment: item.componentOptions.propsData.label,
|
|
}
|
|
}
|
|
})
|
|
})
|
|
this.model.attrs.connect.splice(1, this.model.attrs.connect.length - 1, ...arr)
|
|
this.model.attrs.connect.splice(1, this.model.attrs.connect.length - 1, ...arr)
|
|
},
|
|
},
|
|
- addForm () {
|
|
|
|
|
|
+ addForm() {
|
|
this.$emit('addForm', this.model.attrs.connect.slice(1, this.model.attrs.connect.length))
|
|
this.$emit('addForm', this.model.attrs.connect.slice(1, this.model.attrs.connect.length))
|
|
},
|
|
},
|
|
- bindTable (tableName) {
|
|
|
|
|
|
+ bindTable(tableName) {
|
|
this.$refs.bindTable.base(this.tableList)
|
|
this.$refs.bindTable.base(this.tableList)
|
|
},
|
|
},
|
|
- handleBind (val) {
|
|
|
|
|
|
+ handleBind(val) {
|
|
this.model.attrs.connect = val
|
|
this.model.attrs.connect = val
|
|
},
|
|
},
|
|
- onTabChange (key) {
|
|
|
|
|
|
+ onTabChange(key) {
|
|
this.selectKey = key
|
|
this.selectKey = key
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+ },
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style lang="less" scoped>
|
|
<style lang="less" scoped>
|
|
-.options{
|
|
|
|
- margin-bottom:5px ;
|
|
|
|
|
|
+.options {
|
|
|
|
+ margin-bottom: 5px;
|
|
}
|
|
}
|
|
</style>
|
|
</style>
|