hejianhao
2025-04-16 dab2d210ca06c1faa514c6388fbd5de1ab355360
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
<template>
  <div class="custom-scroll">
    <v-header
      :title="'抽奖活动获奖名单'"
      :bar="bar"
      search
      @on-search="onSearch"
    ></v-header>
    <div>
      <div class="fl-fw mr-b-10 fz-9">
        <div>
          奖品总量:<span class="fc-red fw-bold">{{ statisObj.total }}</span>
        </div>
        <div class="mr-l-30">
          已奖励:<span class="fc-red fw-bold">{{ statisObj.total-statisObj.surplus }}</span>
        </div>
        <div class="mr-l-30">
          剩余奖品:<span class="fc-red fw-bold">{{ statisObj.surplus }}</span>
        </div>
      </div>
      <div class="fl-fw">
        <div
          class="fl-f mr-r-20 mr-b-10"
          v-for="(it, ix) in goodsList"
          :key="ix"
        >
          <el-image
            fit="cover"
            class="img-style"
            :src="it.image"
            :preview-src-list="[it.image]"
          >
          </el-image>
          <div class="mr-l-10 fl-co">
            <span class="mr-t-6">{{ it.name }}</span>
            <span class="mr-t-10"
              >已奖励:<span class="fc-red">{{
                it.total - it.surplus
              }}</span></span
            >
            <span class="mr-t-10"
              >剩余奖品:<span class="fc-red">{{
                it.surplus
              }}</span></span
            >
          </div>
        </div>
      </div>
    </div>
    <div class="add fl-al mr-b-10">
      <el-button :disabled="!tds.length" size="small" type="primary" @click.stop="clickHandle('import')"
        >导出</el-button
      >
      <el-button size="small" @click="$router.go(-1)">返回上一页</el-button>
    </div>
    <div class="tab">
      <v-table :trs="trs" :tds="tds">
        <template v-slot:status="item">
          <span v-if="item.scope.status === 1">待兑换</span>
          <span v-if="item.scope.status === 2">已兑换</span>
          <span v-if="item.scope.status === 3">已失效</span>
        </template>
        <template v-slot:createTime="item">
          <span>{{ rTime(item.scope.createTime) }}</span>
        </template>
        <template v-slot:staffTime="item">
          <span>{{ rTime(item.scope.staffTime) }}</span>
        </template>
        <template v-slot:image="{ scope }">
          <div class="fl-cen" v-if="scope.image">
            <el-image
              fit="cover"
              style="width: 30px; height: 30px"
              :src="scope.image"
              :preview-src-list="[scope.image]"
            >
            </el-image>
          </div>
        </template>
        <template v-slot:btn="{ scope }">
          <el-button @click="clickHandle('edit', scope)" type="text"
            >编辑</el-button
          >
          <el-button @click="clickHandle('look', scope)" type="text"
            >查看</el-button
          >
          <el-button @click="clickHandle('delete', scope)" type="text"
            >删除</el-button
          >
          <el-button @click="clickHandle('award', scope)" type="text"
            >获奖名单</el-button
          >
        </template>
      </v-table>
    </div>
    <v-tool-page :item="paged" @on-page="onPage"></v-tool-page>
  </div>
</template>
 
<script>
import { mapState } from "vuex";
import { dateTime } from "../../utils/common";
export default {
  props: {},
  components: {},
  data() {
    return {
      dialogVisible: false,
      bar: [
        { title: "关键字", name: "keyword" },
        {
          title: "状态",
          name: "status",
          type: "select",
          list: [
            {
              value: 1,
              label: "待兑换",
            },
            {
              value: 2,
              label: "已兑换",
            },
            {
              value: 3,
              label: "已失效",
            },
          ],
        },
      ],
      trs: [
        { text: "序号", val: "id", width: "60px" },
        { text: "用户昵称", val: "nickName" },
        { text: "姓名", val: "username" },
        { text: "联系电话", val: "phone" },
        { text: "中奖时间", val: "btn", slot: "createTime" },
        { text: "奖品名称", val: "prizeName" },
        { text: "奖品图片", val: "btn", slot: "image" },
        { text: "核销人", val: "staffName" },
        { text: "核销时间", val: "btn", slot: "staffTime" },
        { text: "状态", val: "btn", slot: "status" },
      ],
      tds: [],
      paged: { page: 0, total: 0, r: 0, limit: 10 },
      search: {},
      goodsList: [],
      statisObj: {},
    };
  },
  computed: {
    ...mapState({ vuex_page: "pageReset" }),
  },
  watch: {
    vuex_page: {
      handler(n) {
        if (n.page === this.$route.path) {
          this.init();
        }
      },
      deep: true,
    },
  },
  methods: {
    rTime(t) {
      return dateTime(t);
    },
    handleClose() {
      this.dialogVisible = false;
    },
    onSearch(v) {
      this.search = demo.copy(v);
      this.paged.page = 1;
      this.init();
    },
    // 分页点击
    onPage(v) {
      if (v.page === this.paged.page && v.page && !v.reset) {
        return 0;
      }
      this.paged.page = v.page;
      this.paged.limit = v.limit;
      this.init();
    },
    // 获取数据
    init() {
      let v = demo.copy(
        Object.assign(this.search, {
          page: this.paged.page,
          size: this.paged.limit,
          paramId: this.$route.query.id,
        })
      );
      this.$api.post("comActRaffleRecord/queryAll", v, (e) => {
        this.paged.total = e.total;
        this.paged.r++;
        this.tds = e.records || [];
      });
    },
    // 页面操作
    clickHandle(type, row) {
      switch (type) {
        case "import": {
          let v = demo.copy(
            Object.assign(this.search, {
              page: this.paged.page,
              size: this.paged.limit,
              paramId: this.$route.query.id,
            })
          );
          this.$api.post("comActRaffleRecord/export", v, (e) => {
            location.href = e;
          });
          break;
        }
        default: {
          break;
        }
      }
    },
    getActStatis() {
      this.$api.get(
        "comActRaffleRecord/queryPrize",
        {
          id: this.$route.query.id,
        },
        (e) => {
          this.statisObj = e;
          this.goodsList = e.comActRafflePrizeVOList;
        }
      );
    },
  },
  mounted() {
    this.getActStatis();
  },
};
</script>
<style scoped>
.custom-scroll {
  overflow: scroll;
}
.text-label {
  width: 150px;
  text-align: right;
}
.text-box {
  width: 200px;
}
.img-style {
  width: 100px;
  height: 100px;
  border-radius: 10px;
}
</style>