|
@@ -71,7 +71,7 @@
|
|
|
:wrapperCol="BaseTool.Constant.wrapperCol"
|
|
|
>
|
|
|
<a-input
|
|
|
- v-decorator="['rows']"/>
|
|
|
+ v-decorator="['rows', {rules: [{required: true, message: '不能为空'}]}]"/>
|
|
|
</a-form-item>
|
|
|
</row-item>
|
|
|
<row-item>
|
|
@@ -81,7 +81,7 @@
|
|
|
:wrapperCol="BaseTool.Constant.wrapperCol"
|
|
|
>
|
|
|
<a-input
|
|
|
- v-decorator="['sort']"/>
|
|
|
+ v-decorator="['sort', {rules: [{required: true, message: '不能为空'}]}]"/>
|
|
|
</a-form-item>
|
|
|
</row-item>
|
|
|
<row-item>
|
|
@@ -91,7 +91,7 @@
|
|
|
:wrapperCol="BaseTool.Constant.wrapperCol"
|
|
|
>
|
|
|
<a-input
|
|
|
- v-decorator="['minLength']"/>
|
|
|
+ v-decorator="['minLength', {rules: [{required: true, message: '不能为空'}]}]"/>
|
|
|
</a-form-item>
|
|
|
</row-item>
|
|
|
<row-item>
|
|
@@ -101,7 +101,7 @@
|
|
|
:wrapperCol="BaseTool.Constant.wrapperCol"
|
|
|
>
|
|
|
<a-input
|
|
|
- v-decorator="['maxLength']"/>
|
|
|
+ v-decorator="['maxLength', {rules: [{required: true, message: '不能为空'}]}]"/>
|
|
|
</a-form-item>
|
|
|
</row-item>
|
|
|
<row-item>
|
|
@@ -132,13 +132,13 @@
|
|
|
:data-source="data"
|
|
|
:columns="columns"
|
|
|
tableLayout="auto"
|
|
|
- rowKey="id"
|
|
|
+ rowKey="name"
|
|
|
:row-selection="rowSelection">
|
|
|
<span slot="action" slot-scope="record">
|
|
|
<template>
|
|
|
<a @click="handleOption(record)">修改</a>
|
|
|
<a-divider type="vertical" />
|
|
|
- <a-popconfirm title="是否要删除该条数据?" @confirm="handleDelOption(record.id)">
|
|
|
+ <a-popconfirm title="是否要删除该条数据?" @confirm="handleDelOption(record.name)">
|
|
|
<a>删除</a>
|
|
|
</a-popconfirm>
|
|
|
</template>
|
|
@@ -154,6 +154,8 @@
|
|
|
<script>
|
|
|
import OptionForm from './OptionForm'
|
|
|
import DetailList from '@/components/tools/DetailList'
|
|
|
+import pick from 'lodash.pick'
|
|
|
+import Vue from 'vue'
|
|
|
export default {
|
|
|
name: 'FieldTemplateOptionForm',
|
|
|
components: {
|
|
@@ -223,7 +225,22 @@ export default {
|
|
|
// 如果是空标识添加
|
|
|
this.modalTitle = '字段设置'
|
|
|
this.record = record
|
|
|
- this.data = record.optionList
|
|
|
+ this.data = record.optionList || []
|
|
|
+ const { form: { setFieldsValue } } = this
|
|
|
+ // 日期处理
|
|
|
+ this.$nextTick(() => {
|
|
|
+ setFieldsValue(Object.assign(pick(record, [
|
|
|
+ 'label',
|
|
|
+ 'fieldName',
|
|
|
+ 'type',
|
|
|
+ 'required',
|
|
|
+ 'sort',
|
|
|
+ 'rows',
|
|
|
+ 'minLength',
|
|
|
+ 'maxLength',
|
|
|
+ 'defaultValue'
|
|
|
+ ])))
|
|
|
+ })
|
|
|
},
|
|
|
save () {
|
|
|
const { form: { validateFieldsAndScroll } } = this
|
|
@@ -233,13 +250,14 @@ export default {
|
|
|
this.confirmLoading = false
|
|
|
return
|
|
|
}
|
|
|
- values.optionList = this.optionList
|
|
|
+ values.optionList = this.data
|
|
|
this.handleCancel(values)
|
|
|
})
|
|
|
},
|
|
|
handleCancel (values) {
|
|
|
this.visible = false
|
|
|
this.confirmLoading = false
|
|
|
+ this.data = []
|
|
|
this.form.resetFields()
|
|
|
console.log(values)
|
|
|
if (this.BaseTool.Object.isNotBlank(values)) {
|
|
@@ -257,15 +275,34 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
handleOptionList (values) {
|
|
|
- console.log(values)
|
|
|
- if (this.optionList == null) {
|
|
|
- this.optionList = []
|
|
|
+ let dataSource = [...this.data]
|
|
|
+ if (dataSource == null) {
|
|
|
+ dataSource = []
|
|
|
+ }
|
|
|
+ if (values.name == null || values.name === '') {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let find = false
|
|
|
+ console.log('data.length: ' + dataSource.length)
|
|
|
+ for (let j = 0; j < dataSource.length; j++) {
|
|
|
+ if (values.name === dataSource[j].name) {
|
|
|
+ find = true
|
|
|
+ this.data = dataSource.map(item => {
|
|
|
+ return item.name === values.name ? values : item
|
|
|
+ })
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!find) {
|
|
|
+ dataSource.push(values)
|
|
|
+ console.log('data.length: ' + dataSource.length)
|
|
|
+ this.data = dataSource
|
|
|
+ console.log('data.length: ' + this.data.length)
|
|
|
}
|
|
|
- this.optionList.push(values)
|
|
|
},
|
|
|
- handleDelOption (index) {
|
|
|
- console.log(index)
|
|
|
- this.optionList.splice(index, 1)
|
|
|
+ handleDelOption (name) {
|
|
|
+ const dataSource = [...this.data]
|
|
|
+ this.data = dataSource.filter(item => item.name !== name)
|
|
|
}
|
|
|
}
|
|
|
}
|