InforList.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. <template>
  2. <div>
  3. <div class="upload_record" v-if="!isShowDetail">
  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="dec">时间降序</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 > 0 ? "已下载" : "未下载" }}</td>
  73. <td>{{ obj.report === "1" ? "已反馈" : "未反馈" }}</td>
  74. <td v-if="operation" :style="trStyle" class="operationStyle">
  75. <span style="cursor:pointer"
  76. v-for="(operationObj, i) in operation"
  77. :key="i"
  78. @click="
  79. operationObj.function(obj, index);
  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></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. nowIndex: 0,
  126. searchName: "",
  127. timeSortVal: "dec",
  128. reportSortVal: "",
  129. downloadSortVal: "",
  130. //initialPage: true,
  131. tableHeaderD: [
  132. "资料名称",
  133. "素材时间",
  134. "经销商范围",
  135. "上传时间",
  136. "下载状态",
  137. "反馈状态",
  138. "操作",
  139. ],
  140. operation: [
  141. {
  142. name: "下载",
  143. function: (obj, i) => {
  144. console.log(obj, i);
  145. let config = {
  146. url: "/dealerDownload",
  147. data: {
  148. informationId: obj.id,
  149. agentId:this.userId
  150. },
  151. };
  152. this.downloadPost(config, obj);
  153. },
  154. },
  155. {
  156. name: "查看详情>",
  157. function: (obj, i) => {
  158. let data = {
  159. informationId: obj.id,
  160. };
  161. this.showDetail(data, i);
  162. console.log(obj, i);
  163. },
  164. },
  165. ],
  166. // 表格配置
  167. sum: 10, // 一共有多少条数据
  168. pageSize: 20, // 每页展示的数据
  169. discolor: false, // flase是隔行变色
  170. currentPage: 1,
  171. tableData: [
  172. {
  173. informationName: "北京博瑞",
  174. filePulishTime: "2021/02",
  175. accountScope: "传播类型1",
  176. fileUploadDate: "",
  177. download: "已下载",
  178. report: "未反馈",
  179. asc: "false",
  180. },
  181. ],
  182. tableFileData: [],
  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. onlineUrl: "http://8.136.230.133:8080",
  194. userId: 254,
  195. };
  196. },
  197. computed: {
  198. // 表格总页数
  199. totalPage() {
  200. return Math.ceil(this.sum / this.pageSize);
  201. },
  202. isShowDetail() {
  203. return this.$route.query && this.$route.query.tag ? true : false;
  204. },
  205. },
  206. methods: {
  207. feedback: () => {
  208. alert("反馈");
  209. },
  210. download: function () {
  211. alert("下载");
  212. },
  213. // 获取某一页面的数据,展示在表格
  214. changePage: function (page) {
  215. this.currentPage = page;
  216. this.getDataListPage(this.currentPage);
  217. },
  218. // 点击上一页,下一页,首页,尾页
  219. jumpPage: function (item) {
  220. switch (item) {
  221. case 1:
  222. this.currentPage = 1;
  223. break;
  224. case 2:
  225. this.currentPage = this.currentPage - 1;
  226. break;
  227. case 3:
  228. this.currentPage = this.currentPage + 1;
  229. break;
  230. case 4:
  231. this.currentPage = this.totalPage;
  232. break;
  233. }
  234. console.log(this.currentPage);
  235. this.getDataListPage(this.currentPage);
  236. },
  237. //下载文件
  238. downloadPost: function (config, obj) {
  239. console.log("下载文件:", config, obj);
  240. let url =
  241. this.onlineUrl +
  242. "/dealerDownload?informationId=" +
  243. config.data.informationId+'&agentId='+ config.data.agentId;
  244. window.open(url);
  245. let data = {
  246. // asc: asc,
  247. // report: report,
  248. //download: 1,
  249. Page: this.currentPage,
  250. Rows: this.pageSize,
  251. agentId: this.userId,
  252. };
  253. this.newGetDataList(data);
  254. },
  255. //查看详情
  256. showDetail: function (config, i) {
  257. console.log(config);
  258. /* //获取附件数据
  259. this.$http({
  260. url: "/selectInformationFileList",
  261. method: "post",
  262. data: config,
  263. })
  264. .then((res) => {
  265. if (res.data.code === 200) {
  266. this.tableFileData = res.data.data;
  267. }
  268. })
  269. .catch((err) => {
  270. console.log(err);
  271. }); */
  272. this.$router.push({
  273. query: {
  274. tag: "infoListDetail",
  275. informationId: config.informationId,
  276. nowIndex: i,
  277. agentId: this.userId,
  278. Page: this.currentPage,
  279. Rows: this.pageSize,
  280. },
  281. });
  282. },
  283. //获取资料列表
  284. getDataList: function () {
  285. this.$http({
  286. url: "/firmsUploadListByAgent",
  287. method: "post",
  288. data: {
  289. agentId: this.userId,
  290. Page: this.currentPage,
  291. Rows: this.pageSize,
  292. },
  293. })
  294. .then((res) => {
  295. console.log(res);
  296. if (res.data.code === 200) {
  297. this.tableData = res.data.data;
  298. this.sum = res.data.count;
  299. //修改素材时间显示格式
  300. let len = this.tableData.length;
  301. for (let i = 0; i < len; i++) {
  302. let newValue = "";
  303. let temp = this.tableData[i].filePulishTime;
  304. if (this.tableData[0].filePulishTime.length >= 7) {
  305. newValue = temp.slice(0, 4) + "/" + temp.slice(5, 7); //+ "/" + temp.slice(8,10)
  306. this.$set(this.tableData[i], "filePulishTime", newValue);
  307. }
  308. }
  309. //修改上传时间显示格式
  310. for (let i = 0; i < len; i++) {
  311. let newValue = "";
  312. let temp = this.tableData[i].fileUploadDate;
  313. if (this.tableData[0].fileUploadDate.length >= 10) {
  314. newValue =
  315. temp.slice(0, 4) +
  316. "/" +
  317. temp.slice(5, 7) +
  318. "/" +
  319. temp.slice(8, 10) +
  320. " " +
  321. temp.slice(11, 19);
  322. this.$set(this.tableData[i], "fileUploadDate", newValue);
  323. }
  324. }
  325. }
  326. })
  327. .catch((err) => {
  328. console.log(err);
  329. });
  330. },
  331. //分页 获取资料列表
  332. getDataListPage: function (nowpage) {
  333. this.$http({
  334. url: "/firmsUploadListByAgent",
  335. method: "post",
  336. data: {
  337. agentId: this.userId,
  338. Page: nowpage,
  339. Rows: this.pageSize,
  340. },
  341. })
  342. .then((res) => {
  343. console.log(res);
  344. if (res.data.code === 200) {
  345. this.tableData = res.data.data;
  346. //修改素材时间显示格式
  347. let len = this.tableData.length;
  348. for (let i = 0; i < len; i++) {
  349. let newValue = "";
  350. let temp = this.tableData[i].filePulishTime;
  351. if (this.tableData[0].filePulishTime.length >= 7) {
  352. newValue = temp.slice(0, 4) + "/" + temp.slice(5, 7); //+ "/" + temp.slice(8,10)
  353. this.$set(this.tableData[i], "filePulishTime", newValue);
  354. }
  355. }
  356. //修改上传时间显示格式
  357. for (let i = 0; i < len; i++) {
  358. let newValue = "";
  359. let temp = this.tableData[i].fileUploadDate;
  360. if (this.tableData[0].fileUploadDate.length >= 10) {
  361. newValue =
  362. temp.slice(0, 4) +
  363. "/" +
  364. temp.slice(5, 7) +
  365. "/" +
  366. temp.slice(8, 10) +
  367. " " +
  368. temp.slice(11, 19);
  369. this.$set(this.tableData[i], "fileUploadDate", newValue);
  370. }
  371. }
  372. }
  373. })
  374. .catch((err) => {
  375. console.log(err);
  376. });
  377. },
  378. //条件筛选 获取新的资料列表
  379. newGetDataList: function (config) {
  380. console.log("new Getdata1", config);
  381. this.$http({
  382. url: "/firmsUploadListByAgent",
  383. method: "post",
  384. data: config,
  385. })
  386. .then((res) => {
  387. console.log("new Getdata2", res);
  388. if (res.data.code === 200) {
  389. this.tableData = res.data.data;
  390. this.sum = res.data.count;
  391. //修改素材时间显示格式
  392. let len = this.tableData.length;
  393. for (let i = 0; i < len; i++) {
  394. let newValue = "";
  395. let temp = this.tableData[i].filePulishTime;
  396. if (this.tableData[0].filePulishTime.length >= 7) {
  397. newValue = temp.slice(0, 4) + "/" + temp.slice(5, 7); //+ "/" + temp.slice(8,10)
  398. this.$set(this.tableData[i], "filePulishTime", newValue);
  399. }
  400. }
  401. //修改上传时间显示格式
  402. for (let i = 0; i < len; i++) {
  403. let newValue = "";
  404. let temp = this.tableData[i].fileUploadDate;
  405. if (this.tableData[0].fileUploadDate.length >= 10) {
  406. newValue =
  407. temp.slice(0, 4) +
  408. "/" +
  409. temp.slice(5, 7) +
  410. "/" +
  411. temp.slice(8, 10) +
  412. " " +
  413. temp.slice(11, 19);
  414. this.$set(this.tableData[i], "fileUploadDate", newValue);
  415. }
  416. }
  417. }
  418. })
  419. .catch((err) => {
  420. console.log(err);
  421. });
  422. },
  423. //搜索资料名
  424. searchByName: function () {
  425. console.log("insearchByName", this.searchName);
  426. let searchName = this.searchName;
  427. let data = {
  428. informationName: searchName,
  429. Page: 1,
  430. Rows: this.pageSize,
  431. agentId: this.userId,
  432. //搜索条件重置
  433. asc: false,
  434. report: "",
  435. download: "",
  436. };
  437. //搜索条件重置
  438. this.timeSortVal = "dec";
  439. this.reportSortVal = "";
  440. this.downloadSortVal = "";
  441. this.newGetDataList(data);
  442. },
  443. searchByCondition: function () {
  444. console.log("insearchByCondition", this.searchName);
  445. let asc = this.timeSortVal === "dec" ? false : true;
  446. let report = "";
  447. if (this.reportSortVal === "already") {
  448. report = this.reportSortVal === "already" ? true : false;
  449. } else if (this.reportSortVal === "notyet") {
  450. report = this.reportSortVal === "notyet" ? false : true;
  451. }
  452. let download = "";
  453. if (this.downloadSortVal === "already") {
  454. download = this.downloadSortVal === "already" ? true : false;
  455. } else if (this.downloadSortVal === "notyet") {
  456. download = this.downloadSortVal === "notyet" ? false : true;
  457. }
  458. let data = {
  459. asc: asc,
  460. report: report,
  461. download: download,
  462. Page: 1,
  463. Rows: this.pageSize,
  464. agentId: this.userId,
  465. };
  466. this.newGetDataList(data);
  467. },
  468. },
  469. mounted() {
  470. let localUserId = localStorage.getItem("userId");
  471. if (localUserId) {
  472. console.log("经销商ID", localUserId);
  473. this.userId = localUserId;
  474. } else {
  475. console.log("经销商ID 254");
  476. this.userId = 254;
  477. }
  478. this.getDataList();
  479. },
  480. };
  481. </script>
  482. <style scoped lang="less">
  483. .searchBox {
  484. width: 100%;
  485. height: 40px;
  486. display: flex;
  487. align-items: center;
  488. margin-left: 40px;
  489. }
  490. .sortBox {
  491. display: flex;
  492. justify-content: flex-end;
  493. height: 40px;
  494. align-items: center;
  495. }
  496. .sort_inside {
  497. display: flex;
  498. width: 400px;
  499. justify-content: space-between;
  500. }
  501. /* 查看详情样式 */
  502. .table_template {
  503. text-align: center;
  504. .table {
  505. background-color: #fff;
  506. border-collapse: collapse;
  507. border: none;
  508. width: 100%;
  509. td {
  510. border: 1px solid #ccc;
  511. }
  512. span {
  513. &:hover {
  514. cursor: pointer;
  515. }
  516. }
  517. }
  518. }
  519. .table_gray {
  520. background-color: #eeeeee;
  521. }
  522. .operationStyle span {
  523. color: #0000ff;
  524. }
  525. .operationStyle {
  526. color: #0000ff;
  527. display: flex;
  528. justify-content: space-around;
  529. align-items: center;
  530. }
  531. /* 搜索栏 */
  532. .search {
  533. padding: 10px 15px 10px 10px;
  534. display: flex;
  535. align-items: center;
  536. .input {
  537. background-color: #fff;
  538. padding: 2px;
  539. display: flex;
  540. align-items: center;
  541. margin-left: 16px;
  542. border: 1px solid #ccc;
  543. img {
  544. width: 28px;
  545. height: 28px;
  546. border: 1px solid #ccc;
  547. border-radius: 4px;
  548. }
  549. input {
  550. background-color: #fff;
  551. border: 1px solid #ccc;
  552. margin-left: 4px;
  553. color: #555;
  554. font-size: 12px;
  555. height: 24px;
  556. }
  557. }
  558. }
  559. .HeadLeft {
  560. border: 1px solid #ccc;
  561. }
  562. .pageD {
  563. display: flex;
  564. justify-content: flex-end;
  565. align-items: center;
  566. margin-top: 10px;
  567. }
  568. .pageD p {
  569. margin-left: 16px;
  570. }
  571. </style>