account.vue 24 KB

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