riku
2023-12-20 f58f07875461b7cc8205978cf4f0fac86564df72
src/views/fytz/user/UserInfo.vue
@@ -3,7 +3,7 @@
    <template #options>
      <FYOptionLocation
        :allOption="true"
        :level="4"
        :level="5"
        v-model:value="formSearch._locations"
      ></FYOptionLocation>
      <FYOptionText
@@ -36,41 +36,57 @@
        </template>
      </el-table-column>
      <el-table-column prop="userInfo.acountname" label="账号" width="110" />
      <el-table-column prop="sceneTypeName" label="类型" width="130" />
      <el-table-column prop="biProvinceName" label="省" width="90" />
      <el-table-column prop="biCityName" label="市" width="90" />
      <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="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="scope">
          {{ scope.row.userInfo.isenable ? '上线中' : '已下线' }}
        <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="160">
      <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="scope">
          <el-button
            :loading="scope.row.loading1"
            type="primary"
            size="small"
            @click="editRow(scope)"
            >查看</el-button
          >
          <el-button
            :loading="scope.row.loading2"
            :type="scope.row.userInfo.isenable != '0' ? 'danger' : 'primary'"
            size="small"
            @click="itemActive(scope)"
            >{{ scope.row.userInfo.isenable != '0' ? '下线' : '上线' }}</el-button
          >
        <template #default="{ row }">
          <el-space>
            <!-- <el-button :loading="row.loading1" type="primary" size="small" @click="editRow(row)"
              >查看</el-button
            > -->
            <el-button
              :loading="row.loading2"
              :type="row.userInfo.isenable != '0' ? 'danger' : 'primary'"
              size="small"
              @click="itemActive(row)"
              >{{ row.userInfo.isenable != '0' ? '下线' : '上线' }}</el-button
            >
            <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>
@@ -80,6 +96,7 @@
<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';
@@ -139,37 +156,49 @@
        }
      });
    },
    editRow(scope) {
      scope.row.loading1 = true;
      this.loadingStore.pushLoading(() => (scope.row.loading1 = false));
      this.$router.push(`userEdit/${scope.row.userInfo.guid}`);
    editRow(row) {
      row.loading1 = true;
      this.loadingStore.pushLoading(() => (row.loading1 = false));
      this.$router.push(`userEdit/${row.userInfo.guid}`);
    },
    itemActive(scope) {
    itemActive(row) {
      const param = {
        guid: scope.row.userInfo.guid,
        isenable: !scope.row.userInfo.isenable
        guid: row.userInfo.guid,
        isenable: !row.userInfo.isenable
      };
      const msg = scope.row.userInfo.isenable ? '下线' : '上线';
      const msg = row.userInfo.isenable ? '下线' : '上线';
      useMessageBoxTip({
        confirmMsg: `确认${msg}该场景?`,
        confirmTitle: msg,
        onConfirm: async () => {
          scope.row.loading2 = true;
          row.loading2 = true;
          return userApi
            .updateUserInfo(param)
            .then((res) => {
              if (res.success) {
                scope.row.userInfo.isenable = param.isenable;
                row.userInfo.isenable = param.isenable;
              }
            })
            .finally(() => {
              scope.row.loading2 = false;
              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:
          creditApi.downloadCode(userId)
          break;
        default:
          break;
      }
    }
  }
};