InforList.vue 14 KB

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