123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 |
- <template>
- <div>
- <a-card :bordered="false">
- <div class="table-page-search-wrapper">
- <a-form layout="inline">
- <a-row :gutter="48">
- <a-col :md="8" :sm="32">
- <a-form-item label="标题">
- <a-input v-model="queryParam.articleContentTitle" allow-clear placeholder="请输入标题搜索" />
- </a-form-item>
- </a-col>
- <a-col :md="8" :sm="32">
- <a-form-item label="类型">
- <a-select v-model="queryParam.systemDictType" placeholder="请选择类型" allow-clear>
- <a-select-option
- v-for="(item,index) in typeDictTypeDropDown"
- :key="index"
- :value="item.code"
- >{{ item.name }}</a-select-option>
- </a-select>
- </a-form-item>
- </a-col>
- <a-col :md="8" :sm="32">
- <a-button type="primary" @click="$refs.table.refresh(true)">搜索</a-button>
- <a-button type="primary" style="margin-left: 8px" icon="plus" @click="$refs.detailsOplog.add()">新增</a-button>
- </a-col>
- </a-row>
- </a-form>
- <!-- 表格 -->
- <s-table
- ref="table"
- size="default"
- :pagination="false"
- :loading="loading"
- :columns="columns"
- :data="loadData"
- :rowKey="(record) => record.articleContentId"
- >
- <span slot="articleContentTitle" slot-scope="text">
- <ellipsis :length="30" tooltip>{{ text }}</ellipsis>
- </span>
- <span slot="articleContentCover" slot-scope="src">
- <img :src="src | getImgUrl" width="60" height="45" @click="showPreviewImg(src)" style="cursor: pointer;"/>
- </span>
- <span slot="articleContentAbstract" slot-scope="text">
- <ellipsis :length="80" tooltip>{{ text }}</ellipsis>
- </span>
- <span slot="articleContentType" slot-scope="text">
- {{ typeFilter(text) }}
- </span>
- <span slot="action" slot-scope="text, record">
- <a-popconfirm placement="top" :title="record.articleContentIsLine===1? '是否确认下线该条目?':'是否确认上线该条目?'" @confirm="() => editjobStatusStatus(record.articleContentIsLine,record)">
- <a>{{ statusFilter(record.articleContentIsLine) }}</a>
- </a-popconfirm>
- <a-divider type="vertical"/>
- <a v-if="hasPerm('articleContent:edit')" @click="$refs.detailsOplog.edit(record)">编辑</a>
- <a-divider type="vertical" v-if="hasPerm('articleContent:edit') && hasPerm('articleContent:delete')"/>
- <a-popconfirm v-if="hasPerm('articleContent:delete')" placement="topRight" title="是否确认删除该条目?" @confirm="() => articleContentDelete(record)">
- <a>删除</a>
- </a-popconfirm>
- </span>
- </s-table>
- </div>
- <details-oplog ref="detailsOplog" @ok="handleOk"/>
- <a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel" title="预览">
- <img alt="example" style="width: 100%" :src="previewImage" />
- </a-modal>
- </a-card>
- </div>
- </template>
- <script>
- import { STable, Ellipsis } from '@/components'
- import homeApi from '@/api/homeApi'
- import { setImgUrl } from '@/utils/img'
- import {
- findArticleContentById,
- updateArticleContent,
- deleteArticleContent
- } from '@/api/modular/system/contentControlApi'
- import detailsOplog from './details'
- export default {
- components: {
- STable,
- detailsOplog,
- Ellipsis
- },
- data () {
- return {
- // 查询参数
- queryParam: { id: '', systemDictType: '', articleContentTitle: '' },
- typeDictTypeDropDown: homeApi.systemTypeList,
- // 表头
- columns: [
- {
- title: '序号',
- dataIndex: 'dataIndex',
- customRender: (text, row, index) => {
- return index + 1
- },
- align: 'center',
- width: '90px'
- },
- {
- title: '标题',
- dataIndex: 'articleContentTitle',
- scopedSlots: { customRender: 'articleContentTitle' }
- },
- {
- title: '封面',
- dataIndex: 'articleContentCover',
- scopedSlots: { customRender: 'articleContentCover' },
- align: 'center',
- width: '150px'
- },
- {
- title: '摘要',
- dataIndex: 'articleContentAbstract',
- scopedSlots: { customRender: 'articleContentAbstract' }
- },
- {
- title: '内容类型',
- dataIndex: 'articleContentType',
- scopedSlots: { customRender: 'articleContentType' },
- width: '120px'
- },
- {
- title: '分类',
- dataIndex: 'articleContentClassify'
- },
- {
- title: '子分类',
- dataIndex: 'articleContentSubclassify'
- },
- {
- title: '排序',
- dataIndex: 'articleContentSort',
- align: 'center',
- width: '60px'
- }
- ],
- loading: true,
- loadData: parameter => {
- return findArticleContentById(Object.assign(parameter, this.queryParam)).then((res) => {
- if (this.hasPerm('ArticleContent:list')) {
- return res.data
- }
- })
- },
- selectedRows: [],
- statusDictTypeDropDown: [{ code: 0, name: '下线' }, { code: 1, name: '上线' }],
- previewVisible: false,
- previewImage: ''
- }
- },
- created () {
- if (this.hasPerm('articleContent:edit') || this.hasPerm('articleContent:delete') || hasPerm('articleContent:start') || hasPerm('articleContent:stop')) {
- this.columns.push({
- title: '操作',
- width: '150px',
- dataIndex: 'action',
- scopedSlots: { customRender: 'action' }
- })
- }
- },
- filters: {
- getImgUrl (v) {
- return setImgUrl(v)
- }
- },
- methods: {
- statusFilter (status) {
- const values = this.statusDictTypeDropDown.filter(item => item.code === status)
- if (values.length > 0) {
- return values[0].name
- } else {
- return '上线'
- }
- },
- typeFilter (status) {
- const values = this.typeDictTypeDropDown.filter(item => item.code === status)
- if (values.length > 0) {
- return values[0].name
- } else {
- return ''
- }
- },
- /**
- * 启动停止
- */
- editjobStatusStatus (code, record) {
- if (code === 1) {
- updateArticleContent({ id: record.articleContentId, isLine: 0 }).then(res => {
- if (res.status === 200) {
- if (res.data) {
- this.$message.success('下线成功')
- this.$refs.table.refresh()
- } else {
- this.$message.error('下线失败')
- }
- } else {
- this.$message.error('下线失败:' + res.msg)
- }
- })
- } else {
- updateArticleContent({ id: record.articleContentId, isLine: 1 }).then(res => {
- if (res.status === 200) {
- if (res.data) {
- this.$message.success('上线成功')
- this.$refs.table.refresh()
- } else {
- this.$message.error('上线失败')
- }
- } else {
- this.$message.error('上线失败:' + res.msg)
- }
- })
- }
- },
- articleContentDelete (record) {
- deleteArticleContent({ id: record.articleContentId }).then((res) => {
- if (res.status === 200) {
- if (res.data) {
- this.$message.success('删除成功')
- this.$refs.table.refresh()
- } else {
- this.$message.error('删除失败')
- }
- } else {
- this.$message.error('删除失败:' + res.msg)
- }
- }).catch((err) => {
- this.$message.error('删除错误:' + err.message)
- })
- },
- handleOk () {
- this.$refs.table.refresh()
- },
- showPreviewImg (src) {
- this.previewImage = setImgUrl(src)
- this.previewVisible = true
- },
- handleCancel () {
- this.previewVisible = false
- }
- }
- }
- </script>
- <style lang="less">
- .mr5 {
- margin-right: 5px;
- }
- </style>
|