account.vue 27 KB

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