unitAdmin.vue 8.95 KB
Newer Older
xulili's avatar
xulili committed
1
<template>
xulili's avatar
xulili committed
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
  <!-- 平台用户单位管理员账号管理 -->
  <div class="user-wrapper height100">
    <div class="search-container">
      <el-form :inline="true" :model="form">
        <el-form-item>
          <el-input
            v-model="form.userName"
            placeholder="请输入管理员姓名"
            suffix-icon="el-icon-search"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item>
            <el-select 
             v-model="form.orgId"
             filterable 
             placeholder="请选择所属单位"
             clearable>
              <el-option
                v-for="item in organList"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              >
              </el-option>
            </el-select>
        </el-form-item>
       <el-form-item>
          <el-cascader
            v-model="form.areaId"
            change-on-select
            :props="cascaderProps"
            :options="areaOptions"
             placeholder="请选择区域"
             clearable>
          </el-cascader>
        </el-form-item>
        <el-form-item>
xulili's avatar
xulili committed
40
          <div class="btn-group">
xulili's avatar
xulili committed
41 42
            <el-button type="primary" @click="handleSubmit">查询</el-button>
            <el-button @click="handleReset">重置</el-button>
xulili's avatar
xulili committed
43
          </div>
xulili's avatar
xulili committed
44 45 46 47 48 49 50 51 52 53 54
        </el-form-item>
      </el-form>
      <div class="page-tip">
        <span class="page-tip-title">页面说明:</span>
        <span class="page-tips"
          >管理员姓名即管理员用户名。可以新增账号,“*”为必填项。可以对账号信息进行修改及重置密码</span
        >
      </div>
    </div>
    <div class="table-content">
      <div class="btn-group">
xulili's avatar
xulili committed
55
        <el-button type="primary" @click="handleAdd()">新建账号</el-button>
xulili's avatar
xulili committed
56
      </div>
xulili's avatar
xulili committed
57 58 59 60
      <account-table
        :feildList="feildList"
        :list="list"
        @action="handleAction"
xulili's avatar
xulili committed
61
        :currentPage="page._index"
xulili's avatar
xulili committed
62 63 64 65 66 67
      />
      <party-pagination :page="page" @changePage="handleChangeCurrent" />
    </div>
    <add-dialog ref="addDialog" @success="getFirstPageList()" />
    <edit-dialog ref="editDialog" @success="getFirstPageList()" />
    <msg-dialog ref="msgDilaog" :msgInfo="msgInfo" />
xulili's avatar
xulili committed
68 69 70
  </div>
</template>
<script>
xulili's avatar
xulili committed
71 72 73 74 75 76
import { partyPagination } from "@/components/index";
import accountTable from "./components/accountTable";
import { addDialog, editDialog } from "./unitAdminDialog";
import msgDialog from "./msgDialog.vue";
import { getAreas } from "@/config/area";
import { getOrgListWithOutPage } from "@/config/organ";
xulili's avatar
xulili committed
77
export default {
xulili's avatar
xulili committed
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
  data() {
    return {
      form: {
        userName: "",
        orgId:'',
        type: 2,  //1.用户账号 2.平台单位单位管理员账号 3.机顶盒账号 4.运维账号
        areaId:[]
      },
      feildList: [
        { prop: "userName", label: "管理员姓名" },
        { prop: "phone", label: "手机号码" },
        { prop: "telephone", label: "固定电话" },
        { prop: "weChat", label: "微信号" },
        { prop: "email", label: "邮箱" },
        { prop: "orgName", label: "所属单位" },
        { prop: "exiredDate", label: "到期时间" },
        { prop: "statusName", label: "账号状态" },
        { prop: "", label: "操作", isEdit: true, width: 280 },
      ],
      list: [],
      page: {
        _index: 1,
        _size: 10,
        total: 0,
      },
      activeRow: {},
      msgInfo: {},
      organList: [],
      areaOptions: [],
      cascaderProps: {
        label: "name",
        value: "code",
        checkStrictly: true,
      },
    };
  },
  components: {
    partyPagination,
    accountTable,
    addDialog,
    editDialog,
    msgDialog,
  },
  mounted() {
    this.getOrgList();
    this.getAreas();
    this.getFirstPageList();
  },
  methods: {
    // 获取区域数据  
    getAreas() {
      getAreas().then((res) => {
        this.areaOptions = res;
      });
xulili's avatar
xulili committed
132
    },
xulili's avatar
xulili committed
133 134 135 136 137
    // 获取机构列表
    getOrgList() {
      getOrgListWithOutPage().then((res) => {
        this.organList = res;
      });
xulili's avatar
xulili committed
138
    },
xulili's avatar
xulili committed
139 140 141 142 143 144 145
    // 获取第一页数据列表
    getFirstPageList() {
      this.page._index = 1;
      this.getPageList();
    },
    // 查询数据
    handleSubmit() {
xulili's avatar
xulili committed
146
     this.getFirstPageList();
xulili's avatar
xulili committed
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
    },
    // 重置查询
    handleReset() {
       this.form =  {
        userName: "",
        orgId:'',
        type:2,
        areaId:[]
      }
      this.getFirstPageList();
    },
    getPageList() {
      let requestParams = {};
      requestParams._index = this.page._index;
      requestParams._size = this.page._size;
      requestParams.type = this.form.type;
      if (this.form.userName) {
        requestParams.userName = this.form.userName;
      }
      if (this.form.orgId) {
        requestParams.orgId = this.form.orgId;
      }
      if(this.form.areaId.length>0){
        requestParams.areaId = [...this.form.areaId].pop();
      }
      this.$https(
        {
          method: "get",
          url: "tUser/getPageList",
          authType: this.backToken,
xulili's avatar
xulili committed
177
        },
xulili's avatar
xulili committed
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
        requestParams
      )
        .then((res) => {
          if (res.status != 200) {
            this.getResWithOutData();
          } else {
            if (res.data.resultCode == 200) {
              this.list = res.data.data.records;
              this.page._size = res.data.data.size;
              this.page.total = res.data.data.total;
            } else {
              this.getResWithOutData();
            }
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
xulili's avatar
xulili committed
197 198 199 200 201 202 203 204 205
     // 页面返回值为空
        getResWithOutData(){
            this.list = []
            this.page = {
                    _index:1,
                    _size:10,
                    total:0
                }
        },
xulili's avatar
xulili committed
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
    // 新增账号
    handleAdd() {
      this.$refs.addDialog.dialogVisible = true;
    },
    // 编辑
    handleEdit() {
      this.$refs.editDialog.id = this.activeRow.id;
      this.$refs.editDialog.getDetailById();
      this.$refs.editDialog.dialogVisible = true;
    },
    // 重置密码
    handleResetPwd() {
      let _this = this;
      this.$https({
        method: "put",
        url: `tUser/resetPassword?userId=${this.activeRow.id}`,
        authType: this.backToken,
      })
        .then((res) => {
          if (res.status != 200) {
            _this.$message.error(res.data.message);
          } else {
            if (res.data.resultCode == 200) {
              _this.msgInfo = {
                type: "success",
                des: `用户${this.activeRow.userName}密码已重置!`,
              };
              _this.$refs.msgDilaog.dialogVisible = true;
            } else {
              _this.$message.error(res.data.message);
            }
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
    // 禁用
    handleDisable() {
      let _this = this;
      this.$https({
        method: "put",
        url: `tUser/disable?userId=${this.activeRow.id}`,
        authType: this.backToken,
      })
        .then((res) => {
          if (res.status != 200) {
            _this.$message.error(res.data.message);
          } else {
            if (res.data.resultCode == 200) {
              _this.msgInfo = {
                type: "wait",
                des: `${this.activeRow.userName}账号禁用申请已提交,待审核…`,
              };
              _this.$refs.msgDilaog.dialogVisible = true;
              _this.getPageList();
            } else {
              _this.$message.error(res.data.message);
            }
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
    // 激活
    handleActive() {
      let _this = this;
      this.$https({
        method: "put",
xulili's avatar
xulili committed
276
        url: `tUser/enable?userId=${this.activeRow.id}`,
xulili's avatar
xulili committed
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
        authType: this.backToken,
      })
        .then((res) => {
          if (res.status != 200) {
            _this.$message.error(res.data.message);
          } else {
            if (res.data.resultCode == 200) {
              _this.msgInfo = {
                type: "success",
                des: `用户${this.activeRow.userName}账号激活成功!`,
              };
              _this.$refs.msgDilaog.dialogVisible = true;
              _this.getPageList();
            } else {
              this.$message.error(res.data.message);
            }
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
    handleAction(params) {
      this.activeRow = params.row;
      switch (params.type) {
        case "enable":
          this.handleActive();
          break;
        case "disable":
          this.handleDisable();
          break;
        case "reset":
          this.handleResetPwd();
          break;
        case "edit":
          this.handleEdit();
          break;
        default:
          break;
      }
    },
    // 翻页
xulili's avatar
xulili committed
319
    handleChangeCurrent(val) {
xulili's avatar
xulili committed
320 321 322 323 324
      this.page._index = val;
      this.getPageList();
    },
  },
};
xulili's avatar
xulili committed
325 326 327
</script>
<style lang="less" scoped>
</style>