index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. <template>
  2. <div class="app-container">
  3. <el-row type="flex" justify="space-between" style="margin-bottom: 20px">
  4. <div class="grid-content bg-purple">
  5. <el-input
  6. v-model="formData.name"
  7. @change="Search"
  8. placeholder="请输入业务管理员名称"
  9. style="width: 100%"
  10. >
  11. <i slot="prefix" class="el-input__icon el-icon-search" />
  12. </el-input>
  13. </div>
  14. <div class="grid-content bg-purple">
  15. <el-dropdown @command="handleCommand">
  16. <div class="pulldown">
  17. <span v-if="!status" class="el-dropdown-link">
  18. 业务管理员状态
  19. </span>
  20. <span v-if="status" class="el-dropdown-link">
  21. {{ status }}
  22. </span>
  23. <i class="el-icon-arrow-down el-icon--right" />
  24. </div>
  25. <el-dropdown-menu slot="dropdown">
  26. <el-dropdown-item command="全部">全部</el-dropdown-item>
  27. <el-dropdown-item command="正常">正常</el-dropdown-item>
  28. <el-dropdown-item command="删除">删除</el-dropdown-item>
  29. </el-dropdown-menu>
  30. </el-dropdown>
  31. </div>
  32. <div class="grid-content bg-purple">
  33. <el-dropdown @command="handlehpCommand">
  34. <div class="pulldown">
  35. <span v-if="!Auditstatus" class="el-dropdown-link"> 审核状态 </span>
  36. <span v-if="Auditstatus" class="el-dropdown-link">
  37. {{ Auditstatus }}
  38. </span>
  39. <i class="el-icon-arrow-down el-icon--right" />
  40. </div>
  41. <el-dropdown-menu slot="dropdown">
  42. <el-dropdown-item command="全部">全部</el-dropdown-item>
  43. <el-dropdown-item command="待审核">待审核</el-dropdown-item>
  44. <el-dropdown-item command="通过">通过</el-dropdown-item>
  45. <el-dropdown-item command="未通过">未通过</el-dropdown-item>
  46. </el-dropdown-menu>
  47. </el-dropdown>
  48. </div>
  49. <div
  50. class="grid-content bg-purple"
  51. style="display: flex; justify-content: flex-end; margin-left: 10px"
  52. >
  53. <el-button type="success" @click="success">审核成功</el-button>
  54. <el-button type="danger" @click="failed">审核失败</el-button>
  55. <el-button type="primary" @click="recover">恢复</el-button>
  56. <el-button type="warning" @click="deleted">删除</el-button>
  57. <el-button type="primary" @click="batchExports">导出</el-button>
  58. </div>
  59. </el-row>
  60. <el-table
  61. :row-key="getRowKey"
  62. v-loading="listLoading"
  63. :data="temporaryList"
  64. element-loading-text="Loading"
  65. border
  66. fit
  67. highlight-current-row
  68. @selection-change="handleSelectionChange"
  69. @select-all="handleAll"
  70. >
  71. <el-table-column align="center" label="" width="55" type="selection" :reserve-selection="true" />
  72. <el-table-column
  73. label="业务管理员名称"
  74. align="center"
  75. width="180"
  76. prop="realName"
  77. />
  78. <el-table-column label="账号" align="center" prop="account" />
  79. <el-table-column
  80. label="联系电话"
  81. width="180"
  82. align="center"
  83. prop="mobile"
  84. />
  85. <el-table-column
  86. label="审核状态"
  87. align="center"
  88. prop="approveStatusText"
  89. />
  90. <el-table-column
  91. label="业务管理员状态"
  92. align="center"
  93. prop="statusText"
  94. width="180"
  95. />
  96. <el-table-column
  97. label="时间"
  98. width="180"
  99. align="center"
  100. prop="createdAt"
  101. />
  102. <el-table-column
  103. align="center"
  104. prop="created_at"
  105. label="操作"
  106. width="300"
  107. >
  108. <template slot-scope="scope">
  109. <el-tag
  110. type="success"
  111. style="cursor: pointer; margin: 0 5px"
  112. @click="Srecover(scope.row.id)"
  113. v-if="scope.row.status == 1"
  114. >恢复</el-tag
  115. >
  116. <el-tag
  117. type="danger"
  118. style="cursor: pointer; margin: 0 5px"
  119. @click="Sdeleted(scope.row.id)"
  120. v-if="scope.row.status == 0"
  121. >删除</el-tag
  122. >
  123. <el-tag
  124. type="primary"
  125. v-permission="['admin']"
  126. style="cursor: pointer; margin: 0 5px"
  127. @click="reset(scope.row.id)"
  128. >重置密码
  129. </el-tag>
  130. </template>
  131. </el-table-column>
  132. </el-table>
  133. <!-- 重置密码弹窗 -->
  134. <el-dialog title="重置密码" :visible.sync="dialogVisible" width="30%">
  135. <el-form ref="form" :model="password" label-width="80px">
  136. <el-form-item label="登录密码" prop="password.newpassword">
  137. <el-input
  138. v-model="password.newpassword"
  139. style="width: 300px"
  140. show-password
  141. ></el-input>
  142. </el-form-item>
  143. <el-form-item label="确认密码" prop="password.ConfirmnewPassword">
  144. <el-input
  145. v-model="password.ConfirmnewPassword"
  146. style="width: 300px"
  147. show-password
  148. ></el-input>
  149. </el-form-item>
  150. <el-form-item>
  151. <el-button @click="dialogVisible = false">取 消</el-button>
  152. <el-button type="primary" @click="onSubmit">提交修改</el-button>
  153. </el-form-item>
  154. </el-form>
  155. </el-dialog>
  156. <div class="pagesip">
  157. <el-button
  158. type="primary"
  159. size="small"
  160. style="background-color: #d8ab5a; border-color: #d8ab5a; margin: 0 20px"
  161. @click="jumpFirstPage"
  162. >首页
  163. </el-button>
  164. <el-pagination
  165. ref="pagination"
  166. background
  167. layout="total,prev, pager, next"
  168. :total="total"
  169. :page-size="pagesize"
  170. :current-page="currentPage"
  171. prev-text="上一页"
  172. next-text="下一页"
  173. @current-change="handleCurrentChange"
  174. />
  175. <el-button
  176. type="primary"
  177. size="small"
  178. style="background-color: #d8ab5a; border-color: #d8ab5a; margin: 0 20px"
  179. @click="jumpLastPage"
  180. >尾页
  181. </el-button>
  182. </div>
  183. </div>
  184. </template>
  185. <script>
  186. import { dataConversionUtil } from "../../utils/Excel.js";
  187. import { getAccountSearch } from "@/api/account";
  188. export default {
  189. filters: {
  190. statusFilter(status) {
  191. const statusMap = {
  192. published: "success",
  193. draft: "gray",
  194. deleted: "danger",
  195. };
  196. return statusMap[status];
  197. },
  198. },
  199. data() {
  200. return {
  201. dialogVisible: false,
  202. // 表单数据
  203. formData: {
  204. startTime: "",
  205. endTime: "",
  206. name: "",
  207. status: "", //审核状态
  208. isDeleted: "", //删除状态
  209. },
  210. // 重置密码
  211. password: {
  212. newpassword: "",
  213. ConfirmnewPassword: "",
  214. userId: "",
  215. },
  216. /* 当前页数 */
  217. currentPage: 1,
  218. /* 每页显示个数 */
  219. pagesize: 10,
  220. /* 总条数 */
  221. total: 20,
  222. temporaryList: [],
  223. srcList: [],
  224. list: [],
  225. listLoading: false,
  226. status: "",
  227. Auditstatus: "",
  228. checked: false,
  229. pickerOptions: {
  230. shortcuts: [
  231. {
  232. text: "最近一周",
  233. onClick(picker) {
  234. const end = new Date();
  235. const start = new Date();
  236. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  237. picker.$emit("pick", [start, end]);
  238. },
  239. },
  240. {
  241. text: "最近一个月",
  242. onClick(picker) {
  243. const end = new Date();
  244. const start = new Date();
  245. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  246. picker.$emit("pick", [start, end]);
  247. },
  248. },
  249. {
  250. text: "最近三个月",
  251. onClick(picker) {
  252. const end = new Date();
  253. const start = new Date();
  254. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  255. picker.$emit("pick", [start, end]);
  256. },
  257. },
  258. ],
  259. },
  260. value1: "",
  261. value2: "",
  262. exportExcelData1: [], //导出列表缓存数据整页
  263. exportExcelData2: [], //导出列表缓存数据单选
  264. };
  265. },
  266. mounted() {
  267. this.getAllList();
  268. },
  269. methods: {
  270. /* 获取列表数据 */
  271. getAllList(searchForm = {}) {
  272. const params = {
  273. pageIndex: this.currentPage,
  274. pageSize: this.pagesize,
  275. };
  276. getAccountSearch({
  277. ...params,
  278. ...searchForm,
  279. }).then((res) => {
  280. const { data } = res;
  281. this.temporaryList = data.result;
  282. this.srcList = data.result;
  283. this.total = res.data.total;
  284. });
  285. },
  286. success() {
  287. const ids = Array.from(this.multipleSelection, ({ id }) => id);
  288. this.$request({
  289. url: "/api/Account/manager",
  290. method: "post",
  291. data: {
  292. ids: ids,
  293. operateType: 3,
  294. },
  295. }).then((res) => {
  296. if (res.code == 200) {
  297. this.$message({
  298. type: "success",
  299. message: res.msg,
  300. });
  301. this.getAllList();
  302. } else {
  303. this.$message({
  304. type: "error",
  305. message: res.msg,
  306. });
  307. this.getAllList();
  308. }
  309. });
  310. },
  311. failed() {
  312. const ids = Array.from(this.multipleSelection, ({ id }) => id);
  313. this.$request({
  314. url: "/api/Account/manager",
  315. method: "post",
  316. data: {
  317. ids: ids,
  318. operateType: 4,
  319. },
  320. }).then((res) => {
  321. if (res.code == 200) {
  322. this.$message({
  323. type: "success",
  324. message: res.msg,
  325. });
  326. this.getAllList();
  327. } else {
  328. this.$message({
  329. type: "error",
  330. message: res.msg,
  331. });
  332. this.getAllList();
  333. }
  334. });
  335. },
  336. recover() {
  337. const ids = Array.from(this.multipleSelection, ({ id }) => id);
  338. this.$request({
  339. url: "/api/Account/manager",
  340. method: "post",
  341. data: {
  342. ids: ids,
  343. operateType: 2,
  344. },
  345. }).then((res) => {
  346. if (res.code == 200) {
  347. this.$message({
  348. type: "success",
  349. message: "恢复成功",
  350. });
  351. this.getAllList();
  352. } else {
  353. this.$message({
  354. type: "error",
  355. message: "恢复失败",
  356. });
  357. this.getAllList();
  358. }
  359. });
  360. },
  361. deleted() {
  362. const ids = Array.from(this.multipleSelection, ({ id }) => id);
  363. this.$request({
  364. url: "/api/Account/manager",
  365. method: "post",
  366. data: {
  367. ids: ids,
  368. operateType: 1,
  369. },
  370. }).then((res) => {
  371. if (res.code == 200) {
  372. this.$message({
  373. type: "success",
  374. message: "删除成功",
  375. });
  376. this.getAllList();
  377. } else {
  378. this.$message({
  379. type: "error",
  380. message: "删除失败",
  381. });
  382. this.getAllList();
  383. }
  384. });
  385. },
  386. Srecover(id) {
  387. this.$request({
  388. url: "/api/Account/manager",
  389. method: "post",
  390. data: {
  391. ids: [id],
  392. operateType: 2,
  393. },
  394. }).then((res) => {
  395. if (res.code == 200) {
  396. this.$message({
  397. type: "success",
  398. message: "恢复成功",
  399. });
  400. this.getAllList();
  401. } else {
  402. this.$message({
  403. type: "error",
  404. message: "恢复失败",
  405. });
  406. this.getAllList();
  407. }
  408. });
  409. },
  410. Sdeleted(id) {
  411. this.$request({
  412. url: "/api/Account/manager",
  413. method: "post",
  414. data: {
  415. ids: [id],
  416. operateType: 1,
  417. },
  418. }).then((res) => {
  419. if (res.code == 200) {
  420. this.$message({
  421. type: "success",
  422. message: "删除成功",
  423. });
  424. this.getAllList();
  425. } else {
  426. this.$message({
  427. type: "error",
  428. message: "删除失败",
  429. });
  430. this.getAllList();
  431. }
  432. });
  433. },
  434. /* 输入出票人名称查询 */
  435. Search() {
  436. this.currentPage = 1;
  437. this.searchForm = {
  438. ...this.formData,
  439. };
  440. this.getAllList(this.searchForm);
  441. },
  442. /* 业务员状态筛选 */
  443. handleCommand(command) {
  444. this.status = command;
  445. if (command === "全部") {
  446. this.formData.isDeleted = "";
  447. }
  448. if (command === "正常") {
  449. this.formData.isDeleted = 0;
  450. }
  451. if (command === "删除") {
  452. this.formData.isDeleted = 1;
  453. }
  454. this.currentPage = 1;
  455. this.searchForm = {
  456. ...this.formData,
  457. };
  458. this.getAllList(this.searchForm);
  459. },
  460. /* 审核状态筛选 */
  461. handlehpCommand(command) {
  462. this.Auditstatus = command;
  463. if (command === "全部") {
  464. this.formData.status = "";
  465. }
  466. if (command === "待审核") {
  467. this.formData.status = 1;
  468. }
  469. if (command === "通过") {
  470. this.formData.status = 2;
  471. }
  472. if (command === "未通过") {
  473. this.formData.status = 3;
  474. }
  475. this.currentPage = 1;
  476. this.searchForm = {
  477. ...this.formData,
  478. };
  479. this.getAllList(this.searchForm);
  480. },
  481. /* 分页功能,改变当前页 */
  482. handleCurrentChange(val) {
  483. this.currentPage = val;
  484. this.getAllList(this.searchForm);
  485. },
  486. /* 分页功能去首页 */
  487. jumpFirstPage() {
  488. this.$refs.pagination.handleCurrentChange(1);
  489. this.$emit("handleCurrentChange", 1);
  490. },
  491. /* 分页功能:去尾页 */
  492. jumpLastPage() {
  493. let font = this.$refs.pagination;
  494. let cpage = Math.ceil(font.total / font.pageSize);
  495. font.handleCurrentChange(cpage);
  496. },
  497. getRowKey(row) {
  498. return row.id;
  499. },
  500. /* 批量导出数据 */
  501. handleSelectionChange(data) {
  502. this.multipleSelection = data;
  503. },
  504. handleAll(data) {
  505. this.multipleSelection = data;
  506. },
  507. /* 批量导出 */
  508. batchExports() {
  509. if (this.multipleSelection == "") {
  510. this.Exports()
  511. } else {
  512. var tableHeader = [
  513. [
  514. "序号",
  515. "业务管理员姓名",
  516. "账号",
  517. "联系电话",
  518. "业务管理员状态",
  519. "审核状态",
  520. "时间",
  521. ],
  522. ];
  523. var dataList = [];
  524. this.multipleSelection.forEach((item, index) => {
  525. dataList.push([
  526. index + 1,
  527. item.realName,
  528. item.account,
  529. item.mobile,
  530. item.statusText,
  531. item.approveStatusText,
  532. item.createdAt,
  533. ]);
  534. });
  535. dataConversionUtil.dataToExcel("业务管理员列表", tableHeader, dataList);
  536. this.$message.success("导出成功!");
  537. }
  538. },
  539. /* 全部导出合同列表数据 */
  540. getContacts() {
  541. const data = {
  542. pageIndex: "",
  543. pageSize: -1,
  544. startTime: "",
  545. endTime: "",
  546. isDeleted: "",
  547. status: "",
  548. };
  549. getAccountSearch({ ...data }).then((res) => {
  550. const { result } = res.data;
  551. this.multipleSelection = result;
  552. });
  553. },
  554. /* 全部导出 */
  555. Exports() {
  556. this.getContacts();
  557. setTimeout(() => {
  558. var tableHeader = [
  559. [
  560. "序号",
  561. "业务管理员姓名",
  562. "账号",
  563. "联系电话",
  564. "业务管理员状态",
  565. "审核状态",
  566. "时间",
  567. ],
  568. ];
  569. var dataList = [];
  570. this.multipleSelection.forEach((item, index) => {
  571. dataList.push([
  572. index + 1,
  573. item.realName,
  574. item.account,
  575. item.mobile,
  576. item.statusText,
  577. item.approveStatusText,
  578. item.createdAt,
  579. ]);
  580. });
  581. dataConversionUtil.dataToExcel("业务管理员列表", tableHeader, dataList);
  582. this.$message.success("导出成功!");
  583. }, 1000);
  584. },
  585. // 重置业务员密码
  586. reset(id) {
  587. this.dialogVisible = true;
  588. this.password.userId = id;
  589. },
  590. // 提交修改密码
  591. onSubmit() {
  592. if (this.password.newpassword !== this.password.ConfirmnewPassword) {
  593. this.$message({
  594. type: "error",
  595. message: "密码与确认密码不一致",
  596. });
  597. } else if (
  598. this.password.newpassword.length < 6 ||
  599. this.password.ConfirmnewPassword < 6
  600. ) {
  601. this.$message({
  602. type: "error",
  603. message: "密码与确认密码至少6位",
  604. });
  605. } else {
  606. this.$request({
  607. url: "/api/Account/password/resetUser",
  608. method: "post",
  609. data: {
  610. password: this.password.newpassword,
  611. userId: this.password.userId,
  612. },
  613. }).then((res) => {
  614. console.log(res);
  615. if (res.code === 200) {
  616. this.$message({
  617. type: "success",
  618. message: "重置成功",
  619. });
  620. this.dialogVisible = false;
  621. }
  622. });
  623. }
  624. },
  625. },
  626. };
  627. </script>
  628. <style lang="scss" scoped>
  629. .pulldown {
  630. width: 185px;
  631. height: 40px;
  632. border: 1px solid #e8e8e8;
  633. border-radius: 10px;
  634. display: flex;
  635. justify-content: center;
  636. align-items: center;
  637. justify-content: space-between;
  638. padding: 0 20px;
  639. color: #999999;
  640. }
  641. .pagesip {
  642. width: 100%;
  643. margin: 20px auto;
  644. display: flex;
  645. // align-items: center;
  646. justify-content: flex-end;
  647. }
  648. .el-pagination.is-background .el-pager li:not(.disabled).active {
  649. background-color: #d8ab5a;
  650. }
  651. .el-col {
  652. margin-bottom: 20px;
  653. }
  654. </style>