index.vue 28 KB

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