Blame view

ant-design-vue-base/src/views/publish/JeecgQuestionsList.vue 3.97 KB
1a2d344e   wxy   初始化项目
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
  <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>