Browse Source

内容管理-05070225

master
代震 4 years ago
parent
commit
0385a6f1db
  1. 57
      src/views/content/content-edit.vue
  2. 17
      src/views/content/content-list.vue
  3. 1
      src/views/content/create_form.js

57
src/views/content/content-edit.vue

@ -1,9 +1,9 @@
<!-- 用户编辑弹窗 -->
<template>
<el-dialog :title="isUpdate?'修改用户':'添加用户'" :visible="visible" width="88%" :destroy-on-close="true" :lock-scroll="false"
<el-dialog :title="isUpdate?'编辑':'添加'" :visible="visible" width="80%" :destroy-on-close="true" :lock-scroll="false"
custom-class="ele-dialog-form" @update:visible="updateVisible">
<!-- <p>formData: {{dig_value}}</p> -->
<form-create v-model="dig_form" :rule="dig_rule" :option="dig_option" :value.sync="dig_value"></form-create>
<form-create v-model="dig_form" :rule="edit_rule" :option="dig_option"></form-create>
</el-dialog>
</template>
@ -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: {
/* 下拉树组件格式化数据 */

17
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 {
// code0code: 2000
@ -207,7 +196,7 @@ export default {
} else {
this.current = null;
}
console.log(this.current)
// console.log(this.current)
this.showEdit = true;
},
/* 删除 */

1
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 = {};

Loading…
Cancel
Save