MrNoticeList.vue 10.1 KB
<template>
  <a-card :bordered='false'>
    <!-- 查询区域 -->
    <div class='table-page-search-wrapper'>
      <a-form layout='inline' @keyup.enter.native='searchQuery'>
        <a-row :gutter='24'>
          <a-col :lg='7' :md='8' :sm='24' :xl='6'>
            <a-form-item label='主题'>
              <j-input v-model='queryParam.subject' placeholder='请输入主题'></j-input>
            </a-form-item>
          </a-col>
          <a-col :lg='7' :md='8' :sm='24' :xl='6'>
            <a-form-item label='类型'>
              <j-dict-select-tag v-model='queryParam.type' dictCode='notice_type' placeholder='请选择类型' />
            </a-form-item>
          </a-col>
          <a-col :lg='7' :md='8' :sm='24' :xl='6'>
            <a-form-item label='状态'>
              <j-dict-select-tag v-model='queryParam.status' dictCode='	send_status' placeholder='请选择状态' />
            </a-form-item>
          </a-col>
          <template v-if='toggleSearchStatus'>
            <a-col :lg='11' :md='12' :sm='24' :xl='10'>
              <a-form-item label='发布时间'>
                <j-date v-model='queryParam.pubDate_begin' class='query-group-cust' placeholder='请选择开始日期'></j-date>
                <span class='query-group-split-cust'></span>
                <j-date v-model='queryParam.pubDate_end' class='query-group-cust' placeholder='请选择结束日期'></j-date>
              </a-form-item>
            </a-col>
          </template>
          <a-col :lg='7' :md='8' :sm='24' :xl='6'>
            <span class='table-page-search-submitButtons' style='float: left;overflow: hidden;'>
              <a-button icon='search' type='primary' @click='searchQuery'>查询</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class='table-operator'>
      <a-button icon='plus' type='primary' @click='handleAdd'>新增</a-button>
      <a-dropdown v-if='selectedRowKeys.length > 0'>
        <a-menu slot='overlay'>
          <a-menu-item key='1' @click='batchDel'>
            <a-icon type='delete' />
            删除
          </a-menu-item>
        </a-menu>
        <a-button style='margin-left: 8px'> 批量操作
          <a-icon type='down' />
        </a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class='ant-alert ant-alert-info' style='margin-bottom: 16px;'>
        <i class='anticon anticon-info-circle ant-alert-icon'></i> 已选择 <a
        style='font-weight: 600'>{{ selectedRowKeys.length }}</a>项
        <a style='margin-left: 24px' @click='onClearSelected'>清空</a>
      </div>

      <a-table
        ref='table'
        :columns='columns'
        :dataSource='dataSource'
        :loading='loading'
        :pagination='ipagination'
        :rowSelection='{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}'
        :scroll='{x:true}'
        bordered
        class='j-table-force-nowrap'
        rowKey='id'
        size='middle'
        @change='handleTableChange'>

        <template slot='htmlSlot' slot-scope='text'>
          <div v-html='text'></div>
        </template>
        <template slot='imgSlot' slot-scope='text'>
          <span v-if='!text' style='font-size: 12px;font-style: italic;'>无图片</span>
          <img v-else :src='getImgView(text)' alt='' height='25px'
               style='max-width:80px;font-size: 12px;font-style: italic;' />
        </template>
        <template slot='fileSlot' slot-scope='text'>
          <span v-if='!text' style='font-size: 12px;font-style: italic;'>无文件</span>
          <a-button
            v-else
            :ghost='true'
            icon='download'
            size='small'
            type='primary'
            @click='downloadFile(text)'>
            下载
          </a-button>
        </template>

        <span slot='action' slot-scope='text, record'>
           <a @click="handleDetail(record)">详情</a>
            <a-divider type="vertical"/>
            <a @click="handleEdit(record)" v-if="record.status!=1">编辑</a>
            <a-divider type="vertical" v-if="record.status!=1"/>
           <a @click="isPublish(record)" v-if="record.status!=1">发布</a>
           <a @click="isNotPublish(record)" v-if="record.status==1">撤销</a>
            <a-divider type="vertical"/>
            <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
              <a>删除</a>
            </a-popconfirm>
        </span>

      </a-table>
    </div>

    <mr-notice-modal ref='modalForm' @ok='modalFormOk'></mr-notice-modal>

    <j-modal
      :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
      :title='modalDetail.title'
      :visible.sync='modalDetail.visible'
      :width='800'
      switchFullscreen
    >
      <template>
        <p class='news_title'>{{ info.subject }}</p>
        <div class='sub_info'>
          <span>{{ info.type_dictText }}</span>
          <span>{{ info.pubDate }}</span>
          <span>{{ info.views }}次浏览</span>
        </div>
        <a-divider />
        <div class='scroll_area'>
          <div v-html='info.content'></div>
        </div>
      </template>
    </j-modal>
  </a-card>
</template>

<script>

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import MrNoticeModal from '../modules/mrNotice/MrNoticeModal'
import { putAction } from '@/api/manage'

export default {
  name: 'MrNoticeList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    MrNoticeModal
  },
  data() {
    var that = this
    let ellipsis = (v, l = 40) => (<j-ellipsis value={that.textReplaceAll(v)} length={l} />)
    return {
      model: {},
      description: '未检通知管理页面',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '主题',
          align: 'center',
          dataIndex: 'subject'
        },
        {
          title: '内容',
          align: 'center',
          dataIndex: 'content',
          scopedSlots: { customRender: 'htmlSlot' },
          customRender: (t) => ellipsis(t)
        },
        {
          title: '类型',
          align: 'center',
          dataIndex: 'type_dictText'
        },
        {
          title: '状态',
          align: 'center',
          dataIndex: 'status_dictText'
        },
        {
          title: '发布时间',
          align: 'center',
          dataIndex: 'pubDate',
          customRender: function(text) {
            return !text ? '' : (text.length > 10 ? text.substr(0, 10) : text)
          }
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: '/MrNotice/mrNotice/list',
        delete: '/MrNotice/mrNotice/delete',
        deleteBatch: '/MrNotice/mrNotice/deleteBatch',
        exportXlsUrl: '/MrNotice/mrNotice/exportXls',
        importExcelUrl: 'MrNotice/mrNotice/importExcel',
        ispublish: '/MrNotice/mrNotice/ispublish',
        isNotPublish: '/MrNotice/mrNotice/isNotPublish'

      },
      dictOptions: {},
      superFieldList: [],
      modalDetail: {
        title: '详情',
        visible: false
      },
      info: {},
      disableSubmit: true
    }
  },
  created() {
    this.getSuperFieldList()
  },
  computed: {
    importExcelUrl: function() {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },
  methods: {
    handleDetail(record) {
      this.modalDetail.visible = true
      // record.content = this.textReplaceAll(record.content)
      // record.content = this.textReplaceAll(record.content)
      console.log(record)
      this.info = record
    },
    initDictConfig() {
    },
    textReplaceAll: function(text) {
      if (null != text && '' != text && undefined != text) {
        var reg = /<[^<>]+>/g
        var afterText = text.replace(reg, '').replace(/&nbsp;/ig, '').replace(/&ldquo;/ig, '').replace(/&rdquo;/ig, '')
        return afterText
      } else {
        return text
      }
    },
    isPublish: function(record) {
      var that = this
      let formData = Object.assign(this.model, record)
      putAction(that.url.ispublish, formData).then((res) => {
        if (res.success) {
          that.$message.success(res.message)
          that.loadData()
        } else {
          that.$message.warning(res.message)
        }
      })
    },
    isNotPublish: function(record) {
      var that = this
      let formData = Object.assign(this.model, record)
      putAction(that.url.isNotPublish, formData).then((res) => {
        if (res.success) {
          that.$message.success(res.message)
          that.loadData()
        } else {
          that.$message.warning(res.message)
        }
      })
    },
    getSuperFieldList() {
      let fieldList = []
      fieldList.push({ type: 'string', value: 'subject', text: '主题', dictCode: '' })
      fieldList.push({ type: 'Text', value: 'content', text: '内容', dictCode: '' })
      fieldList.push({ type: 'date', value: 'pubDate', text: '发布时间' })
      fieldList.push({ type: 'string', value: 'type', text: '类型(集体服务1,活动通知2)', dictCode: '' })
      fieldList.push({ type: 'string', value: 'status', text: '状态(未发布,已发布,撤回)', dictCode: '' })
      this.superFieldList = fieldList
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';

.news_title {
  margin: 0 auto 20px auto;
  width: 80%;
  font-size: 18px;
  text-align: center;
  line-height: 2;
  font-weight: bold;
}

.sub_info {
  margin: 0;
  display: flex;
  justify-content: space-between;
  color: #9e9e9e;
}

.cover {
  margin: 0 auto 20px auto;
  width: 60%;
  height: 260px;
}

.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scroll_area {
  max-height: 600px;
  max-height: 500px;
  padding-right: 10px;
  overflow-y: auto;
}
</style>