account.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797
  1. <template>
  2. <div class="app-container">
  3. <div class="tree-container">
  4. <div style="padding: 10px; display: flex;">
  5. <el-button icon="el-icon-refresh-right" size="small" @click="refreshDepartment()" style="padding: 9px 10px; margin-right: 6px"></el-button>
  6. <el-input
  7. placeholder="输入关键字进行过滤"
  8. size="small"
  9. clearable
  10. v-model="filterText">
  11. </el-input>
  12. </div>
  13. <el-tree
  14. :data="departmentList"
  15. :props="defaultProps"
  16. default-expand-all
  17. highlight-current
  18. :expand-on-click-node="false"
  19. :filter-node-method="filterNode"
  20. @node-click="handleNodeClick"
  21. node-key="id"
  22. ref="listTree">
  23. <div class="custom-tree-node" slot-scope="{ node, data }">
  24. <i :class="data.children && data.children.length > 0 ? 'el-icon-folder-opened':'el-icon-document-remove'"></i><span>{{ node.label }}</span>
  25. </div>
  26. </el-tree>
  27. </div>
  28. <div class="mymain-container">
  29. <div class="screen-container">
  30. <!-- <div class="top clearfix">
  31. <div class="title fl">条件筛选</div>
  32. </div> -->
  33. <el-form ref="screenForm" :model="screenForm" label-width="70px" size="small" label-position="left">
  34. <el-row :gutter="20">
  35. <el-col :xs="24" :sm="12" :lg="12">
  36. <el-form-item label="账号名称" prop="name">
  37. <el-input v-model="screenForm.name" placeholder="请输入账号名称"></el-input>
  38. </el-form-item>
  39. </el-col>
  40. <el-col :xs="24" :sm="12" :lg="12" class="tr">
  41. <el-form-item label="">
  42. <el-button size="small" @click="resetScreenForm">清空</el-button>
  43. <el-button size="small" type="primary" @click="submitScreenForm">搜索</el-button>
  44. </el-form-item>
  45. </el-col>
  46. </el-row>
  47. </el-form>
  48. </div>
  49. <div class="btn-group clearfix" style="margin-top: 20px">
  50. <div class="fl">
  51. <el-button size="small" type="primary" @click="openAccountForm('add')">添加账号</el-button>
  52. </div>
  53. <div class="fr">
  54. <!-- <el-upload
  55. class="import-btn"
  56. style="height: 0; width: 0; overflow: hidden;"
  57. :action="baseURL + 'student/import'"
  58. :http-request="handleImport"
  59. :file-list="importFileList"
  60. v-if="checkBtnRole('import')"
  61. >
  62. <el-button size="small" type="primary" :loading="importLoading">{{ importLoading ? '导入中...' : '导入' }}</el-button>
  63. </el-upload>
  64. <el-button size="small" type="primary" @click="handleExport">导出</el-button>
  65. <el-button size="small" type="primary" :loading="importLoading" @click="clickImport">{{ importLoading ? '导入中...' : '导入' }}</el-button>
  66. <el-button size="small" @click="handleDownload" v-if="checkBtnRole('download')">下载导入模板</el-button> -->
  67. </div>
  68. </div>
  69. <div class="table">
  70. <el-table v-loading="listLoading" :data="dataList" element-loading-text="Loading" border fit highlight-current-row stripe>
  71. <!-- <el-table-column align="center" type="selection" width="55" fixed></el-table-column> -->
  72. <el-table-column align="center" label="账号" prop="userName" min-width="120"></el-table-column>
  73. <el-table-column align="center" label="用户名" prop="nickName" min-width="120"></el-table-column>
  74. <el-table-column align="center" label="角色" prop="roleName" min-width="100"></el-table-column>
  75. <el-table-column align="center" label="创建时间" prop="createTime" min-width="160"></el-table-column>
  76. <el-table-column align="center" label="最后登录时间" prop="lastLoginTime" min-width="160"></el-table-column>
  77. <el-table-column align="center" label="状态" class-name="status-col">
  78. <template slot-scope="scope">
  79. <el-tag :type="scope.row.status ? 'success':'danger'">{{ scope.row.status ? '正常':'冻结' }}</el-tag>
  80. </template>
  81. </el-table-column>
  82. <el-table-column align="center" label="操作" min-width="160">
  83. <template slot-scope="scope">
  84. <template v-if="checkBtnRole('status')">
  85. <el-popconfirm v-if="scope.row.status" style="margin-right: 10px;" title="确定冻结吗?" @onConfirm="changeStatus(scope.row.adminUserId, 0)" >
  86. <el-button slot="reference" type="text">冻结</el-button>
  87. </el-popconfirm>
  88. <el-popconfirm v-else style="margin-right: 10px;" title="确定恢复吗?" @onConfirm="changeStatus(scope.row.adminUserId, 1)" >
  89. <el-button slot="reference" type="text">恢复</el-button>
  90. </el-popconfirm>
  91. </template>
  92. <el-button type="text" @click="openAccountForm('edit', scope.row.adminUserId)" v-if="checkBtnRole('edit')">编辑</el-button>
  93. <el-button type="text" @click="handleReset(scope.row.adminUserId)" v-if="checkBtnRole('reset')">重置密码</el-button>
  94. <!-- <el-popconfirm style="margin-left: 10px;" title="确定删除吗?" @onConfirm="deleteAccount(scope.row.id)" v-if="checkBtnRole('del')">
  95. <el-button slot="reference" type="text">删除</el-button>
  96. </el-popconfirm> -->
  97. </template>
  98. </el-table-column>
  99. </el-table>
  100. </div>
  101. <div class="pagination clearfix">
  102. <div class="fr">
  103. <el-pagination
  104. @size-change="handleSizeChange"
  105. @current-change="handleCurrentChange"
  106. :current-page="currentPage"
  107. :page-sizes="[10, 20, 30, 50]"
  108. :page-size="10"
  109. layout="total, sizes, prev, pager, next, jumper"
  110. :total="listTotal">
  111. </el-pagination>
  112. </div>
  113. </div>
  114. </div>
  115. <!-- 添加编辑账号 -->
  116. <el-dialog :title="AccountFormType == 'add' ? '添加账号':'编辑账号'" :visible.sync="AccountFormVisible" :show-close="false" width="40%" :close-on-click-modal="false">
  117. <el-form ref="AccountForm" :model="AccountForm" :rules="AccountFormRules" label-position="left" label-width="80px">
  118. <el-form-item label="账号" prop="account">
  119. <el-input v-model="AccountForm.account" autocomplete="off" placeholder="请输入账号"></el-input>
  120. </el-form-item>
  121. <el-form-item label="用户名" prop="nickName">
  122. <el-input v-model="AccountForm.nickName" autocomplete="off" placeholder="请输入用户名"></el-input>
  123. </el-form-item>
  124. <el-form-item label="角色组" prop="role">
  125. <el-select v-model="AccountForm.role" placeholder="请选择角色组" style="width: 100%;">
  126. <el-option :label="item.name" :value="item.adminRoleId" v-for="(item, index) in roleList" :key="index"></el-option>
  127. </el-select>
  128. </el-form-item>
  129. <el-form-item label="部门" prop="department" v-show="roleObj.type === 0">
  130. <el-tree
  131. :data="departmentList"
  132. show-checkbox
  133. :check-strictly="true"
  134. node-key="adminWebsitId"
  135. ref="tree"
  136. highlight-current
  137. :props="props">
  138. </el-tree>
  139. </el-form-item>
  140. <el-form-item label="经销商" prop="dealer" v-show="roleObj.type === 0 && roleObj.name === '经销商'">
  141. <el-select v-model="AccountForm.dealer" placeholder="请选择经销商" style="width: 100%;">
  142. <el-option :label="item.name" :value="item.id" v-for="(item, index) in dealerList" :key="index"></el-option>
  143. </el-select>
  144. </el-form-item>
  145. <el-form-item label="商户" prop="merchant" v-show="roleObj.type === 1 || roleObj.type === 2">
  146. <el-select v-model="AccountForm.merchant" placeholder="请选择商户" style="width: 100%;">
  147. <el-option :label="item.adminCompanyName" :value="item.adminCompanyId" v-for="(item, index) in merchantList" :key="index"></el-option>
  148. </el-select>
  149. </el-form-item>
  150. <el-form-item label="集团公司" prop="isGroup" v-show="roleObj.type === 0 && roleObj.name === '经销商'">
  151. <el-radio-group v-model="AccountForm.isGroup">
  152. <el-radio :label="false">否</el-radio>
  153. <el-radio :label="true">是</el-radio>
  154. </el-radio-group>
  155. </el-form-item>
  156. <el-form-item label="所属集团" prop="company" v-show="roleObj.type === 0 && roleObj.name === '经销商' && !AccountForm.isGroup">
  157. <el-select v-model="AccountForm.company" placeholder="请选择所属集团" style="width: 100%;">
  158. <el-option :label="item.name" :value="item.id" v-for="(item, index) in dealerList" :key="index"></el-option>
  159. </el-select>
  160. </el-form-item>
  161. <el-form-item label="密码" prop="newPassword">
  162. <el-input v-model="AccountForm.newPassword" ref="password1" autocomplete="off" placeholder="请输入密码" :type="passwordType1"></el-input>
  163. <span class="show-pwd" @click="showPwd(1)">
  164. <svg-icon :icon-class="passwordType1 === 'password' ? 'eye' : 'eye-open'" />
  165. </span>
  166. </el-form-item>
  167. <el-form-item label="确认密码" prop="confirmPassword">
  168. <el-input v-model="AccountForm.confirmPassword" ref="password2" autocomplete="off" placeholder="请再次输入密码" :type="passwordType2"></el-input>
  169. <span class="show-pwd" @click="showPwd(2)">
  170. <svg-icon :icon-class="passwordType2 === 'password' ? 'eye' : 'eye-open'" />
  171. </span>
  172. </el-form-item>
  173. </el-form>
  174. <div slot="footer" class="dialog-footer">
  175. <el-button @click="cancelAccountForm">取 消</el-button>
  176. <el-button type="primary" @click="submitAccountForm">确 定</el-button>
  177. </div>
  178. </el-dialog>
  179. <!-- 重置密码 -->
  180. <el-dialog title="重置密码" :visible.sync="resetFormVisible" :show-close="false" width="40%" :close-on-click-modal="false">
  181. <el-form ref="resetForm" :model="resetForm" :rules="resetFormRules" label-position="left" label-width="100px">
  182. <el-form-item label="输入新密码" prop="newPassword">
  183. <el-input v-model="resetForm.newPassword" ref="password1" autocomplete="off" placeholder="请输入新密码" :type="passwordType1"></el-input>
  184. <span class="show-pwd" @click="showPwd(1)">
  185. <svg-icon :icon-class="passwordType1 === 'password' ? 'eye' : 'eye-open'" />
  186. </span>
  187. </el-form-item>
  188. <el-form-item label="确认密码" prop="confirmPassword">
  189. <el-input v-model="resetForm.confirmPassword" ref="password2" autocomplete="off" placeholder="请再次输入新密码" :type="passwordType2"></el-input>
  190. <span class="show-pwd" @click="showPwd(2)">
  191. <svg-icon :icon-class="passwordType2 === 'password' ? 'eye' : 'eye-open'" />
  192. </span>
  193. </el-form-item>
  194. </el-form>
  195. <div slot="footer" class="dialog-footer">
  196. <el-button @click="cancelResetForm">取 消</el-button>
  197. <el-button type="primary" @click="submitResetForm">确 定</el-button>
  198. </div>
  199. </el-dialog>
  200. </div>
  201. </template>
  202. <script>
  203. import { getDepartmentList, getAccountList, addAccount, editAccount, deleteAccount, getAccountDetail, getRoleList, getMerchantList, getDealerList, changeAccountStatus, resetPassword } from '@/api/setting'
  204. import { findElem, downloadFiles, handleImport } from '@/utils/util'
  205. export default {
  206. data() {
  207. var validatePass = (rule, value, callback) => {
  208. if (value === '') {
  209. callback(new Error('请输入新密码'));
  210. } else if (value && value.length < 6) {
  211. callback(new Error('密码长度至少6位'));
  212. } else {
  213. if (this.resetForm.confirmPassword !== '') {
  214. this.$refs.resetForm.validateField('confirmPassword');
  215. }
  216. callback();
  217. }
  218. };
  219. var validatePass2 = (rule, value, callback) => {
  220. if (value === '') {
  221. callback(new Error('请再次输入密码'));
  222. } else if (value !== this.resetForm.newPassword) {
  223. callback(new Error('两次输入密码不一致'));
  224. } else {
  225. callback();
  226. }
  227. };
  228. var validatePass3 = (rule, value, callback) => {
  229. if (value === '') {
  230. callback(new Error('请输入新密码'));
  231. } else if (value && value.length < 6) {
  232. callback(new Error('密码长度至少6位'));
  233. } else {
  234. if (this.AccountForm.confirmPassword !== '') {
  235. this.$refs.AccountForm.validateField('confirmPassword');
  236. }
  237. callback();
  238. }
  239. };
  240. var validatePass4 = (rule, value, callback) => {
  241. if (value === '') {
  242. callback(new Error('请再次输入密码'));
  243. } else if (value !== this.AccountForm.newPassword) {
  244. callback(new Error('两次输入密码不一致'));
  245. } else {
  246. callback();
  247. }
  248. };
  249. return {
  250. baseURL: process.env.VUE_APP_BASE_API,
  251. dataList: null, // 列表数据
  252. moduleList: null, // 模块列表
  253. listLoading: true, // 列表加载loading
  254. screenForm: { // 筛选表单数据
  255. name: '', // 名称
  256. },
  257. currentPage: 1, // 当前页码
  258. pageSize: 10, // 每页数量
  259. listTotal: 0, // 列表总数
  260. selectDepartment: null, // 选中的部门
  261. AccountFormType: 'add',
  262. AccountFormVisible: false,
  263. AccountForm: {
  264. account: '', // 账号
  265. nickName: '', // 用户名
  266. merchant: '', // 商户
  267. dealer: '', //经销商
  268. role: '', // 角色组
  269. isGroup: false,
  270. company: '',
  271. newPassword: '', // 新密码
  272. confirmPassword: '', // 确认密码
  273. },
  274. AccountFormRules: {
  275. account: [
  276. { required: true, message: '请输入账号', trigger: 'blur' }
  277. ],
  278. nickName: [
  279. { required: true, message: '请输入用户名', trigger: 'blur' }
  280. ],
  281. role: [
  282. { required: true, message: '请选择角色组', trigger: 'change' }
  283. ],
  284. newPassword: [
  285. { required: true, validator: validatePass3, trigger: 'blur' }
  286. ],
  287. confirmPassword: [
  288. { required: true, validator: validatePass4, trigger: 'blur' }
  289. ],
  290. },
  291. editAccountId: null,
  292. filterText: '',
  293. departmentList: [],
  294. defaultProps: {
  295. children: 'children',
  296. label: 'name'
  297. },
  298. props: {
  299. multiple: true,
  300. value: 'adminWebsitId',
  301. label: 'name',
  302. children: 'children',
  303. },
  304. tableSelection: [],
  305. importLoading: false, // 导入加载loading
  306. importFileList: [], // 导入列表
  307. resetId: null,
  308. resetFormVisible: false,
  309. resetForm: {
  310. newPassword: '', // 新密码
  311. confirmPassword: '', // 确认密码
  312. },
  313. resetFormRules: {
  314. newPassword: [
  315. { required: true, validator: validatePass, trigger: 'blur' }
  316. ],
  317. confirmPassword: [
  318. { required: true, validator: validatePass2, trigger: 'blur' }
  319. ],
  320. },
  321. roleList: [], // 角色列表
  322. roleObj: {}, // 选中的角色
  323. merchantList: [],
  324. dealerList: [],
  325. passwordType1: 'password',
  326. passwordType2: 'password',
  327. }
  328. },
  329. watch: {
  330. filterText(val) {
  331. this.$refs.listTree.filter(val);
  332. },
  333. 'AccountForm.role'() {
  334. if(this.AccountForm.role) {
  335. let index = findElem(this.roleList, 'adminRoleId', this.AccountForm.role);
  336. this.roleObj = this.roleList[index];
  337. }
  338. }
  339. },
  340. async created() {
  341. this.getTree();
  342. this.getList();
  343. },
  344. methods: {
  345. // 查询按钮权限
  346. checkBtnRole(value) {
  347. // let btnRole = this.$route.meta.roles;
  348. // if(!btnRole) {return true}
  349. // let index = btnRole.indexOf(value);
  350. // return index >= 0 ? true : false;
  351. return true;
  352. },
  353. // 获取角色列表
  354. async getRoleList() {
  355. const result = await new Promise((resolve, reject) => {
  356. getRoleList({pageNum: 1, pageSize: -1}).then(res => {
  357. this.roleList = res.data.records;
  358. resolve(res.data);
  359. }).catch(res => {
  360. resolve([]);
  361. })
  362. })
  363. return result;
  364. },
  365. // 获取商户列表
  366. async getMerchantList() {
  367. const result = await new Promise((resolve, reject) => {
  368. getMerchantList({
  369. pageNum: 1,
  370. pageSize: -1
  371. }).then(res => {
  372. this.merchantList = res.data.records;
  373. resolve(res.data.records);
  374. }).catch(res => {
  375. resolve([]);
  376. })
  377. })
  378. return result;
  379. },
  380. // 获取经销商列表
  381. async getDealerList() {
  382. const result = await new Promise((resolve, reject) => {
  383. getDealerList({
  384. pageNum: 1,
  385. pageSize: -1,
  386. bindUser: false
  387. }).then(res => {
  388. this.dealerList = res.data.records;
  389. resolve(res.data.records);
  390. }).catch(res => {
  391. resolve([]);
  392. })
  393. })
  394. return result;
  395. },
  396. // 获取部门列表
  397. getTree() {
  398. getDepartmentList().then(res => {
  399. this.departmentList = res.data;
  400. })
  401. },
  402. // 获取账号列表
  403. getList() {
  404. this.listLoading = true;
  405. let params = {
  406. pageNum: this.currentPage,
  407. pageSize: this.pageSize,
  408. adminWebsitId: this.selectDepartment ? this.selectDepartment.adminWebsitId : '',
  409. userName: this.screenForm.name
  410. };
  411. getAccountList(params).then(res => {
  412. this.dataList = res.data.records;
  413. this.listTotal = res.data.total;
  414. this.listLoading = false;
  415. })
  416. },
  417. // 更改每页数量
  418. handleSizeChange(val) {
  419. this.pageSize = val;
  420. this.currentPage = 1;
  421. this.getList();
  422. },
  423. // 更改当前页
  424. handleCurrentChange(val) {
  425. this.currentPage = val;
  426. this.getList();
  427. },
  428. // 提交筛选表单
  429. submitScreenForm() {
  430. this.currentPage = 1;
  431. this.getList();
  432. },
  433. // 重置筛选表单
  434. resetScreenForm() {
  435. this.$refs.screenForm.resetFields();
  436. this.currentPage = 1;
  437. this.getList();
  438. },
  439. // 筛选部门
  440. filterNode(value, data) {
  441. if (!value) return true;
  442. return data.name.indexOf(value) !== -1;
  443. },
  444. // 选择部门
  445. handleNodeClick(data) {
  446. console.log(data);
  447. if(this.selectDepartment && data.adminWebsitId === this.selectDepartment.adminWebsitId) {
  448. this.$refs.listTree.setCurrentKey(null);
  449. this.selectDepartment = null;
  450. }else {
  451. this.selectDepartment = data;
  452. }
  453. this.getList();
  454. },
  455. // 刷新部门
  456. refreshDepartment() {
  457. this.$refs.listTree.setCurrentKey(null);
  458. this.selectDepartment = null;
  459. this.getTree();
  460. this.getList();
  461. },
  462. // 打开 新增编辑 账号表单
  463. async openAccountForm(type, id) {
  464. this.AccountFormType = type;
  465. this.AccountFormVisible = true;
  466. await this.getMerchantList();
  467. await this.getDealerList();
  468. await this.getRoleList();
  469. if(type == 'add') {
  470. if(this.selectDepartment) {
  471. this.$refs.tree.setCheckedKeys([this.selectDepartment.adminWebsitId]);
  472. }
  473. }
  474. if(type == 'edit') {
  475. this.editAccountId = id;
  476. getAccountDetail({adminUserId: id}).then(res => {
  477. this.AccountForm.account = res.data.userName;
  478. this.AccountForm.role = res.data.roleId;
  479. this.AccountForm.nickName = res.data.nickName;
  480. this.AccountForm.merchant = res.data.companyWechatId;
  481. this.AccountForm.dealer = res.data.customerId;
  482. this.AccountForm.isGroup = res.data.isGroupCompany;
  483. this.AccountForm.company = res.data.parentCustomerId;
  484. this.$refs.tree.setCheckedKeys(res.data.adminWebsitIds || []);
  485. })
  486. }
  487. },
  488. // 取消 新增编辑 账号表单
  489. cancelAccountForm(){
  490. this.AccountFormVisible = false;
  491. this.$refs.AccountForm.resetFields();
  492. this.passwordType1 = 'password';
  493. this.passwordType2 = 'password';
  494. },
  495. // 提交 账号表单
  496. submitAccountForm() {
  497. this.$refs.AccountForm.validate((valid) => {
  498. if (valid) {
  499. let params = {
  500. userName: this.AccountForm.account,
  501. nickName: this.AccountForm.nickName,
  502. roleId: this.AccountForm.role,
  503. password: this.AccountForm.newPassword,
  504. }
  505. if(this.roleObj.type === 0) {
  506. params.adminWebsitIds = this.$refs.tree.getCheckedKeys();
  507. if(this.roleObj.name === '经销商') {
  508. params.customerId = this.AccountForm.dealer;
  509. params.isGroupCompany = this.AccountForm.isGroup;
  510. params.parentCustomerId = this.AccountForm.company;
  511. }
  512. }else {
  513. params.adminCompanyId = this.AccountForm.merchant;
  514. }
  515. if(this.AccountFormType == 'edit') {
  516. params.adminUserId = this.editAccountId;
  517. editAccount(params).then(res => {
  518. this.cancelAccountForm();
  519. this.getList();
  520. this.$successMsg('编辑成功');
  521. })
  522. }else {
  523. addAccount(params).then(res => {
  524. this.cancelAccountForm();
  525. this.getList();
  526. this.$successMsg('添加成功');
  527. })
  528. }
  529. }
  530. })
  531. },
  532. // 表格选择列
  533. handleTableSelection(val) {
  534. this.tableSelection = val;
  535. },
  536. // 批量删除账号
  537. batchDeleteAccount() {
  538. if(this.tableSelection.length < 1) {
  539. return this.$errorMsg('至少选择一名账号');
  540. }
  541. this.$confirm(`确定删除选中的账号吗?`, '提示', {
  542. confirmButtonText: '确定',
  543. cancelButtonText: '取消',
  544. type: 'warning'
  545. }).then(() => {
  546. let AccountIds = [];
  547. this.tableSelection.forEach(item => {
  548. AccountIds.push(item.id);
  549. });
  550. deleteAccount({id: AccountIds.join(',')}).then(res => {
  551. this.$successMsg();
  552. this.getTree();
  553. this.getList();
  554. })
  555. }).catch(() => {});
  556. },
  557. // 删除账号
  558. deleteAccount(id) {
  559. deleteAccount({id: id}).then(res => {
  560. this.$successMsg();
  561. this.getTree();
  562. this.getList();
  563. })
  564. },
  565. // 操作 - 更改状态(type: 禁用0,启用1)
  566. changeStatus(id, type) {
  567. type = type ? true : false
  568. changeAccountStatus({adminUserId: id, status: type}).then(res => {
  569. this.getList();
  570. this.$successMsg();
  571. })
  572. },
  573. // 显示隐藏密码
  574. showPwd(num) {
  575. if(num == 1) {
  576. if (this.passwordType1 === 'password') {
  577. this.passwordType1 = ''
  578. } else {
  579. this.passwordType1 = 'password'
  580. }
  581. this.$nextTick(() => {
  582. this.$refs.password1.focus()
  583. })
  584. }
  585. if(num == 2) {
  586. if (this.passwordType2 === 'password') {
  587. this.passwordType2 = ''
  588. } else {
  589. this.passwordType2 = 'password'
  590. }
  591. this.$nextTick(() => {
  592. this.$refs.password2.focus()
  593. })
  594. }
  595. },
  596. // 重置密码
  597. handleReset(id) {
  598. this.resetId = id;
  599. this.resetFormVisible = true;
  600. },
  601. // 取消重置密码
  602. cancelResetForm(){
  603. this.resetFormVisible = false;
  604. this.passwordType1 = 'password';
  605. this.passwordType2 = 'password';
  606. this.$refs.resetForm.resetFields();
  607. },
  608. // 提交重置密码
  609. submitResetForm() {
  610. this.$refs.resetForm.validate((valid) => {
  611. if (valid) {
  612. let params = {
  613. password: this.resetForm.newPassword,
  614. adminUserId: this.resetId
  615. }
  616. resetPassword(params).then(res => {
  617. this.cancelResetForm();
  618. this.getList();
  619. this.$successMsg();
  620. })
  621. }
  622. })
  623. },
  624. // 导出
  625. handleExport() {
  626. let screenData = {
  627. adminWebsitId: this.selectDepartment ? this.selectDepartment.websitId : '',
  628. keyword: this.screenForm.name
  629. };
  630. downloadFiles('wechat/enterprise/export', screenData);
  631. },
  632. // 下载导入模版
  633. handleDownload() {
  634. downloadFiles('wechat/enterprise/download');
  635. },
  636. clickImport() {
  637. if(!this.selectDepartment) {
  638. return this.$errorMsg('请选择部门');
  639. }else {
  640. document.querySelector('.import-btn input').click();
  641. }
  642. },
  643. // 导入
  644. async handleImport(param) {
  645. this.importLoading = true;
  646. const file = param.file;
  647. const formData = new FormData();
  648. formData.append("file", file);
  649. formData.append("mainDepartmentId", this.selectDepartment.websitId);
  650. let result = await handleImport('wechat/enterprise/import', formData);
  651. this.importLoading = false;
  652. this.importFileList = [];
  653. if(result.code == 200) {
  654. this.$alert(result.message, '导入成功', {
  655. confirmButtonText: '确定'
  656. });
  657. this.getList();
  658. }else {
  659. this.$alert(result.message, '导入失败', {
  660. confirmButtonText: '确定'
  661. });
  662. }
  663. },
  664. }
  665. }
  666. </script>
  667. <style scoped lang="scss">
  668. .app-container {
  669. display: flex;
  670. .tree-container {
  671. width: 18%;
  672. height: calc(100vh - 110px);
  673. flex-shrink: 0;
  674. background: #f5f5f5;
  675. margin-right: 2%;
  676. display: flex;
  677. flex-direction: column;
  678. overflow-y: hidden;
  679. .el-tree {
  680. height: 100%;
  681. background: none;
  682. width: 100%;
  683. overflow: scroll;
  684. // ::v-deep .el-tree-node:focus > .el-tree-node__content {
  685. // color: #ffffff;
  686. // background-color: #409EFF;
  687. // }
  688. ::v-deep >.el-tree-node {
  689. display: inline-block;
  690. min-width: 100%;
  691. }
  692. ::v-deep .el-tree-node>.el-tree-node__content {
  693. padding-right: 10px;
  694. align-self: baseline;
  695. }
  696. ::v-deep .el-tree-node.is-current>.el-tree-node__content {
  697. background-color: #409EFF;
  698. .custom-tree-node {
  699. i {
  700. color: #fff;
  701. }
  702. span {
  703. color: #fff;
  704. }
  705. }
  706. }
  707. ::v-deep .el-tree-node>.el-tree-node__children {
  708. overflow: unset;
  709. }
  710. .custom-tree-node {
  711. i {
  712. font-size: 14px;
  713. color: #999;
  714. }
  715. span {
  716. font-size: 14px;
  717. margin-left: 6px;
  718. color: #666;
  719. }
  720. }
  721. }
  722. }
  723. .mymain-container {
  724. width: 80%;
  725. margin-top: 0;
  726. }
  727. }
  728. ::v-deep .el-divider--vertical {
  729. margin: 0 15px;
  730. }
  731. .show-pwd {
  732. position: absolute;
  733. right: 15px;
  734. top: 0;
  735. font-size: 16px;
  736. cursor: pointer;
  737. user-select: none;
  738. }
  739. </style>