JeecgQuestionsList.vue 3.97 KB
<template>
  <a-card :bordered='false'>
    <!-- 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'>{{ selectedQuestionKeys.length }}</a>项
        <a style='margin-left: 24px' @click='onClearSelected'>清空</a>
      </div>

      <a-table
        ref='table'
        size='middle'
        bordered
        rowKey='id'
        :columns='columns'
        :dataSource='dataSource'
        :pagination='ipagination'
        :loading='loading'
        :rowSelection='{selectedQuestionKeys: selectedQuestionKeys, onChange: onSelectQuestionChange}'
        @change='handleTableChange'>
      </a-table>
    </div>
  </a-card>
</template>

<script>
// import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction } from '@/api/manage'

export default {
  name: 'JeecgQusetionsList',
  // mixins: [JeecgListMixin],
  components: {},
  data() {
    return {
      dataSource: [],
      /* 分页参数 */
      ipagination: {
        current: 1,
        pageSize: 10,
        pageSizeOptions: ['10', '20', '30'],
        showTotal: (total, range) => {
          return range[0] + '-' + range[1] + ' 共' + total + '条'
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      },
      loading: false,
      selectedQuestionKeys: [],
      selectionQuestions: [],
      description: '题库列表',
      // 表头
      columns: [
        {
          title: '问题',
          align: 'center',
          dataIndex: 'question'
        },
        {
          title: '选项类型',
          align: 'center',
          dataIndex: 'optionType_dictText'
        },
        {
          title: '答案代号',
          align: 'center',
          dataIndex: 'answer_dictText'
        }
      ],
      url: {
        list: '/publish/question/list'
      },
      questionQueryParam: {}
    }
  },
  methods: {
    handleTableChange(pagination, filters, sorter) {
      //分页、排序、筛选变化时触发
      //TODO 筛选
      console.log(pagination)
      if (Object.keys(sorter).length > 0) {
        this.isorter.column = sorter.field
        this.isorter.order = 'ascend' == sorter.order ? 'asc' : 'desc'
      }
      this.ipagination = pagination
      this.loadData()
    },
    onSelectQuestionChange(selectedQuestionKeys, selectionQuestions) {
      this.selectedQuestionKeys = selectedQuestionKeys
      this.selectionQuestions = selectionQuestions
      // console.log(selectedRowKeys)
      // console.log(selectionRows)
    },
    onClearSelected() {
      this.selectedRowKeys = []
      this.selectionRows = []
    },
    loadData(arg) {
      if (arg === 1) {
        this.ipagination.current = 1
      }
      //update-begin--Author:kangxiaolin  Date:20190905 for:[442]主子表分开维护,生成的代码子表的分页改为真实的分页--------------------
      var params = this.questionQueryParam
      console.log(params)
      var questionId = params.questionId
      var parameter = {
        type: params.type, pageNo: this.ipagination.current,
        pageSize: this.ipagination.pageSize
      }
      if (questionId != '' && questionId != undefined && questionId != null) {
        parameter = {
          id: params.questionId, pageNo: this.ipagination.current,
          pageSize: this.ipagination.pageSize
        }
      }
      console.log(parameter)
      getAction(this.url.list, parameter).then((res) => {
        if (res.success) {
          this.dataSource = res.result.records
          this.ipagination.total = res.result.total
        } else {
          this.dataSource = null
        }
      })

    },
    getOrderMain(record) {
      console.log('数据改变')
      // this.queryParam.questionId = questionId
      this.questionQueryParam = Object.assign({}, record)
      this.loadData(1)
    }
  }
}
</script>
<style scoped>
.ant-card {
  margin-left: -30px;
  margin-right: -30px;
}
</style>