UploadRecord.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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.tag ? 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. this.detailData = this.tableData[i];
  133. this.$router.push({ query: { tag: 'detail' } });
  134. },
  135. // 上传记录列表接口
  136. getFirmsUploadList: function (data = {}) {
  137. this.$http({
  138. method: "post",
  139. url: "/firmsUploadList",
  140. data: data,
  141. })
  142. .then((res) => {
  143. console.log(res);
  144. if (res.data && res.data.code === 200) {
  145. this.tableData = res.data.data;
  146. this.sum = res.data.count;
  147. } else {
  148. console.log(res);
  149. }
  150. })
  151. .catch((err) => {
  152. console.log(err);
  153. });
  154. },
  155. // 下载资料接口
  156. selectInformationAgentList: function (dataId) {
  157. return new Promise((resolve, reject) => {
  158. this.$http({
  159. url: '/selectInformationAgentList',
  160. method: "post",
  161. data: {id: dataId},
  162. responseType: 'blob'
  163. })
  164. .then((res) => {
  165. console.log(res);
  166. resolve(res);
  167. let link = document.createElement("a");
  168. link.href = window.URL.createObjectURL(new Blob([res.data]));
  169. link.target = "_blank";
  170. //文件名和格式
  171. link.download = "文件模板.zip";
  172. document.body.appendChild(link);
  173. link.click();
  174. document.body.removeChild(link);
  175. })
  176. .catch((err) => {
  177. reject(err);
  178. });
  179. });
  180. },
  181. // 删除记录接口
  182. deleteInformationInfo: function (dataId) {
  183. this.$http({
  184. method: "post",
  185. url: "/deleteInformationInfo",
  186. data: {
  187. id: dataId,
  188. },
  189. })
  190. .then((res) => {
  191. if(res.data && res.data.code === 200){
  192. alert('删除成功');
  193. }else{
  194. console.log(res.message)
  195. }
  196. })
  197. .catch((err) => {
  198. console.log(err);
  199. });
  200. },
  201. },
  202. created() {
  203. this.getFirmsUploadList();
  204. },
  205. };
  206. </script>
  207. <style scoped lang="less">
  208. .upload_record {
  209. .search {
  210. border: 1px solid #ccc;
  211. padding: 10px;
  212. display: flex;
  213. align-items: center;
  214. .input {
  215. background-color: #fff;
  216. border: 1px solid #ccc;
  217. padding: 2px;
  218. display: flex;
  219. img {
  220. width: 28px;
  221. height: 28px;
  222. border: 1px solid #ccc;
  223. }
  224. input {
  225. background-color: #fff;
  226. border: 1px solid #ccc;
  227. margin-left: 3px;
  228. color: #555;
  229. font-size: 12px;
  230. }
  231. }
  232. }
  233. .sort {
  234. display: flex;
  235. justify-content: flex-end;
  236. margin-top: 10px;
  237. height: 30px;
  238. p {
  239. margin: 10px 5px 0 15px;
  240. text-align: center;
  241. height: 20px;
  242. }
  243. select {
  244. border: 1px solid #ccc;
  245. font-size: 12px;
  246. height: 30px;
  247. }
  248. }
  249. }
  250. input {
  251. outline: none;
  252. border: 1px solid #ccc;
  253. }
  254. input:focus {
  255. animation: shadowAni 200ms linear forwards;
  256. }
  257. @keyframes shadowAni {
  258. 0% {
  259. border-color: #cccccc;
  260. box-shadow: inset 0px 0px 0 #ccc;
  261. }
  262. 100% {
  263. border-color: #75b9f0;
  264. box-shadow: 0px 0px 5px #75b9f0;
  265. }
  266. }
  267. </style>