index.vue 16 KB

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