account.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788
  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="newPassword">
  157. <el-input v-model="AccountForm.newPassword" ref="password1" autocomplete="off" placeholder="请输入密码" :type="passwordType1"></el-input>
  158. <span class="show-pwd" @click="showPwd(1)">
  159. <svg-icon :icon-class="passwordType1 === 'password' ? 'eye' : 'eye-open'" />
  160. </span>
  161. </el-form-item>
  162. <el-form-item label="确认密码" prop="confirmPassword">
  163. <el-input v-model="AccountForm.confirmPassword" ref="password2" autocomplete="off" placeholder="请再次输入密码" :type="passwordType2"></el-input>
  164. <span class="show-pwd" @click="showPwd(2)">
  165. <svg-icon :icon-class="passwordType2 === 'password' ? 'eye' : 'eye-open'" />
  166. </span>
  167. </el-form-item>
  168. </el-form>
  169. <div slot="footer" class="dialog-footer">
  170. <el-button @click="cancelAccountForm">取 消</el-button>
  171. <el-button type="primary" @click="submitAccountForm">确 定</el-button>
  172. </div>
  173. </el-dialog>
  174. <!-- 重置密码 -->
  175. <el-dialog title="重置密码" :visible.sync="resetFormVisible" :show-close="false" width="40%" :close-on-click-modal="false">
  176. <el-form ref="resetForm" :model="resetForm" :rules="resetFormRules" label-position="left" label-width="100px">
  177. <el-form-item label="输入新密码" prop="newPassword">
  178. <el-input v-model="resetForm.newPassword" ref="password1" autocomplete="off" placeholder="请输入新密码" :type="passwordType1"></el-input>
  179. <span class="show-pwd" @click="showPwd(1)">
  180. <svg-icon :icon-class="passwordType1 === 'password' ? 'eye' : 'eye-open'" />
  181. </span>
  182. </el-form-item>
  183. <el-form-item label="确认密码" prop="confirmPassword">
  184. <el-input v-model="resetForm.confirmPassword" ref="password2" autocomplete="off" placeholder="请再次输入新密码" :type="passwordType2"></el-input>
  185. <span class="show-pwd" @click="showPwd(2)">
  186. <svg-icon :icon-class="passwordType2 === 'password' ? 'eye' : 'eye-open'" />
  187. </span>
  188. </el-form-item>
  189. </el-form>
  190. <div slot="footer" class="dialog-footer">
  191. <el-button @click="cancelResetForm">取 消</el-button>
  192. <el-button type="primary" @click="submitResetForm">确 定</el-button>
  193. </div>
  194. </el-dialog>
  195. </div>
  196. </template>
  197. <script>
  198. import { getDepartmentList, getAccountList, addAccount, editAccount, deleteAccount, getAccountDetail, getRoleList, getMerchantList, getDealerList, changeAccountStatus, resetPassword } from '@/api/setting'
  199. import { findElem, downloadFiles, handleImport } from '@/utils/util'
  200. export default {
  201. data() {
  202. var validatePass = (rule, value, callback) => {
  203. if (value === '') {
  204. callback(new Error('请输入新密码'));
  205. } else if (value && value.length < 6) {
  206. callback(new Error('密码长度至少6位'));
  207. } else {
  208. if (this.resetForm.confirmPassword !== '') {
  209. this.$refs.resetForm.validateField('confirmPassword');
  210. }
  211. callback();
  212. }
  213. };
  214. var validatePass2 = (rule, value, callback) => {
  215. if (value === '') {
  216. callback(new Error('请再次输入密码'));
  217. } else if (value !== this.resetForm.newPassword) {
  218. callback(new Error('两次输入密码不一致'));
  219. } else {
  220. callback();
  221. }
  222. };
  223. var validatePass3 = (rule, value, callback) => {
  224. if (value === '') {
  225. callback(new Error('请输入新密码'));
  226. } else if (value && value.length < 6) {
  227. callback(new Error('密码长度至少6位'));
  228. } else {
  229. if (this.AccountForm.confirmPassword !== '') {
  230. this.$refs.AccountForm.validateField('confirmPassword');
  231. }
  232. callback();
  233. }
  234. };
  235. var validatePass4 = (rule, value, callback) => {
  236. if (value === '') {
  237. callback(new Error('请再次输入密码'));
  238. } else if (value !== this.AccountForm.newPassword) {
  239. callback(new Error('两次输入密码不一致'));
  240. } else {
  241. callback();
  242. }
  243. };
  244. return {
  245. baseURL: process.env.VUE_APP_BASE_API,
  246. dataList: null, // 列表数据
  247. moduleList: null, // 模块列表
  248. listLoading: true, // 列表加载loading
  249. screenForm: { // 筛选表单数据
  250. name: '', // 名称
  251. },
  252. currentPage: 1, // 当前页码
  253. pageSize: 10, // 每页数量
  254. listTotal: 0, // 列表总数
  255. selectDepartment: null, // 选中的部门
  256. AccountFormType: 'add',
  257. AccountFormVisible: false,
  258. AccountForm: {
  259. account: '', // 账号
  260. nickName: '', // 用户名
  261. merchant: '', // 商户
  262. dealer: '', //经销商
  263. role: '', // 角色组
  264. isGroup: false,
  265. newPassword: '', // 新密码
  266. confirmPassword: '', // 确认密码
  267. },
  268. AccountFormRules: {
  269. account: [
  270. { required: true, message: '请输入账号', trigger: 'blur' }
  271. ],
  272. nickName: [
  273. { required: true, message: '请输入用户名', trigger: 'blur' }
  274. ],
  275. role: [
  276. { required: true, message: '请选择角色组', trigger: 'change' }
  277. ],
  278. newPassword: [
  279. { required: true, validator: validatePass3, trigger: 'blur' }
  280. ],
  281. confirmPassword: [
  282. { required: true, validator: validatePass4, trigger: 'blur' }
  283. ],
  284. },
  285. editAccountId: null,
  286. filterText: '',
  287. departmentList: [],
  288. defaultProps: {
  289. children: 'children',
  290. label: 'name'
  291. },
  292. props: {
  293. multiple: true,
  294. value: 'adminWebsitId',
  295. label: 'name',
  296. children: 'children',
  297. },
  298. tableSelection: [],
  299. importLoading: false, // 导入加载loading
  300. importFileList: [], // 导入列表
  301. resetId: null,
  302. resetFormVisible: false,
  303. resetForm: {
  304. newPassword: '', // 新密码
  305. confirmPassword: '', // 确认密码
  306. },
  307. resetFormRules: {
  308. newPassword: [
  309. { required: true, validator: validatePass, trigger: 'blur' }
  310. ],
  311. confirmPassword: [
  312. { required: true, validator: validatePass2, trigger: 'blur' }
  313. ],
  314. },
  315. roleList: [], // 角色列表
  316. roleObj: {}, // 选中的角色
  317. merchantList: [],
  318. dealerList: [],
  319. passwordType1: 'password',
  320. passwordType2: 'password',
  321. }
  322. },
  323. watch: {
  324. filterText(val) {
  325. this.$refs.listTree.filter(val);
  326. },
  327. 'AccountForm.role'() {
  328. if(this.AccountForm.role) {
  329. let index = findElem(this.roleList, 'adminRoleId', this.AccountForm.role);
  330. this.roleObj = this.roleList[index];
  331. }
  332. }
  333. },
  334. async created() {
  335. this.getTree();
  336. this.getList();
  337. },
  338. methods: {
  339. // 查询按钮权限
  340. checkBtnRole(value) {
  341. // let btnRole = this.$route.meta.roles;
  342. // if(!btnRole) {return true}
  343. // let index = btnRole.indexOf(value);
  344. // return index >= 0 ? true : false;
  345. return true;
  346. },
  347. // 获取角色列表
  348. async getRoleList() {
  349. const result = await new Promise((resolve, reject) => {
  350. getRoleList({pageNum: 1, pageSize: -1}).then(res => {
  351. this.roleList = res.data.records;
  352. resolve(res.data);
  353. }).catch(res => {
  354. resolve([]);
  355. })
  356. })
  357. return result;
  358. },
  359. // 获取商户列表
  360. async getMerchantList() {
  361. const result = await new Promise((resolve, reject) => {
  362. getMerchantList({
  363. pageNum: 1,
  364. pageSize: -1
  365. }).then(res => {
  366. this.merchantList = res.data.records;
  367. resolve(res.data.records);
  368. }).catch(res => {
  369. resolve([]);
  370. })
  371. })
  372. return result;
  373. },
  374. // 获取经销商列表
  375. async getDealerList() {
  376. const result = await new Promise((resolve, reject) => {
  377. getDealerList({
  378. pageNum: 1,
  379. pageSize: -1,
  380. bindUser: false
  381. }).then(res => {
  382. this.dealerList = res.data.records;
  383. resolve(res.data.records);
  384. }).catch(res => {
  385. resolve([]);
  386. })
  387. })
  388. return result;
  389. },
  390. // 获取部门列表
  391. getTree() {
  392. getDepartmentList().then(res => {
  393. this.departmentList = res.data;
  394. })
  395. },
  396. // 获取账号列表
  397. getList() {
  398. this.listLoading = true;
  399. let params = {
  400. pageNum: this.currentPage,
  401. pageSize: this.pageSize,
  402. adminWebsitId: this.selectDepartment ? this.selectDepartment.adminWebsitId : '',
  403. keyword: this.screenForm.name
  404. };
  405. getAccountList(params).then(res => {
  406. this.dataList = res.data.records;
  407. this.listTotal = res.data.total;
  408. this.listLoading = false;
  409. })
  410. },
  411. // 更改每页数量
  412. handleSizeChange(val) {
  413. this.pageSize = val;
  414. this.currentPage = 1;
  415. this.getList();
  416. },
  417. // 更改当前页
  418. handleCurrentChange(val) {
  419. this.currentPage = val;
  420. this.getList();
  421. },
  422. // 提交筛选表单
  423. submitScreenForm() {
  424. this.currentPage = 1;
  425. this.getList();
  426. },
  427. // 重置筛选表单
  428. resetScreenForm() {
  429. this.$refs.screenForm.resetFields();
  430. this.currentPage = 1;
  431. this.getList();
  432. },
  433. // 筛选部门
  434. filterNode(value, data) {
  435. if (!value) return true;
  436. return data.name.indexOf(value) !== -1;
  437. },
  438. // 选择部门
  439. handleNodeClick(data) {
  440. console.log(data);
  441. if(this.selectDepartment && data.adminWebsitId === this.selectDepartment.adminWebsitId) {
  442. this.$refs.listTree.setCurrentKey(null);
  443. this.selectDepartment = null;
  444. }else {
  445. this.selectDepartment = data;
  446. }
  447. this.getList();
  448. },
  449. // 刷新部门
  450. refreshDepartment() {
  451. this.$refs.listTree.setCurrentKey(null);
  452. this.selectDepartment = null;
  453. this.getTree();
  454. this.getList();
  455. },
  456. // 打开 新增编辑 账号表单
  457. async openAccountForm(type, id) {
  458. this.AccountFormType = type;
  459. this.AccountFormVisible = true;
  460. await this.getMerchantList();
  461. await this.getDealerList();
  462. await this.getRoleList();
  463. if(type == 'add') {
  464. if(this.selectDepartment) {
  465. this.$refs.tree.setCheckedKeys([this.selectDepartment.adminWebsitId]);
  466. }
  467. }
  468. if(type == 'edit') {
  469. this.editAccountId = id;
  470. getAccountDetail({adminUserId: id}).then(res => {
  471. this.AccountForm.account = res.data.userName;
  472. this.AccountForm.role = res.data.roleId;
  473. this.AccountForm.nickName = res.data.nickName;
  474. this.AccountForm.merchant = res.data.companyWechatId;
  475. this.AccountForm.dealer = res.data.customerId;
  476. this.AccountForm.isGroup = res.data.isGroupCompany;
  477. this.$refs.tree.setCheckedKeys(res.data.adminWebsitIds || []);
  478. })
  479. }
  480. },
  481. // 取消 新增编辑 账号表单
  482. cancelAccountForm(){
  483. this.AccountFormVisible = false;
  484. this.$refs.AccountForm.resetFields();
  485. this.passwordType1 = 'password';
  486. this.passwordType2 = 'password';
  487. },
  488. // 提交 账号表单
  489. submitAccountForm() {
  490. this.$refs.AccountForm.validate((valid) => {
  491. if (valid) {
  492. let params = {
  493. userName: this.AccountForm.account,
  494. nickName: this.AccountForm.nickName,
  495. roleId: this.AccountForm.role,
  496. password: this.AccountForm.newPassword,
  497. }
  498. if(this.roleObj.type === 0) {
  499. params.adminWebsitIds = this.$refs.tree.getCheckedKeys();
  500. if(this.roleObj.name === '经销商') {
  501. params.customerId = this.AccountForm.dealer;
  502. params.isGroupCompany = this.AccountForm.isGroup;
  503. }
  504. }else {
  505. params.adminCompanyId = this.AccountForm.merchant;
  506. }
  507. if(this.AccountFormType == 'edit') {
  508. params.adminUserId = this.editAccountId;
  509. editAccount(params).then(res => {
  510. this.cancelAccountForm();
  511. this.getList();
  512. this.$successMsg('编辑成功');
  513. })
  514. }else {
  515. addAccount(params).then(res => {
  516. this.cancelAccountForm();
  517. this.getList();
  518. this.$successMsg('添加成功');
  519. })
  520. }
  521. }
  522. })
  523. },
  524. // 表格选择列
  525. handleTableSelection(val) {
  526. this.tableSelection = val;
  527. },
  528. // 批量删除账号
  529. batchDeleteAccount() {
  530. if(this.tableSelection.length < 1) {
  531. return this.$errorMsg('至少选择一名账号');
  532. }
  533. this.$confirm(`确定删除选中的账号吗?`, '提示', {
  534. confirmButtonText: '确定',
  535. cancelButtonText: '取消',
  536. type: 'warning'
  537. }).then(() => {
  538. let AccountIds = [];
  539. this.tableSelection.forEach(item => {
  540. AccountIds.push(item.id);
  541. });
  542. deleteAccount({id: AccountIds.join(',')}).then(res => {
  543. this.$successMsg();
  544. this.getTree();
  545. this.getList();
  546. })
  547. }).catch(() => {});
  548. },
  549. // 删除账号
  550. deleteAccount(id) {
  551. deleteAccount({id: id}).then(res => {
  552. this.$successMsg();
  553. this.getTree();
  554. this.getList();
  555. })
  556. },
  557. // 操作 - 更改状态(type: 禁用0,启用1)
  558. changeStatus(id, type) {
  559. type = type ? true : false
  560. changeAccountStatus({adminUserId: id, status: type}).then(res => {
  561. this.getList();
  562. this.$successMsg();
  563. })
  564. },
  565. // 显示隐藏密码
  566. showPwd(num) {
  567. if(num == 1) {
  568. if (this.passwordType1 === 'password') {
  569. this.passwordType1 = ''
  570. } else {
  571. this.passwordType1 = 'password'
  572. }
  573. this.$nextTick(() => {
  574. this.$refs.password1.focus()
  575. })
  576. }
  577. if(num == 2) {
  578. if (this.passwordType2 === 'password') {
  579. this.passwordType2 = ''
  580. } else {
  581. this.passwordType2 = 'password'
  582. }
  583. this.$nextTick(() => {
  584. this.$refs.password2.focus()
  585. })
  586. }
  587. },
  588. // 重置密码
  589. handleReset(id) {
  590. this.resetId = id;
  591. this.resetFormVisible = true;
  592. },
  593. // 取消重置密码
  594. cancelResetForm(){
  595. this.resetFormVisible = false;
  596. this.passwordType1 = 'password';
  597. this.passwordType2 = 'password';
  598. this.$refs.resetForm.resetFields();
  599. },
  600. // 提交重置密码
  601. submitResetForm() {
  602. this.$refs.resetForm.validate((valid) => {
  603. if (valid) {
  604. let params = {
  605. password: this.resetForm.newPassword,
  606. adminUserId: this.resetId
  607. }
  608. resetPassword(params).then(res => {
  609. this.cancelResetForm();
  610. this.getList();
  611. this.$successMsg();
  612. })
  613. }
  614. })
  615. },
  616. // 导出
  617. handleExport() {
  618. let screenData = {
  619. adminWebsitId: this.selectDepartment ? this.selectDepartment.websitId : '',
  620. keyword: this.screenForm.name
  621. };
  622. downloadFiles('wechat/enterprise/export', screenData);
  623. },
  624. // 下载导入模版
  625. handleDownload() {
  626. downloadFiles('wechat/enterprise/download');
  627. },
  628. clickImport() {
  629. if(!this.selectDepartment) {
  630. return this.$errorMsg('请选择部门');
  631. }else {
  632. document.querySelector('.import-btn input').click();
  633. }
  634. },
  635. // 导入
  636. async handleImport(param) {
  637. this.importLoading = true;
  638. const file = param.file;
  639. const formData = new FormData();
  640. formData.append("file", file);
  641. formData.append("mainDepartmentId", this.selectDepartment.websitId);
  642. let result = await handleImport('wechat/enterprise/import', formData);
  643. this.importLoading = false;
  644. this.importFileList = [];
  645. if(result.code == 200) {
  646. this.$alert(result.message, '导入成功', {
  647. confirmButtonText: '确定'
  648. });
  649. this.getList();
  650. }else {
  651. this.$alert(result.message, '导入失败', {
  652. confirmButtonText: '确定'
  653. });
  654. }
  655. },
  656. }
  657. }
  658. </script>
  659. <style scoped lang="scss">
  660. .app-container {
  661. display: flex;
  662. .tree-container {
  663. width: 18%;
  664. height: calc(100vh - 110px);
  665. flex-shrink: 0;
  666. background: #f5f5f5;
  667. margin-right: 2%;
  668. display: flex;
  669. flex-direction: column;
  670. overflow-y: hidden;
  671. .el-tree {
  672. height: 100%;
  673. background: none;
  674. width: 100%;
  675. overflow: scroll;
  676. // ::v-deep .el-tree-node:focus > .el-tree-node__content {
  677. // color: #ffffff;
  678. // background-color: #409EFF;
  679. // }
  680. ::v-deep >.el-tree-node {
  681. display: inline-block;
  682. min-width: 100%;
  683. }
  684. ::v-deep .el-tree-node>.el-tree-node__content {
  685. padding-right: 10px;
  686. align-self: baseline;
  687. }
  688. ::v-deep .el-tree-node.is-current>.el-tree-node__content {
  689. background-color: #409EFF;
  690. .custom-tree-node {
  691. i {
  692. color: #fff;
  693. }
  694. span {
  695. color: #fff;
  696. }
  697. }
  698. }
  699. ::v-deep .el-tree-node>.el-tree-node__children {
  700. overflow: unset;
  701. }
  702. .custom-tree-node {
  703. i {
  704. font-size: 14px;
  705. color: #999;
  706. }
  707. span {
  708. font-size: 14px;
  709. margin-left: 6px;
  710. color: #666;
  711. }
  712. }
  713. }
  714. }
  715. .mymain-container {
  716. width: 80%;
  717. margin-top: 0;
  718. }
  719. }
  720. ::v-deep .el-divider--vertical {
  721. margin: 0 15px;
  722. }
  723. .show-pwd {
  724. position: absolute;
  725. right: 15px;
  726. top: 0;
  727. font-size: 16px;
  728. cursor: pointer;
  729. user-select: none;
  730. }
  731. </style>