InforList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. <template>
  2. <div>
  3. <div class="upload_record" v-if="initialPage">
  4. <!-- <h1>资料列表</h1> -->
  5. <div class="search HeadLeft">
  6. <div class="input">
  7. <img src="../../img/search.png" />
  8. <input
  9. type="text"
  10. name=""
  11. id=""
  12. placeholder="请输入要搜索的资料名"
  13. v-model="searchName"
  14. />
  15. </div>
  16. <button @click="searchByName">搜索</button>
  17. </div>
  18. <!-- <div class="searchBox">
  19. <div class="search_inside">
  20. <span><img src="" alt="" /></span>
  21. <input type="text" name="" id="" placeholder="请输入要搜索的资料名" />
  22. <button>搜索</button>
  23. </div>
  24. </div> -->
  25. <div class="sortBox">
  26. <div class="sort_inside">
  27. <span>是否下载</span>
  28. <select name="" id="isDownload" v-model="downloadSortVal">
  29. <option value="">不限</option>
  30. <option value="already">已下载</option>
  31. <option value="notyet">未下载</option>
  32. </select>
  33. <span>是否反馈</span>
  34. <select name="" id="isReturn" v-model="reportSortVal">
  35. <option value="">不限</option>
  36. <option value="already">已反馈</option>
  37. <option value="notyet">未反馈</option>
  38. </select>
  39. <span>排序</span>
  40. <select name="" id="timeSort" v-model="timeSortVal">
  41. <option value="">时间降序</option>
  42. <option value="asc">时间升序</option>
  43. </select>
  44. </div>
  45. <button @click="searchByCondition">确定</button>
  46. </div>
  47. <div class="tableD">
  48. <div class="table_template">
  49. <table class="table">
  50. <thead>
  51. <tr :style="tableHeadStyle">
  52. <td
  53. v-for="(item, index) in tableHeaderD"
  54. :key="index"
  55. :style="tableHeadStyle"
  56. >
  57. {{ item }}
  58. </td>
  59. </tr>
  60. </thead>
  61. <tbody>
  62. <tr
  63. v-for="(obj, index) in tableData"
  64. :key="index"
  65. :class="{ table_gray: !discolor && index % 2 === 0 }"
  66. >
  67. <!-- <td v-for="(item, i) in obj" :key="i" :style="trStyle"> -->
  68. <td>{{ obj.informationName || "北京博瑞" }}</td>
  69. <td>{{ obj.filePulishTime || "2021/02" }}</td>
  70. <td>{{ obj.accountScope === 1 ? "共通" : "部分" }}</td>
  71. <td>{{ obj.fileUploadDate || "2021/01/10 12:12" }}</td>
  72. <td>{{ obj.download === 1 ? "已下载" : "未下载" }}</td>
  73. <td>{{ obj.report === 1 ? "已反馈" : "未反馈" }}</td>
  74. <td v-if="operation" :style="trStyle" class="operationStyle">
  75. <span
  76. v-for="(operationObj, i) in operation"
  77. :key="i"
  78. @click="
  79. operationObj.function(obj);
  80. nowIndex = index;
  81. "
  82. >{{ operationObj.name }}
  83. </span>
  84. </td>
  85. </tr>
  86. </tbody>
  87. </table>
  88. </div>
  89. </div>
  90. <div class="pageD">
  91. <TablePage
  92. :totalPage="totalPage"
  93. :currentPage="currentPage"
  94. @change_page="changePage"
  95. @jump_page="jumpPage"
  96. />
  97. <p>共{{ totalPage }}页,共{{ sum }}条数据</p>
  98. </div>
  99. </div>
  100. <div v-else>
  101. <Detail :detailData="tableData" :nowIndex="nowIndex"></Detail>
  102. </div>
  103. </div>
  104. </template>
  105. <script>
  106. import TablePage from "../../components/TablePage";
  107. import Detail from "./components/InfoListItemDetail";
  108. export default {
  109. props: {
  110. isManufacturer: {
  111. type: String,
  112. default: "distributor",
  113. },
  114. detailVisible: {
  115. type: Boolean,
  116. default: true,
  117. },
  118. },
  119. components: {
  120. TablePage,
  121. Detail,
  122. },
  123. data() {
  124. return {
  125. searchName: "",
  126. timeSortVal: "",
  127. reportSortVal: "",
  128. downloadSortVal: "",
  129. initialPage: this.detailVisible,
  130. tableHeaderD: [
  131. "资料名称",
  132. "素材时间",
  133. "经销商范围",
  134. "上传时间",
  135. "下载状态",
  136. "反馈状态",
  137. "操作",
  138. ],
  139. operation: [
  140. {
  141. name: "下载",
  142. function: (obj) => {
  143. //this.download();
  144. let config = {
  145. url: "/dealerDownload",
  146. data: {
  147. informationId: obj.id,
  148. agentId: obj.agentId,
  149. },
  150. };
  151. this.downloadPost(config);
  152. },
  153. },
  154. /* {
  155. name: "反馈",
  156. function: () => {
  157. this.feedback();
  158. },
  159. }, */
  160. {
  161. name: "查看详情>",
  162. function: (i) => {
  163. this.showDetail(i);
  164. },
  165. },
  166. ],
  167. // 表格配置
  168. sum: 240, // 一共有多少条数据
  169. pageSize: 20, // 每页展示的数据
  170. discolor: false, // flase是隔行变色
  171. currentPage: 1,
  172. tableData: [
  173. {
  174. informationName: "北京博瑞",
  175. filePulishTime: "2021/02",
  176. accountScope: "传播类型1",
  177. fileUploadDate: "",
  178. download: "已下载",
  179. report: "未反馈",
  180. asc: "false",
  181. },
  182. ],
  183. tableHeadStyle: {
  184. background: "#848484",
  185. height: "30px",
  186. color: "white",
  187. },
  188. trStyle: {
  189. minwidth: "150px",
  190. height: "30px",
  191. overflow: "hidden",
  192. },
  193. };
  194. },
  195. computed: {
  196. // 表格总页数
  197. totalPage() {
  198. return Math.ceil(this.sum / this.pageSize);
  199. },
  200. },
  201. methods: {
  202. showDetail: function () {
  203. //alert("展示详情");
  204. this.initialPage = !this.initialPage;
  205. },
  206. feedback: () => {
  207. alert("反馈");
  208. },
  209. download: function () {
  210. alert("下载");
  211. },
  212. // 获取某一页面的数据,展示在表格
  213. changePage: function (page) {
  214. this.currentPage = page;
  215. console.log(page);
  216. },
  217. // 点击上一页,下一页,首页,尾页
  218. jumpPage: function (item) {
  219. switch (item) {
  220. case 1:
  221. this.currentPage = 1;
  222. break;
  223. case 2:
  224. this.currentPage = this.currentPage - 1;
  225. break;
  226. case 3:
  227. this.currentPage = this.currentPage + 1;
  228. break;
  229. case 4:
  230. this.currentPage = this.totalPage;
  231. break;
  232. }
  233. console.log(this.currentPage);
  234. },
  235. //下载文件
  236. downloadPost: function (config) {
  237. console.log("下载文件:", config);
  238. return new Promise((resolve, reject) => {
  239. this.$http({
  240. url: config.url,
  241. method: "post",
  242. data: config.data,
  243. })
  244. .then((res) => {
  245. console.log(res);
  246. resolve(res);
  247. let link = document.createElement("a");
  248. link.href = window.URL.createObjectURL(new Blob([res.data]));
  249. link.target = "_blank";
  250. //文件名和格式
  251. link.download = "文件模板.xlsx";
  252. document.body.appendChild(link);
  253. link.click();
  254. document.body.removeChild(link);
  255. })
  256. .catch((err) => {
  257. reject(err);
  258. });
  259. });
  260. },
  261. //获取资料列表
  262. getDataList: function () {
  263. this.$http({
  264. url: "/firmsUploadListByAgent",
  265. method: "post",
  266. data: {},
  267. })
  268. .then((res) => {
  269. console.log(res);
  270. if (res.data.code === 200) {
  271. this.tableData = res.data.data;
  272. this.sum = res.data.count;
  273. }
  274. })
  275. .catch((err) => {
  276. console.log(err);
  277. });
  278. },
  279. //获取新的资料列表
  280. newGetDataList: function (config) {
  281. console.log("new Getdata1", config);
  282. this.$http({
  283. url: "/firmsUploadListByAgent",
  284. method: "post",
  285. data: config,
  286. })
  287. .then((res) => {
  288. console.log("new Getdata2", res);
  289. if (res.data.code === 200) {
  290. this.tableData = res.data.data;
  291. this.sum = res.data.count;
  292. }
  293. })
  294. .catch((err) => {
  295. console.log(err);
  296. });
  297. },
  298. //以时间排序
  299. /* sortByTime: function () {
  300. let asc = this.timeSortVal === "asc" ? false : true;
  301. let data = {
  302. asc: asc,
  303. };
  304. this.newGetDataList(data);
  305. }, */
  306. //反馈筛选
  307. /* sortByReport: function () {
  308. let reportId = this.reportSortVal === "already" ? true : false;
  309. let data = {
  310. reportId: reportId,
  311. };
  312. this.newGetDataList(data);
  313. }, */
  314. //下载筛选
  315. sortByDownload: function () {
  316. if (this.downloadSortVal === "notyet") {
  317. console.log("notyet");
  318. } else if (this.downloadSortVal === "already") {
  319. console.log("already");
  320. }
  321. },
  322. //搜索资料名
  323. searchByName: function () {
  324. console.log("insearchByName", this.searchName);
  325. let searchName = this.searchName;
  326. let data = {
  327. informationName: searchName,
  328. };
  329. this.newGetDataList(data);
  330. },
  331. searchByCondition: function () {
  332. console.log("insearchByCondition", this.searchName);
  333. let asc = this.timeSortVal === "asc" ? false : true;
  334. let reportId = this.reportSortVal === "already" ? true : false;
  335. let data = {
  336. asc: asc,
  337. reportId: reportId,
  338. };
  339. this.newGetDataList(data);
  340. },
  341. },
  342. mounted() {
  343. this.getDataList();
  344. },
  345. };
  346. </script>
  347. <style scoped lang="less">
  348. .searchBox {
  349. width: 100%;
  350. height: 40px;
  351. display: flex;
  352. align-items: center;
  353. margin-left: 40px;
  354. }
  355. .sortBox {
  356. display: flex;
  357. justify-content: flex-end;
  358. height: 40px;
  359. align-items: center;
  360. }
  361. .sort_inside {
  362. display: flex;
  363. width: 400px;
  364. justify-content: space-between;
  365. }
  366. /* 查看详情样式 */
  367. .table_template {
  368. text-align: center;
  369. .table {
  370. background-color: #fff;
  371. border-collapse: collapse;
  372. border: none;
  373. width: 100%;
  374. td {
  375. border: 1px solid #ccc;
  376. }
  377. span {
  378. &:hover {
  379. cursor: pointer;
  380. }
  381. }
  382. }
  383. }
  384. .table_gray {
  385. background-color: #eeeeee;
  386. }
  387. .operationStyle span {
  388. color: #0000ff;
  389. }
  390. .operationStyle {
  391. color: #0000ff;
  392. display: flex;
  393. justify-content: space-around;
  394. align-items: center;
  395. }
  396. /* 搜索栏 */
  397. .search {
  398. padding: 10px 15px 10px 10px;
  399. display: flex;
  400. align-items: center;
  401. .input {
  402. background-color: #fff;
  403. padding: 2px;
  404. display: flex;
  405. align-items: center;
  406. margin-left: 16px;
  407. border: 1px solid #ccc;
  408. img {
  409. width: 28px;
  410. height: 28px;
  411. border: 1px solid #ccc;
  412. border-radius: 4px;
  413. }
  414. input {
  415. background-color: #fff;
  416. border: 1px solid #ccc;
  417. margin-left: 4px;
  418. color: #555;
  419. font-size: 12px;
  420. height: 24px;
  421. }
  422. }
  423. }
  424. .HeadLeft {
  425. border: 1px solid #ccc;
  426. }
  427. .pageD {
  428. display: flex;
  429. justify-content: flex-end;
  430. align-items: center;
  431. margin-top: 10px;
  432. }
  433. .pageD p {
  434. margin-left: 16px;
  435. }
  436. </style>