index.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. <template>
  2. <div class="newUserManagement">
  3. <div class="flex-wrap newUserManagement-content">
  4. <div class="newUserManagement-content-left">
  5. <!-- <div class="head flex">
  6. <div class="title">账号组列表</div>
  7. <el-button @click="handleAdd" class="serButton" type="primary" plain size="small">新增</el-button>
  8. </div>
  9. <div class="contents">
  10. <el-scrollbar ref="scroll" style="height: 100%">
  11. <el-tree :data="data" :props="defaultProps" :expand-on-click-node="false" highlight-current node-key="user_group_id" default-expand-all @node-click="handleNodeClick">
  12. <span class="custom-tree-node" slot-scope="{ node, data }">
  13. <span class="customTxt">{{ node.label }}</span>
  14. <span v-show="treeCheckId == data.user_group_id" class="customBtn">
  15. <span v-if="data.user_group_id != 0" @click.stop="handleRemove(node, data)">删除</span>
  16. </span>
  17. </span>
  18. </el-tree>
  19. </el-scrollbar>
  20. </div> -->
  21. <div class="newService-content-left-top">
  22. <div class="flex head">
  23. <div class="title">账号组列表</div>
  24. <el-button @click="handleAdd" class="serButton" size="small">新增</el-button>
  25. </div>
  26. <div class="search">
  27. <el-input size="small" placeholder="请输入内容" clearable prefix-icon="el-icon-search" :filter-node-method="filterArrNode" v-model="search">
  28. </el-input>
  29. </div>
  30. </div>
  31. <div class="newService-content-left-bottom">
  32. <template v-if="dataList.length">
  33. <el-scrollbar ref="scroll" style="height: 100%">
  34. <div v-loading="loading" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.8)">
  35. <!-- <div v-for="(item,index) in dataList" :key="index" @click.stop="handleNodeClick(item,index)" :class="index == activeIndex ? 'active':''" class="contents flex">
  36. <div class="left">
  37. <span class="txt">{{ item.user_group_name }}</span>
  38. </div>
  39. <div v-show="activeIndex == index" class="right">
  40. <span @click.stop="handleRemove(item)" class="error">删除</span>
  41. </div>
  42. </div> -->
  43. <el-tree ref="treeArr" :data="arrs" :props="defaultArrProps" highlight-current :filter-node-method="filterArrNode" default-expand-all node-key="user_group_id" @node-click="handleNodeClick" :expand-on-click-node="false">
  44. <span class="custom-tree-node" slot-scope="{ node,data }">
  45. <div class="flex">
  46. <span class="customTxt">{{ node.label }}</span>
  47. <span v-show="treeCheckId == data.user_group_id" class="customBtn">
  48. <span v-if="data.user_group_id" @click.stop="handleRemove(data)">删除</span>
  49. </span>
  50. </div>
  51. </span>
  52. </el-tree>
  53. </div>
  54. </el-scrollbar>
  55. </template>
  56. <template v-else>
  57. <el-empty description="暂无数据"></el-empty>
  58. </template>
  59. </div>
  60. </div>
  61. <div class="newUserManagement-content-right flex1">
  62. <div class="newUserManagement-content-right-top">
  63. <div class="head flex">
  64. <div class="title">账号组信息</div>
  65. <el-button @click="handleSave" type="primary" size="small" :disabled="editGroupDisabled">保存</el-button>
  66. </div>
  67. <div class="contents">
  68. <el-form :inline="true" :rules="rules" ref="form" :model="formInline" class="demo-form-inline">
  69. <el-form-item prop="user_group_name" label="账号组名称">
  70. <el-input style="width:260px;margin-right: 30px;" size="small" v-model="formInline.user_group_name" placeholder="请输入账号组名称" :disabled="editGroupDisabled"></el-input>
  71. </el-form-item>
  72. <el-form-item prop="up_user_group_name" label="上级用户组">
  73. <el-select style="width:260px;margin-right: 30px;" size="small" clearable v-model="formInline.up_user_group_id" placeholder="请选择上级用户组" :disabled="editGroupDisabled">
  74. <el-option v-for="item in arrTree" :key="item.user_group_id" :label="item.user_group_name" :value="item.user_group_id">
  75. </el-option>
  76. </el-select>
  77. </el-form-item>
  78. <el-form-item label="描述">
  79. <el-input style="width:260px;" size="small" v-model="formInline.user_group_comment" placeholder="请输入描述" :disabled="editGroupDisabled"></el-input>
  80. </el-form-item>
  81. </el-form>
  82. </div>
  83. </div>
  84. <div class="newUserManagement-content-right-bottom">
  85. <div class="head flex">
  86. <div class="title">账号列表</div>
  87. <el-button @click="handleTableAdd" type="primary" size="small" :disabled="addUserDisabled">新增</el-button>
  88. </div>
  89. <div class="contents">
  90. <el-table :data="tableData" height="100%" border style="width: 100%">
  91. <el-table-column prop="user_name" label="用户名">
  92. </el-table-column>
  93. <el-table-column prop="user_status" label="状态">
  94. <template slot-scope="scope">
  95. <div>{{ scope.row.user_status ? '启用' :'禁用' }}</div>
  96. </template>
  97. </el-table-column>
  98. <!-- <el-table-column prop="token_valid_duration" label="令牌有效时长">
  99. </el-table-column> -->
  100. <el-table-column prop="user_comment" label="描述">
  101. </el-table-column>
  102. <el-table-column label="操作" width="235">
  103. <template slot-scope="scope">
  104. <el-button @click="handleTablepaswod(scope.row)" type="primary" plain size="small">修改密码 </el-button>
  105. <el-button @click="handleTableEdit(scope.row)" type="primary" plain size="small">编辑 </el-button>
  106. <!-- <el-button @click="handleTableAuth(scope.row)" type="primary" plain size="small">账号授权 </el-button> -->
  107. <el-button @click="handleTableDel(scope.row)" type="danger" size="small">删除 </el-button>
  108. </template>
  109. </el-table-column>
  110. </el-table>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. <Dialog :flag="paswordFlag">
  116. <div class="dialog-content">
  117. <div class="title">{{ dataTitle }}</div>
  118. <div class="contents">
  119. <el-form ref="ruleForms" :model="ruleForm" :rules="tableRules" label-width="100px" class="demo-ruleForm">
  120. <el-form-item label="账号密码" prop="user_pwd">
  121. <div class="flex-wrap">
  122. <el-input v-model="ruleForm.user_pwd" class="r25" size="small" placeholder="请输入密码" />
  123. <el-button size="small" @click="restPwd" style="position: relative;top: 4px;" class="r26" type="primary">生成密码</el-button>
  124. </div>
  125. </el-form-item>
  126. </el-form>
  127. </div>
  128. <div class="foot right">
  129. <el-button size="small" @click="handleOkSk('ruleForms')" class="r24" type="primary">确定</el-button>
  130. <el-button @click="eledite" size="small">取消</el-button>
  131. </div>
  132. </div>
  133. </Dialog>
  134. <Dialog :flag="tableFlag">
  135. <div class="dialog-content">
  136. <div class="title">{{ dataTitle }}</div>
  137. <div class="contents">
  138. <el-form ref="ruleForm" :model="ruleForm" :rules="tableRules" label-width="100px" class="demo-ruleForm">
  139. <el-form-item label="账号组关联" prop="user_gropu_id">
  140. <el-select style="width: 100%" size="small" v-model="ruleForm.user_group_id" placeholder="请选择">
  141. <el-option v-for="item in arrTree" :key="item.user_group_id" :label="item.user_group_name" :value="item.user_group_id"> </el-option>
  142. </el-select>
  143. </el-form-item>
  144. <el-form-item label="账号名称" prop="user_name">
  145. <el-input v-model="ruleForm.user_name" size="small" placeholder="请输入账号名称" />
  146. </el-form-item>
  147. <!-- <el-form-item label="账号密码" prop="user_pwd">
  148. <div class="flex-wrap">
  149. <el-input v-model="ruleForm.user_pwd" class="r25" size="small" placeholder="请输入密码" />
  150. <el-button size="small" @click="restPwd" style="position: relative;top: 4px;" class="r26" type="primary">生成密码</el-button>
  151. </div>
  152. </el-form-item> -->
  153. <el-form-item label="二级密码" prop="user_sec_pwd">
  154. <el-input v-model="ruleForm.user_sec_pwd" size="small" placeholder="请输入二级密码" />
  155. </el-form-item>
  156. <!-- <el-form-item label="令牌有限期" prop="token_valid_duration">
  157. <el-input v-model="ruleForm.token_valid_duration" size="small" placeholder="请输入令牌有限期(小时)" />
  158. </el-form-item> -->
  159. <el-form-item label="账号描述" prop="user_comment">
  160. <el-input v-model="ruleForm.user_comment" size="small" type="textarea" :rows="3" placeholder="请输入账号描述" />
  161. </el-form-item>
  162. <el-form-item label="是否启用" prop="user_status">
  163. <el-radio v-model="ruleForm.user_status" :label="2">是</el-radio>
  164. <el-radio v-model="ruleForm.user_status" :label="0">否</el-radio>
  165. </el-form-item>
  166. </el-form>
  167. </div>
  168. <div class="foot right">
  169. <el-button size="small" @click="handleOk('ruleForm')" class="r24" type="primary">确定</el-button>
  170. <el-button @click="eledite" size="small">取消</el-button>
  171. </div>
  172. </div>
  173. </Dialog>
  174. <Dialog :flag="dialogFlag" class="dialog-check-group">
  175. <div class="dialog-wrapper">
  176. <div class="title">角色列表</div>
  177. <div class="content">
  178. <!-- <el-tree ref="columnSetTree" :data="tableCols" :class="colsCheckClass" show-checkbox node-key="index" :default-expand-all="true" :props="{
  179. label: 'role_name',
  180. children: 'role_ID',
  181. }" :default-checked-keys="checkedKeysTemp" @check="handleCheck" /> -->
  182. <el-checkbox v-model="item.role_status" v-for="(item, index) in tableCols" :key="index" @change="handleCheckedCitiesChange(item)">{{ item.role_name }}</el-checkbox>
  183. </div>
  184. <div class="foot right t30">
  185. <!-- <el-button size="medium" class="r24" type="primary" @click="onCheck">确定</el-button> -->
  186. <el-button size="medium" @click="hide">关闭</el-button>
  187. </div>
  188. </div>
  189. </Dialog>
  190. <Dialog :flag="rmFlag">
  191. <div class="airportInfoDialog">
  192. <div class="title del-title">删除</div>
  193. <div class="content del-content">
  194. <span class="el-icon-error error r10"></span>您是否确认删除<span class="error l10">{{ rmTitle }}</span>
  195. </div>
  196. <div class="foot right Delfoot">
  197. <el-button size="small" class="r24" @click="tableRemove" type="danger">删除</el-button>
  198. <el-button size="small" @click="rmFlag = false">取消</el-button>
  199. </div>
  200. </div>
  201. </Dialog>
  202. </div>
  203. </template>
  204. <script>
  205. import pb from '@/layout/mixin/getPublicData'
  206. import Dialog from '@/layout/components/Dialog'
  207. import pf from '@/layout/mixin/publicFunc'
  208. import MD5 from 'blueimp-md5'
  209. import { listToTree } from '@/utils/validate'
  210. export default {
  211. name: 'NewManageMent',
  212. components: { Dialog },
  213. mixins: [pb, pf],
  214. data () {
  215. return {
  216. data: [
  217. {
  218. up_user_group_id: -1,
  219. user_group_comment: '',
  220. user_group_id: 0,
  221. user_group_name: '全部账号组',
  222. user_group_status: true,
  223. children: []
  224. }
  225. ],
  226. search: '',
  227. activeIndex: null,
  228. loading: false,
  229. treeCheckId: '',
  230. formInline: {
  231. user_group_name: '',
  232. user_group_comment: '',
  233. up_user_group_id: ''
  234. },
  235. rules: {
  236. user_group_name: [{ required: true, message: '请输入账号组名称', trigger: 'blur' }],
  237. },
  238. ruleForm: {
  239. "token_valid_time": null,
  240. "token_valid_duration": null,
  241. "user_code": null,
  242. "user_code_expire": null,
  243. "user_comment": null,
  244. "user_group_id": null,
  245. "user_id": null,
  246. "user_name": null,
  247. "user_pwd": null,
  248. "user_sec_pwd": null,
  249. "user_status": null,
  250. "user_token": null
  251. },
  252. tableRules: {
  253. user_name: [{ required: true, message: "请输入账号名称", trigger: "blur" }],
  254. user_group_id: [{ required: true, message: '请选择账号组', trigger: 'change' }],
  255. user_pwd: [{ required: true, message: "请输入密码", trigger: "blur" }],
  256. },
  257. paswordFlag: false,//修改密码
  258. tableFlag: false,
  259. title: '新增',
  260. type: '',
  261. dataType: 'add',
  262. dataTitle: '新增账号',
  263. dataObj: {},
  264. defaultProps: {
  265. children: 'children',
  266. label: 'user_group_name'
  267. },
  268. tableData: [],
  269. rmFlag: false,
  270. rmObj: {},
  271. rmTitle: '',
  272. options: [],
  273. rmType: '1',
  274. tableCols: [],
  275. dialogFlag: false,
  276. checkedKeysTemp: [],
  277. userId: '',
  278. arrs: [],
  279. authId: null,
  280. defaultArrProps: {
  281. children: 'children',
  282. label: 'user_group_name'
  283. },
  284. arrTree: [],
  285. treeCheckObj: {}
  286. }
  287. },
  288. watch: {
  289. search (val) {
  290. this.$refs.treeArr.filter(val);
  291. }
  292. },
  293. mounted () {
  294. this.getTreeData()
  295. },
  296. computed: {
  297. dataList () {
  298. return this.arrs
  299. },
  300. editGroupDisabled () {
  301. return !this.type
  302. },
  303. addUserDisabled () {
  304. return !this.treeCheckId
  305. }
  306. },
  307. methods: {
  308. async getTreeData () {
  309. const { code, returnData } = await this.getQueryListAuth(this.queryId)
  310. if (code == 0) {
  311. if (returnData && returnData.length) {
  312. this.arrTree = _.cloneDeep(returnData)
  313. const treeMenu = listToTree(returnData, 'up_user_group_id', 'user_group_id')
  314. this.arrs = treeMenu
  315. }
  316. }
  317. },
  318. filterArrNode (value, data) {
  319. if (!value) return true;
  320. return data.user_group_name.indexOf(value) !== -1;
  321. },
  322. handleAdd () {
  323. this.type = 'add'
  324. this.treeCheckId = null
  325. this.tableData = []
  326. this.clearForm()
  327. this.formInline.user_group_name = '新建账号组'
  328. const datas = this.arrs.filter(item => item.user_group_name == '新建账号组')
  329. if (datas && datas.length) {
  330. return
  331. }
  332. this.arrs.push({ user_group_name: '新建账号组', user_group_id: 'test' })
  333. // console.log(this.arrs)
  334. // this.treeCheckId = this.arrs[this.arrs.length-1].user_group_id
  335. },
  336. async handleNodeClick (data) {
  337. if (data.user_group_id) {
  338. const datas = this.arrTree.filter(item => item.user_group_id == data.up_user_group_id)
  339. this.treeCheckId = data.user_group_id
  340. this.treeCheckObj = _.cloneDeep(data)
  341. this.formInline = _.cloneDeep(data)
  342. if (data.user_group_id != 'test') {
  343. if (!data.up_user_group_id || datas.length < 1) {
  344. this.formInline.up_user_group_id = ''
  345. }
  346. this.type = 'edit'
  347. const { code, returnData } = await this.getQueryList(SERVICE_ID.getUserTableId, {
  348. up_user_group_id: data.user_group_id
  349. })
  350. if (code == 0 && returnData && returnData.length) {
  351. this.tableData = returnData
  352. } else {
  353. this.tableData = []
  354. }
  355. }
  356. }
  357. },
  358. //清空表单
  359. clearForm () {
  360. const data = this.formInline
  361. for (const key in data) {
  362. if (Object.hasOwnProperty.call(data, key)) {
  363. data[key] = null
  364. }
  365. }
  366. this.$refs['form'].resetFields()
  367. },
  368. clearTableForm () {
  369. const data = this.ruleForm
  370. for (const key in data) {
  371. if (Object.hasOwnProperty.call(data, key)) {
  372. data[key] = null
  373. }
  374. }
  375. setTimeout(() => {
  376. this.$refs['ruleForm'].resetFields()
  377. }, 50);
  378. },
  379. restPwd () {
  380. this.ruleForm.user_pwd = '123!@#QWEqwe'
  381. },
  382. //树删除
  383. handleRemove (data) {
  384. this.rmTitle = data.user_group_name
  385. this.rmFlag = true
  386. this.rmObj = data
  387. this.rmType = '1'
  388. },
  389. async tableRemove () {
  390. if (this.rmType == '1') {
  391. const { user_group_id } = this.treeCheckObj
  392. if (user_group_id == 'test') {
  393. this.arrs.pop()
  394. } else {
  395. if (this.rmObj.children) {
  396. delete this.rmObj.children
  397. }
  398. const { code } = await this.getChangeList(this.queryId, this.rmObj, 3)
  399. if (code == 0) {
  400. this.getTreeData()
  401. this.rmObj = {}
  402. this.clearForm()
  403. this.tipMsg(code)
  404. }
  405. }
  406. } else {
  407. const { user_name } = this.dataObj
  408. const { user_group_id } = this.treeCheckObj
  409. const { code } = await this.getChangeList(SERVICE_ID.getUserTableId, { user_name, up_user_group_id: user_group_id }, 3)
  410. this.tipMsg(code)
  411. if (code == 0) {
  412. const { returnData } = await this.getQueryList(SERVICE_ID.getUserTableId, {
  413. up_user_group_id: this.dataObj.up_user_group_id
  414. })
  415. this.tableData = returnData
  416. this.dataObj = {}
  417. this.clearTableForm()
  418. }
  419. }
  420. this.rmFlag = false
  421. },
  422. async handleSave () {
  423. this.$refs['form'].validate(async (valid) => {
  424. if (valid) {
  425. let code = null
  426. let mesResult = null
  427. this.formInline.user_group_id = this.treeCheckId
  428. const data = _.cloneDeep(this.formInline)
  429. // console.log(this.type)
  430. if (this.type = 'edit') {
  431. const id = this.formInline.user_group_id
  432. if (id && id != 'test') {
  433. const res = await this.getChangeList(this.queryId, data, 2, 'user_group_id')
  434. code = res.code
  435. } else {
  436. let result = null
  437. if (id == 'test') {
  438. data.user_group_id = null
  439. result = await this.getChangeList(this.queryId, data, 1)
  440. } else {
  441. result = await this.getChangeList(this.queryId, data, 1)
  442. }
  443. code = result.code
  444. mesResult = result
  445. }
  446. }
  447. if (code == 0) {
  448. if (this.type == 'add') {
  449. this.clearForm()
  450. }
  451. this.getTreeData()
  452. this.tipMsg(code)
  453. } else {
  454. if (mesResult.code == -1 && mesResult.message.toString().includes('for key')) {
  455. this.tipMsg(code, '账号组名称重复,请重新输入')
  456. } else {
  457. this.tipMsg(code)
  458. }
  459. }
  460. }
  461. else {
  462. return false
  463. }
  464. })
  465. },
  466. handleTableAdd () {
  467. if (this.treeCheckObj.user_group_id) {
  468. this.tableFlag = true
  469. this.dataType = 'add'
  470. this.dataTitle = '新增账号'
  471. this.clearTableForm()
  472. this.ruleForm.user_group_id = this.treeCheckObj.user_group_id
  473. } else {
  474. this.$message.error('请选中用户后再操作')
  475. }
  476. },
  477. handleTableEdit (row) {
  478. row.user_group_id = row.up_user_group_id
  479. this.tableFlag = true
  480. this.dataType = 'edit'
  481. this.userId = row.user_id
  482. this.dataTitle = '编辑账号'
  483. this.ruleForm = _.cloneDeep(row)
  484. },
  485. async handleTableAuth (row) {
  486. this.dialogFlag = true
  487. const result = await this.getQueryList(SERVICE_ID.roleListId)
  488. const msg = await this.getQueryList(SERVICE_ID.userAuthorizationId, {
  489. user_id: row.user_id
  490. })
  491. if (result.code == 0 && result.returnData && result.returnData.length) {
  492. this.tableCols = result.returnData
  493. this.tableCols.forEach(element => {
  494. element.user_id = row.user_id
  495. });
  496. }
  497. if (msg.code == 0 && msg.returnData && msg.returnData.length) {
  498. msg.returnData.forEach(element => {
  499. this.tableCols.forEach(res => {
  500. if (res.role_ID == element.role_id) {
  501. res.role_status = true
  502. }
  503. });
  504. });
  505. }
  506. // console.log(this.tableCols)
  507. // console.log(code)
  508. },
  509. handleTablepaswod (row) {
  510. this.paswordFlag = true
  511. this.dataType = 'edit'
  512. this.dataTitle = '修改密码'
  513. this.userId = row.user_id
  514. const ruleForm = _.cloneDeep(row)
  515. ruleForm.user_pwd = ''
  516. this.ruleForm = ruleForm
  517. },
  518. async handleTableDel (row) {
  519. this.dataObj = row
  520. this.rmTitle = row.user_name
  521. this.rmFlag = true
  522. this.rmType = '2'
  523. },
  524. async handleCheckedCitiesChange (data) {
  525. let arr = {}
  526. let event = null
  527. if (data.role_status == true) {
  528. event = 1
  529. arr = {
  530. role_id: data.role_ID,
  531. user_id: data.user_id
  532. }
  533. } else if (data.role_status == false) {
  534. event = 3
  535. arr = {
  536. role_id: data.role_ID,
  537. user_id: data.user_id
  538. }
  539. }
  540. const { code } = await this.getChangeList(SERVICE_ID.userAuthorizationId, arr, event)
  541. this.tipMsg(code)
  542. },
  543. hide () {
  544. this.dialogFlag = false
  545. },
  546. async handleOkSk () {
  547. const id = this.ruleForm.user_group_id || this.ruleForm.user_id
  548. if (id) {
  549. const r = PLATFROM_CONFIG.editRule
  550. const b = r.test(this.ruleForm.user_pwd)
  551. if (b) {
  552. this.ruleForm.user_pwd = MD5(this.ruleForm.user_pwd)
  553. const data = _.cloneDeep(this.ruleForm)
  554. const { user_id, user_pwd } = data
  555. const newData = {
  556. user_id,
  557. user_pwd
  558. }
  559. const { code } = await this.getChangeList(SERVICE_ID.getUserTableId, newData, 2, 'user_id')
  560. this.tipMsg(code)
  561. const result = await this.getQueryList(SERVICE_ID.getUserTableId, {
  562. up_user_group_id: this.treeCheckObj.user_group_id
  563. })
  564. this.tableData = result.returnData
  565. // this.clearTableForm()
  566. this.tableFlag = false
  567. this.paswordFlag = false
  568. } else {
  569. this.$message.error('请根据密码规则设置密码')
  570. }
  571. }
  572. },
  573. async handleOk (data) {
  574. this.$refs[data].validate(async (valid) => {
  575. if (valid) {
  576. // this.ruleForm.user_pwd= MD5(this.ruleForm.user_pwd)
  577. if (this.dataType == 'add') {
  578. this.ruleForm.up_user_group_id = this.ruleForm.user_group_id
  579. delete this.ruleForm.user_group_id
  580. const data = this.ruleForm
  581. const { code, message } = await this.getChangeList(SERVICE_ID.getUserTableId, data, 1)
  582. if (code == -1 && message.toString().includes('for key')) {
  583. this.tipMsg(code, '账号名称重复,请重新输入')
  584. } else {
  585. this.tipMsg(code)
  586. }
  587. } else {
  588. const id = this.ruleForm.user_group_id || this.ruleForm.user_id
  589. if (id) {
  590. this.ruleForm.user_pwd = MD5(this.ruleForm.user_pwd)
  591. this.ruleForm.up_user_group_id = this.ruleForm.user_group_id
  592. const data = _.cloneDeep(this.ruleForm)
  593. delete data.user_group_id
  594. delete data.user_pwd
  595. const { code } = await this.getChangeList(SERVICE_ID.getUserTableId, data, 2, 'user_id')
  596. this.tipMsg(code)
  597. }
  598. }
  599. const result = await this.getQueryList(SERVICE_ID.getUserTableId, {
  600. up_user_group_id: this.treeCheckObj.user_group_id
  601. })
  602. this.tableData = result.returnData
  603. this.clearTableForm()
  604. this.tableFlag = false
  605. this.paswordFlag = false
  606. }
  607. else {
  608. return false
  609. }
  610. })
  611. },
  612. eledite () {
  613. this.paswordFlag = false
  614. this.tableFlag = false
  615. this.clearTableForm()
  616. }
  617. }
  618. }
  619. </script>
  620. <style lang="scss" scoped>
  621. .newUserManagement {
  622. padding: 24px;
  623. height: calc(100vh - 80px);
  624. .custom-tree-node {
  625. flex: 1;
  626. font-size: 14px;
  627. padding-right: 24px;
  628. .customBtn {
  629. color: #dd3838;
  630. font-size: 12px;
  631. margin-top: 3px;
  632. }
  633. }
  634. &-content {
  635. height: 100%;
  636. .title {
  637. font-size: 20px;
  638. font-family: Microsoft YaHei;
  639. font-weight: bold;
  640. color: #101116;
  641. }
  642. &-left {
  643. height: 100%;
  644. width: 440px;
  645. background: #ffffff;
  646. box-shadow: 0px 3px 3px 0px rgba(0, 0, 0, 0.1);
  647. border-radius: 4px;
  648. margin-right: 16px;
  649. .newService-content-left-top {
  650. padding: 24px 24px 18px 24px;
  651. .search {
  652. margin-top: 18px;
  653. }
  654. }
  655. .newService-content-left-bottom {
  656. height: calc(100% - 130px);
  657. padding-right: 5px;
  658. }
  659. .contents {
  660. // margin-top: 24px;
  661. padding: 0 24px;
  662. height: 42px;
  663. line-height: 42px;
  664. .left {
  665. font-size: 16px;
  666. font-family: Microsoft YaHei;
  667. font-weight: bold;
  668. color: #101116;
  669. }
  670. .right {
  671. color: #dd3838;
  672. cursor: pointer;
  673. }
  674. .custom-tree-node {
  675. flex: 1;
  676. display: flex;
  677. align-items: center;
  678. justify-content: space-between;
  679. font-size: 14px;
  680. padding-right: 8px;
  681. .customBtn {
  682. color: #dd3838;
  683. font-size: 12px;
  684. }
  685. }
  686. }
  687. .active {
  688. background: #e4f3f9;
  689. }
  690. }
  691. &-right {
  692. &-top {
  693. height: 136px;
  694. background: #ffffff;
  695. box-shadow: 0px 3px 3px 0px rgba(0, 0, 0, 0.1);
  696. border-radius: 4px;
  697. padding: 24px;
  698. .contents {
  699. .el-form-item {
  700. margin-bottom: 0;
  701. margin-top: 20px;
  702. }
  703. }
  704. }
  705. &-bottom {
  706. margin-top: 16px;
  707. height: calc(100% - 152px);
  708. background: #ffffff;
  709. box-shadow: 0px 3px 3px 0px rgba(0, 0, 0, 0.1);
  710. border-radius: 4px;
  711. padding: 24px;
  712. .contents {
  713. margin-top: 24px;
  714. height: calc(100% - 50px);
  715. }
  716. }
  717. }
  718. }
  719. }
  720. </style>