This commit is contained in:
g7hoo 2022-08-10 17:01:51 +08:00
parent c435901f3b
commit c1e152405d
2 changed files with 14 additions and 20 deletions

View File

@ -58,7 +58,14 @@
/> />
<div v-else style="background: #eee; border-radius: 8px; height: 200px;"> <div v-else style="background: #eee; border-radius: 8px; height: 200px;">
<el-row> <el-row>
<el-form ref="AttrForm" :model="AttrForm" :rules="AttrFormRules"></el-form> <el-form ref="AttrForm" :model="AttrForm" :rules="AttrFormRules">
<el-form-item v-for="field in attrFormFields" :key="field.prop" :prop="field.prop" :label="field.name">
<!-- 子窗口只给input吧太麻烦了有特殊需求就不用这个组件了 -->
<el-input v-model="AttrForm[field.prop]" clearable />
<!-- TODO: mounted里初始化AttrFormconfigs里设置AttrFormRulesmounted里设置attrFormFields -->
<!-- TODO: 单独用一个组件来展示动态属性这一部分 -->
</el-form-item>
</el-form>
</el-row> </el-row>
<el-row> <el-row>
<el-button size="small" @click="showAddAttr = false">取消</el-button> <el-button size="small" @click="showAddAttr = false">取消</el-button>
@ -122,6 +129,7 @@ export default {
props: { props: {
configs: { configs: {
/** /**
* TODO: 定义及使用方式应改用README.md文件记录
* type: 'dialog' | 'drawer' | 'page' * type: 'dialog' | 'drawer' | 'page'
* fields: Array<string|object> * fields: Array<string|object>
* - fields.object: { name, type: 'number'|'textarea'|'select'|'date'|.., required: boolean, validator: boolean(是否需要验证), [options]: any[], api: string(自动获取数据的接口一般为getcode接口)} * - fields.object: { name, type: 'number'|'textarea'|'select'|'date'|.., required: boolean, validator: boolean(是否需要验证), [options]: any[], api: string(自动获取数据的接口一般为getcode接口)}
@ -162,6 +170,7 @@ export default {
}, },
defaultPlaceholders: {}, // defaultNames defaultPlaceholders: {}, // defaultNames
/** 表单相关属性 */ /** 表单相关属性 */
visible: false, visible: false,
isEdit: false, isEdit: false,
isDetail: false, isDetail: false,
@ -254,27 +263,12 @@ export default {
/** 单独设置 id */ /** 单独设置 id */
this.$set(this.dataForm, 'id', null) this.$set(this.dataForm, 'id', null)
// TODOdelete next lines
console.log('dataform: ', this.dataForm)
console.log('rules: ', this.dataFormRules)
}) })
}, },
updated() { updated() {
this.isUpdated = true // emit(refreshDataList) this.isUpdated = true // emit(refreshDataList)
}, },
// beforeDestroy() {
//
// localStoragedataForm
// emit
//
// localStorage
// if (cached && compareCache(this.dataForm, localStorage...) || !isEdit) {
// // emit
// clearCache()
// this.$emit('refreshDataList')
// }
// },
methods: { methods: {
getLabel(n, c) { getLabel(n, c) {
const opt = this.configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)] const opt = this.configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)]

View File

@ -161,8 +161,8 @@ const addOrUpdateConfigs = {
tableConfigs: [ tableConfigs: [
{ type: 'index', name: '序号' }, { type: 'index', name: '序号' },
{ prop: 'createTime', name: '添加时间', filter: val => (val ? moment(val).format('YYYY-MM-DD hh:mm:ss') : '-') }, { prop: 'createTime', name: '添加时间', filter: val => (val ? moment(val).format('YYYY-MM-DD hh:mm:ss') : '-') },
{ prop: 'name', name: '属性名' }, { prop: 'name', name: '属性名', formField: true },
{ prop: 'code', name: '属性值' }, { prop: 'code', name: '属性值', formField: true },
{ prop: 'operations', name: '操作', fixed: 'right', width: 180, subcomponent: TableOperateComponent, options: ['edit', 'delete'] } { prop: 'operations', name: '操作', fixed: 'right', width: 180, subcomponent: TableOperateComponent, options: ['edit', 'delete'] }
] ]
} }