index.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795
  1. <!--系统用户管理-->
  2. <template>
  3. <div class="app-container user">
  4. <el-row :gutter="20" style="flex:1;display: flex;overflow: hidden">
  5. <!--部门数据-->
  6. <el-col :span="4" :xs="24" stlye="width:260px;" class=" scrollbar-box">
  7. <div class="head-container">
  8. <el-tree
  9. highlight-current
  10. :data="deptOptions"
  11. :props="defaultProps"
  12. icon-class=""
  13. :expand-on-click-node="false"
  14. :filter-node-method="filterNode"
  15. ref="tree"
  16. default-expand-all
  17. @node-click="handleNodeClick"
  18. />
  19. </div>
  20. </el-col>
  21. <!--用户数据-->
  22. <el-col :span="20" :xs="24" style="flex:1;display: flex;flex-direction: column;">
  23. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
  24. <el-form-item label="" prop="searchValue" label-width="68px">
  25. <el-input
  26. v-model="queryParams.searchValue"
  27. placeholder="用户名称/联系方式"
  28. clearable
  29. style="width: 240px"
  30. />
  31. </el-form-item>
  32. <el-form-item label="" prop="state">
  33. <el-select
  34. v-model="queryParams.state"
  35. placeholder="请选择状态"
  36. clearable
  37. style="width: 240px"
  38. >
  39. <el-option
  40. v-for="dict in stateOptions"
  41. :key="dict.dictValue"
  42. :label="dict.dictLabel"
  43. :value="dict.dictValue"
  44. />
  45. </el-select>
  46. </el-form-item>
  47. <el-form-item label="">
  48. <el-date-picker
  49. :clearable="false"
  50. v-model="dateRange"
  51. size="small"
  52. style="width: 240px"
  53. value-format="yyyy-MM-dd"
  54. type="daterange"
  55. range-separator="-"
  56. start-placeholder="创建时间"
  57. end-placeholder="创建时间"
  58. ></el-date-picker>
  59. </el-form-item>
  60. <p class="page-inquire-common-style-button" @click="handleQuery">查询</p>
  61. <p class="page-reset-common-style-button" @click="resetQuery">重置</p>
  62. <p class="page-submit-common-style-button"
  63. style="float: right;"
  64. @click="handleAdd"
  65. v-hasPermiRouter="['system:user:add']"
  66. >新增</p>
  67. </el-form>
  68. <el-table class="table-box min-list-box" v-loading="loading" border :data="userList">
  69. <el-table-column label="账号" align="left" key="account" prop="account" show-overflow-tooltip/>
  70. <el-table-column label="用户昵称" align="left" key="userName" prop="userName" show-overflow-tooltip/>
  71. <el-table-column label="归属部门" align="left" key="deptName" prop="deptName" show-overflow-tooltip/>
  72. <el-table-column label="联系方式" align="left" key="mobile" prop="mobile" width="200" show-overflow-tooltip />
  73. <el-table-column label="状态" align="left" key="state" width="120" show-overflow-tooltip>
  74. <template slot-scope="scope">
  75. <el-switch
  76. @click.native="handleStatusChange(scope.row)"
  77. class="switch captcha-img"
  78. :active-value="true"
  79. :inactive-value="false"
  80. active-color="#0183FA"
  81. inactive-color="#999"
  82. v-model="scope.row.state"
  83. active-text="启用"
  84. inactive-text="停用"
  85. disabled
  86. ></el-switch>
  87. </template>
  88. </el-table-column>
  89. <el-table-column label="创建时间" align="left" prop="createTime" width="160" show-overflow-tooltip>
  90. <template slot-scope="scope">
  91. <span>{{ parseTime(scope.row.createTime,"{y}-{m}-{d} {h}:{i}") }}</span>
  92. </template>
  93. </el-table-column>
  94. <el-table-column
  95. label="操作"
  96. align="left"
  97. width="220"
  98. class-name="small-padding fixed-width"
  99. v-if="tableButtonType">
  100. <template slot-scope="scope">
  101. <div class="table-button-box">
  102. <p class="table-button-null"></p>
  103. <p class="table-button-p"
  104. @click="handleUpdate(scope.row)"
  105. v-hasPermiRouter="['system:user:edit']"
  106. >修改</p>
  107. <p class="table-button-p"
  108. @click="handleDelete(scope.row)"
  109. v-hasPermiRouter="['system:user:del']"
  110. >删除</p>
  111. <el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)"
  112. v-hasPermiRouter="['system:user:reset']">
  113. <span class="table-button-p">更多>></span>
  114. <el-dropdown-menu slot="dropdown">
  115. <el-dropdown-item command="handleResetPwd">修改密码</el-dropdown-item>
  116. </el-dropdown-menu>
  117. </el-dropdown>
  118. <p class="table-button-null"></p>
  119. </div>
  120. </template>
  121. </el-table-column>
  122. </el-table>
  123. <pagination :page-sizes="[20, 30, 40, 50]"
  124. v-show="total>0"
  125. :total="total"
  126. layout="total, prev, pager, next, sizes, jumper"
  127. :page.sync="queryParams.page"
  128. :limit.sync="queryParams.pageSize"
  129. @pagination="getList"
  130. />
  131. </el-col>
  132. </el-row>
  133. <!-- 添加或修改参数配置对话框 -->
  134. <el-dialog :title="title" :visible.sync="open" width="630px" append-to-body :close-on-click-modal="false">
  135. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  136. <el-row>
  137. <el-col :span="12">
  138. <el-form-item label="用户名" prop="userName">
  139. <el-input v-model="form.userName" placeholder="请输入用户名" maxlength="30" style="width:200px;" />
  140. </el-form-item>
  141. </el-col>
  142. <el-col :span="12">
  143. <el-form-item label="联系方式" prop="mobile">
  144. <el-input v-model="form.mobile" placeholder="请输入联系方式" maxlength="11" style="width:200px;"/>
  145. </el-form-item>
  146. </el-col>
  147. </el-row>
  148. <el-row>
  149. <el-col :span="12">
  150. <el-form-item label="类型" prop="userType">
  151. <!--<el-select v-model="form.roleIds" placeholder="请选择" style="width:200px;">-->
  152. <el-select v-model="form.userType" collapse-tags
  153. @change="positionSelectClick"
  154. :disabled="userStanding !== '-1'"
  155. placeholder="请选择" style="width:200px;">
  156. <el-option
  157. v-for="item in userTypeList"
  158. :key="item.key"
  159. :label="item.value"
  160. :value="item.key"
  161. ></el-option>
  162. </el-select>
  163. </el-form-item>
  164. </el-col>
  165. <el-col :span="12">
  166. <el-form-item label="归属部门" prop="deptId">
  167. <el-cascader
  168. style="width:200px;"
  169. v-model="form.deptId"
  170. :options="deptOptionsList"
  171. :show-all-levels="false"
  172. :props="{ checkStrictly: true, children:'child', value: 'deptId', label: 'deptName',emitPath:false }"></el-cascader>
  173. </el-form-item>
  174. <!--<el-form-item label="归属部门" prop="deptId">-->
  175. <!--<treeselect v-model="form.deptId" :options="deptOptions"-->
  176. <!--:normalizer="normalizer" :show-count="true"-->
  177. <!--placeholder="请选择上级部门" style="width:200px;"/>-->
  178. <!--</el-form-item>-->
  179. </el-col>
  180. </el-row>
  181. <el-row>
  182. <el-col :span="12">
  183. <el-form-item v-if="!form.userId" label="账号" prop="account">
  184. <el-input v-model="form.account" placeholder="请输入账号" maxlength="30" style="width:200px;"/>
  185. </el-form-item>
  186. </el-col>
  187. <el-col :span="12">
  188. <el-form-item v-if="!form.userId" label="密码" prop="password">
  189. <el-input v-model="form.password" placeholder="请输入密码" type="password" maxlength="20" show-password style="width:200px;"/>
  190. </el-form-item>
  191. </el-col>
  192. </el-row>
  193. <el-row>
  194. <el-col :span="12">
  195. <el-form-item label="角色" prop="roleIds">
  196. <!--<el-select v-model="form.roleIds" placeholder="请选择" style="width:200px;">-->
  197. <el-select v-model="form.roleIds" collapse-tags
  198. :disabled="userStanding !== '-1'"
  199. placeholder="请选择" style="width:200px;">
  200. <el-option
  201. v-for="item in roleOptions"
  202. :key="item.roleId"
  203. :label="item.roleName"
  204. :value="item.roleId"
  205. ></el-option>
  206. </el-select>
  207. </el-form-item>
  208. </el-col>
  209. <el-col :span="12">
  210. <el-form-item label="状态" prop="state">
  211. <el-radio-group v-model="form.state" style="width:200px;">
  212. <el-radio
  213. v-for="dict in stateOptions"
  214. :key="dict.dictValue"
  215. :label="dict.dictValue"
  216. >{{dict.dictLabel}}</el-radio>
  217. </el-radio-group>
  218. </el-form-item>
  219. </el-col>
  220. </el-row>
  221. </el-form>
  222. <div slot="footer" class="dialog-footer dialog-footer-box">
  223. <p class="dialog-footer-button-null"></p>
  224. <p class="dialog-footer-button-info" @click="cancel">取消</p>
  225. <p class="dialog-footer-button-primary" @click="submitForm">提交</p>
  226. <p class="dialog-footer-button-null"></p>
  227. </div>
  228. </el-dialog>
  229. <!--修改密码-->
  230. <el-dialog title="修改密码" :visible.sync="reviseOpen" v-if="reviseOpen" width="600px" append-to-body class="teacher-revise-dialog-box">
  231. <el-form :model="passwordForm" ref="passwordForm" :inline="true" :rules="rules" class="addCheckPage-min">
  232. <el-form-item label="新密码" prop="password" label-width="110px" >
  233. <el-input type="password" v-model="passwordForm.password" :validate-event="false"
  234. clearable maxlength="20" style="width:420px;" placeholder="请输入新密码"/>
  235. </el-form-item>
  236. <el-form-item label="确认新密码" prop="newPassword" label-width="110px" style="margin-top: 15px;">
  237. <el-input type="password" v-model="passwordForm.newPassword" :validate-event="false"
  238. clearable maxlength="20" style="width:420px;" placeholder="请确认新密码"/>
  239. </el-form-item>
  240. </el-form>
  241. <!--<p class="teacher-text-p">确定要重置该账号的密码吗?</p>-->
  242. <!--<p class="teacher-text-p">确定操作后,该账号密码将重置为系统初始密码。</p>-->
  243. <div slot="footer" class="dialog-footer dialog-footer-box">
  244. <p class="dialog-footer-button-null"></p>
  245. <p class="dialog-footer-button-info" @click="reviseOpenOff">取消</p>
  246. <p class="dialog-footer-button-primary" @click="putUserResetPwd">提交</p>
  247. <p class="dialog-footer-button-null"></p>
  248. </div>
  249. </el-dialog>
  250. </div>
  251. </template>
  252. <script>
  253. import { listUser, getUser, delUser, addUser, updateUser, resetUserPwd, changeUserStatus } from "@/apiDemo/system/user";
  254. import { getToken } from "@/utils/auth";
  255. // import { treeselect } from "@/api/system/dept";
  256. import Treeselect from "@riophae/vue-treeselect";
  257. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  258. //V3新
  259. import { systemUserUserTypeList,systemUserAdd,systemUserDetail,
  260. systemUserUpdate,systemUserEditState,systemUserDelete,systemUserEditPasswd,systemRoleDropList } from "@/api/commonality/permission";
  261. import { systemDeptOrganizeStructure } from "@/api/commonality/permission";
  262. import md5 from 'js-md5';
  263. export default {
  264. name: "User",
  265. components: { Treeselect },
  266. data() {
  267. const equalToPassword = (rule, value, callback) => {
  268. if (this.passwordForm.newPassword !== value) {
  269. callback(new Error("两次输入的密码不一致"));
  270. } else {
  271. callback();
  272. }
  273. };
  274. const equalToPasswordTwo = (rule, value, callback) => {
  275. if (this.passwordForm.password !== value) {
  276. callback(new Error("两次输入的密码不一致"));
  277. } else {
  278. callback();
  279. }
  280. };
  281. // 不能连续字符(如123、abc)连续3位或3位以上
  282. const LxStr = (rule, value, callback) => {
  283. const regex = /([a-zA-Z])\1{2}/;
  284. const regex2 = /(\d)\1{2}/;
  285. const result = value.match(regex);
  286. const result2 = value.match(regex2);
  287. let arr = value.split('')
  288. let flag = true
  289. for (let i = 1; i < arr.length - 1; i++) {
  290. let firstIndex = arr[i - 1].charCodeAt()
  291. let secondIndex = arr[i].charCodeAt()
  292. let thirdIndex = arr[i + 1].charCodeAt()
  293. thirdIndex - secondIndex == 1
  294. secondIndex - firstIndex == 1
  295. if ((thirdIndex - secondIndex == 1) && (secondIndex - firstIndex == 1)) {
  296. flag = false
  297. }
  298. }
  299. if (result||result2||!flag) {
  300. return callback(new Error('不能输入如:123,abc,111,aaa等形式的连续型字符'));
  301. }else{
  302. callback()
  303. }
  304. }
  305. return {
  306. tableButtonType:this.hasPermiDom(['system:user:edit','system:user:detail','system:user:del','system:user:reset']),
  307. // 身份
  308. userStanding:localStorage.getItem('userStanding'),
  309. // 遮罩层
  310. loading: true,
  311. // 选中数组
  312. ids: [],
  313. // 非单个禁用
  314. single: true,
  315. // 非多个禁用
  316. multiple: true,
  317. // 显示搜索条件
  318. showSearch: true,
  319. // 总条数
  320. total: 0,
  321. // 用户表格数据
  322. userList: null,
  323. // 弹出层标题
  324. title: "",
  325. // 部门树选项
  326. deptOptions: null,
  327. deptOptionsList: null,
  328. deptOptionsData:null,
  329. normalizer(node){
  330. //去掉children=[]的children属性
  331. if(node.children && !node.children.length){
  332. delete node.children;
  333. }
  334. return {
  335. id: node.deptId,
  336. parentId:node.parentId,
  337. label:node.deptName,
  338. deptNum:node.deptNum,
  339. deptType:node.deptType,
  340. children:node.child,
  341. }
  342. },
  343. // 是否显示弹出层
  344. open: false,
  345. // 部门名称
  346. deptName: undefined,
  347. // 默认密码
  348. initPassword: undefined,
  349. // 日期范围
  350. dateRange: [],
  351. // 状态数据字典
  352. stateOptions: [{dictValue:true,dictLabel:'启用'},{dictValue:false,dictLabel:'禁用'}],
  353. // 性别状态字典
  354. sexOptions: [],
  355. // 岗位选项
  356. postOptions: [],
  357. // 角色选项
  358. roleOptions: [],
  359. // 类型选项
  360. userTypeList:[
  361. {value:'系统用户',key:0},
  362. {value:'院级大屏',key:3},
  363. {value:'校级大屏',key:4},
  364. ],
  365. defaultProps: {
  366. children: "child",
  367. label: "deptName"
  368. },
  369. // 查询参数
  370. queryParams: {
  371. page:1,
  372. pageSize:20,
  373. userTypes:[0,3,4],
  374. deptId:null,
  375. searchValue: null,
  376. state: null,
  377. },
  378. // 表单参数
  379. form: {
  380. userName:"",
  381. mobile:"",
  382. deptId:null,
  383. roleIds:[],
  384. account:"",
  385. password:"",
  386. state:true,
  387. userType:0
  388. },
  389. // 表单校验
  390. rules: {
  391. account: [
  392. { required: true, message: "请输入用户昵称", trigger: "blur" },
  393. { required: true, message: "请输入用户昵称", validator: this.spaceJudgment, trigger: "blur" }
  394. ],
  395. deptId: [
  396. { required: true, message: "请选择归属部门", trigger: "blur" },
  397. ],
  398. roleIds: [
  399. { required: true, message: "请选择角色", trigger: "blur" },
  400. ],
  401. userType: [
  402. { required: true, message: "请选择类型", trigger: "blur" },
  403. ],
  404. state: [
  405. { required: true, message: "请选择状态", trigger: "blur" },
  406. ],
  407. userName: [
  408. { required: true, message: "用户名不能为空", trigger: "blur" },
  409. { required: true, message: "用户名不能为空", validator: this.spaceJudgment, trigger: "blur" }
  410. ],
  411. password: [
  412. { required: true, message: "用户密码不能为空",trigger :"blur"},
  413. { required: true, message: "用户密码不能为空", validator: this.spaceJudgment,trigger :"blur"},
  414. // { required: true, validator: equalToPassword,trigger :"blur"},
  415. { required: true, message: "不能输入如:123,abc,111,aaa等形式的连续型字符", validator: LxStr,trigger :"blur"},
  416. {
  417. pattern: /^(?=(?:.*[A-Z]){1})(?=(?:.*[a-z]){1})(?=(?:.*[0-9]){1})(?=(?:.*[!@#*?&]){1})(?!(.)\1)(.{10,16})$/,
  418. message: '密码长度最少10位 最多16位,必须同时包含一个大写字母、一个小写字母、一个数字和一个特殊字符!@#*?&',trigger :"blur"
  419. }
  420. ],
  421. newPassword: [
  422. { required: true, message: "确认新密码不能为空",trigger :"blur"},
  423. { required: true, message: "用户密码不能为空", validator: this.spaceJudgment,trigger :"blur"},
  424. { required: true, validator: equalToPasswordTwo,trigger :"blur"},
  425. { required: true, message: "不能输入如:123,abc,111,aaa等形式的连续型字符", validator: LxStr,trigger :"blur"},
  426. {
  427. pattern: /^(?=(?:.*[A-Z]){1})(?=(?:.*[a-z]){1})(?=(?:.*[0-9]){1})(?=(?:.*[!@#*?&]){1})(?!(.)\1)(.{10,16})$/,
  428. message: '密码长度最少10位 最多16位,必须同时包含一个大写字母、一个小写字母、一个数字和一个特殊字符!@#*?&',trigger :"blur"
  429. }
  430. ],
  431. email: [
  432. {
  433. type: "email",
  434. message: "'请输入正确的邮箱地址",
  435. trigger: ["blur", "change"]
  436. }
  437. ],
  438. mobile: [
  439. { required: true, message: "请输入正确的联系方式", trigger: "blur" },
  440. { required: true, message: "请输入正确的联系方式", validator: this.spaceJudgment, trigger: "blur" },
  441. {
  442. pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
  443. message: "请输入正确的联系方式",
  444. trigger: "blur"
  445. }
  446. ]
  447. },
  448. // 重置密码弹层开关
  449. reviseOpen: false,
  450. passwordForm:{
  451. password:"",
  452. newPassword:"",
  453. },
  454. };
  455. },
  456. watch: {
  457. // 根据名称筛选部门树
  458. // deptName(val) {
  459. // this.$refs.tree.filter(val);
  460. // }
  461. },
  462. created() {
  463. this.systemDeptOrganizeStructure();
  464. this.getList();
  465. this.systemRoleDropList();
  466. },
  467. methods: {
  468. /*===========V3开始===========*/
  469. systemDeptOrganizeStructure(){
  470. systemDeptOrganizeStructure({deptName:this.inputDeptName}).then(response => {
  471. for(let i=0;i<response.data.length;i++){
  472. if(response.data[i].child){
  473. for(let o=0;o<response.data[i].child.length;o++){
  474. if(response.data[i].child[o].child){
  475. delete response.data[i].child[o].child
  476. }
  477. }
  478. }
  479. }
  480. this.$set(this,'deptOptions',response.data);
  481. this.$set(this,'deptOptionsData',JSON.parse(JSON.stringify(response.data)));
  482. });
  483. },
  484. /** 查询用户列表 */
  485. getList() {
  486. this.loading = true;
  487. let obj = JSON.parse(JSON.stringify(this.queryParams))
  488. if(this.dateRange[0]){
  489. obj.startTime = this.dateRange[0]+'T00:00:00'
  490. obj.endTime = this.dateRange[1]+'T23:59:59'
  491. }else{
  492. obj.startTime = "";
  493. obj.endTime = "";
  494. }
  495. systemUserUserTypeList(obj).then(response => {
  496. this.userList = response.data.records;
  497. this.total = response.data.total;
  498. this.loading = false;
  499. }
  500. );
  501. },
  502. //角色下拉列表
  503. systemRoleDropList(){
  504. systemRoleDropList({roleName :'',pageSize:100}).then(response => {
  505. this.roleOptions = response.data;
  506. }
  507. );
  508. },
  509. // 筛选节点
  510. filterNode(value, data) {
  511. if (!value) return true;
  512. return data.label.indexOf(value) !== -1;
  513. },
  514. // 节点单击事件
  515. handleNodeClick(data) {
  516. this.queryParams.deptId = data.deptId;
  517. this.getList();
  518. },
  519. // 用户状态修改
  520. handleStatusChange(row) {
  521. let text = row.state ? "停用" : "启用";
  522. this.$confirm('确认要' + text + '"' + row.userName + '"?', "警告", {
  523. confirmButtonText: "确定",
  524. cancelButtonText: "取消",
  525. type: "warning"
  526. }).then(function() {
  527. return systemUserEditState({userId:row.userId, state:!row.state});
  528. }).then(() => {
  529. this.getList();
  530. this.msgSuccess("操作成功");
  531. }).catch(function() {
  532. });
  533. },
  534. /** 新增按钮操作 */
  535. handleAdd() {
  536. this.reset();
  537. this.open = true;
  538. this.$set(this,'deptOptionsList',JSON.parse(JSON.stringify(this.deptOptionsData)));
  539. this.title = "添加用户";
  540. },
  541. /** 删除按钮操作 */
  542. handleDelete(row) {
  543. const userIds = row.userId || this.ids;
  544. this.$confirm('确认删除"'+row.userName+'"?', "警告", {
  545. confirmButtonText: "确定",
  546. cancelButtonText: "取消",
  547. type: "warning"
  548. }).then(function() {
  549. return systemUserDelete({userId:userIds});
  550. }).then(() => {
  551. this.getList();
  552. this.msgSuccess("删除成功");
  553. }).catch(() => {});
  554. },
  555. /** 修改按钮操作 */
  556. handleUpdate(row) {
  557. this.reset();
  558. systemUserDetail({userId:row.userId}).then(response => {
  559. let obj = {
  560. userId:response.data.userId,
  561. userName:response.data.userName,
  562. mobile:response.data.mobile,
  563. deptId:response.data.deptId,
  564. state:response.data.state,
  565. // roleIds:obj.roleIds[0]?response.data.roleIds.split(','):[],
  566. roleIds:response.data.roleIds[0],
  567. userType:response.data.userType
  568. };
  569. this.positionSelectClick(response.data.userType);
  570. this.$set(this,'deptOptionsList',JSON.parse(JSON.stringify(this.deptOptionsData)));
  571. this.$set(this,'form',JSON.parse(JSON.stringify(obj)));
  572. this.open = true;
  573. this.title = "修改用户";
  574. });
  575. },
  576. /** 提交按钮 */
  577. submitForm() {
  578. this.$refs["form"].validate(valid => {
  579. if (valid) {
  580. if (this.form.userId) {
  581. let obj = JSON.parse(JSON.stringify(this.form))
  582. obj.roleIds = obj.roleIds + '';
  583. systemUserUpdate(obj).then(response => {
  584. this.msgSuccess("修改成功");
  585. this.open = false;
  586. this.getList();
  587. });
  588. } else {
  589. let obj = JSON.parse(JSON.stringify(this.form))
  590. obj.password = md5(obj.password)
  591. obj.roleIds = obj.roleIds + '';
  592. systemUserAdd(obj).then(response => {
  593. this.msgSuccess("新增成功");
  594. this.open = false;
  595. this.getList();
  596. });
  597. }
  598. }
  599. });
  600. },
  601. //关闭重置密码页面
  602. reviseOpenOff(){
  603. this.reviseOpen = false;
  604. this.resetPwdId = "";
  605. },
  606. //修改密码
  607. putUserResetPwd(){
  608. this.$refs["passwordForm"].validate(valid => {
  609. if (valid) {
  610. let obj = {
  611. userId : this.resetPwdId,
  612. password:md5(this.passwordForm.password)
  613. };
  614. systemUserEditPasswd(obj).then(response => {
  615. this.reviseOpen = false;
  616. this.msgSuccess("修改成功");
  617. });
  618. }
  619. });
  620. },
  621. /*===========V3结束===========*/
  622. // 取消按钮
  623. cancel() {
  624. this.open = false;
  625. this.reset();
  626. },
  627. // 表单重置
  628. reset() {
  629. this.$set(this,'form',{
  630. userName:"",
  631. mobile:"",
  632. deptId:null,
  633. roleIds:[],
  634. account:"",
  635. password:"",
  636. state:true,
  637. userType:0
  638. });
  639. },
  640. /** 搜索按钮操作 */
  641. handleQuery() {
  642. this.queryParams.page = 1;
  643. this.getList();
  644. },
  645. /** 重置按钮操作 */
  646. resetQuery() {
  647. this.dateRange = [];
  648. this.$set(this,'queryParams',{
  649. page:1,
  650. pageSize:20,
  651. userTypes:[0,3,4],
  652. deptId:this.queryParams.deptId,
  653. searchValue: null,
  654. state: null,
  655. });
  656. this.handleQuery();
  657. },
  658. // 更多操作触发
  659. handleCommand(command, row) {
  660. switch (command) {
  661. case "handleResetPwd":
  662. this.reset();
  663. this.title = "修改密码";
  664. this.resetPwdId = row.userId;
  665. this.$set(this,'passwordForm',{
  666. password:"",
  667. newPassword:"",
  668. });
  669. this.reviseOpen = true;
  670. break;
  671. default:
  672. break;
  673. }
  674. },
  675. positionSelectClick(data){
  676. //选中
  677. let self = this;
  678. if(data == 0){
  679. this.$set(this.form,'deptId',null);
  680. this.$set(this,'deptOptionsList',JSON.parse(JSON.stringify(this.deptOptionsData)));
  681. }else if(data == 3){
  682. let list = [];
  683. for(let i=0;i<self.deptOptionsData.length;i++){
  684. if(self.deptOptionsData[i].child){
  685. for(let o=0;o<self.deptOptionsData[i].child.length;o++){
  686. list.push({
  687. deptId:self.deptOptionsData[i].child[o].deptId,
  688. deptName:self.deptOptionsData[i].child[o].deptName
  689. })
  690. }
  691. }
  692. }
  693. this.$set(this.form,'deptId',null);
  694. this.$set(this,'deptOptionsList',JSON.parse(JSON.stringify(list)));
  695. }else if(data == 4){
  696. this.$set(this.form,'deptId',null);
  697. let list = [];
  698. list.push({
  699. deptId:this.deptOptionsData[0].deptId,
  700. deptName:this.deptOptionsData[0].deptName
  701. })
  702. this.$set(this,'deptOptionsList',JSON.parse(JSON.stringify(list)));
  703. }
  704. this.$forceUpdate();
  705. },
  706. }
  707. };
  708. </script>
  709. <style scoped lang="scss">
  710. .user {
  711. display: flex!important;
  712. flex-direction: column;
  713. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  714. padding:20px;
  715. overflow: hidden;
  716. }
  717. ::v-deep .head-container{
  718. /*==========树结构开始==========*/
  719. .el-tree-node__expand-icon.expanded {
  720. -webkit-transform: rotate(0deg)!important;
  721. transform: rotate(0deg)!important;
  722. }
  723. //未展开
  724. .el-icon-caret-right:before {
  725. content:"\e6d9";
  726. color:#999;
  727. font-size: 12px;
  728. border: 1px solid #999;;
  729. border-radius: 2px;
  730. }
  731. //展开
  732. .el-tree-node__expand-icon.expanded.el-icon-caret-right:before{
  733. content:"\e6d8";
  734. color:#999;
  735. font-size: 12px;
  736. border: 1px solid #999;;
  737. border-radius: 2px;
  738. }
  739. .el-tree-node__expand-icon.is-leaf:before{
  740. color: transparent!important;
  741. border: none;
  742. cursor: default;
  743. }
  744. .el-tree .el-tree-node__label{
  745. font-size:14px;
  746. color:#333333;
  747. font-weight:700;
  748. }
  749. .el-tree .el-tree-node__children .el-tree-node__label{
  750. font-size: 14px!important;
  751. }
  752. .el-tree .el-tree-node__children .el-tree-node__children .el-tree-node__label{
  753. color:#333333;
  754. font-size: 14px!important;
  755. }
  756. .el-tree-node__content{
  757. height:37px;
  758. }
  759. /*==========树结构结束==========*/
  760. }
  761. ::v-deep .min-list-box{
  762. .switch .el-switch__label {
  763. position: absolute;
  764. display: none;
  765. color: #fff !important;
  766. }
  767. .switch .el-switch__label--right {
  768. z-index: 1;
  769. }
  770. .switch .el-switch__label--right span{
  771. margin-left: 10px;
  772. }
  773. .switch .el-switch__label--left {
  774. z-index: 1;
  775. }
  776. .switch .el-switch__label--left span{
  777. margin-left: 24px;
  778. }
  779. .switch .el-switch__label.is-active {
  780. display: block;
  781. }
  782. .switch.el-switch .el-switch__core,
  783. .el-switch .el-switch__label {
  784. width: 64px !important;
  785. margin: 0;
  786. }
  787. }
  788. </style>