Browse Source

Merge branch 'master' of ssh://101.201.226.163:50022/binbin0314/datang-admin

master
aBin 4 years ago
parent
commit
f4f1d27c55
  1. 16
      src/api/contentDetail.js
  2. 5
      src/components/Detail/addOrEdit.vue
  3. 42
      src/components/Detail/editor.vue
  4. 76
      src/components/Detail/index.vue

16
src/api/contentDetail.js

@ -17,6 +17,22 @@ export function POST_QUERY_DETAIL(params) {
}) })
} }
/**
* 单个内容详情
* @param params
* @returns {Promise<T | never>}
* @constructor
*/
export function QUERY_DETAIL(params) {
return request({
url: `${contentDetail}/detail`,
method: 'post',
data:params
}).then(res => {
return res.data
})
}
/** /**
* 删除内容详情 * 删除内容详情
* @param params * @param params

5
src/components/Detail/addOrEdit.vue

@ -42,7 +42,7 @@
labelPosition: 'right', labelPosition: 'right',
formLabelAlign: { formLabelAlign: {
showPage: ['00', '0000'], showPage: ['00', '0000'],
content: 0 content: ''
}, },
BASE_API, BASE_API,
tabList, tabList,
@ -55,9 +55,6 @@
showPage: [ showPage: [
{ type: 'array', required: true, message: '请选择位置', trigger: 'change' } { type: 'array', required: true, message: '请选择位置', trigger: 'change' }
], ],
content: [
{ required: true, message: '请选择状态', trigger: 'change' }
],
} }
} }
}, },

42
src/components/Detail/editor.vue

@ -1,3 +1,43 @@
<template> <template>
<div>55565</div> <div id="editorSection" @change="handleChange"></div>
</template> </template>
<script>
import Editor from "tui-editor"; /* ES6 */
import "tui-editor/dist/tui-editor.css"; // editor's ui
import "tui-editor/dist/tui-editor-contents.css"; // editor's content
import "codemirror/lib/codemirror.css"; // codemirror
import "highlight.js/styles/github.css"; // code block highlight
import { init } from "echarts/lib/echarts";
export default {
name: "mytuieditor",
mounted() {
this.initialize();
},
beforeDestroy() {
this.tuieditor = null;
delete this.tuieditor;
},
methods: {
initialize() {
if (this.$el) {
this.tuieditor = new Editor({
el: document.querySelector("#editorSection"),
initialEditType: "wysiwyg",
previewStyle: "vertical",
height: "300px"
});
this.tuieditor.getHtml();
}
},
handleChange(value){
console.log('value: ', value);
}
}
};
</script>
<style>
</style>

76
src/components/Detail/index.vue

@ -11,28 +11,23 @@
<div class="table"> <div class="table">
<el-table <el-table
:data="lists" :data="lists"
style="width: 100%"> style="width: 100%"
@expand-change="getDetail"
>
<el-table-column type="expand"> <el-table-column type="expand">
<template slot-scope="props"> <template slot-scope="props">
<el-form label-position="left" inline class="demo-table-expand"> <el-form label-position="left" inline class="demo-table-expand">
<el-form-item label="商品名称"> <el-form-item label="正文">
商品名称 {{ lists.row.content || '' }}
<!-- <span>{{ props.row.name }}</span> -->
</el-form-item> </el-form-item>
</el-form> </el-form>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column
prop="id"
label="序号"
type="index"
align="center">
</el-table-column>
<el-table-column <el-table-column
prop="name" prop="name"
label="位置" label="位置"
align="center" align="center"
width="250"> >
<template slot-scope="lists"> <template slot-scope="lists">
{{ setCode(lists.row.showPage) }} {{ setCode(lists.row.showPage) }}
</template> </template>
@ -41,27 +36,27 @@
prop="name" prop="name"
label="创建时间" label="创建时间"
align="center" align="center"
width="250"> >
<template slot-scope="lists"> <template slot-scope="lists">
{{ setCode(lists.row.createdAt) }} {{ $moment(lists.row.createdAt).format('YYYY-MM-DD HH:mm') }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="name" prop="name"
label="修改时间" label="修改时间"
align="center" align="center"
width="250"> >
<template slot-scope="lists"> <template slot-scope="lists">
{{ setCode(lists.row.updatedAt) }} {{ $moment(lists.row.updatedAt).format('YYYY-MM-DD HH:mm') }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="name" prop="name"
label="最后修改人登录名" label="最后修改人登录名"
align="center" align="center"
width="250"> >
<template slot-scope="lists"> <template slot-scope="lists">
{{ setCode(lists.row.modifyName) }} {{ lists.row.modifyName }}
</template> </template>
</el-table-column> </el-table-column>
@ -69,7 +64,7 @@
fixed="right" fixed="right"
label="操作" label="操作"
align="center" align="center"
width="250"> >
<template slot-scope="lists"> <template slot-scope="lists">
<el-button <el-button
type="primary" type="primary"
@ -120,6 +115,7 @@
const AddOrEdit = () => import('./addOrEdit.vue'); const AddOrEdit = () => import('./addOrEdit.vue');
import { import {
POST_QUERY_DETAIL, POST_QUERY_DETAIL,
QUERY_DETAIL,
DELETE_DETAIL DELETE_DETAIL
} from '@/api/contentDetail' } from '@/api/contentDetail'
import Alert from "@/utils/alert"; import Alert from "@/utils/alert";
@ -155,7 +151,7 @@
}, },
methods: { methods: {
/** /**
* 获取轮播图列表 * 获取详情列表
*/ */
getList() { getList() {
const { pageNum, pageSize, showPage } = this; const { pageNum, pageSize, showPage } = this;
@ -184,6 +180,30 @@
this.getList() this.getList()
}, },
/**
* 单个内容详情
*/
getDetail(row){
let arr = this.lists
let index = arr.findIndex(item => item.detailId === row.detailId)
const { showPage } = this;
const params = {
detailId: row.detailId,
pageNum: 1,
pageSize: 10,
showPage
};
QUERY_DETAIL(params).then(res => {
console.log('res: ', res);
if(res.code === 200){
arr[index].content = res.data.content
this.lists = [...arr]
}else{
Alert.fail('获取失败');
}
});
},
// //
setCode(showPage){ setCode(showPage){
let item = null let item = null
@ -197,7 +217,7 @@
} }
} }
} }
return item.title return item && item.title ? item.title : ''
}, },
addModal(){ addModal(){
@ -227,14 +247,14 @@
const params = { const params = {
id id
}; };
DELETE_DETAIL(params).then((res) => { // DELETE_DETAIL(params).then((res) => {
if(res.code === 200){ // if(res.code === 200){
Alert.success('删除成功'); // Alert.success('');
this.getList() // this.getList()
}else{ // }else{
Alert.fail(res.msg || '删除失败'); // Alert.fail(res.msg || '');
} // }
}); // });
this.visible = false this.visible = false
}, },
} }

Loading…
Cancel
Save