<template>
  <template-page ref="pageRef" :get-list="getList" :table-attributes="tableAttributes" :table-events="tableEvents"
    :options-evens-group="optionsEvensGroup" :moreParameters="moreParameters" :column-parsing="columnParsing"
    :operation="operation" :exportList="exportList">
  </template-page>
</template>

<script>
import TemplatePage from '@/components/template/template-page-1.vue'
import import_mixin from '@/components/template/import_mixin.js'
import { deleteModule, templateListPageV2, templatePageExport } from '@/api/goods'
export default {
  components: { TemplatePage },
  mixins: [import_mixin],
  data() {
    return {
      // 事件组合
      optionsEvensGroup: [
        [
          [
            {
              name: '添加模块',
              isRole: true,
              click: () => {
                this.$router.push({
                  name: "watermark_add",
                  query: {}
                })
              }
            }
          ],
        ],
      ],
      // 表格属性
      tableAttributes: {
        // 启用勾选列
        selectColumn: false
      },
      // 表格事件
      tableEvents: {
        'selection-change': this.selectionChange
      },
      // 勾选选中行
      recordSelected: [],
    }
  },
  computed: {
    // 更多参数
    moreParameters() {
      return []
    },
  },
  methods: {
    // 列表请求函数
    getList(pm){
      pm.params.push({ "param": "a.type", "compare": "=", "value": '2' })
      return templateListPageV2(pm)
    },
    // 列表导出函数
    exportList: templatePageExport,
    // 表格列解析渲染数据更改
    columnParsing(item, defaultData) {
      return defaultData
    },
    // 监听勾选变化
    selectionChange(data) {
      this.recordSelected = data
    },
    // 表格操作列
    operation(h, { row, index, column }) {
      return (
        <div class='operation-btns'>
          <el-button type="text" onClick={() => {
            this.$router.push({
              name: "watermark_add",
              query: {
                id: row.commonTemplateId
              }
            })
          }}>编辑</el-button>
          <el-popconfirm
            title="确定删除吗？"
            onConfirm={() => {
              deleteModule({
                commonTemplateId: row.commonTemplateId
              }).then(res => {
                this.$message({ type: 'success', message: '删除成功!' })
                this.$refs.pageRef.refreshList()
              })
            }}
          >
            <el-button type="text" slot="reference">删除</el-button>
          </el-popconfirm>
        </div>
      )
    },
  }
}
</script>

<style lang="scss" scoped></style>
