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
<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('/jh_activity_add')"
        >新增</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
              class="col_primary"
              v-for="(i, j) in is_level(+item.scope.activityType)"
              :key="j + '-btn'"
              @click="onEvent(i, item.scope)"
              >{{ i.t }}</span
            >
          </div>
        </template>
        <template v-slot:activityType="item">
          <b>{{ isactivityType(+item.scope.activityType - 1) }}</b>
        </template>
        <template v-slot:time="item">
          <b
            >{{ item.scope.activityStartTime }}~{{
              item.scope.activityEndTime
            }}</b
          >
        </template>
        <template v-slot:rewardWay="{ scope }">
          <b>{{ scope.rewardWay == 1 ? "按次奖励" : "" }}</b>
        </template>
        <template v-slot:times="item">
          <b>{{ item.scope.applyStartTime }}~{{ item.scope.applyEndTime }}</b>
        </template>
        <template v-slot:num="item">
          <b
            >{{ item.scope.number }}/{{
              item.scope.peopleNumber < 0 ? "无限" : item.scope.peopleNumber
            }}</b
          >
        </template>
      </v-tool-table>
      <v-tool-page :item="paged" @on-page="onPage"></v-tool-page>
    </div>
    <!-- 二维码 -->
  </div>
</template>
 
<script>
import { mapState } from "vuex";
export default {
  props: {},
  components: {},
  data() {
    return {
      dialogVisible: false,
      bar: [
        { title: "活动名称", name: "title" },
        { title: "状态", name: "activityType", type: "select", list: [] },
        { title: "活动时间", name: "time", type: "times" }
      ],
      trs: [
        { text: "序号", val: "index", width: "50px" },
        { text: "活动名称", val: "title" },
        { text: "活动地点", val: "address" },
        { text: "参与人数", val: "btn", slot: "num", width: "90px" },
        { text: "奖励金汇币", val: "award" },
        // { text: "志愿者人数", val: "btn", slot: "num2", width: "90px" },
        { text: "活动状态", val: "btn", slot: "activityType" },
        { text: "发布时间", val: "creationTime" },
        { text: "活动时间", val: "btn", slot: "time" },
        { text: "报名时间", val: "btn", slot: "times" },
        { text: "操作", val: "btn" }
      ],
      tds: [],
      paged: { page: 0, total: 0, r: 0, limit: 10 },
      os: {},
      search: {},
      item_id: "",
      row_data: {},
      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
    }
  },
  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": {
          console.log(item);
          this.$store.dispatch("setFixed", {
            event: "add",
            data: {
              type: "act-cancel",
              data: {
                id: this.item_id,
                name: this.row_data.title,
                people: this.row_data.contactName
              }
            },
            time: Date.now()
          });
          break;
        }
        default: {
          break;
        }
      }
    },
    // 按钮权限
    is_level(id) {
      /**
        状态:待发布、未开始、报名中、进行中、已结束、已取消
        ①待发布:存草稿的状态;可发布、查看、编辑、删除
        ②未开始:未到报名时间;可查看、编辑、删除
        ④进行中:包括报名到活动结束之前的时间;可报名名单、查看、取消
        ⑤已结束:已到活动结束时间;可报名名单、查看
        ⑥已取消:到活动开始时,未达到需报名人数则自动取消
      */
      let v = [
        { t: "体验反馈", v: "feedback", by: [1, 2, 3, 4, 5, 6] },
        { 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 "feedback": // 报名名单
          this.$router.push(this.$nav.url("/jh_activity_feedback/" + 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("/jh_activity_detail/" + item.id));
          break;
        case "upd": // 编辑
          this.$router.push(this.$nav.url("/jh_activity_edit/" + item.id));
          break;
        case "del": // 删除
          this.$js.model("删除", "是否删除[" + item.title + "]", res => {
            if (res) {
              this.$api.del(
                "Jinhui/experienceExpurgateData",
                { 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.title,
                people: item.contactName
              }
            },
            time: Date.now()
          });
          break;
        default:
      }
    },
    // 状态
    isactivityType(v) {
      return (
        ["未开始", "报名中", "进行中", "已结束", "已取消"][v] || ""
        // 1待开始 2报名中 3已开始 4已结束 5已取消
      );
    },
    onSearch(v) {
      if (v.time && v.time.length && v.time[1]) {
        v.activityStartTime = v.time[0];
        v.activityEndTime = v.time[1];
      } else {
        v.activityStartTime = "";
        v.activityEndTime = "";
      }
      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;
    },
 
    // 保存图片
    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
        })
      );
      this.$api.get("Jinhui/experienceGetList", 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;
          item.activityStartTime = this.$$moment(item.activityStartTime).format(
            "YYYY-MM-DD HH:MM:SS"
          );
          item.activityEndTime = this.$$moment(item.activityEndTime).format(
            "YYYY-MM-DD HH:MM:SS"
          );
          item.applyStartTime = this.$$moment(item.applyStartTime).format(
            "YYYY-MM-DD HH:MM:SS"
          );
          item.applyEndTime = this.$$moment(item.applyEndTime).format(
            "YYYY-MM-DD HH:MM:SS"
          );
        });
      });
    }
  },
  mounted() {
    this.bar[1].list = this.$api.static.party_activityType();
  }
};
</script>
<style lang="less" scoped>
.page_activity {
  overflow-y: auto;
  .tab,
  .add {
    margin-bottom: 10px;
  }
  .code-img {
    width: 200px;
    height: 200px;
    border: 1px red solid;
    margin: auto;
    overflow: hidden;
    img {
      width: 100%;
    }
  }
  .text-f {
    font-size: 13px;
    padding-top: 15px;
    line-height: 20px;
  }
}
</style>