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
<template>
  <div class="page_status">
    <v-header
      title="设备列表"
      :bar="bar"
      search
      @on-search="onSearch"
    ></v-header>
    <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" @click="onCheck(item.scope.id)"
              >查看</span
            >
          </div>
        </template>
      </v-tool-table>
    </div>
    <v-tool-page :item="paged" @on-page="onPage"></v-tool-page>
  </div>
</template>
 
<script>
import { mapState } from "vuex";
export default {
  props: {},
  components: {},
  data() {
    return {
      bar: [
        { title: "设备ID", name: "title" },
        { title: "用户姓名", name: "time" }
      ],
      trs: [
        { text: "序号", val: "index", width: "50px" },
        { text: "绑定日期", val: "name" },
        { text: "设备编号", val: "age" },
        { text: "设备状态", val: "sex" },
        { text: "设备电量", val: "btn", slot: "status" },
        { text: "绑定用户", val: "btn", slot: "zd" }
      ],
      tds: [],
      paged: { page: 0, total: 0, r: 0, limit: 10 },
      os: {},
      search: {}
    };
  },
  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: {
    // 置顶
    onSearch(v) {
      if (v.time && v.time.length && v.time[1]) {
        v.publishAtBegin = v.time[0];
        v.publishAtEnd = v.time[1];
      } else {
        v.publishAtBegin = "";
        v.publishAtEnd = "";
      }
      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();
    },
    // 获取数据
    init() {
      let v = demo.copy(
        Object.assign(this.os, this.search, {
          pageNum: this.paged.page,
          pageSize: this.paged.limit,
          category: "10" // 1.社区动态  3.基务公开
        })
      );
      this.$api.post("communityactivity/pagedynamic", 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;
        });
      });
    },
    onCheck(id) {
      this.$router.push({
        path: "/jh_OldManWristband_Detail",
        query: { id: "10", type: id }
      });
    }
  },
  mounted() {
    //查询动态分类列表
    // this.queryDynamic();
  }
};
</script>
 
<style lang="less" scoped>
.page_status {
  overflow-y: auto;
  .add,
  .tab {
    margin-bottom: 10px;
  }
}
</style>