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> <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"> custom-class="ele-dialog-form" @update:visible="updateVisible">
<!-- <p>formData: {{dig_value}}</p> --> <!-- <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> </el-dialog>
</template> </template>
@ -19,7 +19,7 @@ import TinymceEditor from '@/components/TinymceEditor';
visible: Boolean, visible: Boolean,
// //
edit_data: Object, edit_data: Object,
// //
edit_rule: Array edit_rule: Array
}, },
data() { data() {
@ -28,14 +28,10 @@ import TinymceEditor from '@/components/TinymceEditor';
loading: false, loading: false,
// //
isUpdate: false, isUpdate: false,
//
roleList: [],
// //
dig_form: {}, dig_form: {},
// //
dig_value: {}, dig_value: {},
//
dig_rule: [],
// //
dig_option: { dig_option: {
form: { form: {
@ -54,35 +50,22 @@ import TinymceEditor from '@/components/TinymceEditor';
} }
}, },
watch: { watch: {
edit_rule: { visible: {
handler(valNew) { handler(valNew) {
// console.log("") this.$nextTick(() => {
this.dig_rule = valNew; if (valNew) {
const _em = this for(let i in this.edit_data){
this.dig_option.onSubmit = () => { let flag = Object.keys(this.dig_form.form).includes(i);
_em.save() if (flag) {
} this.dig_form.form[i] = this.edit_data[i]
}, }
deep: true }
}, this.isUpdate = true;
edit_data: { } else {
handler(valNew) { this.dig_form.resetFields()
console.log(valNew !== null) this.isUpdate = false;
if (valNew !== null) {
if (valNew['cate_id'] !== undefined) {
valNew['cate_id'] = valNew['cate_id_str']
} }
// 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 deep: true
} }
@ -91,7 +74,11 @@ import TinymceEditor from '@/components/TinymceEditor';
formCreate.component('editor', TinymceEditor); formCreate.component('editor', TinymceEditor);
}, },
mounted() { mounted() {
// this.queryRoles(); // console.log('表单已加载')
const _em = this
this.dig_option.onSubmit = () => {
_em.save()
}
}, },
methods: { methods: {
/* 下拉树组件格式化数据 */ /* 下拉树组件格式化数据 */

17
src/views/content/content-list.vue

@ -111,13 +111,9 @@ export default {
// //
columns: [ columns: [
{ {
columnKey: 'action', columnKey: 'index',
fixed: 'right',
label: '操作',
width: 130,
align: 'center', align: 'center',
resizable: false, resizable: false
slot: 'action'
} }
], ],
response: { response: {
@ -142,7 +138,6 @@ export default {
methods: { methods: {
/* 获取数据 */ /* 获取数据 */
parseData(res) { parseData(res) {
// console.log(res);
let showList = res.data.field_info.list_fields; let showList = res.data.field_info.list_fields;
this.columns = [{ this.columns = [{
columnKey: 'action', columnKey: 'action',
@ -171,20 +166,14 @@ export default {
newObj.slot = 'image' newObj.slot = 'image'
} else if (ele.field === 'status') { } else if (ele.field === 'status') {
newObj.slot = 'status' // status newObj.slot = 'status' // status
// newObj.width = '75'
} else if (ele.field === 'sort') { } else if (ele.field === 'sort') {
newObj.sortable = 'custom' newObj.sortable = 'custom'
// newObj.width = '75'
} }
this.columns.push(newObj) this.columns.push(newObj)
// console.log(ele)
} }
}) })
// this.columns.push()
// console.log(this.columns)
// console.log(res.data.content_data); // console.log(res.data.content_data);
// console.log(res.data.field_info.editFields); // console.log(res.data.field_info.editFields);
// this.edit_rule = res.data.field_info.editFields;
this.edit_rule = getForm(res.data.field_info.editFields); this.edit_rule = getForm(res.data.field_info.editFields);
return { return {
// code0code: 2000 // code0code: 2000
@ -207,7 +196,7 @@ export default {
} else { } else {
this.current = null; this.current = null;
} }
console.log(this.current) // console.log(this.current)
this.showEdit = true; this.showEdit = true;
}, },
/* 删除 */ /* 删除 */

1
src/views/content/create_form.js

@ -2,7 +2,6 @@
import setting from "@/config/setting"; import setting from "@/config/setting";
export function getForm(valNew) { export function getForm(valNew) {
console.log(valNew)
const rule = [] const rule = []
for (let e of valNew) { for (let e of valNew) {
let eItem = {}; let eItem = {};

Loading…
Cancel
Save