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
<template>
  <div class="page_activity">
    <v-header
      title="项目活动"
    ></v-header>
    <div class="add" v-if="newVal.status === 3">
      <el-button
        type="primary"
        size="small"
        @click.stop="
          $router.push('/act_act_add?type=4&projectId=' + $route.query.id)
        "
        >新增</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.participantMax < 0 ? "无限" : item.scope.participantMax
            }}</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">
        <el-image class="code-img" :src="codeImg" :preview-src-list="[codeImg]">
        </el-image>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button size="mini" @click="resetCode">重置二维码</el-button>
        <el-button size="mini" @click="saveImgHandle">下载保存</el-button>
        <el-button size="mini" @click="dialogVisible = false">关 闭</el-button>
      </span>
    </el-dialog>
  </div>
</template>
 
<script>
import { mapState } from "vuex";
export default {
  props: {
    item: { type: Object },
    level: { type: Number },
  },
  components: {},
  data() {
    return {
      dialogVisible: false,
      bar: [
        // { title: "活动名称", name: "activityName" },
        // { title: "状态", name: "status", type: "select", list: [] },
        // {
        //   title: "积分奖励方式",
        //   name: "rewardWay",
        //   type: "select",
        //   list: [
        //     {
        //       label: "按次奖励",
        //       value: 1,
        //     },
        //   ],
        // },
        // { title: "活动时间", name: "time", type: "times" },
      ],
      trs: [
        { text: "序号", val: "index", width: "50px" },
        { text: "活动名称", val: "activityName" },
        { text: "活动类型", val: "activityType" },
        { text: "活动地点", val: "activityAddr" },
        { text: "居民人数", val: "btn", slot: "num", width: "90px" },
        { text: "积分奖励方式", val: "btn", slot: "rewardWay" },
        // { 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: {},
      newVal: {},
      codeImg: "",
      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,
    },
    item(val) {
      this.newVal = val;
    },
  },
  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("/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("/act_act_list/" + this.item_id));
          break;
        }
        case "close": {
          this.$store.dispatch("setFixed", {
            event: "add",
            data: {
              type: "act-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;
      switch (i.v) {
        case "list": // 报名名单
          this.$router.push(this.$nav.url("/act_act_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("/act_act_detail/" + item.id));
          break;
        case "code": // 二维码
          this.actObj = item;
          this.$api.post(
            "comActActivityCode/getQRCode",
            {
              id: item.id,
              type: 4,
            },
            (e) => {
              this.dialogVisible = true;
              this.codeImg = e;
            }
          );
          break;
        case "upd": // 编辑
          this.$router.push(this.$nav.url("/act_act_edit/" + 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: "act-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;
    },
    // 重置二维码
    resetCode() {
      this.codeImg = "";
      this.$api.post(
        "comActActivityCode/resetQRCode",
        {
          id: this.actObj.id,
          type: 1,
        },
        (e) => {
          demo.toast("重置成功");
          this.codeImg = e;
        }
      );
    },
    // 保存图片
    saveImgHandle() {
      let a = document.createElement("a");
      a.href = this.codeImg;
      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: "4",
          projectId: this.$route.query.id,
        })
      );
      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();
  },
};
</script>
<style lang='less' scoped>
.page_activity {
  overflow-y: auto;
  .tab,
  .add {
    margin-bottom: 10px;
  }
}
</style>