<template>
  <!-- 通知机制 -->
  <el-card shadow="never" class="aui-card--fill propaganda">
    <div class="mod-sys__role">
      <head-template head-left="通知机制">
        <el-button size="small" @click="enterHandle">平台入口</el-button>
        <el-button type="primary" size="small" icon="el-icon-plus" @click="addOrUpdateHandle()">新增</el-button>
      </head-template>
      <el-table
        v-loading="dataListLoading"
        :data="dataList"
        :height="tableHeight"
        style="width: 100%;"
        @selection-change="dataListSelectionChangeHandle"
        @sort-change="dataListSortChangeHandle"
      >
        <!-- <el-table-column type="selection" header-align="center" align="center" width="50" /> -->
        <el-table-column prop="node" label="状态节点" header-align="center" align="center" />
        <el-table-column prop="title" label="名称" header-align="center" align="center" />
        <el-table-column prop="url" label="URL" header-align="center" align="center">
          <template slot-scope="scope">
            <span class="url-span" @click="URLEnterHandle(scope.row)"> {{ scope.row.url }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="updateDate" label="修改时间" header-align="center" align="center" />
        <el-table-column prop="remark" label="备注" header-align="center" align="center">
          <template slot-scope="scope">
            {{ scope.row.remark ? scope.row.remark : '-' }}
          </template>
        </el-table-column>
        <el-table-column prop="operation" label="操作" header-align="center" align="center">
          <template slot-scope="scope">
            <span style="color: #1890ff; padding-right: 8px" class="button-span" @click="addOrUpdateHandle(scope.row.id,scope.row)">编辑</span>
            <span style="color: #ff4d4f;" class="button-span" @click="deleteHandle(scope.row.id)">删除</span>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination background layout="prev, pager, next" :total="total" @current-change="pageCurrentChangeHandle" />
      <!-- 弹窗, 新增 / 修改 -->
      <add-propaganda v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList" @closeDialog="addOrUpdateVisible=false" />
    </div>
  </el-card>
</template>

<script>
import addPropaganda from './add-propaganda.vue'
import mixinViewModule from '@/mixins/view-module'
import tableAutoHeight from '@/mixins/tableAutoHeight'
import headTemplate from '@/components/head'
export default {
  components: {
    addPropaganda,
    headTemplate
  },
  mixins: [mixinViewModule, tableAutoHeight],
  data() {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/preach',
        deleteURL: '/preach',
        deleteIsBatch: true,
        getDataListIsPage: false
      },
      dataForm: {
        name: ''
      }
    }
  },
  methods: {
    // URL入口
    enterHandle() {
      window.open('https://mp.weixin.qq.com/')
    },
    // 链接跳转
    URLEnterHandle(scopeRow) {
      window.open(scopeRow.url)
    }
  }
}
</script>
<style lang="scss" scoped>
.propaganda {
  .url-span {
    white-space: nowrap; // 段落不换行
    text-overflow: ellipsis;
    overflow: hidden;
  }
  .url-span:hover {
    color: #1e79ff;
    cursor: pointer;
  }
  .button-span {
    cursor: pointer;
  }
}
</style>
