Blame view

src/views/system/users/index.vue 11.8 KB
xiaomiao committed
1
<template>
xiaomiao committed
2
  <div class="from-clues">
xiaomiao committed
3 4
    <div class="from-clues-header">
      <el-form ref="ruleForm" :model="form" label-width="100px">
5
        <el-form-item v-if="BASE_API.THEME == 'jg'">
任超 committed
6 7
          <Breadcrumb />
        </el-form-item>
xiaomiao committed
8
        <el-row class="mb-5">
9 10 11
          <el-col :span="4">
            <el-form-item label="用户名" prop="loginName">
              <el-input v-model.trim="form.loginName" class="width100" clearable placeholder="用户名"></el-input>
xiaomiao committed
12 13
            </el-form-item>
          </el-col>
14 15 16 17 18 19 20 21 22 23 24
          <el-col :span="4">
            <el-form-item label="姓名" prop="name">
              <el-input v-model.trim="form.name" class="width100" clearable placeholder="姓名"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="工号" prop="code">
              <el-input v-model.trim="form.code" class="width100" clearable placeholder="工号"></el-input>
            </el-form-item>
          </el-col>
          <!-- 操作按钮 -->
25
          <el-col :span="12" class="btnColRight">
xiaomiao committed
26
            <btn nativeType="cx" @click="getTableList">查询</btn>
27 28
            <btn nativeType="cx" @click="handleAdd">添加人员</btn>
          </el-col>
xiaomiao committed
29 30 31 32
        </el-row>
      </el-form>
    </div>
    <div class="from-clues-content">
任超 committed
33
      <lb-table :pagination="false" @size-change="handleSizeChange" @p-current-change="handleCurrentChange"
34 35
        :column="tableData.columns" :calcHeight="BASE_API.calcHeight" :data="tableData.data" :expand-row-keys="keyList"
        row-key="dictid">
xiaomiao committed
36
      </lb-table>
xiaomiao committed
37
    </div>
任超 committed
38
    <EditDialog ref="dialogForm" v-model="isDialog" @ok="reloadTableData" />
xiaomiao committed
39 40 41
  </div>
</template>
<script>
任超 committed
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
import {
  getUuid,
  judgeSort,
  realMove,
  findParents,
  removeTreeListItem,
} from "@/utils/operation";
import {
  resetPassword,
  getUserList, getUserLists
} from "@/api/personnelManage";
import { api, deleteAction, getAction } from '@/api/manageApi'
import data from "./data";
import { deleteDomStr } from '@/utils/proDomStr'
import tableMixin from "@/mixins/tableMixin.js";
import EditDialog from "./edit-dialog.vue";
import { updateOrder } from "@/api/orders"
export default {
  name: "menus",
  mixins: [tableMixin],
  components: {
    EditDialog,
  },
  data () {
    return {
      isDialog: false,
      taskData: null,
      keyList: [],
      form: {
        loginName: "",
        name: "",
        code: "",
      },
      queryParam: {},
      selectType: "0",
      queryName: "",
      organizationId: "", // 组织机构ID
      departmentId: "", // 部门ID
      departmentList: [], // 部门列表
      levelList: [], // 职务级别
      sexList: [],
      typeOptions: [
        {
          value: "0",
          label: "姓名",
任超 committed
87
        },
任超 committed
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
        {
          value: "1",
          label: "工号",
        },
        {
          value: "2",
          label: "部门",
        },
        {
          value: "3",
          label: "机构",
        },
      ],

      selectionList: [],
      tableData: {
        columns: [
105
          {
任超 committed
106 107 108 109
            label: "序号",
            type: "index",
            width: "50",
            index: this.indexMethod,
110
          },
任超 committed
111 112 113 114 115 116 117 118 119
        ]
          .concat(data.columns())
          .concat([
            {
              label: "职位",
              render: (h, scope) => {
                return (
                  <div v-show={scope.row.jobLevel !== null}>{scope.row.jobLevel ? "干事" : "经理"}</div>
                )
120

任超 committed
121 122
              }
            },
xiaomiao committed
123
            {
任超 committed
124 125 126 127 128 129
              label: "负责人",
              render: (h, scope) => {
                return (
                  <i v-show={scope.row.isDuty !== null} class="el-icon-check" />
                )
              }
xiaomiao committed
130
            },
任超 committed
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
            {
              label: "排序",
              width: 300,
              render: (h, scope) => {
                return (
                  <div>
                    <el-button
                      type="text"
                      class='movebtnColor'
                      disabled={scope.row.isTop}
                      onClick={() => {
                        this.updateOrder(scope.row, 'TOP');
                      }}
                    >
                      置顶
                    </el-button>
                    <el-button
                      type="text"
                      class='movebtnColor'
                      disabled={scope.row.isTop}
                      onClick={() => {
                        this.updateOrder(scope.row, 'UP');
                      }}
                    >
                      上移
                    </el-button>
                    <el-button
                      type="text"
                      class='movebtnColor'
                      disabled={scope.row.isBottom}
                      onClick={() => {
                        this.updateOrder(scope.row, 'DOWN');
                      }}
                    >
                      下移
                    </el-button>
                    <el-button
                      type="text"
                      size="mini"
                      class='movebtnColor'
                      disabled={scope.row.isBottom}
                      onClick={() => {
                        this.updateOrder(scope.row, 'BOTTOM');
                      }}
                    >
                      置底
                    </el-button>
                  </div>
                );
xiaomiao committed
180
              },
任超 committed
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
            },
            {
              label: "操作",
              width: 380,
              render: (h, scope) => {
                return (
                  <div>
                    <el-button
                      type="text"
                      size="mini"
                      class='resetbtnColor'
                      onClick={() => {
                        this.resetPassword(scope.row.id);
                      }}
                    >
                      重置
                    </el-button>
                    <el-button
                      type="text"
                      size="mini"
                      class='successColor'
                      onClick={() => {
                        this.handleEdit(scope.row);
                      }}
                    >
                      修改
                    </el-button>
                    <el-button
                      type="text"
                      size="mini"
                      class='delColor'
                      onClick={() => {
                        this.handleDelete(scope.row.id, scope.row.name);
                      }}
                    >
                      删除
                    </el-button>
                  </div>
                );
xiaomiao committed
220
              },
任超 committed
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
            },
          ]),
        data: [],
      },
    };
  },
  created () {
    this.getTableList();
  },
  computed: {
    departmentid () {
      return this.$store.state.user.userInfo;
    },
  },
  methods: {
    handleAdd () {
      this.isDialog = true
      this.$refs.dialogForm.adds();
      this.$refs.dialogForm.title = "添加";
    },
    // 查询
    getTableList () {
      this.queryParam = {
        name: this.form.name,
        code: this.form.code,
        loginName: this.form.loginName,
      };
      getUserLists(this.queryParam).then((res) => {
        if (res.status === 1) {
          this.loading = false;
          this.tableData.data = res.content;
          this.tableData.data = judgeSort(this.tableData.data);
          let arr = []
          this.tableData.data.forEach((item) => {
            arr.push(item.departmentId)
          })
          this.getDepts(arr)
        } else {
          this.$message.error({ message: res.message, showClose: true })
        }
      })
    },
    // 获取组织机构
    getDepts (deptIdArr) {
      let params = {
        queryOptions: {
          conditionGroup: {
            conditions: [
269
              {
任超 committed
270 271 272
                property: "id",
                value: deptIdArr,
                operator: "IN",
273
              },
任超 committed
274 275 276 277
            ],
            queryRelation: "AND",
          },
          orderBys: [],
278 279
        },
      };
任超 committed
280 281 282 283
      getAction(api.departments, params).then(
        (res) => {
          let deptsList = res.content;
          deptsList.forEach((ele) => {
xiaomiao committed
284
            this.tableData.data.forEach((item) => {
任超 committed
285 286 287
              if (ele.id == item.departmentId) {
                item.departmentName = ele.name
              }
xiaomiao committed
288
            })
任超 committed
289
          })
290

任超 committed
291 292 293 294 295 296 297 298
        },
        (err) => {
          console.log("err :", err);
        }
      );
    },
    // getTableList () {
    //   this.loading = true;
xiaomiao committed
299

任超 committed
300 301 302 303 304 305 306 307 308 309 310
    //   getUserList().then((res) => {
    //     if (res.status === 1) {
    //       console.log("res人员列表", res);
    //       this.loading = false;
    //       this.tableData.data = res.content;
    //       this.tableData.data = judgeSort(this.tableData.data);
    //     } else {
    //       this.$message.error({ message: res.message, showClose: true });
    //     }
    //   });
    // },
任超 committed
311

任超 committed
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330
    // 重置用户密码
    resetPassword (data) {
      const ids = []
      if (data instanceof Array) {
        data.forEach((item) => {
          ids.push(item.id)
        })
      } else {
        ids.push(data)
      }
      if (ids.length === 0) {
        this.$message({
          message: '请选择需要重置密码的用户!',
          showClose: true
        })
        return
      }
      this.$confirm(
        `<div  class="customer-message-wrapper">
xiaomiao committed
331
              <h5 class="title">确定要重置密码吗</h5>
xiaomiao committed
332 333 334 335
               <p class="result">执行后,数据将
                 <span >无法恢复</span>
                </p>
        </div>`,
任超 committed
336 337
        '执行确认',
        {
xiaomiao committed
338
          dangerouslyUseHTMLString: true,
xiaomiao committed
339 340 341 342
          customClass: 'customer-delete',
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
任超 committed
343 344 345 346 347 348
        }
      )
        .then(() => {
          resetPassword(ids).then((res) => {
            if (res.status === 1) {
              this.$message.success({ message: res.message, showClose: true })
349
              this.getTableList()
任超 committed
350 351 352
            } else {
              this.$message.error({ message: res.message, showClose: true })
            }
任超 committed
353
          })
任超 committed
354 355
        })
        .catch(() => { })
xiaomiao committed
356
    },
任超 committed
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409
    //排序
    updateOrder (record, operate) {
      const findIndex = this.tableData.data.findIndex(item => item.id === record.id)
      let swapId = ''
      if (operate === 'UP') {
        swapId = this.tableData.data[findIndex - 1].id
      } else if (operate === 'DOWN') {
        swapId = this.tableData.data[findIndex + 1].id
      }
      updateOrder('/rest/users', record, operate, swapId).then(res => {
        if (res.status === 1) {
          this.$message.success({ message: res.message, showClose: true })
          this.getTableList();
        } else {
          this.$message.error({ message: res.message, showClose: true })
        }
      })
    },

    // 修改人员信息
    handleEdit (row) {
      console.log("rowwwww", row);
      this.isDialog = true
      this.$refs.dialogForm.edit(row);
      this.$refs.dialogForm.title = "修改";
    },
    // 删除
    handleDelete (id, content) {
      this.$confirm(deleteDomStr(content), '执行确认', {
        dangerouslyUseHTMLString: true,
        customClass: 'customer-delete',
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          deleteAction(`${api.users}/${id}`).then((res) => {
            if (res.status === 1) {
              this.$message.success({ message: res.message, showClose: true })
            } else {
              this.$message.error({ message: res.message, showClose: true })
            }
            this.getTableList()
          })
        })
        .catch(() => { })
    },
    // 新增回显
    reloadTableData () {
      this.getTableList()
    },
  },
};
xiaomiao committed
410
</script>
xiaomiao committed
411
<style scoped lang="scss">
412
@import "~@/styles/mixin.scss";
xiaomiao committed
413
</style>