InforList.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  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="sortBox">
  19. <div class="sort_inside">
  20. <span>是否下载</span>
  21. <select name="" id="isDownload" v-model="downloadSortVal">
  22. <option value="">不限</option>
  23. <option value="already">已下载</option>
  24. <option value="notyet">未下载</option>
  25. </select>
  26. <span>是否完成</span>
  27. <select name="" id="isReturn" v-model="reportSortVal">
  28. <option value="">不限</option>
  29. <option value="already">已完成</option>
  30. <option value="notyet">待办</option>
  31. </select>
  32. <span>排序</span>
  33. <select name="" id="timeSort" v-model="timeSortVal">
  34. <option value="dec">时间降序</option>
  35. <option value="asc">时间升序</option>
  36. </select>
  37. </div>
  38. <button @click="searchByCondition">确定</button>
  39. </div>
  40. <div class="tableD">
  41. <div class="table_template">
  42. <table class="table">
  43. <thead>
  44. <tr :style="tableHeadStyle">
  45. <td
  46. v-for="(item, index) in tableHeaderD"
  47. :key="index"
  48. :style="tableHeadStyle"
  49. >
  50. {{ item }}
  51. </td>
  52. </tr>
  53. </thead>
  54. <tbody>
  55. <tr
  56. v-for="(obj, index) in tableData"
  57. :key="index"
  58. :class="{ table_gray: !discolor && index % 2 === 0 }"
  59. >
  60. <!-- <td v-for="(item, i) in obj" :key="i" :style="trStyle"> -->
  61. <td>{{ obj.informationName || "北京博瑞" }}</td>
  62. <td>{{ (obj.filePulishTime || "").replace("-", "/") }}</td>
  63. <td>{{ obj.accountScope == 1 ? "共通" : "部分" }}</td>
  64. <td>
  65. {{
  66. (obj.fileUploadDate || "")
  67. .replace("T", " ")
  68. .slice(0, -4)
  69. .replace(RegExp("-", "g"), "/")
  70. }}
  71. </td>
  72. <td>{{ obj.download > 0 ? "已下载" : "未下载" }}</td>
  73. <td>
  74. <!-- <span
  75. @click="waitToReport(obj.report, index)"
  76. :class="showItemOperation"
  77. class="reportStyle"
  78. >待办</span
  79. > -->
  80. <!-- :class="{ reportStyle: obj.report == 0 ? true : false }" -->
  81. <!-- <span :class="!showItemOperation">已完成</span> -->
  82. <!-- <span
  83. @click="waitToReport(obj, index)"
  84. :class="{
  85. showItemOperationStyle: obj.report == 1 ? true : false,
  86. }"
  87. class="reportStyle"
  88. >待办</span
  89. >
  90. <span
  91. :class="{
  92. showItemOperationStyle: obj.report == 0 ? true : false,
  93. }"
  94. >已完成</span
  95. > -->
  96. <span v-if="!obj.endDate || (obj.endDate && obj.download == 1 && obj.report == 1)">已完成</span>
  97. <span v-else @click="waitToReport(obj, index)" :class="{noDownLoad: obj.download == '0'}">待办</span>
  98. </td>
  99. <td v-if="operation" :style="trStyle" class="operationStyle">
  100. <span
  101. style="cursor: pointer"
  102. v-for="(operationObj, i) in operation"
  103. :key="i"
  104. @click="
  105. operationObj.function(obj, index);
  106. nowIndex = index;
  107. "
  108. >{{ operationObj.name }}
  109. </span>
  110. </td>
  111. </tr>
  112. </tbody>
  113. </table>
  114. </div>
  115. </div>
  116. <div class="pageD">
  117. <TablePage
  118. :totalPage="totalPage"
  119. :currentPage="currentPage"
  120. @change_page="changePage"
  121. @jump_page="jumpPage"
  122. />
  123. <p>共{{ totalPage }}页,共{{ sum }}条数据</p>
  124. </div>
  125. </div>
  126. <div v-else>
  127. <Detail></Detail>
  128. </div>
  129. </div>
  130. </template>
  131. <script>
  132. import TablePage from "../../components/TablePage";
  133. import Detail from "./components/InfoListItemDetail";
  134. import { env_url } from "../../config/env";
  135. export default {
  136. props: {
  137. isManufacturer: {
  138. type: String,
  139. default: "distributor",
  140. },
  141. detailVisible: {
  142. type: Boolean,
  143. default: true,
  144. },
  145. },
  146. components: {
  147. TablePage,
  148. Detail,
  149. },
  150. data() {
  151. return {
  152. nowIndex: 0,
  153. searchName: "",
  154. timeSortVal: "dec",
  155. reportSortVal: "",
  156. downloadSortVal: "",
  157. //initialPage: true,
  158. tableHeaderD: [
  159. "资料名称",
  160. "素材时间",
  161. "经销商范围",
  162. "上传时间",
  163. "下载状态",
  164. "任务状态",
  165. "操作",
  166. ],
  167. operation: [
  168. {
  169. name: "下载",
  170. function: (obj, i) => {
  171. console.log(obj, i);
  172. let config = {
  173. url: "/dealerDownload",
  174. data: {
  175. informationId: obj.id,
  176. agentId: this.userId,
  177. },
  178. };
  179. this.downloadPost(config, obj);
  180. },
  181. },
  182. {
  183. name: "查看详情>",
  184. function: (obj, i) => {
  185. let data = {
  186. informationId: obj.id,
  187. };
  188. this.showDetail(data, i);
  189. console.log(obj, i);
  190. },
  191. },
  192. ],
  193. // 表格配置
  194. sum: 0, // 一共有多少条数据
  195. pageSize: 20, // 每页展示的数据
  196. discolor: false, // flase是隔行变色
  197. currentPage: 1,
  198. tableData: [],
  199. tableFileData: [],
  200. tableHeadStyle: {
  201. background: "#848484",
  202. height: "30px",
  203. color: "white",
  204. },
  205. trStyle: {
  206. minwidth: "150px",
  207. height: "30px",
  208. overflow: "hidden",
  209. },
  210. onlineUrl: env_url, //'http://8.140.188.129:8080'线上 //http://8.136.230.133:8080 //测试
  211. userId: localStorage.getItem("userId"),
  212. endDate: "",
  213. localReport: "",
  214. };
  215. },
  216. computed: {
  217. // 表格总页数
  218. totalPage() {
  219. return Math.ceil(this.sum / this.pageSize);
  220. },
  221. isShowDetail() {
  222. return this.$route.query && this.$route.query.tag ? true : false;
  223. },
  224. showItemOperation: function () {
  225. console.log(this.localReport);
  226. if (!this.localReport) {
  227. console.log(this.localReport);
  228. return { showItemOperationStyle: false };
  229. } else {
  230. return { showItemOperationStyle: true };
  231. }
  232. /* let now = new Date().getTime();
  233. if (!this.endDate) {
  234. console.log("超出反馈时间", this.endDate);
  235. return { showItemOperationStyle: true };
  236. } else {
  237. let end = Date.parse(new Date(this.endDate));
  238. if (now > end) {
  239. return { showItemOperationStyle: true };
  240. } else {
  241. return { showItemOperationStyle: false };
  242. }
  243. } */
  244. },
  245. },
  246. methods: {
  247. download: function () {
  248. alert("下载");
  249. },
  250. // 获取某一页面的数据,展示在表格
  251. changePage: function (page) {
  252. this.currentPage = page;
  253. //携带搜索条件
  254. let data = {
  255. informationName: this.searchName,
  256. asc: this.timeSortVal == "dec" ? false : true,
  257. report: "",
  258. download: "",
  259. Page: this.currentPage,
  260. Rows: this.pageSize,
  261. agentId: this.userId,
  262. };
  263. if (this.reportSortVal) {
  264. data.report = this.reportSortVal === "already" ? true : false;
  265. }
  266. if (this.downloadSortVal) {
  267. data.download = this.downloadSortVal === "already" ? true : false;
  268. }
  269. this.newGetDataList(data);
  270. },
  271. // 点击上一页,下一页,首页,尾页
  272. jumpPage: function (item) {
  273. switch (item) {
  274. case 1:
  275. this.currentPage = 1;
  276. break;
  277. case 2:
  278. this.currentPage = this.currentPage - 1;
  279. break;
  280. case 3:
  281. this.currentPage = this.currentPage + 1;
  282. break;
  283. case 4:
  284. this.currentPage = this.totalPage;
  285. break;
  286. }
  287. console.log(this.currentPage);
  288. //携带搜索条件
  289. let data = {
  290. informationName: this.searchName,
  291. asc: this.timeSortVal == "dec" ? false : true,
  292. report: "",
  293. download: "",
  294. Page: this.currentPage,
  295. Rows: this.pageSize,
  296. agentId: this.userId,
  297. };
  298. if (this.reportSortVal) {
  299. data.report = this.reportSortVal === "already" ? true : false;
  300. }
  301. if (this.downloadSortVal) {
  302. data.download = this.downloadSortVal === "already" ? true : false;
  303. }
  304. this.newGetDataList(data);
  305. },
  306. //下载文件
  307. downloadPost: function (config, obj) {
  308. console.log("下载文件:", config, obj);
  309. let url =
  310. this.onlineUrl +
  311. "/dealerDownload?informationId=" +
  312. config.data.informationId +
  313. "&agentId=" +
  314. config.data.agentId;
  315. window.open(url);
  316. let data = {
  317. informationName: this.searchName,
  318. asc: this.timeSortVal == "dec" ? false : true,
  319. report: "",
  320. download: "",
  321. Page: this.currentPage,
  322. Rows: this.pageSize,
  323. agentId: this.userId,
  324. };
  325. if (this.reportSortVal) {
  326. data.report = this.reportSortVal === "already" ? true : false;
  327. }
  328. if (this.downloadSortVal) {
  329. data.download = this.downloadSortVal === "already" ? true : false;
  330. }
  331. this.newGetDataList(data);
  332. },
  333. //查看详情
  334. showDetail: function (config, i) {
  335. console.log(config);
  336. /* //获取附件数据
  337. this.$http({
  338. url: "/selectInformationFileList",
  339. method: "post",
  340. data: config,
  341. })
  342. .then((res) => {
  343. if (res.data.code === 200) {
  344. this.tableFileData = res.data.data;
  345. }
  346. })
  347. .catch((err) => {
  348. console.log(err);
  349. }); */
  350. let report = '';
  351. let download = '';
  352. if (this.reportSortVal) {
  353. report = this.reportSortVal === "already" ? true : false;
  354. }
  355. if (this.downloadSortVal) {
  356. download = this.downloadSortVal === "already" ? true : false;
  357. }
  358. this.$router.push({
  359. path: "/inforList/detail",
  360. query: {
  361. tag: "infoListDetail",
  362. informationId: config.informationId,
  363. nowIndex: i,
  364. informationName: this.searchName,
  365. asc: this.timeSortVal == "dec" ? false : true,
  366. report: report,
  367. download: download,
  368. Page: this.currentPage,
  369. Rows: this.pageSize,
  370. agentId: this.userId,
  371. },
  372. });
  373. },
  374. //获取资料列表
  375. getDataListPage: function () {
  376. this.$http({
  377. url: "/firmsUploadListByAgent",
  378. method: "post",
  379. data: {
  380. asc: false,
  381. agentId: this.userId,
  382. Page: this.currentPage,
  383. Rows: this.pageSize,
  384. },
  385. })
  386. .then((res) => {
  387. console.log(res, 'aaaaaaaaaaaaaaa')
  388. if (res.data.code === 200) {
  389. this.tableData = res.data.data;
  390. this.sum = res.data.count;
  391. }
  392. })
  393. .catch((err) => {
  394. console.log(err);
  395. });
  396. },
  397. //条件筛选 获取新的资料列表
  398. newGetDataList: function (config) {
  399. this.$http({
  400. url: "/firmsUploadListByAgent",
  401. method: "post",
  402. data: config,
  403. })
  404. .then((res) => {
  405. if (res.data.code === 200) {
  406. this.tableData = res.data.data;
  407. this.sum = res.data.count;
  408. }
  409. })
  410. .catch((err) => {
  411. console.log(err);
  412. });
  413. },
  414. //搜索资料名
  415. searchByName: function (p) {
  416. console.log("insearchByName", p);
  417. let searchName = this.searchName;
  418. let data = {
  419. informationName: searchName,
  420. Page: p,
  421. Rows: this.pageSize,
  422. agentId: this.userId,
  423. //搜索条件重置
  424. asc: false,
  425. report: "",
  426. download: "",
  427. };
  428. //搜索条件重置
  429. this.timeSortVal = "dec";
  430. this.reportSortVal = "";
  431. this.downloadSortVal = "";
  432. this.$http({
  433. url: "/firmsUploadListByAgent",
  434. method: "post",
  435. data: data,
  436. })
  437. .then((res) => {
  438. if (res.data.code === 200) {
  439. this.tableData = res.data.data;
  440. this.sum = res.data.count;
  441. }
  442. })
  443. .catch((err) => {
  444. console.log(err);
  445. });
  446. },
  447. searchByCondition: function () {
  448. let asc = this.timeSortVal === "dec" ? false : true;
  449. let report = "";
  450. if (this.reportSortVal === "already") {
  451. report = this.reportSortVal === "already" ? true : false;
  452. } else if (this.reportSortVal === "notyet") {
  453. report = this.reportSortVal === "notyet" ? false : true;
  454. }
  455. let download = "";
  456. if (this.downloadSortVal === "already") {
  457. download = this.downloadSortVal === "already" ? true : false;
  458. } else if (this.downloadSortVal === "notyet") {
  459. download = this.downloadSortVal === "notyet" ? false : true;
  460. }
  461. let data = {
  462. informationName: '',
  463. asc: asc,
  464. report: report,
  465. download: download,
  466. Page: this.currentPage,
  467. Rows: this.pageSize,
  468. agentId: this.userId,
  469. };
  470. if (!this.searchName) {
  471. this.newGetDataList(data);
  472. console.log("insearchByCondition", data);
  473. } else {
  474. data.informationName = this.searchName;
  475. this.newGetDataList(data);
  476. console.log("insearchByCondition", data);
  477. }
  478. },
  479. //待办跳转
  480. // waitToReport: function (obj, i) {
  481. // this.endDate = this.tableData[i].endDate;
  482. // this.localReport = this.tableData[i].report;
  483. // console.log(obj.report == 0, obj.download == 0);
  484. // console.log(obj);
  485. // if (obj.report == 0 && obj.download != 0) {
  486. // console.log("待办跳转");
  487. // this.$router.push({
  488. // path: "/uploadLink/sonUploadLink",
  489. // query: { informationName: obj.informationName, id: obj.id },
  490. // });
  491. // }
  492. // },
  493. waitToReport: function(obj) {
  494. let data = new Date();
  495. let year = data.getFullYear();
  496. let month = data.getMonth() + 1;
  497. let day = data.getDate();
  498. if (month < 10) {
  499. month = "0" + month;
  500. } else {
  501. month = month + "";
  502. }
  503. let endDate = obj.endDate.replace(RegExp("-", "g"), "");
  504. let localDate = year + month + day;
  505. let dateFlag = (+endDate) - (+localDate)
  506. if (obj.report == 0 && obj.download != 0 && dateFlag >= 0) {
  507. this.$router.push({
  508. path: "/uploadLink/sonUploadLink",
  509. query: { informationName: obj.informationName, id: obj.id },
  510. });
  511. }
  512. },
  513. },
  514. // watch: {
  515. // //普通的watch监听
  516. // userId(newValue) {
  517. // if(newValue) {
  518. // this.getDataListPage()
  519. // }
  520. // }
  521. // },
  522. mounted() {
  523. setTimeout(() => {
  524. this.userId = localStorage.getItem("userId");
  525. this.getDataListPage();
  526. }, 500);
  527. },
  528. };
  529. </script>
  530. <style scoped lang="less">
  531. .searchBox {
  532. width: 100%;
  533. height: 40px;
  534. display: flex;
  535. align-items: center;
  536. margin-left: 40px;
  537. }
  538. .sortBox {
  539. display: flex;
  540. justify-content: flex-end;
  541. height: 40px;
  542. align-items: center;
  543. }
  544. .sort_inside {
  545. display: flex;
  546. width: 400px;
  547. justify-content: space-between;
  548. }
  549. /* 查看详情样式 */
  550. .table_template {
  551. text-align: center;
  552. .table {
  553. background-color: #fff;
  554. border-collapse: collapse;
  555. border: none;
  556. width: 100%;
  557. td {
  558. border: 1px solid #ccc;
  559. }
  560. span {
  561. &:hover {
  562. cursor: pointer;
  563. }
  564. }
  565. }
  566. }
  567. .table_gray {
  568. background-color: #eeeeee;
  569. }
  570. .operationStyle span {
  571. color: #0000ff;
  572. }
  573. .operationStyle {
  574. color: #0000ff;
  575. display: flex;
  576. justify-content: space-around;
  577. align-items: center;
  578. }
  579. /* 搜索栏 */
  580. .search {
  581. padding: 10px 15px 10px 10px;
  582. display: flex;
  583. align-items: center;
  584. .input {
  585. background-color: #fff;
  586. padding: 2px;
  587. display: flex;
  588. align-items: center;
  589. margin-left: 16px;
  590. border: 1px solid #ccc;
  591. img {
  592. width: 28px;
  593. height: 28px;
  594. border: 1px solid #ccc;
  595. border-radius: 4px;
  596. }
  597. input {
  598. background-color: #fff;
  599. border: 1px solid #ccc;
  600. margin-left: 4px;
  601. color: #555;
  602. font-size: 12px;
  603. height: 24px;
  604. }
  605. }
  606. }
  607. .HeadLeft {
  608. border: 1px solid #ccc;
  609. }
  610. .pageD {
  611. display: flex;
  612. justify-content: flex-end;
  613. align-items: center;
  614. margin-top: 10px;
  615. }
  616. .pageD p {
  617. margin-left: 16px;
  618. }
  619. .reportStyle {
  620. text-decoration: underline;
  621. cursor: pointer;
  622. }
  623. .showItemOperationStyle {
  624. display: none;
  625. }
  626. .noDownLoad{
  627. color: rgb(173, 162, 162);
  628. cursor: text!important;
  629. }
  630. </style>