hcong
2024-10-22 2f3ed8493285728d0f83d50f3a342dbad5a06f9f
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
<template>
  <FYTable @search="onSearch" :row-class-name="tableRowClassName">
    <template #options>
      <FYOptionLocation
        :allOption="true"
        :level="5"
        v-model:value="formSearch._locations"
      ></FYOptionLocation>
      <FYOptionText
        label="场景名称"
        placeholder="输入名称关键字"
        v-model:value="formSearch.searchText"
      ></FYOptionText>
      <FYOptionScene
        :allOption="true"
        :type="1"
        v-model:value="formSearch.scensetype"
      ></FYOptionScene>
      <FYOptionOnlineStatus
        :allOption="true"
        v-model:value="formSearch.online"
      ></FYOptionOnlineStatus>
    </template>
 
    <template #table-column>
      <el-table-column
        fixed="left"
        prop="userInfo.realname"
        label="名称"
        :show-overflow-tooltip="true"
        width="400"
      >
      </el-table-column>
      <el-table-column prop="userInfo.acountname" label="账号" width="110" />
      <el-table-column prop="sceneTypeName" label="类型" width="100" />
      <el-table-column prop="biProvinceName" label="省" width="80" />
      <el-table-column prop="biCityName" label="市" width="80" />
      <!-- <el-table-column prop="districtname" label="区县" width="90" /> -->
      <el-table-column prop="userInfo.extension1" label="区县" width="80" />
      <el-table-column prop="biTownName" label="街道" width="110" />
      <el-table-column prop="biArea" label="集中区" width="110" />
      <el-table-column prop="biManagementCompany" label="物业" min-width="110" />
      <el-table-column prop="userInfo.isenable" label="状态" width="90">
        <template #default="{ row }">
          {{ row.userInfo.isenable ? '上线中' : '已下线' }}
        </template>
      </el-table-column>
      <el-table-column prop="userInfo.usertype" label="用户类型" width="90" />
      <el-table-column fixed="right" align="right" label="操作" width="190">
        <template #header>
          <el-button icon="DocumentAdd" size="default" type="success" @click="drawer = true"
            >新增用户</el-button
          >
        </template>
        <template #default="{ row }">
          <el-space>
            <el-button
              :loading="row.loading2"
              :type="row.userInfo.isenable != '0' ? 'danger' : 'primary'"
              size="small"
              @click="itemActive(row)"
              >{{ row.userInfo.isenable != '0' ? '下线' : '上线' }}</el-button
            >
            <el-button-group>
              <el-button type="primary" :loading="row.loading1" size="small" @click="editRow(row)"
                >查看</el-button
              >
              <el-dropdown @command="handleCommand" trigger="click">
                <el-button
                  type="primary"
                  :loading="row.downloadLoading"
                  size="small"
                  :icon="row.downloadLoading ? '' : 'ArrowDown'"
                ></el-button>
                <template #dropdown>
                  <el-dropdown-menu>
                    <el-dropdown-item icon="Download" :command="{ c: 1, p: row }"
                      >下载环信码</el-dropdown-item
                    >
                  </el-dropdown-menu>
                </template>
              </el-dropdown>
            </el-button-group>
            <!-- <el-dropdown
              split-button
              :loading="row.loading1"
              size="small"
              type="primary"
              @click="editRow(row)"
              @command="handleCommand"
              trigger="click"
            >
              查看
              <template #dropdown>
                <el-dropdown-menu>
                  <el-dropdown-item icon="Download" :command="{ c: 1, p: row }"
                    >下载环信码</el-dropdown-item
                  >
                </el-dropdown-menu>
              </template>
            </el-dropdown> -->
          </el-space>
        </template>
      </el-table-column>
    </template>
  </FYTable>
  <CompUserInfoAddDrawer v-model="drawer"></CompUserInfoAddDrawer>
</template>
 
<script>
import userApi from '@/api/fytz/userApi';
import creditApi from '@/api/fytz/creditApi';
import { useLoadingStore } from '@/stores/loadingStore';
import { mapStores } from 'pinia';
import { useMessageBoxTip } from '@/composables/messageBox';
import CompUserInfoAddDrawer from '@/views/fytz/user/components/CompUserInfoAddDrawer.vue';
 
export default {
  components: {
    CompUserInfoAddDrawer
  },
  data() {
    return {
      // 查询条件
      formSearch: {
        _locations: {},
        searchText: '',
        scensetype: {},
        online: {}
      },
      // 新增用户弹出框
      drawer: false
    };
  },
  computed: {
    ...mapStores(useLoadingStore)
  },
  methods: {
    onSearch(page, func) {
      const f = this.formSearch;
      const area = {};
      // 行政区划
      area.provinceCode = f._locations.pCode;
      area.provinceName = f._locations.pName;
      if (area.provinceCode == null) {
        area.provinceCode = null;
        area.provinceName = null;
      }
      area.cityCode = f._locations.cCode;
      area.cityName = f._locations.cName;
      area.districtCode = f._locations.dCode;
      area.districtName = f._locations.dName;
      area.townCode = f._locations.tCode;
      area.townName = f._locations.tName;
      // 场景类型
      area.sceneTypes = [];
      f.scensetype.value == null
        ? (area.sceneTypes = [])
        : (area.sceneTypes = [f.scensetype.value]);
      // 上下线状态
      area.online = f.online.value;
      // 关键字
      area.searchText = f.searchText;
 
      userApi.fetchUser(page.currentPage, page.pageSize, area).then((res) => {
        if (res) {
          func({
            data: res.data,
            total: res.head.totalCount
          });
        }
      });
    },
    editRow(row) {
      row.loading1 = true;
      this.loadingStore.pushLoading(() => (row.loading1 = false));
      this.$router.push(`userEdit/${row.userInfo.guid}`);
    },
    itemActive(row) {
      const param = {
        guid: row.userInfo.guid,
        isenable: !row.userInfo.isenable
      };
      const msg = row.userInfo.isenable ? '下线' : '上线';
      useMessageBoxTip({
        confirmMsg: `确认${msg}该场景?`,
        confirmTitle: msg,
        onConfirm: async () => {
          row.loading2 = true;
          return userApi
            .updateUserInfo(param)
            .then((res) => {
              if (res.success) {
                row.userInfo.isenable = param.isenable;
              }
            })
            .finally(() => {
              row.loading2 = false;
            });
        }
      });
    },
    tableRowClassName({ row }) {
      return row.userInfo.isenable ? 'online-row' : 'offline-row';
    },
    handleCommand(e) {
      const userId = e.p.userInfo.guid;
      switch (e.c) {
        // 下载环信码
        case 1:
          e.p.downloadLoading = true;
          creditApi.downloadCode(userId).finally(() => {
            e.p.downloadLoading = false;
          });
          break;
 
        default:
          break;
      }
    }
  }
};
</script>
<style></style>