|
|
@@ -0,0 +1,282 @@
|
|
|
+<template>
|
|
|
+ <div class="ele-body">
|
|
|
+ <el-card shadow="never">
|
|
|
+ <!-- 搜索表单 -->
|
|
|
+ <el-form :model="table.where" label-width="90px" class="ele-form-search"
|
|
|
+ @keyup.enter.native="$refs.table.reload()" @submit.native.prevent>
|
|
|
+ <el-row :gutter="15">
|
|
|
+ <el-col :md="8" :sm="12">
|
|
|
+ <el-form-item label="标题:">
|
|
|
+ <el-input v-model="table.where.title" placeholder="请输入标题" clearable/>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :md="6" :sm="12">
|
|
|
+ <div class="ele-form-actions">
|
|
|
+ <el-button type="primary" @click="$refs.table.reload()" icon="el-icon-search"
|
|
|
+ class="ele-btn-icon">查询
|
|
|
+ </el-button>
|
|
|
+ <el-button @click="(table.where={attr_type: 2})&&$refs.table.reload()">重置</el-button>
|
|
|
+ </div>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-form>
|
|
|
+ <!-- 操作按钮 -->
|
|
|
+ <div class="ele-table-tool ele-table-tool-default">
|
|
|
+ <el-button @click="showEdit=true" type="primary" icon="el-icon-plus" class="ele-btn-icon" size="small"
|
|
|
+ v-if="permission.includes('sys:ad:add')">添加
|
|
|
+ </el-button>
|
|
|
+ <el-button @click="remove()" type="danger" icon="el-icon-delete" class="ele-btn-icon" size="small"
|
|
|
+ v-if="permission.includes('sys:ad:dall')">批量删除
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+ <!-- 数据表格 -->
|
|
|
+ <ele-data-table ref="table" :config="table" :choose.sync="choose" height="calc(100vh - 315px)"
|
|
|
+ highlight-current-row>
|
|
|
+ <template slot-scope="{index}">
|
|
|
+ <el-table-column type="selection" width="45" align="center" fixed="left"/>
|
|
|
+ <el-table-column type="index" :index="index" label="编号" width="60" align="center" fixed="left"
|
|
|
+ show-overflow-tooltip/>
|
|
|
+ <el-table-column label="封面" min-width="100" align="center">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <el-avatar shape="square" :size="25" :src="row.cover"/>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="title" label="标题" sortable="custom" show-overflow-tooltip min-width="200">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <a v-if="row.url" :href="row.url" target="_blank">{{row.title}}</a>
|
|
|
+ <a v-else>{{row.title}}</a>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="description" label="描述" show-overflow-tooltip min-width="200"
|
|
|
+ align="center"/>
|
|
|
+ <el-table-column prop="status" label="状态" sortable min-width="100">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <ele-dot :type="['danger', 'success'][row.status]" :ripple="row.status===0"
|
|
|
+ :text="['禁用','正常'][row.status]"/>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="sort" label="排序" sortable="custom" show-overflow-tooltip/>
|
|
|
+ <el-table-column label="发布时间" sortable="custom" show-overflow-tooltip min-width="160">
|
|
|
+ <template slot-scope="{row}">{{ row.post_time_text }}</template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="创建时间" sortable="custom" show-overflow-tooltip min-width="160">
|
|
|
+ <template slot-scope="{row}">{{ row.create_time }}</template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作" width="130px" align="center" :resizable="false" fixed="right">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <el-link @click="edit(row)" icon="el-icon-edit" type="primary" :underline="false"
|
|
|
+ v-if="permission.includes('sys:ad:edit')">修改
|
|
|
+ </el-link>
|
|
|
+ <el-popconfirm title="确定要删除此文章吗?" @confirm="remove(row)" class="ele-action">
|
|
|
+ <el-link slot="reference" icon="el-icon-delete" type="danger" :underline="false"
|
|
|
+ v-if="permission.includes('sys:ad:delete')">删除
|
|
|
+ </el-link>
|
|
|
+ </el-popconfirm>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </template>
|
|
|
+ </ele-data-table>
|
|
|
+ </el-card>
|
|
|
+ <!-- 编辑弹窗 -->
|
|
|
+ <el-dialog :title="editForm.id?'修改文章':'修改文章'" :visible.sync="showEdit" width="700px"
|
|
|
+ @closed="editForm={status: 1}" :destroy-on-close="true" custom-class="ele-dialog-form" :lock-scroll="false">
|
|
|
+ <el-form :model="editForm" ref="editForm" :rules="editRules" label-width="100px">
|
|
|
+ <el-form-item label="文章图片:">
|
|
|
+ <uploadImage :limit="1" v-model="editForm.cover"></uploadImage>
|
|
|
+ </el-form-item>
|
|
|
+ <el-row :gutter="15">
|
|
|
+ <el-col :sm="15">
|
|
|
+
|
|
|
+ <el-form-item label="文章标题:" prop="title">
|
|
|
+ <el-input v-model="editForm.title" placeholder="请输入文章标题" clearable/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="单页类型:" prop="title">
|
|
|
+ <el-select v-model="editForm.type" placeholder="请选类型" class="ele-block">
|
|
|
+ <el-option v-for="(v,k) in types" :label="v.name" :value="v.value" :key="k"/>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="作者来源:" prop="author">
|
|
|
+ <el-input v-model="editForm.author" placeholder="请输入文章作者来源" clearable/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="发布时间:" prop="start_time">
|
|
|
+ <el-date-picker
|
|
|
+ v-model="editForm.post_time"
|
|
|
+ type="datetime"
|
|
|
+ placeholder="选择发布时间"
|
|
|
+ size="small">
|
|
|
+ </el-date-picker>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="排序号:" prop="sort">
|
|
|
+ <el-input-number v-model="editForm.sort" controls-position="right" :min="0"
|
|
|
+ placeholder="请输入排序号" class="ele-fluid ele-text-left"/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="文章描述:" prop="description">
|
|
|
+ <el-input type="textarea" v-model="editForm.description" placeholder="请输入文章描述" clearable/>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :sm="24">
|
|
|
+
|
|
|
+ <!-- 富文本编辑器 -->
|
|
|
+ <el-form-item label="文章内容:" prop="description">
|
|
|
+ <tinymce-editor v-model="editForm.content" :init="editContent"/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="状态:">
|
|
|
+ <el-radio-group v-model="editForm.status">
|
|
|
+ <el-radio :label="1">正常</el-radio>
|
|
|
+ <el-radio :label="2">禁用</el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer">
|
|
|
+ <el-button @click="showEdit=false">取消</el-button>
|
|
|
+ <el-button type="primary" @click="save">保存</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import uploadImage from '@/components/uploadImage'
|
|
|
+import {mapGetters} from "vuex";
|
|
|
+import TinymceEditor from '@/components/TinymceEditor'
|
|
|
+export default {
|
|
|
+ name: "SysArticleHelp",
|
|
|
+ components: {uploadImage,TinymceEditor},
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ table: {url: '/article/index', where: {attr_type: 2}}, // 表格配置
|
|
|
+ choose: [], // 表格选中数据
|
|
|
+ showEdit: false, // 是否显示表单弹窗
|
|
|
+ editForm: {status: 1}, // 表单数据
|
|
|
+ types: [
|
|
|
+ {name: '关于我们', value: 2},
|
|
|
+ {name: '注册协议', value: 3},
|
|
|
+ ],
|
|
|
+ editRules: { // 表单验证规则
|
|
|
+ title: [
|
|
|
+ {required: true, message: '请输入文章标题', trigger: 'blur'}
|
|
|
+ ],
|
|
|
+ type: [
|
|
|
+ {required: true, message: '请输入文章单页类型', trigger: 'blur'}
|
|
|
+ ],
|
|
|
+ content: [
|
|
|
+ {required: true, message: '请输入文章内容', trigger: 'blur'}
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ // 文章位列表
|
|
|
+ adSortList: [],
|
|
|
+
|
|
|
+ // 自定义文件上传(这里使用把选择的文件转成blob演示)
|
|
|
+ file_picker_callback: (callback, value, meta) => {
|
|
|
+ let input = document.createElement('input');
|
|
|
+ input.setAttribute('type', 'file');
|
|
|
+ // 设定文件可选类型
|
|
|
+ if (meta.filetype === 'image') {
|
|
|
+ input.setAttribute('accept', 'image/*');
|
|
|
+ } else if (meta.filetype === 'media') {
|
|
|
+ input.setAttribute('accept', 'video/*');
|
|
|
+ }
|
|
|
+ input.onchange = () => {
|
|
|
+ let file = input.files[0];
|
|
|
+ let reader = new FileReader();
|
|
|
+ reader.onload = (e) => {
|
|
|
+ let blob = new Blob([e.target.result], {type: file.type});
|
|
|
+ callback(URL.createObjectURL(blob));
|
|
|
+ };
|
|
|
+ reader.readAsArrayBuffer(file);
|
|
|
+ }
|
|
|
+ input.click();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapGetters(["permission"]),
|
|
|
+
|
|
|
+ editContent() {
|
|
|
+ return {
|
|
|
+ menubar: false,
|
|
|
+ file_picker_callback: this.file_picker_callback,
|
|
|
+ skin_url: this.$store.state.theme.theme === 'dark' ? '/tinymce/skins/ui/oxide-dark' : '/tinymce/skins/ui/oxide',
|
|
|
+ content_css: this.$store.state.theme.theme === 'dark' ? '/tinymce/skins/content/dark/content.css' : '/tinymce/skins/content/default/content.css'
|
|
|
+ };
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ /* 显示编辑 */
|
|
|
+ edit(row) {
|
|
|
+ this.editForm = Object.assign({}, row);
|
|
|
+ this.showEdit = true;
|
|
|
+ },
|
|
|
+ /* 保存编辑 */
|
|
|
+ save() {
|
|
|
+ this.$refs['editForm'].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ const loading = this.$loading({lock: true});
|
|
|
+ this.editForm.attr_type = 2;
|
|
|
+ this.$http.post('/article/edit', this.editForm).then(res => {
|
|
|
+ loading.close();
|
|
|
+ if (res.data.code === 0) {
|
|
|
+ this.showEdit = false;
|
|
|
+ this.$message({type: 'success', message: res.data.msg});
|
|
|
+ this.$refs.table.reload();
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.data.msg);
|
|
|
+ }
|
|
|
+ }).catch(e => {
|
|
|
+ loading.close();
|
|
|
+ this.$message.error(e.message);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /* 删除 */
|
|
|
+ remove(row) {
|
|
|
+ if (!row) { // 批量删除
|
|
|
+ if (this.choose.length === 0) return this.$message.error('请至少选择一条数据');
|
|
|
+ let ids = this.choose.map(d => d.id);
|
|
|
+ this.$confirm('确定要删除选中的文章吗?', '提示', {type: 'warning'}).then(() => {
|
|
|
+ const loading = this.$loading({lock: true});
|
|
|
+ this.$http.post('/article/delete', {id: ids}).then(res => {
|
|
|
+ loading.close();
|
|
|
+ if (res.data.code === 0) {
|
|
|
+ this.$message({type: 'success', message: res.data.msg});
|
|
|
+ this.$refs.table.reload();
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.data.msg);
|
|
|
+ }
|
|
|
+ }).catch(e => {
|
|
|
+ loading.close();
|
|
|
+ this.$message.error(e.message);
|
|
|
+ });
|
|
|
+ }).catch(() => 0);
|
|
|
+ } else { // 单个删除
|
|
|
+ const loading = this.$loading({lock: true});
|
|
|
+ this.$http.post('/article/delete', {id: row.id}).then(res => {
|
|
|
+ loading.close();
|
|
|
+ if (res.data.code === 0) {
|
|
|
+ this.$message({type: 'success', message: res.data.msg});
|
|
|
+ this.$refs.table.reload();
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.data.msg);
|
|
|
+ }
|
|
|
+ }).catch(e => {
|
|
|
+ loading.close();
|
|
|
+ this.$message.error(e.message);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.ele-block >>> .el-upload, .ele-block >>> .el-upload-dragger {
|
|
|
+ width: 100%;
|
|
|
+}
|
|
|
+</style>
|