Blame view

wenjuan/src/components/basics/couponTable.vue 4.91 KB
e5b57447   杨鑫   '分包问卷'
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
  <template>
    <el-dialog :append-to-body="true" :close-on-click-modal="false" width="1000px" title="选择优惠券" :visible.sync="visible">
      <div class="proSelectBox">
        <!-- 搜索 -->
        <div class="topSearch">
          <div class="formSearch">
            <el-form :inline="true" :model="formData">
              <el-form-item label="">
                <el-input v-model="formData.keyword" class="inputKeyword" placeholder="请输入优惠券名称" />
              </el-form-item>
              <el-form-item>
                <el-button type="primary" plain @click="search">查询</el-button>
                <el-button plain @click="clear">重置</el-button>
              </el-form-item>
            </el-form>
          </div>
        </div>
        <!-- 表格 -->
        <div class="tableBox">
          <el-table
            ref="multipleTable"
            :data="tableData"
            max-height="500"
            border
            row-key="productId"
            style="width: 100%"
            @selection-change="handleSelectionChange"
          >
            <el-table-column
              v-if="isMultiple"
              width="40"
              type="selection"
              :reserve-selection="true"
              fixed="left"
            />
            <el-table-column v-else label="" width="40" align="center">
              <template slot-scope="scope">
                <el-radio v-model="tableRadio" :label="scope.row"><i /></el-radio>
              </template>
            </el-table-column>
            <el-table-column
              prop="activityName"
              label="优惠券名称"
d64cd58f   wesley88   上传验收小程序
44
45
              width="180"
            />
e5b57447   杨鑫   '分包问卷'
46
47
            <el-table-column
              prop="content"
d64cd58f   wesley88   上传验收小程序
48
49
              label="内容"
            />
e5b57447   杨鑫   '分包问卷'
50
51
            <el-table-column
              prop="activityStartTime"
d64cd58f   wesley88   上传验收小程序
52
53
              label="活动开始时间"
            />
e5b57447   杨鑫   '分包问卷'
54
55
            <el-table-column
              prop="activityEndTime"
d64cd58f   wesley88   上传验收小程序
56
57
              label="活动结束时间"
            />
e5b57447   杨鑫   '分包问卷'
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
          </el-table>
          <div class="fenye">
            <el-pagination
              :current-page="currentPage"
              :hide-on-single-page="true"
              :page-sizes="[10, 20, 50, 100]"
              :page-size="pageSize"
              layout="total, sizes, prev, pager, next, jumper"
              :total="total"
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
            />
          </div>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="visible = false">取 消</el-button>
        <el-button type="primary" @click="doSubmit">确 定</el-button>
      </span>
    </el-dialog>
  </template>
  
  <script>
  import {
    getCoupons
  } from '@/api/public'
  export default {
    name: 'CouponTable',
    props: {
      cId: {
        type: Number,
        default: 0
      },
      cIds: {
        type: Array,
        default: () => []
      },
      isMultiple: {
        type: Boolean,
        default: false
      }
    },
d64cd58f   wesley88   上传验收小程序
100
    data () {
e5b57447   杨鑫   '分包问卷'
101
102
103
104
105
106
107
108
109
110
111
112
113
      return {
        visible: false,
        tableRadio: '',
        formData: {
          keyword: ''
        },
        currentPage: 1,
        total: 0,
        pageSize: 10,
        tableData: [],
        multipleSelection: []
      }
    },
d64cd58f   wesley88   上传验收小程序
114
    mounted () {
e5b57447   杨鑫   '分包问卷'
115
116
117
118
      this.getTableData()
    },
    methods: {
      // 获取优惠券信息
d64cd58f   wesley88   上传验收小程序
119
      getTableData () {
e5b57447   杨鑫   '分包问卷'
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
        var _this = this
        const params = {
          page: this.currentPage,
          pageSize: this.pageSize
        }
        if (this.formData.keyword) {
          params.search = this.formData.keyword
        }
        getCoupons(params).then(res => {
          _this.tableData = res.data.list
          _this.total = res.data.total
          // 表格斌值
          if (this.isMultiple) {
            if (this.cIds.length > 0) {
              this.tableData.forEach(row => {
                for (let i = 0; i < this.cIds.length; i++) {
                  if (this.cIds[i] === row.activityId) {
                    this.$refs.multipleTable.toggleRowSelection(row, true)
                  }
                }
              })
            }
          } else {
            if (this.cId !== 0) {
              this.tableRadio = this.cId
              this.tableData.forEach(row => {
                if (this.cId === row.activityId) {
                  this.tableRadio = row
                }
              })
            }
          }
        })
      },
      // 搜索
d64cd58f   wesley88   上传验收小程序
155
      search () {
e5b57447   杨鑫   '分包问卷'
156
157
        this.getTableData()
      },
d64cd58f   wesley88   上传验收小程序
158
      clear () {
e5b57447   杨鑫   '分包问卷'
159
160
161
162
        this.formData.keyword = ''
        this.getTableData()
      },
      // 每页条数改变
d64cd58f   wesley88   上传验收小程序
163
      handleSizeChange (val) {
e5b57447   杨鑫   '分包问卷'
164
165
166
167
        this.pageSize = val
        this.getTableData()
      },
      // 当前页改变
d64cd58f   wesley88   上传验收小程序
168
      handleCurrentChange (val) {
e5b57447   杨鑫   '分包问卷'
169
170
171
172
        this.currentPage = val
        this.getTableData()
      },
      // 多选改变
d64cd58f   wesley88   上传验收小程序
173
      handleSelectionChange (val) {
e5b57447   杨鑫   '分包问卷'
174
175
176
        this.multipleSelection = val
      },
      // 提交
d64cd58f   wesley88   上传验收小程序
177
      doSubmit () {
e5b57447   杨鑫   '分包问卷'
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
        if (this.isMultiple) {
          this.$emit('doSubmit', this.multipleSelection)
        } else {
          this.$emit('doSubmit', this.tableRadio)
        }
        this.visible = false
      }
    }
  }
  </script>
  
  <style scoped>
  .proSelectBox .formSearch .inputKeyword{
    width: 200px;
  }
  </style>