UploadRecord.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <div class="upload_record">
  3. <div v-if="!isShowDetail">
  4. <div class="search">
  5. <div class="input">
  6. <img src="../../img/search.png" />
  7. <input type="text" @focus="focusInput" v-model="inputValue" />
  8. </div>
  9. <div class="current_button" @click="search">搜索</div>
  10. </div>
  11. <div class="sort">
  12. <Count :sum="sum" />
  13. <p>排序</p>
  14. <select v-model="order" @change="sort">
  15. <option value="">按时间降序</option>
  16. <option value="DESC">按时间升序</option>
  17. </select>
  18. </div>
  19. <div class="table">
  20. <Table
  21. :tableData="tableData"
  22. @download="download"
  23. @delet="delet"
  24. @detail="detail"
  25. >
  26. </Table>
  27. </div>
  28. <TablePage
  29. :currentPage="currentPage"
  30. :totalPage="totalPage"
  31. @change_page="changePage"
  32. @jump_page="jumpPage"
  33. ></TablePage>
  34. </div>
  35. <div v-else>
  36. <Detail
  37. :detailData='detailData'
  38. ></Detail>
  39. </div>
  40. </div>
  41. </template>
  42. <script>
  43. import Count from "../../components/Count";
  44. import Table from "./components/UploadRecordTable";
  45. import TablePage from "../../components/TablePage";
  46. import Detail from "./components/UploadRecordDetail";
  47. export default {
  48. components: {
  49. Count,
  50. Table,
  51. TablePage,
  52. Detail,
  53. },
  54. data() {
  55. return {
  56. inputValue: "请输入要搜索的资料名",
  57. order: "", // 排序方式
  58. sum: 100, // 表格总数据
  59. currentPage: 1,
  60. pageSize: 20,
  61. tableData: [],
  62. detailData: {}
  63. };
  64. },
  65. computed: {
  66. // 表格总页数
  67. totalPage() {
  68. return Math.ceil(this.sum / this.pageSize);
  69. },
  70. isShowDetail() {
  71. return this.$route.query && this.$route.query.id ? true : false;
  72. },
  73. },
  74. methods: {
  75. focusInput: function () {
  76. this.inputValue = "";
  77. },
  78. search: function () {
  79. console.log(this.inputValue);
  80. let data = {};
  81. if (this.inputValue !== "请输入要搜索的资料名") {
  82. data = {
  83. informationName: this.inputValue,
  84. };
  85. }
  86. this.getFirmsUploadList(data);
  87. this.inputValue = "请输入要搜索的资料名";
  88. },
  89. sort: function () {
  90. // ASC降序
  91. let asc = this.order === "DESC" ? false : true;
  92. let data = {
  93. asc: asc,
  94. };
  95. this.getFirmsUploadList(data);
  96. },
  97. changePage: function (page) {
  98. this.currentPage = page;
  99. console.log(page);
  100. },
  101. // 点击上一页,下一页,首页,尾页
  102. jumpPage: function (item) {
  103. switch (item) {
  104. case 1:
  105. this.currentPage = 1;
  106. break;
  107. case 2:
  108. this.currentPage = this.currentPage - 1;
  109. break;
  110. case 3:
  111. this.currentPage = this.currentPage + 1;
  112. break;
  113. case 4:
  114. this.currentPage = this.totalPage;
  115. break;
  116. }
  117. console.log(this.currentPage);
  118. },
  119. download: function (i) {
  120. let id = this.tableData[i].id;
  121. console.log(id);
  122. this.selectInformationAgentList(id);
  123. },
  124. delet: function (i) {
  125. let id = this.tableData[i].id;
  126. this.deleteInformationInfo(id);
  127. setTimeout(() => {
  128. this.getFirmsUploadList();
  129. }, 2000)
  130. },
  131. detail: function (i) {
  132. let id = this.tableData[i].id || i;
  133. this.detailData = this.tableData[i];
  134. this.$router.push({ query: { id: id } });
  135. },
  136. // 上传记录列表接口
  137. getFirmsUploadList: function (data = {}) {
  138. this.$http({
  139. method: "post",
  140. url: "/firmsUploadList",
  141. data: data,
  142. })
  143. .then((res) => {
  144. console.log(res);
  145. if (res.data && res.data.code === 200) {
  146. this.tableData = res.data.data;
  147. this.sum = res.data.count;
  148. } else {
  149. console.log(res);
  150. }
  151. })
  152. .catch((err) => {
  153. console.log(err);
  154. });
  155. },
  156. // 下载资料接口
  157. selectInformationAgentList: function (dataId) {
  158. return new Promise((resolve, reject) => {
  159. this.$http({
  160. url: '/selectInformationAgentList',
  161. method: "post",
  162. data: {id: dataId},
  163. responseType: 'blob'
  164. })
  165. .then((res) => {
  166. console.log(res);
  167. resolve(res);
  168. let link = document.createElement("a");
  169. link.href = window.URL.createObjectURL(new Blob([res.data]));
  170. link.target = "_blank";
  171. //文件名和格式
  172. link.download = "文件模板.zip";
  173. document.body.appendChild(link);
  174. link.click();
  175. document.body.removeChild(link);
  176. })
  177. .catch((err) => {
  178. reject(err);
  179. });
  180. });
  181. },
  182. // 删除记录接口
  183. deleteInformationInfo: function (dataId) {
  184. this.$http({
  185. method: "post",
  186. url: "/deleteInformationInfo",
  187. data: {
  188. id: dataId,
  189. },
  190. })
  191. .then((res) => {
  192. if(res.data && res.data.code === 200){
  193. alert('删除成功');
  194. }else{
  195. console.log(res.message)
  196. }
  197. })
  198. .catch((err) => {
  199. console.log(err);
  200. });
  201. },
  202. },
  203. created() {
  204. this.getFirmsUploadList();
  205. },
  206. };
  207. </script>
  208. <style scoped lang="less">
  209. .upload_record {
  210. .search {
  211. border: 1px solid #ccc;
  212. padding: 10px;
  213. display: flex;
  214. align-items: center;
  215. .input {
  216. background-color: #fff;
  217. border: 1px solid #ccc;
  218. padding: 2px;
  219. display: flex;
  220. img {
  221. width: 28px;
  222. height: 28px;
  223. border: 1px solid #ccc;
  224. }
  225. input {
  226. background-color: #fff;
  227. border: 1px solid #ccc;
  228. margin-left: 3px;
  229. color: #555;
  230. font-size: 12px;
  231. }
  232. }
  233. }
  234. .sort {
  235. display: flex;
  236. justify-content: flex-end;
  237. margin-top: 10px;
  238. height: 30px;
  239. p {
  240. margin: 10px 5px 0 15px;
  241. text-align: center;
  242. height: 20px;
  243. }
  244. select {
  245. border: 1px solid #ccc;
  246. font-size: 12px;
  247. height: 30px;
  248. }
  249. }
  250. }
  251. input {
  252. outline: none;
  253. border: 1px solid #ccc;
  254. }
  255. input:focus {
  256. animation: shadowAni 200ms linear forwards;
  257. }
  258. @keyframes shadowAni {
  259. 0% {
  260. border-color: #cccccc;
  261. box-shadow: inset 0px 0px 0 #ccc;
  262. }
  263. 100% {
  264. border-color: #75b9f0;
  265. box-shadow: 0px 0px 5px #75b9f0;
  266. }
  267. }
  268. </style>