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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
<template>
  <div class="page_activity">
    <v-header
      title="社区活动"
      search
      :bar="bar"
      @on-search="onSearch"
    ></v-header>
    <div class="add">
      <el-button
        type="primary"
        size="small"
        @click.stop="$router.push('/com_activity_add')"
        >新增</el-button
      >
      <el-button size="small" @click.stop="$router.push('/activityStatistics')"
        >党建活动统计</el-button
      >
    </div>
    <div class="tab">
      <v-tool-table :trs="trs" :tds="tds">
        <template v-slot:btn="item">
          <div class="table_flex">
            <!-- {{item.scope.id}} -->
            <span
              v-if="item.scope.isQrCode === 1"
              @click="onEvent({ v: 'code' }, item.scope)"
              class="col_primary"
              >二维码</span
            >
            <span
              class="col_primary"
              v-for="(i, j) in is_level(+item.scope.status)"
              :key="j + '-btn'"
              @click="onEvent(i, item.scope)"
              >{{ i.t }}</span
            >
            <el-dropdown
              @command="handleCommand"
              @visible-change="handleCommand2(item.scope)"
              style="
                display: flex;
                align-items: center;
                justify-content: center;
                line-height: 1;
                cursor: pointer;
                color: #2593fc;
              "
            >
              <span class="el-dropdown-link">更多</span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item command="sign">签到记录</el-dropdown-item>
                <el-dropdown-item command="comment">评价记录</el-dropdown-item>
                <el-dropdown-item command="up">报名记录</el-dropdown-item>
                <el-dropdown-item
                  v-if="item.scope.status === 3 || item.scope.status === 4"
                  command="close"
                  >取消活动</el-dropdown-item
                >
              </el-dropdown-menu>
            </el-dropdown>
          </div>
        </template>
        <template v-slot:status="item">
          <b>{{ isStatus(+item.scope.status - 1) }}</b>
        </template>
        <template v-slot:time="item">
          <b>{{ item.scope.beginAt }}~{{ item.scope.endAt }}</b>
        </template>
        <template v-slot:rewardWay="{ scope }">
          <b>{{ scope.rewardWay == 1 ? "按次奖励" : "" }}</b>
        </template>
        <template v-slot:times="item">
          <b>{{ item.scope.signUpBegin }}~{{ item.scope.signUpEnd }}</b>
        </template>
        <template v-slot:num="item">
          <b
            >{{ item.scope.participantNow }}/{{
              item.scope.partyMemberMax < 0 ? "无限" : item.scope.partyMemberMax
            }}</b
          >
        </template>
        <template v-slot:num2="item">
          <b
            >{{ item.scope.volunteerNow }}/{{
              item.scope.volunteerMax < 0 ? "无限" : item.scope.volunteerMax
            }}</b
          >
        </template>
      </v-tool-table>
    </div>
    <v-tool-page :item="paged" @on-page="onPage"></v-tool-page>
    <el-dialog
      title="活动签到码"
      :visible.sync="dialogVisible"
      width="30%"
      :before-close="handleClose"
      center
      append-to-body
    >
      <div class="fl-cen">
        <div class="fl-coc">
          <span>活动签到码</span>
          <el-image
            class="code-img"
            :src="codeImg"
            :preview-src-list="[codeImg]"
          >
          </el-image>
          <el-button size="mini" @click="saveImgHandleLeft"
            >下载保存</el-button
          >
        </div>
        <div class="fl-coc mr-l-50">
          <span>活动签退码</span>
          <el-image
            class="code-img"
            :src="codeImgOut"
            :preview-src-list="[codeImgOut]"
          >
          </el-image>
          <el-button size="mini"@click="saveImgHandleRight"
            >下载保存</el-button
          >
        </div>
      </div>
      <div class="fl-cen mr-t-20">
        <el-button size="mini" @click="resetCodeLeft">重置二维码</el-button>
      </div>
      <div class="fc-999 mr-t-20 lh-15">
        用户需签到两次,签到和签退,二维码重置后,二维码重置后原二维码依
        旧可以进行签到或签退,每个用户仅可对同一个二维码进行一次签到或签
        退,即在完成扫码后该用户将无法继续扫描此码进行签到或签退,用户扫
        了签到码后必须在当天扫描签退码,才可获得积分奖励并累计时长,否则
        视为此次签到无效
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button size="mini" @click="dialogVisible = false">关 闭</el-button>
      </span>
    </el-dialog>
  </div>
</template>
 
<script>
import { mapState } from "vuex";
export default {
  props: {},
  components: {},
  data() {
    return {
      dialogVisible: false,
      bar: [
        { title: "活动名称", name: "activityName" },
        { title: "状态", name: "status", type: "select", list: [] },
        {
          title: "活动类型",
          name: "activityType",
          type: "select",
          list: [],
        },
        { title: "活动时间", name: "time", type: "times" },
      ],
      trs: [
        { text: "序号", val: "index", width: "50px" },
        { text: "活动名称", val: "activityName" },
        { text: "活动地点", val: "activityAddr" },
        // { text: "单次活动时长(小时)", val: "duration" },
        // { text: "单次活动奖励积分", val: "rewardIntegral" },
        { text: "活动分类", val: "activityType" },
        // { text: "党员人数", val: "btn", slot: "num", width: "90px" },
        // { text: "志愿者人数", val: "btn", slot: "num2", width: "90px" },
        { text: "活动状态", val: "btn", slot: "status" },
        { text: "发布时间", val: "publishAt" },
        { text: "活动时间", val: "btn", slot: "time" },
        { text: "报名时间", val: "btn", slot: "times" },
        { text: "评分等级", val: "evaluateLevel" },
        { text: "操作", val: "btn" },
      ],
      tds: [],
      paged: { page: 0, total: 0, r: 0, limit: 10 },
      os: {},
      search: {},
      item_id: "",
      row_data: {},
      codeImg: "",
      codeImgOut: "",
      actObj: {},
    };
  },
  computed: {
    ...mapState({ vuex_page: "pageReset" }),
  },
  watch: {
    vuex_page: {
      handler(n) {
        if (n.page === this.$route.path) {
          this.paged.page = 1;
          this.init();
        }
      },
      deep: true,
    },
  },
  methods: {
    handleCommand2(data) {
      this.item_id = data.id;
      this.row_data = data;
    },
    handleCommand(val, item) {
      switch (val) {
        case "sign": {
          this.$router.push(this.$nav.url("/com_checkRecord/" + this.item_id));
          break;
        }
        case "comment": {
          this.$router.push(this.$nav.url("/evaluateRecord/" + this.item_id));
          break;
        }
        case "up": {
          this.$router.push(
            this.$nav.url("/com_activity_list/" + this.item_id)
          );
          break;
        }
        case "close": {
          console.log(item);
          this.$store.dispatch("setFixed", {
            event: "add",
            data: {
              type: "com-cancel",
              data: {
                id: this.item_id,
                name: this.row_data.activityName,
                people: this.row_data.contactName,
              },
            },
            time: Date.now(),
          });
          break;
        }
        default: {
          break;
        }
      }
    },
    // 按钮权限
    is_level(id) {
      /**
        状态:待发布、未开始、报名中、进行中、已结束、已取消
        ①待发布:存草稿的状态;可发布、查看、编辑、删除
        ②未开始:未到报名时间;可查看、编辑、删除
        ④进行中:包括报名到活动结束之前的时间;可报名名单、查看、取消
        ⑤已结束:已到活动结束时间;可报名名单、查看
        ⑥已取消:到活动开始时,未达到需报名人数则自动取消
      */
      let v = [
        // { t: "报名名单", v: "list", by: [3, 4, 5, 6] },
        { t: "发布", v: "add", by: [1] },
        { t: "查看", v: "sel", by: [1, 2, 3, 4, 5, 6] },
        { t: "编辑", v: "upd", by: [1, 2, 6] },
        { t: "删除", v: "del", by: [1, 2, 6] },
        // { t: "取消", v: "close", by: [3, 4] },
      ];
      let o = v.filter((k) => {
        return k.by.indexOf(+id) >= 0;
      });
      return demo.copy(o);
    },
    // 点击操作按钮
    onEvent(i, item) {
      let t = this;
      // console.log(item);
      switch (i.v) {
        case "list": // 报名名单
          this.$router.push(this.$nav.url("/com_activity_list/" + item.id));
          break;
        case "add": // 发布
          this.$api.post(
            "communityactivity/releaseactivity",
            { id: item.id },
            () => {
              demo.toast("发布成功");
              t.init();
            }
          );
          break;
        case "sel": // 查看
          this.$router.push(this.$nav.url("/com_activity_detail/" + item.id));
          break;
        case "code": // 二维码
          this.actObj = item;
          this.$api.post(
            "comActActivityCode/getQRCode",
            {
              id: item.id,
              type: 1,
              signType: 1,
            },
            (e) => {
              this.dialogVisible = true;
              this.codeImg = e;
            }
          );
          this.$api.post(
            "comActActivityCode/getQRCode",
            {
              id: item.id,
              type: 1,
              signType: 2,
            },
            (e) => {
              this.dialogVisible = true;
              this.codeImgOut = e;
            }
          );
          break;
        case "upd": // 编辑
          this.$router.push(this.$nav.url("/com_activity_add?id=" + item.id));
          break;
        case "del": // 删除
          this.$js.model(
            "删除",
            "是否删除[" + item.activityName + "]",
            (res) => {
              if (res) {
                this.$api.del(
                  "communityactivity/activity",
                  { id: item.id },
                  () => {
                    demo.toast("删除成功");
                    t.init();
                  }
                );
              }
            }
          );
          break;
        case "close": // 取消 cancelReason id
          this.$store.dispatch("setFixed", {
            event: "add",
            data: {
              type: "com-cancel",
              data: {
                id: item.id,
                name: item.activityName,
                people: item.contactName,
              },
            },
            time: Date.now(),
          });
          break;
        default:
      }
    },
    // 状态
    isStatus(v) {
      return (
        ["待发布", "未开始", "报名中", "进行中", "已结束", "已取消"][v] || ""
      );
    },
    onSearch(v) {
      if (v.time && v.time.length && v.time[1]) {
        v.beginAt = v.time[0];
        v.endAt = v.time[1];
      } else {
        v.beginAt = "";
        v.endAt = "";
      }
      this.search = demo.copy(v);
      delete this.search.time;
      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();
    },
    handleClose() {
      this.dialogVisible = false;
    },
    // 重置二维码
    resetCodeLeft() {
      this.codeImg = "";
      this.$api.post(
        "comActActivityCode/resetQRCode",
        {
          id: this.actObj.id,
          type: 1,
          signType: 1,
        },
        (e) => {
          this.codeImg = e;
          this.codeImgOut = "";
          this.$api.post(
            "comActActivityCode/getQRCode",
            {
              id: this.actObj.id,
              type: 1,
              signType: 2,
            },
            (e) => {
              demo.toast("重置成功");
              this.codeImgOut = e;
            }
          );
        }
      );
    },
    resetCodeRight() {
      this.codeImgOut = "";
      this.$api.post(
        "comActActivityCode/resetQRCode",
        {
          id: this.actObj.id,
          type: 1,
          signType: 2,
        },
        (e) => {
          this.codeImgOut = e;
          this.codeImg = "";
          this.$api.post(
            "comActActivityCode/getQRCode",
            {
              id: this.actObj.id,
              type: 1,
              signType: 1,
            },
            (e) => {
              demo.toast("重置成功");
              this.codeImg = e;
            }
          );
        }
      );
    },
    // 保存图片
    saveImgHandleLeft() {
      let a = document.createElement("a");
      a.href = this.codeImg;
      a.setAttribute("download", "chart-download");
      a.click();
    },
    saveImgHandleRight() {
      let a = document.createElement("a");
      a.href = this.codeImgOut;
      a.setAttribute("download", "chart-download");
      a.click();
    },
    // 获取数据
    init() {
      let v = demo.copy(
        Object.assign(this.os, this.search, {
          pageNum: this.paged.page,
          pageSize: this.paged.limit,
          type: "1",
        })
      );
      this.$api.post("communityactivity/pageactivity", v, (e) => {
        this.paged.total = e.total;
        this.paged.r++;
        this.tds = e.records || [];
        e.records.map((item, index) => {
          item.index = (this.paged.page - 1) * this.paged.limit + index + 1;
        });
      });
    },
  },
  mounted() {
    this.bar[1].list = this.$api.static.party_status();
    this.$api.get("communityactivity/activity/type/list", { type: 1 }, (e) => {
      e.forEach((item) => {
        item.label = item.name;
        item.value = item.name;
      });
      this.bar[2].list = e;
    });
  },
};
</script>
<style lang='less' scoped>
.page_activity {
  overflow-y: auto;
  .tab,
  .add {
    margin-bottom: 10px;
  }
}
.lh-15 {
  line-height: 1.5;
}
</style>