MrELearningList.vue 14.5 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 :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="主题">
              <j-input placeholder="请输入主题" v-model="queryParam.subject"></j-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="状态">
              <j-dict-select-tag placeholder="请选择状态" v-model="queryParam.status"
                                 dictCode="send_status"></j-dict-select-tag>
            </a-form-item>
          </a-col>
          <template v-if="toggleSearchStatus">
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="类型">
                <j-dict-select-tag placeholder="请选择类型" v-model="queryParam.type"
                                   dictCode="learn_type"></j-dict-select-tag>
              </a-form-item>
            </a-col>
            <a-col :xl="10" :lg="11" :md="12" :sm="24">
              <a-form-item label="发布时间">
                <j-date placeholder="请选择开始日期" class="query-group-cust" v-model="queryParam.pubDate_begin"></j-date>
                <span class="query-group-split-cust"></span>
                <j-date placeholder="请选择结束日期" class="query-group-cust" v-model="queryParam.pubDate_end"></j-date>
              </a-form-item>
            </a-col>
          </template>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <!--              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>-->
              <!--              <a @click="handleToggleSearch" style="margin-left: 8px">-->
              <!--                {{ toggleSearchStatus ? '收起' : '展开' }}-->
              <!--                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />-->
              <!--              </a>-->
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <!--      <a-button type="primary" icon="download" @click="handleExportXls('网络学习')">导出</a-button>-->
      <!--      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"-->
      <!--                @change="handleImportExcel">-->
      <!--        <a-button type="primary" icon="import">导入</a-button>-->
      <!--      </a-upload>-->
      <!-- 高级查询区域 -->
      <!--      <j-super-query :fieldList="superFieldList" ref="superQueryModal"-->
      <!--                     @handleSuperQuery="handleSuperQuery"></j-super-query>-->
      <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"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @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)" height="25px" alt=""
               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"
            type="primary"
            icon="download"
            size="small"
            @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-e-learning-modal ref="modalForm" @ok="modalFormOk"></mr-e-learning-modal>

    <j-modal
      :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
      :title="modelDetail.title"
      :visible.sync="modelDetail.visible"
      :width="800"
      switchFullscreen
    >
      <template>
        <a-row>
          <a-descriptions :column='2' bordered title=''>
            <a-descriptions-item :span='2' label='主题'>
              <div class='describe'>{{ info.subject }}</div>
            </a-descriptions-item>
            <a-descriptions-item label='发布人'>
              {{ info.createBy }}
            </a-descriptions-item>
            <a-descriptions-item label='类型'>
              <span>{{ info.type_dictText }}<span
                v-if='null!=info.videoType && undefined!=info.videoType'>/{{ info.videoType_dictText }}</span></span>
            </a-descriptions-item>
            <a-descriptions-item label='点赞'>
              {{ info.likesNumber }}次
            </a-descriptions-item>
            <a-descriptions-item label='分享'>
              {{ info.learningNumber }}次
            </a-descriptions-item>
            <a-descriptions-item v-if='info.type==2' label='时长'>
              {{ info.learningTime }}分钟
            </a-descriptions-item>
            <a-descriptions-item label="积分" v-if="info.type==2">
              {{ info.score }}积分
            </a-descriptions-item>
            <a-descriptions-item label="文件" :span="2">
              <a type="link" class="file" v-if="info.type==2">{{ info.url }}</a>
              <video :src="info.url" autoplay="autoplay" v-if="info.type==1"
                     controls="controls"
                     width="480px" height="270px">您的浏览器不支持视频播放
              </video>
            </a-descriptions-item>
          </a-descriptions>
        </a-row>
      </template>
    </j-modal>


  </a-card>
</template>

<script>

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

export default {
  name: 'MrELearningList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    MrELearningModal
  },
  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',
                        scopedSlots: { customRender: 'htmlSlot' },
                        customRender: (t) => ellipsis(t)
                    },
                    {
                        title: '类型',
                        align: 'center',
                        dataIndex: 'type_dictText'
                    },
                    {
                        title: '点赞(次)',
                        align: 'center',
                        dataIndex: 'likesNumber'
                    },
                  {
                    title: '分享(次)',
                    align: 'center',
                    dataIndex: 'learningNumber'
                  },
                    {
                        title: '状态',
                        align: 'center',
                        dataIndex: 'status_dictText'
                    },
                    {
                        title: '积分',
                        align: 'center',
                        dataIndex: 'score'
                    },
                    {
                        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: '/MrELearning/mrELearning/list',
                    delete: '/MrELearning/mrELearning/delete',
                    deleteBatch: '/MrELearning/mrELearning/deleteBatch',
                    exportXlsUrl: '/MrELearning/mrELearning/exportXls',
                    importExcelUrl: 'MrELearning/mrELearning/importExcel',
                    ispublish: '/MrELearning/mrELearning/ispublish',
                    isNotPublish: '/MrELearning/mrELearning/isNotPublish'
                },
                dictOptions: {},
                modelDetail: {
                    title: '详情',
                    visible: false
                },
                info: {},
                disableSubmit: true,
                superFieldList: []
            }
        },
        created() {
            this.getSuperFieldList()
        },
        computed: {
            importExcelUrl: function () {
                return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
            }
        },
        methods: {
            handleDetail: function (record) {
              console.log(record)
              this.modelDetail.visible = true
              record.intruduce = this.textReplaceAll(record.intruduce)
              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
                that.model={}
                let formData = Object.assign(that.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: 'intruduce', text: '介绍', dictCode: '' })
                fieldList.push({ type: 'Text', value: 'url', text: '地址', dictCode: '' })
                fieldList.push({ type: 'string', value: 'status', text: '状态(未发布,已发布,撤回)', dictCode: '' })
                fieldList.push({ type: 'date', value: 'pubDate', text: '发布时间' })
                fieldList.push({ type: 'string', value: 'type', text: '类型(视频1;文件:2;ppt:3)', dictCode: '' })
                fieldList.push({ type: 'int', value: 'likesNumber', text: '点赞数量', dictCode: '' })
                fieldList.push({ type: 'int', value: 'learningNumber', text: '学习数量', dictCode: '' })
                fieldList.push({ type: 'int', value: 'score', text: '分数', dictCode: '' })
                this.superFieldList = fieldList
            }
        }
    }
</script>
<style scoped>
  @import '~@assets/less/common.less';

  .file {
    display: block;
    width: 580px;
    line-height: 2;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .file:hover {
    text-decoration: underline;
  }

  .describe {
    max-width: 580px;
  }
</style>