index.vue 28 KB

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