index.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. <template>
  2. <zj-tab-page ref="tabPage" :defaultActives="[{ key: 'list', label: $route.meta.title + '-列表', essential: true }]">
  3. <template slot-scope="{ activeKey, data }">
  4. <div
  5. :style="{
  6. width: '100%',
  7. height: activeKey == 'list' ? '100%' : '0px',
  8. overflow: activeKey == 'list' ? 'auto' : 'hidden'
  9. }"
  10. >
  11. <div class="app-container">
  12. <div class="setting_title">账户管理</div>
  13. <el-divider></el-divider>
  14. <div class="mymain-container">
  15. <div class="btn-group clearfix">
  16. <div class="fl">
  17. <el-button size="small" type="primary" icon="el-icon-plus" @click="addOrEdit('add')"
  18. >新增账户</el-button
  19. >
  20. </div>
  21. <div class="fr">
  22. <el-select
  23. v-model="screenForm.role"
  24. placeholder="全部"
  25. size="small"
  26. style="width: 120px; margin-right: 10px"
  27. @change="getListByScreen"
  28. >
  29. <el-option label="全部角色" value=""></el-option>
  30. <el-option
  31. :label="item.name"
  32. :value="item.adminRoleId"
  33. v-for="(item, index) in roleList"
  34. :key="index"
  35. ></el-option>
  36. </el-select>
  37. <el-select
  38. v-model="screenForm.status"
  39. placeholder="全部"
  40. size="small"
  41. style="width: 120px; margin-right: 10px"
  42. @change="getListByScreen"
  43. >
  44. <el-option label="全部状态" value=""></el-option>
  45. <el-option
  46. :label="item.label"
  47. :value="item.value"
  48. v-for="(item, index) in select_status"
  49. :key="index"
  50. ></el-option>
  51. </el-select>
  52. <el-input
  53. placeholder="商户名称"
  54. v-model="screenForm.companyWechatName"
  55. size="small"
  56. style="width: 180px"
  57. ></el-input>
  58. <el-input placeholder="账号" v-model="screenForm.keyword" size="small" style="width: 180px">
  59. <el-button slot="append" icon="el-icon-search" size="small" @click="getListByScreen"></el-button>
  60. </el-input>
  61. <el-button
  62. size="small"
  63. @click="
  64. screenForm.companyWechatName = ''
  65. screenForm.keyword = ''
  66. screenForm.role = ''
  67. screenForm.status = ''
  68. getListByScreen()
  69. "
  70. >清空</el-button
  71. >
  72. </div>
  73. </div>
  74. <div class="table">
  75. <el-table
  76. v-loading="listLoading"
  77. :data="dataList"
  78. element-loading-text="Loading"
  79. border
  80. fit
  81. highlight-current-row
  82. stripe
  83. >
  84. <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
  85. <el-table-column align="center" label="商户" prop="companyName" min-width="160"></el-table-column>
  86. <el-table-column align="center" label="账号" prop="userName" min-width="120"></el-table-column>
  87. <el-table-column align="center" label="用户名" prop="nickName" min-width="160"></el-table-column>
  88. <el-table-column align="center" label="角色" prop="roleName" min-width="100"></el-table-column>
  89. <el-table-column align="center" label="创建时间" prop="createTime" min-width="160"></el-table-column>
  90. <el-table-column
  91. align="center"
  92. label="最后登录时间"
  93. prop="lastLoginTime"
  94. min-width="160"
  95. ></el-table-column>
  96. <el-table-column align="center" label="状态" class-name="status-col">
  97. <template slot-scope="scope">
  98. <el-tag :type="scope.row.status ? 'success' : 'danger'">{{
  99. scope.row.status ? '正常' : '冻结'
  100. }}</el-tag>
  101. </template>
  102. </el-table-column>
  103. <el-table-column align="center" label="操作" min-width="160">
  104. <template slot-scope="scope">
  105. <el-popconfirm
  106. v-if="scope.row.status"
  107. style="margin-right: 10px"
  108. title="确定冻结吗?"
  109. @confirm="changeStatus(scope.row.adminUserId, 0)"
  110. >
  111. <el-button slot="reference" type="text">冻结</el-button>
  112. </el-popconfirm>
  113. <el-popconfirm
  114. v-else
  115. style="margin-right: 10px"
  116. title="确定恢复吗?"
  117. @confirm="changeStatus(scope.row.adminUserId, 1)"
  118. >
  119. <el-button slot="reference" type="text">恢复</el-button>
  120. </el-popconfirm>
  121. <el-button type="text" @click="addOrEdit('edit', scope.row.adminUserId)">编辑</el-button>
  122. <el-button type="text" @click="handleReset(scope.row.adminUserId)">重置密码</el-button>
  123. <el-button v-if="userName == 'admin'" type="text" @click="dengluLogin(scope.row)">登入</el-button>
  124. </template>
  125. </el-table-column>
  126. </el-table>
  127. </div>
  128. <div class="pagination clearfix">
  129. <div class="fr">
  130. <el-pagination
  131. @size-change="handleSizeChange"
  132. @current-change="handleCurrentChange"
  133. :current-page="currentPage"
  134. :page-sizes="[10, 20, 30, 50]"
  135. :page-size="10"
  136. layout="total, sizes, prev, pager, next, jumper"
  137. :total="listTotal"
  138. >
  139. </el-pagination>
  140. </div>
  141. </div>
  142. </div>
  143. </div>
  144. </div>
  145. <div v-if="~['add', 'edit'].indexOf(activeKey)" style="box-sizing: border-box; padding: 16px">
  146. <el-form ref="addForm" :model="addForm" :rules="addFormRules" label-position="left" label-width="100px">
  147. <el-row :gutter="20">
  148. <el-col :md="6">
  149. <el-form-item label="账号" prop="account">
  150. <el-input v-model="addForm.account" autocomplete="off" placeholder="请输入账号"></el-input>
  151. </el-form-item>
  152. <h3 style="padding-bottom: 10px"></h3>
  153. </el-col>
  154. <el-col :md="6">
  155. <el-form-item label="用户名" prop="nickName">
  156. <el-input v-model="addForm.nickName" autocomplete="off" placeholder="请输入用户名"></el-input>
  157. </el-form-item>
  158. <h3 style="padding-bottom: 10px"></h3>
  159. </el-col>
  160. <el-col :md="6">
  161. <el-form-item label="手机号" prop="linkPhone">
  162. <el-input v-model="addForm.linkPhone" autocomplete="off" placeholder="请输入手机号"></el-input>
  163. </el-form-item>
  164. <h3 style="padding-bottom: 10px"></h3>
  165. </el-col>
  166. <el-col :md="6">
  167. <el-form-item label="密码" prop="newPassword">
  168. <el-input
  169. v-model="addForm.newPassword"
  170. ref="password1"
  171. autocomplete="off"
  172. placeholder="请输入密码"
  173. :type="passwordType1"
  174. ></el-input>
  175. <span class="show-pwd" @click="showPwd(1)">
  176. <svg-icon :icon-class="passwordType1 === 'password' ? 'eye' : 'eye-open'" />
  177. </span>
  178. </el-form-item>
  179. <h3 style="padding-bottom: 10px"></h3>
  180. </el-col>
  181. <div style="width: 100%">
  182. <el-col :md="6">
  183. <el-form-item label="确认密码" prop="confirmPassword">
  184. <el-input
  185. v-model="addForm.confirmPassword"
  186. ref="password2"
  187. autocomplete="off"
  188. placeholder="请再次输入密码"
  189. :type="passwordType2"
  190. ></el-input>
  191. <span class="show-pwd" @click="showPwd(2)">
  192. <svg-icon :icon-class="passwordType2 === 'password' ? 'eye' : 'eye-open'" />
  193. </span>
  194. </el-form-item>
  195. <h3 style="padding-bottom: 10px"></h3>
  196. </el-col>
  197. <el-col :md="6">
  198. <el-form-item label="部门/网点" prop="rwaide">
  199. <el-cascader
  200. style="width: 100%"
  201. :options="departmentList"
  202. :props="{
  203. checkStrictly: true,
  204. emitPath: false,
  205. multiple: true,
  206. filterable: true,
  207. value: 'adminDeptId',
  208. label: 'deptName'
  209. }"
  210. filterable
  211. v-model="addForm.rwaide"
  212. clearable
  213. >
  214. <template slot-scope="{ node, data }">
  215. <span
  216. >{{ data.pid == '0' ? '' : data.pid == '1' ? '商户-' : data.isWebsit ? '网点-' : '部门-'
  217. }}{{ data.deptName }}</span
  218. >
  219. </template>
  220. </el-cascader>
  221. </el-form-item>
  222. </el-col>
  223. <el-col :md="6" v-if="addForm.adminUserId != userInfoData.adminUserId">
  224. <el-form-item label="角色组" prop="role">
  225. <el-select v-model="addForm.role" placeholder="请选择角色组" style="width: 100%">
  226. <el-option
  227. :label="item.name"
  228. :value="item.adminRoleId"
  229. v-for="(item, index) in roleList"
  230. :key="index"
  231. ></el-option>
  232. </el-select>
  233. </el-form-item>
  234. <h3 style="padding-bottom: 10px"></h3>
  235. </el-col>
  236. <el-col :md="6">
  237. <el-form-item label="是否公众号通知" prop="pubNotice" label-width="120px">
  238. <el-switch v-model="addForm.pubNotice" active-color="#13ce66" inactive-color="#ff4949"> </el-switch>
  239. </el-form-item>
  240. <h3 style="padding-bottom: 10px"></h3>
  241. </el-col>
  242. </div>
  243. <el-col :md="6" v-if="userInfoData.type != 0">
  244. <el-form-item label="是否供应商" prop="isVender" label-width="120px">
  245. <el-switch v-model="addForm.isVender" active-color="#13ce66" inactive-color="#ff4949"> </el-switch>
  246. </el-form-item>
  247. </el-col>
  248. <el-col :md="6" v-if="addForm.isVender && userInfoData.type != 0">
  249. <el-form-item label="供应商" prop="venderId">
  250. <el-select v-model="addForm.venderId" placeholder="请选择供应商" style="width: 100%" filterable>
  251. <el-option
  252. v-for="(item, index) in venderList"
  253. :key="index"
  254. :label="item.venderName"
  255. :value="item.venderId"
  256. :disabled="item.status !== 'ON'"
  257. />
  258. </el-select>
  259. </el-form-item>
  260. </el-col>
  261. </el-row>
  262. </el-form>
  263. <div slot="footer" class="dialog-footer">
  264. <el-button @click="data.removeTab()">取 消</el-button>
  265. <el-button type="primary" @click="submitAddForm(data.removeTab)">确 定</el-button>
  266. </div>
  267. </div>
  268. <div v-if="~['resetpassword'].indexOf(activeKey)" style="box-sizing: border-box; padding: 16px">
  269. <el-form ref="resetForm" :model="resetForm" :rules="resetFormRules" label-position="left" label-width="100px">
  270. <el-form-item label="输入新密码" prop="newPassword">
  271. <el-input
  272. v-model="resetForm.newPassword"
  273. ref="password1"
  274. autocomplete="off"
  275. placeholder="请输入新密码"
  276. :type="passwordType1"
  277. ></el-input>
  278. <span class="show-pwd" @click="showPwd(1)">
  279. <svg-icon :icon-class="passwordType1 === 'password' ? 'eye' : 'eye-open'" />
  280. </span>
  281. </el-form-item>
  282. <el-form-item label="确认密码" prop="confirmPassword">
  283. <el-input
  284. v-model="resetForm.confirmPassword"
  285. ref="password2"
  286. autocomplete="off"
  287. placeholder="请再次输入新密码"
  288. :type="passwordType2"
  289. ></el-input>
  290. <span class="show-pwd" @click="showPwd(2)">
  291. <svg-icon :icon-class="passwordType2 === 'password' ? 'eye' : 'eye-open'" />
  292. </span>
  293. </el-form-item>
  294. </el-form>
  295. <div slot="footer" class="dialog-footer">
  296. <el-button @click="data.removeTab()">取 消</el-button>
  297. <el-button type="primary" @click="submitResetForm(data.removeTab)">确 定</el-button>
  298. </div>
  299. </div>
  300. </template>
  301. </zj-tab-page>
  302. </template>
  303. <script>
  304. import {
  305. getAccountList,
  306. getRoleList,
  307. changeAccountStatus,
  308. resetPassword,
  309. addAccount,
  310. editAccount,
  311. getUserInfo,
  312. getDepartmentList,
  313. getMerchantList
  314. } from '@/api/setting'
  315. import { adminDeptTreeWebsit } from '@/api/departmentManagement.js'
  316. import { listPageV2 } from '@/api/auxiliaryFittings/supplier'
  317. export default {
  318. data() {
  319. var validatePass = (rule, value, callback) => {
  320. if (value === '') {
  321. callback(new Error('请输入新密码'))
  322. } else if (value && value.length < 6) {
  323. callback(new Error('密码长度至少6位'))
  324. } else {
  325. if (this.resetForm.confirmPassword !== '') {
  326. this.$refs.resetForm.validateField('confirmPassword')
  327. }
  328. callback()
  329. }
  330. }
  331. var validatePass2 = (rule, value, callback) => {
  332. if (value === '') {
  333. callback(new Error('请再次输入密码'))
  334. } else if (value !== this.resetForm.newPassword) {
  335. callback(new Error('两次输入密码不一致'))
  336. } else {
  337. callback()
  338. }
  339. }
  340. var validatePass3 = (rule, value, callback) => {
  341. if (!value) {
  342. callback(new Error('请输入新密码'))
  343. } else if (value && value.length < 6) {
  344. callback(new Error('密码长度至少6位'))
  345. } else {
  346. if (this.addForm.confirmPassword !== '') {
  347. this.$refs.addForm.validateField('confirmPassword')
  348. }
  349. callback()
  350. }
  351. }
  352. var validatePass4 = (rule, value, callback) => {
  353. if (!value) {
  354. callback(new Error('请再次输入密码'))
  355. } else if (value !== this.addForm.newPassword) {
  356. callback(new Error('两次输入密码不一致'))
  357. } else {
  358. callback()
  359. }
  360. }
  361. return {
  362. venderList: [],
  363. userName: JSON.parse(localStorage.getItem('greemall_user')).userName,
  364. userInfoData: JSON.parse(localStorage.getItem('greemall_user')),
  365. dataList: null, // 列表数据
  366. listLoading: true, // 列表加载loading
  367. screenForm: {
  368. // 筛选表单数据
  369. role: '', // 角色
  370. status: '', // 状态
  371. keyword: '', // 关键词
  372. companyWechatName: '' //商户名
  373. },
  374. select_status: [
  375. // 筛选字段 - 状态
  376. { label: '正常', value: true },
  377. { label: '冻结', value: false }
  378. ],
  379. currentPage: 1, // 当前页码
  380. pageSize: 10, // 每页数量
  381. listTotal: 0, // 列表总数
  382. roleList: [], // 角色列表
  383. departmentList: [], // 部门列表
  384. merchantList: [], // 商户列表
  385. resetId: null,
  386. resetForm: {
  387. newPassword: '', // 新密码
  388. confirmPassword: '' // 确认密码
  389. },
  390. resetFormRules: {
  391. newPassword: [{ required: true, validator: validatePass, trigger: 'blur' }],
  392. confirmPassword: [{ required: true, validator: validatePass2, trigger: 'blur' }]
  393. },
  394. editId: null,
  395. addFormType: 'add',
  396. addForm: {
  397. account: '', // 账号
  398. nickName: '', // 用户名
  399. role: '', // 角色组
  400. adminWebsitId: [],
  401. adminDeptId: [],
  402. newPassword: '', // 新密码
  403. confirmPassword: '', // 确认密码
  404. pubNotice: true,
  405. isVender: true,
  406. venderId: '',
  407. linkPhone: '',
  408. rwaide: []
  409. },
  410. addFormRules: {
  411. account: [{ required: true, message: '请输入账号', trigger: 'blur' }],
  412. nickName: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
  413. linkPhone: [{ required: true, message: '请输入手机号', trigger: 'blur' }],
  414. role: [{ required: true, message: '请选择角色组', trigger: 'blur' }],
  415. rwaide: [{ required: true, message: '请选择网点', trigger: 'blur' }],
  416. venderId: [{ required: true, message: '请选择网点', trigger: 'blur' }],
  417. newPassword: [{ validator: validatePass3, trigger: 'blur' }],
  418. confirmPassword: [{ validator: validatePass4, trigger: 'blur' }]
  419. },
  420. passwordType1: 'password',
  421. passwordType2: 'password'
  422. }
  423. },
  424. async created() {
  425. await this.getRoleList()
  426. if (this.$route.query.type) {
  427. let index = this.$findElem(this.roleList, 'name', '企业负责人')
  428. this.screenForm.role = this.roleList[index].adminRoleId
  429. }
  430. this.getList()
  431. },
  432. watch: {
  433. 'addForm.role'() {
  434. if (this.addForm.role) {
  435. let index = this.$findElem(this.roleList, 'adminRoleId', this.addForm.role)
  436. }
  437. }
  438. },
  439. methods: {
  440. getList() {
  441. this.listLoading = true
  442. let params = {
  443. roleId: this.screenForm.role,
  444. status: this.screenForm.status,
  445. userName: this.screenForm.keyword,
  446. companyWechatName: this.screenForm.companyWechatName,
  447. pageNum: this.currentPage,
  448. pageSize: this.pageSize,
  449. ...(() => {
  450. if (this.$route.query.companyWechatId) {
  451. return {
  452. companyWechatId: this.$route.query.companyWechatId
  453. }
  454. }
  455. return {}
  456. })()
  457. }
  458. getAccountList(params).then(res => {
  459. this.dataList = res.data.records
  460. this.listTotal = res.data.total
  461. this.listLoading = false
  462. })
  463. },
  464. // 筛选后重新获取列表
  465. getListByScreen() {
  466. this.currentPage = 1
  467. this.getList()
  468. },
  469. // 获取角色列表
  470. async getRoleList() {
  471. const result = await new Promise((resolve, reject) => {
  472. getRoleList({ pageNum: 1, pageSize: 1000 })
  473. .then(res => {
  474. this.roleList = res.data.records
  475. resolve(res.data)
  476. })
  477. .catch(res => {
  478. resolve([])
  479. })
  480. })
  481. return result
  482. },
  483. // 获取部门列表
  484. async getDepartmentList() {
  485. const result = await new Promise((resolve, reject) => {
  486. adminDeptTreeWebsit()
  487. .then(res => {
  488. var list = res.data
  489. if (JSON.parse(localStorage.getItem('greemall_user'))?.type == 1) {
  490. list = list?.[0]?.children
  491. }
  492. resolve(list)
  493. })
  494. .catch(res => {
  495. resolve([])
  496. })
  497. })
  498. return result
  499. },
  500. // 更改每页数量
  501. handleSizeChange(val) {
  502. this.pageSize = val
  503. this.currentPage = 1
  504. this.getList()
  505. },
  506. // 更改当前页
  507. handleCurrentChange(val) {
  508. this.currentPage = val
  509. this.getList()
  510. },
  511. // 操作 - 更改状态(type: 禁用0,启用1)
  512. changeStatus(id, type) {
  513. type = type ? true : false
  514. changeAccountStatus({ adminUserId: id, status: type }).then(res => {
  515. this.getList()
  516. this.$successMsg()
  517. })
  518. },
  519. // 显示隐藏密码
  520. showPwd(num) {
  521. if (num == 1) {
  522. if (this.passwordType1 === 'password') {
  523. this.passwordType1 = ''
  524. } else {
  525. this.passwordType1 = 'password'
  526. }
  527. this.$nextTick(() => {
  528. this.$refs.password1.focus()
  529. })
  530. }
  531. if (num == 2) {
  532. if (this.passwordType2 === 'password') {
  533. this.passwordType2 = ''
  534. } else {
  535. this.passwordType2 = 'password'
  536. }
  537. this.$nextTick(() => {
  538. this.$refs.password2.focus()
  539. })
  540. }
  541. },
  542. // 重置密码
  543. handleReset(id) {
  544. this.$refs.tabPage.addTab({
  545. activeKey: 'resetpassword',
  546. key: 'resetpassword',
  547. label: '重置密码',
  548. triggerEvent: () => {
  549. this.cancelResetForm()
  550. this.$nextTick(() => {
  551. this.resetId = id
  552. })
  553. },
  554. closeEvent: () => {
  555. this.cancelResetForm()
  556. }
  557. })
  558. },
  559. // 取消重置密码
  560. cancelResetForm() {
  561. this.passwordType1 = 'password'
  562. this.passwordType2 = 'password'
  563. this.$refs?.resetForm?.resetFields()
  564. },
  565. // 提交重置密码
  566. submitResetForm(removeTab) {
  567. this.$refs.resetForm.validate(valid => {
  568. if (valid) {
  569. let params = {
  570. password: this.resetForm.newPassword,
  571. adminUserId: this.resetId
  572. }
  573. resetPassword(params).then(res => {
  574. removeTab('list')
  575. this.getList()
  576. this.$successMsg()
  577. })
  578. }
  579. })
  580. },
  581. // 新增编辑 账户
  582. async addOrEdit(type, id) {
  583. this.$refs.tabPage.addTab({
  584. activeKey: type,
  585. key: type,
  586. label: { add: '新增', edit: '编辑' }[type],
  587. triggerEvent: async () => {
  588. listPageV2({
  589. pageNum: 1,
  590. pageSize: -1,
  591. params: [
  592. { param: 'a.status', compare: '=', value: 'ON' },
  593. { param: 'a.vender_type', compare: 'like', value: '辅材' }
  594. ]
  595. }).then(res => {
  596. this.venderList = res.data.records
  597. })
  598. this.cancelAddForm()
  599. this.addFormType = type
  600. this.departmentList = await this.getDepartmentList()
  601. if (type == 'edit') {
  602. this.editId = id
  603. getUserInfo({ adminUserId: id }).then(res => {
  604. this.addForm = {
  605. account: res.data.userName,
  606. role: res.data.roleId,
  607. nickName: res.data.nickName,
  608. pubNotice: res.data.pubNotice,
  609. isVender: res.data.isVender,
  610. venderId: res.data.venderId,
  611. adminWebsitId: res.data.adminWebsitId,
  612. adminDeptId: res.data.adminDeptId,
  613. linkPhone: res.data.linkPhone,
  614. rwaide: [...(res.data.adminWebsitId || []), ...(res.data.adminDeptId || [])]
  615. }
  616. })
  617. }
  618. },
  619. closeEvent: () => {}
  620. })
  621. },
  622. // 取消 新增编辑账户
  623. cancelAddForm() {
  624. this.passwordType1 = 'password'
  625. this.passwordType2 = 'password'
  626. this.$refs?.addForm?.resetFields()
  627. this.$data.addForm = this.$options.data().addForm
  628. },
  629. // 提交 新增编辑账户
  630. submitAddForm(removeTab) {
  631. this.$refs.addForm.validate(valid => {
  632. if (valid) {
  633. let rwaideObjs = (function (node, ids) {
  634. const result = []
  635. function recurse(currentNode) {
  636. if (ids.has(currentNode.adminDeptId)) {
  637. result.push(currentNode)
  638. }
  639. if (currentNode.children) {
  640. currentNode.children.forEach(child => recurse(child))
  641. }
  642. }
  643. for (var item of node) {
  644. recurse(item)
  645. }
  646. return result
  647. })(this.departmentList, new Set([...this.addForm.rwaide]))
  648. let params = {
  649. userName: this.addForm.account,
  650. nickName: this.addForm.nickName,
  651. roleId: this.addForm.role,
  652. password: this.addForm.newPassword,
  653. pubNotice: this.addForm.pubNotice,
  654. isVender: this.addForm.isVender,
  655. venderId: this.addForm.venderId,
  656. linkPhone: this.addForm.linkPhone,
  657. adminDeptId: rwaideObjs.filter(item => !item.isWebsit).map(item => item.adminDeptId),
  658. adminWebsitId: rwaideObjs.filter(item => item.isWebsit).map(item => item.adminDeptId)
  659. }
  660. if (this.addFormType == 'edit') {
  661. params.adminUserId = this.editId
  662. editAccount(params).then(res => {
  663. removeTab('list')
  664. this.getList()
  665. this.$successMsg('编辑成功')
  666. })
  667. } else {
  668. addAccount(params).then(res => {
  669. removeTab('list')
  670. this.getList()
  671. this.$successMsg('新增成功')
  672. })
  673. }
  674. }
  675. })
  676. },
  677. async dengluLogin(row) {
  678. const loading = this.$loading({
  679. lock: true,
  680. text: 'Loading',
  681. spinner: 'el-icon-loading',
  682. background: 'rgba(0, 0, 0, 0.7)'
  683. })
  684. this.$store
  685. .dispatch('user/login', { username: row.userName })
  686. .then(() => {
  687. setTimeout(() => {
  688. loading.close()
  689. window.location.href = '/'
  690. }, 1000)
  691. })
  692. .catch(() => {})
  693. }
  694. }
  695. }
  696. </script>
  697. <style scoped lang="scss">
  698. .show-pwd {
  699. position: absolute;
  700. right: 15px;
  701. top: 0;
  702. font-size: 16px;
  703. cursor: pointer;
  704. user-select: none;
  705. }
  706. </style>