InforList.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <template>
  2. <div>
  3. <div class="upload_record" v-if="initialPage">
  4. <h1>资料列表</h1>
  5. <div class="searchBox">
  6. <div class="search_inside">
  7. <span><img src="" alt="" /></span>
  8. <input type="text" name="" id="" placeholder="请输入要搜索的资料名" />
  9. <button>搜索</button>
  10. </div>
  11. </div>
  12. <div class="sortBox">
  13. <div class="sort_inside">
  14. <span>是否下载</span>
  15. <select name="" id="isDownload">
  16. <option value="">不限</option>
  17. <option value="">是</option>
  18. <option value="">否</option>
  19. </select>
  20. <span>是否反馈</span>
  21. <select name="" id="isReturn">
  22. <option value="">不限</option>
  23. <option value="">是</option>
  24. <option value="">否</option>
  25. </select>
  26. <span>排序</span>
  27. <select name="" id="timeSort">
  28. <option value="">时间降序</option>
  29. <option value="">时间升序</option>
  30. </select>
  31. </div>
  32. <button>确定</button>
  33. </div>
  34. <div class="tableD">
  35. <div class="table_template">
  36. <table class="table">
  37. <thead>
  38. <tr :style="tableHeadStyle">
  39. <td
  40. v-for="(item, index) in tableHeaderD"
  41. :key="index"
  42. :style="tableHeadStyle"
  43. >
  44. {{ item }}
  45. </td>
  46. </tr>
  47. </thead>
  48. <tbody>
  49. <tr
  50. v-for="(obj, index) in tableData"
  51. :key="index"
  52. :class="{ table_gray: !discolor && index % 2 === 0 }"
  53. >
  54. <!-- <td :style="trStyle" v-if="flag">{{ index + 1 }}</td> -->
  55. <td v-for="(item, index) in obj" :key="index" :style="trStyle">
  56. {{ item }}
  57. </td>
  58. <td v-if="operation" :style="trStyle" class="operationStyle">
  59. <span
  60. v-for="(operationObj, i) in operation"
  61. :key="i"
  62. @click="operationObj.function(index)"
  63. >{{ operationObj.name }}
  64. </span>
  65. </td>
  66. </tr>
  67. </tbody>
  68. </table>
  69. </div>
  70. </div>
  71. <div class="pageD">
  72. <TablePage
  73. :totalPage="totalPage"
  74. :currentPage="currentPage"
  75. @change_page="changePage"
  76. @jump_page="jumpPage"
  77. />
  78. </div>
  79. </div>
  80. <div v-else>
  81. <Detail></Detail>
  82. </div>
  83. <!-- <div v-show="!initialPage">
  84. 详情页面
  85. <div><span>资料名称</span><span>{{}}</span></div>
  86. <div><span>上传时间</span><span>{{}}</span></div>
  87. <div>
  88. <div><span>车系</span><span>{{}}</span></div>
  89. <div><span>车型</span><span>{{}}</span></div>
  90. </div>
  91. <div>
  92. <div><span>素材时间</span><span>{{}}</span></div>
  93. <div><span>经销商范围</span><span>{{}}</span></div>
  94. </div>
  95. <div><span>资料描述</span><span>{{}}</span></div>
  96. <span>附件</span>
  97. </div> -->
  98. </div>
  99. </template>
  100. <script>
  101. import TablePage from "../../components/TablePage";
  102. import Detail from './components/UploadLinkDetail';
  103. export default {
  104. props: {
  105. isManufacturer: {
  106. type: String,
  107. default: "distributor",
  108. },
  109. detailVisible: {
  110. type: Boolean,
  111. default: true,
  112. },
  113. },
  114. components: {
  115. TablePage,
  116. Detail,
  117. },
  118. data() {
  119. return {
  120. initialPage: this.detailVisible,
  121. tableHeaderD: [
  122. "资料名称",
  123. "时间类型",
  124. "传播类型",
  125. "上传时间",
  126. "下载状态",
  127. "反馈状态",
  128. "操作",
  129. ],
  130. operation: [
  131. {
  132. name: "下载",
  133. function: () => {
  134. //this.download();
  135. this.downloadPost();
  136. },
  137. },
  138. /* {
  139. name: "反馈",
  140. function: () => {
  141. this.feedback();
  142. },
  143. }, */
  144. {
  145. name: "查看详情>",
  146. function: () => {
  147. this.showDetail();
  148. },
  149. },
  150. ],
  151. // 表格配置
  152. sum: 240, // 一共有多少条数据
  153. pageSize: 20, // 每页展示的数据
  154. discolor: false, // 是否隔行变色
  155. currentPage: 1,
  156. tableData: [
  157. {
  158. name: "北京博瑞",
  159. time: "2021/04",
  160. spread: "传播类型1",
  161. uploadTime: "",
  162. down: "已下载",
  163. feedback: "未反馈",
  164. },
  165. {
  166. name: "雷克萨斯纯电动SUV",
  167. time: "2021/04",
  168. spread: "传播类型1",
  169. uploadTime: "",
  170. down: "已下载",
  171. feedback: "未反馈",
  172. },
  173. {
  174. name: "续航可达400公里",
  175. time: "2021/04",
  176. spread: "传播类型1",
  177. uploadTime: "",
  178. down: "已下载",
  179. feedback: "未反馈",
  180. },
  181. ],
  182. tableHeadStyle: {
  183. background: "#848484",
  184. height: "30px",
  185. color: "white",
  186. },
  187. trStyle: {
  188. width: "150px",
  189. height: "30px",
  190. overflow: "hidden",
  191. },
  192. };
  193. },
  194. computed: {
  195. // 表格总页数
  196. totalPage() {
  197. return Math.ceil(this.sum / this.pageSize);
  198. },
  199. },
  200. methods: {
  201. showDetail: function () {
  202. //alert("展示详情");
  203. this.initialPage = !this.initialPage;
  204. },
  205. feedback: () => {
  206. alert("反馈");
  207. },
  208. download: function () {
  209. alert("下载");
  210. },
  211. // 获取某一页面的数据,展示在表格
  212. changePage: function (page) {
  213. this.currentPage = page;
  214. console.log(page);
  215. },
  216. // 点击上一页,下一页,首页,尾页
  217. jumpPage: function (item) {
  218. switch (item) {
  219. case 1:
  220. this.currentPage = 1;
  221. break;
  222. case 2:
  223. this.currentPage = this.currentPage - 1;
  224. break;
  225. case 3:
  226. this.currentPage = this.currentPage + 1;
  227. break;
  228. case 4:
  229. this.currentPage = this.totalPage;
  230. break;
  231. }
  232. console.log(this.currentPage);
  233. },
  234. submit: function () {
  235. console.log(this.totalPage);
  236. this.sum = this.sum + 1;
  237. console.log(
  238. this.inforName,
  239. this.inforDes,
  240. this.materialTime,
  241. this.range,
  242. this.addByCustomize
  243. );
  244. },
  245. //下载文件
  246. downloadPost: function (config) {
  247. console.log(config);
  248. return new Promise((resolve, reject) => {
  249. this.$http({
  250. url: config.url,
  251. method: "post",
  252. data: config.data,
  253. responseType: "blob",
  254. })
  255. .then((res) => {
  256. // resolve(res);
  257. let link = document.createElement("a");
  258. link.href = window.URL.createObjectURL(new Blob([res.data]));
  259. link.target = "_blank";
  260. //文件名和格式
  261. link.download = "文件模板.xlsx";
  262. document.body.appendChild(link);
  263. link.click();
  264. document.body.removeChild(link);
  265. })
  266. .catch((err) => {
  267. reject(err);
  268. });
  269. });
  270. },
  271. },
  272. mounted() {},
  273. };
  274. </script>
  275. <style scoped lang="less">
  276. .searchBox {
  277. width: 100%;
  278. height: 40px;
  279. display: flex;
  280. align-items: center;
  281. margin-left: 40px;
  282. }
  283. .sortBox {
  284. display: flex;
  285. justify-content: flex-end;
  286. height: 40px;
  287. align-items: center;
  288. }
  289. .sort_inside {
  290. display: flex;
  291. width: 400px;
  292. justify-content: space-between;
  293. }
  294. /* 查看详情样式 */
  295. .table_template {
  296. text-align: center;
  297. .table {
  298. background-color: #fff;
  299. border-collapse: collapse;
  300. border: none;
  301. width: 100%;
  302. td {
  303. border: 1px solid #ccc;
  304. }
  305. span {
  306. &:hover {
  307. cursor: pointer;
  308. }
  309. }
  310. }
  311. }
  312. .table_gray {
  313. background: #f5f5f5;
  314. }
  315. .operationStyle span {
  316. color: #0000ff;
  317. }
  318. </style>