forked from mt-fe-group/mt-yd-ui
update
This commit is contained in:
parent
174e5efae5
commit
c435901f3b
@ -45,8 +45,9 @@
|
|||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<template v-if="dataForm.id && configs.subtable">
|
<template v-if="dataForm.id && configs.subtable">
|
||||||
<h3>{{ configs.subtable.title }}</h3>
|
<h3>{{ configs.subtable.title }} <el-button style="margin-left: 8px;" type="text" @click="showAddAttr = true">添加</el-button></h3>
|
||||||
<component
|
<component
|
||||||
|
v-if="!showAddAttr"
|
||||||
key="sub-table"
|
key="sub-table"
|
||||||
:is="require('../../base-table/index.vue').default"
|
:is="require('../../base-table/index.vue').default"
|
||||||
:table-head-configs="configs.subtable.tableConfigs"
|
:table-head-configs="configs.subtable.tableConfigs"
|
||||||
@ -54,14 +55,26 @@
|
|||||||
:max-height="500"
|
:max-height="500"
|
||||||
@operate-event="handleOperations"
|
@operate-event="handleOperations"
|
||||||
@refreshDataList="getDataList"
|
@refreshDataList="getDataList"
|
||||||
></component>
|
/>
|
||||||
|
<div v-else style="background: #eee; border-radius: 8px; height: 200px;">
|
||||||
|
<el-row>
|
||||||
|
<el-form ref="AttrForm" :model="AttrForm" :rules="AttrFormRules"></el-form>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-button size="small" @click="showAddAttr = false">取消</el-button>
|
||||||
|
<el-button type="primary" size="small" @click="handleSaveAttrForm">保存</el-button>
|
||||||
|
</el-row>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
<span slot="footer" class="dialog-footer">
|
<span slot="footer" class="dialog-footer">
|
||||||
<template v-for="(operate, index) in configs.operations">
|
<template v-for="(operate, index) in configs.operations">
|
||||||
<!-- {{ operate.name | btnNameFilter }} -->
|
<!-- {{ operate.name | btnNameFilter }} -->
|
||||||
<el-button
|
<el-button
|
||||||
v-if="(operate.showAlways || ((dataForm.id && operate.showOnEdit) || (!dataForm.id && !operate.showOnEdit)) && (operate.permission ? $hasPermission(operate.permission) : true))"
|
v-if="
|
||||||
|
operate.showAlways ||
|
||||||
|
(((dataForm.id && operate.showOnEdit) || (!dataForm.id && !operate.showOnEdit)) && (operate.permission ? $hasPermission(operate.permission) : true))
|
||||||
|
"
|
||||||
:key="`operate-${index}`"
|
:key="`operate-${index}`"
|
||||||
:type="btnType[operate.name]"
|
:type="btnType[operate.name]"
|
||||||
@click="handleClick(operate)"
|
@click="handleClick(operate)"
|
||||||
@ -137,16 +150,9 @@ export default {
|
|||||||
return {
|
return {
|
||||||
COLUMN_PER_ROW,
|
COLUMN_PER_ROW,
|
||||||
title,
|
title,
|
||||||
|
/** 按钮相关属性 */
|
||||||
btnName,
|
btnName,
|
||||||
btnType,
|
btnType,
|
||||||
visible: false,
|
|
||||||
isEdit: false,
|
|
||||||
isDetail: false,
|
|
||||||
// cached: false // 不采用缓存比较的方案了,采用 updated 方案: 如果更新了dataForm就在 confirm 时 emit(refreshDataList)
|
|
||||||
isUpdated: false,
|
|
||||||
dataForm: {},
|
|
||||||
subtableDataList: [],
|
|
||||||
dataFormRules: {},
|
|
||||||
defaultNames: {
|
defaultNames: {
|
||||||
name: '名称',
|
name: '名称',
|
||||||
code: '编码',
|
code: '编码',
|
||||||
@ -154,7 +160,19 @@ export default {
|
|||||||
specifications: '规格'
|
specifications: '规格'
|
||||||
// add more...
|
// add more...
|
||||||
},
|
},
|
||||||
defaultPlaceholders: {} // 自动根据 defaultNames 计算得来
|
defaultPlaceholders: {}, // 自动根据 defaultNames 计算得来
|
||||||
|
/** 表单相关属性 */
|
||||||
|
visible: false,
|
||||||
|
isEdit: false,
|
||||||
|
isDetail: false,
|
||||||
|
isUpdated: false,
|
||||||
|
dataForm: {},
|
||||||
|
dataFormRules: {},
|
||||||
|
/** 子列表相关属性 */
|
||||||
|
subtableDataList: [],
|
||||||
|
showAddAttr: false,
|
||||||
|
AttrForm: {},
|
||||||
|
AttrFormRules: {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -164,8 +182,6 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
/** 视情况动态加载table组件 */
|
|
||||||
|
|
||||||
/** 计算 defaultPlaceholders */
|
/** 计算 defaultPlaceholders */
|
||||||
const prefix = '请输入'
|
const prefix = '请输入'
|
||||||
Object.entries(this.defaultNames).map(([key, value]) => {
|
Object.entries(this.defaultNames).map(([key, value]) => {
|
||||||
@ -295,20 +311,13 @@ export default {
|
|||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs['dataForm'].resetFields()
|
this.$refs['dataForm'].resetFields()
|
||||||
this.dataForm.id = id || null
|
this.dataForm.id = id || null
|
||||||
console.log('dataform ===> ', this.dataForm)
|
|
||||||
|
|
||||||
if (this.dataForm.id) {
|
if (this.dataForm.id) {
|
||||||
console.log('here...')
|
|
||||||
this.$http({
|
this.$http({
|
||||||
url: this.$http.adornUrl(`${this.configs.infoUrl}/${this.dataForm.id}`),
|
url: this.$http.adornUrl(`${this.configs.infoUrl}/${this.dataForm.id}`),
|
||||||
method: 'get'
|
method: 'get'
|
||||||
}).then(({ data: res }) => {
|
}).then(({ data: res }) => {
|
||||||
if (res && res.code === 0) {
|
if (res && res.code === 0) {
|
||||||
const dataFormKeys = Object.keys(this.dataForm)
|
const dataFormKeys = Object.keys(this.dataForm)
|
||||||
console.log('keys: ', dataFormKeys)
|
|
||||||
console.log('resdata: ', res.data)
|
|
||||||
console.log('pick: ', pick)
|
|
||||||
console.log('after pick data: ', pick(res.data, dataFormKeys))
|
|
||||||
this.dataForm = pick(res.data, dataFormKeys)
|
this.dataForm = pick(res.data, dataFormKeys)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -360,7 +369,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case 'cancel':
|
case 'cancel':
|
||||||
this.visible = false
|
this.visible = false
|
||||||
// add more..
|
// add more..
|
||||||
}
|
}
|
||||||
@ -370,6 +379,8 @@ export default {
|
|||||||
|
|
||||||
getDataList() {},
|
getDataList() {},
|
||||||
|
|
||||||
|
handleSaveAttrForm() {},
|
||||||
|
|
||||||
handleClose() {
|
handleClose() {
|
||||||
if (this.isAdd || this.isUpdated) this.$emit('refreshDataList')
|
if (this.isAdd || this.isUpdated) this.$emit('refreshDataList')
|
||||||
this.visible = false
|
this.visible = false
|
||||||
|
@ -156,13 +156,14 @@ const addOrUpdateConfigs = {
|
|||||||
],
|
],
|
||||||
subtable: {
|
subtable: {
|
||||||
// for i18n
|
// for i18n
|
||||||
title: '动态添加属性',
|
title: '动态属性',
|
||||||
url: '',
|
url: '/monitoring/productArrt/page',
|
||||||
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: '属性名' },
|
||||||
{ prop: 'code', name: '属性值' }
|
{ prop: 'code', name: '属性值' },
|
||||||
|
{ prop: 'operations', name: '操作', fixed: 'right', width: 180, subcomponent: TableOperateComponent, options: ['edit', 'delete'] }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
// extraComponents: [
|
// extraComponents: [
|
||||||
|
Loading…
Reference in New Issue
Block a user