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
<template>
  <div class="box-a">
    <v-header
      title="业主委员会"
      :bar="bar"
      search
      @on-search="onSearch"
    ></v-header>
    <div class="add">
      <el-button @click="add" type="primary" size="small">新增</el-button>
    </div>
    <div>
      <v-tool-table :trs="trs" :tds="tds">
        <template v-slot:companyType="{ scope }">{{
          ["", "社会团体", "民办非企业单位", "基金会"][scope.companyType]
        }}</template>
        <template v-slot:btn="{ scope }">
          <!-- <el-button @click="details(scope)" type="text">查看详情</el-button> -->
          <el-button @click="edit(scope)" type="text">编辑</el-button>
          <el-button @click="clear(scope.id)" type="text">删除</el-button>
          <el-button @click="resetPassword(scope)" type="text"
            >重置密码</el-button
          >
        </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 {
  name: "index",
  mounted() {
    this.$api.post("villagemanager/pagevillage", {}, (e) => {
      e.data.records.forEach((item) => {
        this.bar[1].list.push({
          value: item.villageId,
          label: item.address,
        });
      });
    });
  },
  data() {
    return {
      bar: [
        { title: "业主委员会名称", name: "name" },
        {
          title: "所属小区",
          name: "areaId",
          type: "select",
          list: [],
        },
        { title: " 联系人", name: "username" },
        { title: " 联系电话", name: "phone" },
      ],
      Authorization: "",
      trs: [
        { text: "序号", val: "id", width: "50px" },
        { text: "业主委员会名称", val: "name" },
        { text: "所属小区", val: "areaName" },
        { text: "联系人", val: "contactName" },
        { text: "联系电话", val: "phone" },
        { text: "平台账号", val: "account" },
        { text: "密码", val: "password" },
        { text: "操作", val: "btn", width: "200px" },
      ],
      tds: [],
      search: {},
      paged: { page: 0, total: 0, r: 0, limit: 10 },
    };
  },
  methods: {
    resetPassword(row) {
      this.$confirm("是否将密码重置为admin123456", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        this.$api.get("resetPassword", { userId: row.userId }, (e) => {
          demo.toast("重置成功");
        });
      });
    },
    add() {
      this.$router.push("/committee_add");
    },
    details(row) {
      //查看详情
      const data = JSON.stringify(row);
      this.$router.push({
        path: "/committee_details",
        query: {
          row: data,
        },
      });
    },
    clear(id) {
      this.$confirm("此操作将永久删除该数据, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          let data = {
            id: id,
          };
          this.$api.get("comActCommittee/del", data, (e) => {
            demo.toast("删除成功");
            this.init();
          });
          // this.$message({
          //   type: 'success',
          //   message: '删除成功!'
          // });
        })
        .catch(() => {});
    },
    edit(row) {
      //编辑
      const data = JSON.stringify(row);
      this.$router.push({
        path: "/committee_add",
        query: {
          row: data,
        },
      });
    },
    onSearch(v) {
      // if (v.time && v.time.length && v.time[1]) {
      //   v.createBegin = v.time[0];
      //   v.createEnd = v.time[1];
      // }
      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.search, {
          page: this.paged.page,
          size: this.paged.limit,
        })
      );
      this.$api.post("comActCommittee/queryAll", v, (e) => {
        this.paged.total = e.total;
        this.tds = e.records;
      });
    },
  },
  computed: {
    ...mapState({ vuex_page: "pageReset" }),
  },
  created() {
    this.Authorization = "Bearer " + demo.$session.get("token") || "";
  },
  watch: {
    vuex_page: {
      handler(n) {
        if (n.page === this.$route.path) {
          this.init();
        }
      },
      deep: true,
    },
  },
};
</script>
 
<style scoped lang="less">
.box-a {
  overflow: scroll;
}
.add {
  margin-bottom: 10px;
  display: flex;
  .upload-box {
    margin: 0 10px;
  }
}
</style>