diff --git a/src/views/content/content-edit.vue b/src/views/content/content-edit.vue index 88fd3dc..fa064c1 100644 --- a/src/views/content/content-edit.vue +++ b/src/views/content/content-edit.vue @@ -1,9 +1,9 @@ @@ -19,7 +19,7 @@ import TinymceEditor from '@/components/TinymceEditor'; visible: Boolean, // 修改回显的数据 edit_data: Object, - // 表单配置 + // 表单配置 生成规则 edit_rule: Array }, data() { @@ -28,14 +28,10 @@ import TinymceEditor from '@/components/TinymceEditor'; loading: false, // 是否是修改 isUpdate: false, - // 角色列表 - roleList: [], // 实例对象 dig_form: {}, // 表单数据 dig_value: {}, - // 表单生成规则 - dig_rule: [], // 组件参数配置 dig_option: { form: { @@ -54,35 +50,22 @@ import TinymceEditor from '@/components/TinymceEditor'; } }, watch: { - edit_rule: { + visible: { handler(valNew) { - // console.log("生成数据规则") - this.dig_rule = valNew; - const _em = this - this.dig_option.onSubmit = () => { - _em.save() - } - }, - deep: true - }, - edit_data: { - handler(valNew) { - console.log(valNew !== null) - if (valNew !== null) { - if (valNew['cate_id'] !== undefined) { - valNew['cate_id'] = valNew['cate_id_str'] + this.$nextTick(() => { + if (valNew) { + for(let i in this.edit_data){ + let flag = Object.keys(this.dig_form.form).includes(i); + if (flag) { + this.dig_form.form[i] = this.edit_data[i] + } + } + this.isUpdate = true; + } else { + this.dig_form.resetFields() + this.isUpdate = false; } - // if (valNew['status'] === 1) { - // valNew['status'] = true - // } - this.dig_value = valNew - this.isUpdate = true; - } else { - // this.dig_value = {} - const fApi = this.dig_form - fApi.resetFields() - this.isUpdate = false; - } + }) }, deep: true } @@ -91,7 +74,11 @@ import TinymceEditor from '@/components/TinymceEditor'; formCreate.component('editor', TinymceEditor); }, mounted() { - // this.queryRoles(); // 查询角色列表 + console.log('表单已加载') + const _em = this + this.dig_option.onSubmit = () => { + _em.save() + } }, methods: { /* 下拉树组件格式化数据 */ diff --git a/src/views/content/content-list.vue b/src/views/content/content-list.vue index 64ca6c9..8e20269 100644 --- a/src/views/content/content-list.vue +++ b/src/views/content/content-list.vue @@ -111,13 +111,9 @@ export default { // 表格列配置 columns: [ { - columnKey: 'action', - fixed: 'right', - label: '操作', - width: 130, + columnKey: 'index', align: 'center', - resizable: false, - slot: 'action' + resizable: false } ], response: { @@ -142,7 +138,6 @@ export default { methods: { /* 获取数据 */ parseData(res) { - // console.log(res); let showList = res.data.field_info.list_fields; this.columns = [{ columnKey: 'action', @@ -171,20 +166,14 @@ export default { newObj.slot = 'image' } else if (ele.field === 'status') { newObj.slot = 'status' // status - // newObj.width = '75' } else if (ele.field === 'sort') { newObj.sortable = 'custom' - // newObj.width = '75' } this.columns.push(newObj) - // console.log(ele) } }) - // this.columns.push() - // console.log(this.columns) // console.log(res.data.content_data); // console.log(res.data.field_info.editFields); - // this.edit_rule = res.data.field_info.editFields; this.edit_rule = getForm(res.data.field_info.editFields); return { // 默认code为0是成功,比如接口code: 200是成功,可以这样改为0 @@ -207,7 +196,7 @@ export default { } else { this.current = null; } - console.log(this.current) + // console.log(this.current) this.showEdit = true; }, /* 删除 */ diff --git a/src/views/content/create_form.js b/src/views/content/create_form.js index 2c147a5..d21c300 100644 --- a/src/views/content/create_form.js +++ b/src/views/content/create_form.js @@ -2,7 +2,6 @@ import setting from "@/config/setting"; export function getForm(valNew) { - console.log(valNew) const rule = [] for (let e of valNew) { let eItem = {};