annexList.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  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.content"
  9. @change="Search"
  10. style="width: 80%"
  11. >
  12. <i slot="prefix" class="el-input__icon el-icon-search"></i>
  13. </el-input>
  14. </div>
  15. </div>
  16. <div class="grid-content bg-purple">
  17. <el-input
  18. placeholder="请输入供应商名称"
  19. v-model="formData.operateUser"
  20. @change="SearchOperateUser"
  21. style="width: 100%"
  22. >
  23. <i slot="prefix" class="el-input__icon el-icon-search"></i>
  24. </el-input>
  25. </div>
  26. <div class="grid-content bg-purple">
  27. <div class="block">
  28. <el-date-picker
  29. v-model="value2"
  30. type="daterange"
  31. align="right"
  32. unlink-panels
  33. range-separator="至"
  34. start-placeholder="开始日期"
  35. end-placeholder="结束日期"
  36. value-format="yyyy-MM-dd"
  37. :picker-options="pickerOptions"
  38. @change="startEndTime"
  39. >
  40. </el-date-picker>
  41. </div>
  42. </div>
  43. <div
  44. class="grid-content bg-purple"
  45. style="display: flex; justify-content: flex-end"
  46. >
  47. <el-button type="primary" @click="toindex">操作日志</el-button>
  48. <el-button type="primary" disabled>附件列表</el-button>
  49. <el-button type="primary" @click="batchExports">导出</el-button>
  50. <el-button type="primary" @click="downloadAppendix">下载</el-button>
  51. </div>
  52. </el-row>
  53. <el-table
  54. :row-key="getRowKey"
  55. v-loading="listLoading"
  56. :data="temporaryList"
  57. element-loading-text="Loading"
  58. border
  59. fit
  60. highlight-current-row
  61. @select="handleSelectionChange"
  62. @select-all="handleAll"
  63. >
  64. <el-table-column
  65. align="center"
  66. label=""
  67. width="55"
  68. type="selection"
  69. :reserve-selection="true"
  70. >
  71. </el-table-column>
  72. <el-table-column align="center" label="合同名称" width="210" prop="name">
  73. </el-table-column>
  74. <el-table-column
  75. label="供应商名称"
  76. align="center"
  77. width="120"
  78. prop="supplierName"
  79. >
  80. </el-table-column>
  81. <el-table-column label="日期" width="120" align="center">
  82. <template slot-scope="scope">
  83. <i class="el-icon-time" />
  84. <span>{{ scope.row.createdAt }}</span>
  85. </template>
  86. </el-table-column>
  87. <!-- 合同附件 -->
  88. <el-table-column
  89. align="center"
  90. label="合同附件"
  91. width="300"
  92. prop="picUrls"
  93. >
  94. <template slot-scope="scope">
  95. <!-- <img
  96. width="100"
  97. height="100"
  98. v-for="item in scope.row.picUrls"
  99. :key="item.id"
  100. :src="item"
  101. /> -->
  102. <FileShow :files="scope.row.picUrls" />
  103. </template>
  104. </el-table-column>
  105. <!-- 发票附件 -->
  106. <el-table-column
  107. align="center"
  108. label="发票附件"
  109. width="300"
  110. prop="invoicePics"
  111. >
  112. <template slot-scope="scope">
  113. <!-- <img
  114. width="100"
  115. height="100"
  116. v-for="item in scope.row.invoicePics"
  117. :key="item.id"
  118. :src="item"
  119. /> -->
  120. <FileShow :files="scope.row.invoicePics" />
  121. </template>
  122. </el-table-column>
  123. <!-- 贸易合同 -->
  124. <el-table-column
  125. align="center"
  126. label="贸易合同"
  127. width="400"
  128. prop="tradePics"
  129. >
  130. <template slot-scope="scope">
  131. <!-- <img
  132. width="100"
  133. height="100"
  134. v-for="item in scope.row.tradePics"
  135. :key="item.id"
  136. :src="item"
  137. /> -->
  138. <FileShow :files="scope.row.tradePics" />
  139. </template>
  140. </el-table-column>
  141. <el-table-column
  142. align="center"
  143. prop="created_at"
  144. label="操作"
  145. width="250"
  146. >
  147. <template slot-scope="scope">
  148. <el-tag
  149. type="primary"
  150. style="cursor: pointer; margin-right: 15px"
  151. @click="todetail(scope.row.id)"
  152. >汇票附件</el-tag
  153. >
  154. <el-tag
  155. type="primary"
  156. style="cursor: pointer; margin-right: 15px"
  157. @click="download(scope.row.id)"
  158. >
  159. 下载</el-tag
  160. >
  161. </template>
  162. </el-table-column>
  163. </el-table>
  164. <div class="pagesip">
  165. <el-button
  166. type="primary"
  167. size="small"
  168. style="background-color: #d8ab5a; border-color: #d8ab5a; margin: 0 20px"
  169. @click="jumpFirstPage"
  170. >首页
  171. </el-button>
  172. <el-pagination
  173. ref="pagination"
  174. background
  175. layout="total,prev, pager, next"
  176. :total="total"
  177. :page-size="pagesize"
  178. :current-page="currentPage"
  179. prev-text="上一页"
  180. next-text="下一页"
  181. @current-change="handleCurrentChange"
  182. />
  183. <el-button
  184. type="primary"
  185. size="small"
  186. style="background-color: #d8ab5a; border-color: #d8ab5a; margin: 0 20px"
  187. @click="jumpLastPage"
  188. >尾页
  189. </el-button>
  190. </div>
  191. </div>
  192. </template>
  193. <script>
  194. import { getAuditLogAttachmentsSearch } from "@/api/auditlog";
  195. import { dataConversionUtil } from "../../utils/Excel.js";
  196. export default {
  197. filters: {
  198. statusFilter(status) {
  199. const statusMap = {
  200. published: "success",
  201. draft: "gray",
  202. deleted: "danger",
  203. };
  204. return statusMap[status];
  205. },
  206. },
  207. data() {
  208. return {
  209. // 表单数据
  210. formData: {
  211. startTime: "",
  212. endTime: "",
  213. name: "",
  214. operateUser: "", //操作人员
  215. content: "", //查询内容
  216. },
  217. /* 当前页数 */
  218. currentPage: 1,
  219. /* 每页显示个数 */
  220. pagesize: 10,
  221. /* 总条数 */
  222. total: 20,
  223. temporaryList: [],
  224. srcList: [],
  225. list: [],
  226. listLoading: false,
  227. status: "",
  228. hpstatus: "",
  229. input4: "",
  230. checked: false,
  231. pickerOptions: {
  232. shortcuts: [
  233. {
  234. text: "最近一周",
  235. onClick(picker) {
  236. const end = new Date();
  237. const start = new Date();
  238. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  239. picker.$emit("pick", [start, end]);
  240. },
  241. },
  242. {
  243. text: "最近一个月",
  244. onClick(picker) {
  245. const end = new Date();
  246. const start = new Date();
  247. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  248. picker.$emit("pick", [start, end]);
  249. },
  250. },
  251. {
  252. text: "最近三个月",
  253. onClick(picker) {
  254. const end = new Date();
  255. const start = new Date();
  256. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  257. picker.$emit("pick", [start, end]);
  258. },
  259. },
  260. ],
  261. },
  262. value1: "",
  263. value2: "",
  264. multipleSelection: [], //导出数据
  265. idsArray: [], //存放所有合同的id名
  266. };
  267. },
  268. mounted() {
  269. this.getAllList();
  270. },
  271. methods: {
  272. /* 获取列表数据 */
  273. getAllList(searchForm = {}) {
  274. const params = {
  275. pageIndex: this.currentPage,
  276. pageSize: this.pagesize,
  277. };
  278. getAuditLogAttachmentsSearch({
  279. ...params,
  280. ...searchForm,
  281. }).then((res) => {
  282. const { data } = res;
  283. this.temporaryList = data.result;
  284. this.srcList = data.result;
  285. this.total = res.data.total;
  286. this.idsArray = this.temporaryList.map((item) => {
  287. return item.id;
  288. });
  289. });
  290. },
  291. /* 请输入查询内容 */
  292. Search() {
  293. this.currentPage = 1;
  294. this.searchForm = {
  295. ...this.formData,
  296. };
  297. this.getAllList(this.searchForm);
  298. },
  299. /* 操作人员查询*/
  300. SearchOperateUser() {
  301. console.log("我是操作人员");
  302. this.currentPage = 1;
  303. this.searchForm = {
  304. ...this.formData,
  305. };
  306. this.getAllList(this.searchForm);
  307. },
  308. // 日期审核状态查询
  309. startEndTime(item) {
  310. if (item == null) {
  311. item = [];
  312. this.formData.startTime = "";
  313. this.formData.endTime = "";
  314. this.currentPage = 1;
  315. this.searchForm = {
  316. ...this.formData,
  317. };
  318. this.getAllList(this.searchForm);
  319. } else {
  320. this.formData.startTime = this.value2[0];
  321. this.formData.endTime = this.value2[1];
  322. this.currentPage = 1;
  323. this.searchForm = {
  324. ...this.formData,
  325. };
  326. this.getAllList(this.searchForm);
  327. }
  328. },
  329. /* 分页功能,改变当前页 */
  330. handleCurrentChange(val) {
  331. this.currentPage = val;
  332. this.getAllList(this.searchForm);
  333. },
  334. /* 分页功能去首页 */
  335. jumpFirstPage() {
  336. this.$refs.pagination.handleCurrentChange(1);
  337. this.$emit("handleCurrentChange", 1);
  338. },
  339. /* 分页功能:去尾页 */
  340. jumpLastPage() {
  341. let font = this.$refs.pagination;
  342. let cpage = Math.ceil(font.total / font.pageSize);
  343. font.handleCurrentChange(cpage);
  344. },
  345. /* 跳转到详情页 */
  346. todetail(id) {
  347. this.$router.push({
  348. path: "/attachmentdetail",
  349. query: {
  350. id: id,
  351. },
  352. });
  353. },
  354. toindex() {
  355. this.$router.push({
  356. path: "/sucuirtyaudit/index",
  357. });
  358. },
  359. // 下载合同附件zip
  360. download(id) {
  361. let that = this;
  362. this.$request({
  363. url: "/api/AuditLog/attachments/download",
  364. method: "post",
  365. data: {
  366. contractIds: [id],
  367. },
  368. responseType: "blob",
  369. }).then((res) => {
  370. let filename = this.getFileName(res.headers["content-disposition"]);
  371. let fileData = res.data;
  372. let blob = new Blob([fileData], { type: "application/zip" });
  373. let url = URL.createObjectURL(blob);
  374. const link = document.createElement("a");
  375. link.href = url;
  376. link.download = filename;
  377. link.click();
  378. // 释放内存
  379. URL.revokeObjectURL(url);
  380. });
  381. },
  382. // 设置zip名
  383. getFileName(contentDisposition) {
  384. var filename = "";
  385. var filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/;
  386. var matches = filenameRegex.exec(contentDisposition);
  387. if (matches != null && matches[1]) {
  388. filename = matches[1].replace(/['"]/g, "");
  389. }
  390. return decodeURI(filename);
  391. },
  392. /* 批量下载附件 */
  393. downloadAppendix() {
  394. let ids = this.multipleSelection.map((item) => {
  395. return item.id;
  396. });
  397. if (ids == "") {
  398. let that = this;
  399. this.$request({
  400. url: "/api/AuditLog/attachments/download",
  401. method: "post",
  402. data: {
  403. contractIds: this.idsArray,
  404. },
  405. responseType: "blob",
  406. }).then((res) => {
  407. let filename = this.getFileName(res.headers["content-disposition"]);
  408. let fileData = res.data;
  409. let blob = new Blob([fileData], { type: "application/zip" });
  410. let url = URL.createObjectURL(blob);
  411. const link = document.createElement("a");
  412. link.href = url;
  413. link.download = filename;
  414. link.click();
  415. // 释放内存
  416. URL.revokeObjectURL(url);
  417. });
  418. } else {
  419. let that = this;
  420. this.$request({
  421. url: "/api/AuditLog/attachments/download",
  422. method: "post",
  423. data: {
  424. contractIds: ids,
  425. },
  426. responseType: "blob",
  427. }).then((res) => {
  428. let filename = this.getFileName(res.headers["content-disposition"]);
  429. let fileData = res.data;
  430. let blob = new Blob([fileData], { type: "application/zip" });
  431. let url = URL.createObjectURL(blob);
  432. const link = document.createElement("a");
  433. link.href = url;
  434. link.download = filename;
  435. link.click();
  436. // 释放内存
  437. URL.revokeObjectURL(url);
  438. });
  439. }
  440. },
  441. getRowKey(row) {
  442. return row.id;
  443. },
  444. /* 批量导出 */
  445. handleSelectionChange(data) {
  446. this.multipleSelection = data;
  447. },
  448. handleAll(data) {
  449. this.multipleSelection = data;
  450. },
  451. /* 批量导出数据 */
  452. batchExports() {
  453. if (this.multipleSelection == "") {
  454. this.Exports();
  455. } else {
  456. var tableHeader = [
  457. [
  458. "序号",
  459. "合同名称",
  460. "供应商名称",
  461. "日期",
  462. "合同附件",
  463. "发票附件",
  464. "贸易合同",
  465. ],
  466. ];
  467. var dataList = [];
  468. this.multipleSelection.forEach((item, index) => {
  469. dataList.push([
  470. index + 1,
  471. item.name,
  472. item.supplierName,
  473. item.createdAt,
  474. item.picUrls,
  475. item.invoicePics,
  476. item.tradePics,
  477. ]);
  478. });
  479. dataConversionUtil.dataToExcel("附件列表", tableHeader, dataList);
  480. this.$message.success("导出成功!");
  481. }
  482. },
  483. /* 全部导出承兑人列表数据 */
  484. getContacts() {
  485. const data = {
  486. pageIndex: "",
  487. pageSize: -1,
  488. startTime: "",
  489. endTime: "",
  490. operateUser: "",
  491. content: "",
  492. };
  493. getAuditLogAttachmentsSearch({ ...data }).then((res) => {
  494. const { result } = res.data;
  495. this.multipleSelection = result;
  496. });
  497. },
  498. /* 全部导出 */
  499. Exports() {
  500. this.getContacts();
  501. setTimeout(() => {
  502. var tableHeader = [
  503. [
  504. "序号",
  505. "合同名称",
  506. "供应商名称",
  507. "日期",
  508. "合同附件",
  509. "发票附件",
  510. "贸易合同",
  511. ],
  512. ];
  513. var dataList = [];
  514. this.multipleSelection.forEach((item, index) => {
  515. dataList.push([
  516. index + 1,
  517. item.name,
  518. item.supplierName,
  519. item.createdAt,
  520. item.picUrls,
  521. item.invoicePics,
  522. item.tradePics,
  523. ]);
  524. });
  525. dataConversionUtil.dataToExcel("附件列表", tableHeader, dataList);
  526. this.$message.success("导出成功!");
  527. }, 1000);
  528. },
  529. },
  530. };
  531. </script>
  532. <style lang="scss" scoped>
  533. .pulldown {
  534. width: 185px;
  535. height: 40px;
  536. border: 1px solid #e8e8e8;
  537. border-radius: 10px;
  538. display: flex;
  539. justify-content: center;
  540. align-items: center;
  541. justify-content: space-between;
  542. padding: 0 20px;
  543. color: #999999;
  544. }
  545. .pagesip {
  546. width: 100%;
  547. margin: 20px auto;
  548. display: flex;
  549. // align-items: center;
  550. justify-content: flex-end;
  551. }
  552. .el-pagination.is-background .el-pager li:not(.disabled).active {
  553. background-color: #d8ab5a;
  554. }
  555. .el-col {
  556. margin-bottom: 20px;
  557. }
  558. </style>