table13.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. <template>
  2. <div>
  3. <ex-table
  4. v-loading="loading"
  5. :table="table"
  6. :data="tableData"
  7. :columns="table13"
  8. :page="pageInfo"
  9. :size="size"
  10. @page-curr-change="handlePageChange"
  11. @page-size-change="handleSizeChange"
  12. @screen-reset="
  13. pageInfo.curr = 1;
  14. parmValue.page = 1;
  15. searchList();
  16. "
  17. @screen-submit="
  18. pageInfo.curr = 1;
  19. parmValue.page = 1;
  20. searchList();
  21. "
  22. @selection="selection_change"
  23. >
  24. <template #table-header="{}">
  25. <div style="width: 100%">
  26. <el-row style="padding: 0 0 0 80px">
  27. <el-col :span="6" style="width: 463px">
  28. <periodDatePickerActive
  29. :start="parmValue.start_date"
  30. :end="parmValue.end_date"
  31. :placeholder="'产品操作'"
  32. :width="'205px'"
  33. :size="searchSize"
  34. @timeReturned="time"
  35. />
  36. </el-col>
  37. <el-col :span="4" style="width: 66px; float: right">
  38. <el-button
  39. type="primary"
  40. style="margin-left: 30px"
  41. @click="download"
  42. :size="searchSize"
  43. class="fr"
  44. >
  45. 导出
  46. </el-button>
  47. </el-col>
  48. <el-col :span="3" style="width: 66px; float: right">
  49. <el-button
  50. :size="searchSize"
  51. type="primary"
  52. style="float: right; margin-left: 5px"
  53. @click="searchList"
  54. >
  55. 刷新
  56. </el-button>
  57. </el-col>
  58. </el-row>
  59. <el-row style="padding: 10px 0 0 0" gutter="10">
  60. <el-col :span="6" style="width: 240px">
  61. <el-input
  62. clearable
  63. placeholder="采购维护人"
  64. v-model="parmValue.creater"
  65. maxlength="40"
  66. :size="searchSize"
  67. @blur="
  68. pageInfo.curr = 1;
  69. parmValue.page = 1;
  70. searchList();
  71. "
  72. >
  73. </el-input>
  74. </el-col>
  75. <el-col :span="6" style="width: 240px">
  76. <el-input
  77. clearable
  78. placeholder="供应商名称"
  79. v-model="parmValue.supplier_name"
  80. maxlength="40"
  81. :size="searchSize"
  82. @blur="
  83. pageInfo.curr = 1;
  84. parmValue.page = 1;
  85. searchList();
  86. "
  87. >
  88. </el-input>
  89. </el-col>
  90. <el-col :span="4" style="width: 66px; float: right">
  91. <el-button
  92. type="warning"
  93. class="fr"
  94. :size="searchSize"
  95. @click="restSearch"
  96. >
  97. 重置
  98. </el-button>
  99. </el-col>
  100. </el-row>
  101. </div>
  102. </template>
  103. <template #operation="{ scope }">
  104. <el-tooltip effect="dark" content="修改内容对比" placement="top">
  105. <i class="el-icon-view tb-icon" @click="dlgTable(scope.row)"></i>
  106. </el-tooltip>
  107. </template>
  108. </ex-table>
  109. <el-dialog
  110. title="产品修改差异对比"
  111. :visible.sync="dialogTableVisible"
  112. :center="true"
  113. align="left"
  114. top="3vh"
  115. width="1040px"
  116. :close-on-click-modal="false"
  117. element-loading-text="拼命加载中"
  118. element-loading-spinner="el-icon-loading"
  119. element-loading-background="rgba(0, 0, 0, 0.8)"
  120. @close="dialogTableVisible = false"
  121. >
  122. <el-table
  123. :data="showData"
  124. :size="searchSize"
  125. border
  126. stripe
  127. max-height="750px"
  128. style="width: 100%; margin: -20px 0 0"
  129. >
  130. <el-table-column
  131. prop="key_name"
  132. label="修改字段名称"
  133. width="130px"
  134. show-overflow-tooltip
  135. />
  136. <el-table-column
  137. prop="key"
  138. label="修改字段"
  139. width="130px"
  140. show-overflow-tooltip
  141. />
  142. <el-table-column prop="before" label="修改前" show-overflow-tooltip>
  143. <template slot-scope="scope">
  144. <div v-if="scope.row.key === 'good_img'">
  145. <img
  146. v-for="(si, sii) in scope.row.before"
  147. :key="si + sii"
  148. :src="si"
  149. alt=""
  150. class="fl"
  151. v-viewer
  152. style="width: 30px; height: 30px"
  153. />
  154. </div>
  155. <div v-else-if="scope.row.key === 'good_info_img'">
  156. <img
  157. v-for="(si, sii) in scope.row.after"
  158. :key="si + sii"
  159. :src="si"
  160. alt=""
  161. v-viewer
  162. class="fl"
  163. style="width: 30px; height: 30px"
  164. />
  165. </div>
  166. <div v-else-if="scope.row.key === 'good_thumb_img'">
  167. <img
  168. v-for="(si, sii) in scope.row.after"
  169. :key="si + sii"
  170. :src="si"
  171. alt=""
  172. v-viewer
  173. class="fl"
  174. style="width: 30px; height: 30px"
  175. />
  176. </div>
  177. <div v-else>{{ scope.row.before }}</div>
  178. </template>
  179. </el-table-column>
  180. <el-table-column prop="after" label="修改后" show-overflow-tooltip>
  181. <template slot-scope="scope">
  182. <div v-if="scope.row.key === 'good_img'">
  183. <img
  184. v-for="(si, sii) in scope.row.after"
  185. :key="si + sii"
  186. :src="si"
  187. alt=""
  188. v-viewer
  189. class="fl"
  190. style="width: 30px; height: 30px"
  191. />
  192. </div>
  193. <div v-else-if="scope.row.key === 'good_info_img'">
  194. <img
  195. v-for="(si, sii) in scope.row.after"
  196. :key="si + sii"
  197. :src="si"
  198. alt=""
  199. v-viewer
  200. class="fl"
  201. style="width: 30px; height: 30px"
  202. />
  203. </div>
  204. <div v-else-if="scope.row.key === 'good_thumb_img'">
  205. <img
  206. v-for="(si, sii) in scope.row.after"
  207. :key="si + sii"
  208. :src="si"
  209. alt=""
  210. v-viewer
  211. class="fl"
  212. style="width: 30px; height: 30px"
  213. />
  214. </div>
  215. <div v-else>{{ scope.row.after }}</div>
  216. </template>
  217. </el-table-column>
  218. </el-table>
  219. </el-dialog>
  220. </div>
  221. </template>
  222. <script>
  223. import mixinPage from "@/mixins/elPaginationHandle";
  224. import resToken from "@/mixins/resToken";
  225. import urlConfig from "@/apis/url-config";
  226. import asyncRequest from "@/apis/service/reportQuery/purchaseReport";
  227. import periodDatePickerActive from "../period-date-picker/main.vue";
  228. import { table13, editTable13 } from "./columns";
  229. import { mapGetters } from "vuex";
  230. export default {
  231. name: "purchaseOrder",
  232. mixins: [mixinPage, resToken],
  233. components: {
  234. periodDatePickerActive,
  235. },
  236. computed: {
  237. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  238. },
  239. data() {
  240. return {
  241. editOld: {},
  242. editNew: {},
  243. dialogTableVisible: false,
  244. //选中数组
  245. changeList: [],
  246. showData: [],
  247. //全局url
  248. fileUrl: urlConfig.baseURL,
  249. //loading
  250. loading: false,
  251. //请求参数集合
  252. parmValue: {
  253. creater: "", //采购维护人
  254. supplier_name: "", // 供应商名称
  255. start_date: "", //起始时间
  256. end_date: "", // 结束时间
  257. page: 1, // 页码
  258. size: 15, // 每页显示条数
  259. },
  260. // 表格 - 数据集合
  261. tableData: [],
  262. // 表格 - 参数
  263. table: {
  264. stripe: true,
  265. border: true,
  266. _defaultHeader_: ["setcol"],
  267. },
  268. // 表格 - 分页
  269. pageInfo: {
  270. size: 15,
  271. curr: 1,
  272. total: 0,
  273. },
  274. table13: table13,
  275. editTable13,
  276. };
  277. },
  278. mounted() {
  279. this.searchList();
  280. },
  281. methods: {
  282. dlgTable(row) {
  283. this.showData = [];
  284. const { before_info, after_info } = row;
  285. let keyList = [];
  286. for (let key in after_info) {
  287. keyList.push(key);
  288. }
  289. for (let i = 0; i < keyList.length; i++) {
  290. let model = {
  291. key: keyList[i],
  292. key_name:
  293. (editTable13.find((s) => s.prop === keyList[i]) || {}).label ||
  294. "--",
  295. before: this.get_key_value(keyList[i], before_info),
  296. after: this.get_key_value(keyList[i], after_info),
  297. };
  298. // console.log(model.key_name)
  299. this.showData.push(model);
  300. }
  301. this.dialogTableVisible = true;
  302. },
  303. get_key_value(key, info) {
  304. if (key === "good_img") {
  305. return info[key] ? (info[key] || "").split(",") : [];
  306. }
  307. else if(key === "good_info_img") {
  308. return info[key] ? (info[key] || "").split(",") : [];
  309. }
  310. else if(key === "good_thumb_img") {
  311. return info[key] ? (info[key] || "").split(",") : [];
  312. }
  313. // else if(key === "cat_id") {
  314. // return info[key] ? (info[key] || "").split(",") : [];
  315. // }
  316. return info[key];
  317. },
  318. //初始化http请求
  319. async searchList() {
  320. if (
  321. (this.parmValue.start_date !== "" && this.parmValue.end_date === "") ||
  322. (this.parmValue.start_date === "" && this.parmValue.end_date !== "")
  323. ) {
  324. this.$message.warning("时间区间不完整!");
  325. return;
  326. }
  327. // return;
  328. this.loading = true;
  329. const res = await asyncRequest.reportchangeloglist(this.parmValue);
  330. console.log(res);
  331. if (res && res.code === 0 && res.data) {
  332. this.tableData = res.data.list;
  333. this.pageInfo.total = Number(res.data.count);
  334. } else if (res && res.code >= 100 && res.code <= 104) {
  335. await this.logout();
  336. } else {
  337. this.tableData = [];
  338. this.pageInfo.total = 0;
  339. this.$message.warning(res.message);
  340. }
  341. this.loading = false;
  342. },
  343. //重置
  344. restSearch() {
  345. this.parmValue = {
  346. creater: "", //采购维护人
  347. supplier_name: "", // 供应商名称
  348. start_date: "", //新建起始时间
  349. end_date: "", // 新建结束时间
  350. page: 1, // 页码
  351. size: 15, // 每页显示条数
  352. };
  353. // 表格 - 分页
  354. this.pageInfo = {
  355. size: 15,
  356. curr: 1,
  357. total: 0,
  358. };
  359. this.searchList();
  360. },
  361. // 时间函数
  362. async time(e) {
  363. this.parmValue.start_date = e.startTime || "";
  364. this.parmValue.end_date = e.endTime || "";
  365. if (
  366. (this.parmValue.start_date !== "" && this.parmValue.end_date === "") ||
  367. (this.parmValue.start_date === "" && this.parmValue.end_date !== "")
  368. ) {
  369. this.$message.warning("时间区间不完整!");
  370. return;
  371. }
  372. this.pageInfo.curr = 1;
  373. this.parmValue.page = 1;
  374. await this.searchList();
  375. },
  376. //选中触发函数
  377. selection_change(e) {
  378. const { list } = e;
  379. //选中的数组集合
  380. this.changeList = list.length > 0 ? JSON.parse(JSON.stringify(list)) : [];
  381. },
  382. //导出文件
  383. async download() {
  384. // if(this.changeList.length<=0){
  385. // this.$message.warning("请选择有效数据")
  386. // return;
  387. // }
  388. let start_date = new Date(this.parmValue.start_date).valueOf();
  389. let end_date = new Date(this.parmValue.end_date).valueOf();
  390. let flag = end_date - start_date > 30 * 24 * 60 * 60 * 1000;
  391. if (this.parmValue.start_date != "" && this.parmValue.end_date != "") {
  392. if (flag) {
  393. this.$message.warning("导出文件的时间区间不能超过30天");
  394. return;
  395. }
  396. } else {
  397. this.$message.warning("请选择导出文件的时间区间");
  398. return;
  399. }
  400. let model = JSON.parse(JSON.stringify(this.parmValue));
  401. // model.is_export = 1;
  402. if (!this.loading) {
  403. this.loading = true;
  404. let httpType = `aplication/zip`;
  405. axios({
  406. method: "post",
  407. url: this.fileUrl + "admin/reportchangelogeexport",
  408. responseType: "blob",
  409. data: model,
  410. headers: {
  411. // 'Content-Type': 'multipart/form-data',
  412. // Accept: "application/vnd.ms-excel"
  413. Accept: httpType,
  414. },
  415. })
  416. .then((res) => {
  417. // console.log(res)
  418. // console.log(this.fileUrl)
  419. // return;
  420. if (res && res.status == 200 && res.data) {
  421. let url = window.URL.createObjectURL(
  422. new Blob([res.data], {
  423. // type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8",
  424. type: httpType,
  425. })
  426. );
  427. let link = document.createElement("a");
  428. link.style.display = "none";
  429. link.href = url;
  430. let excelName = "产品修改报表.zip";
  431. link.setAttribute("download", excelName);
  432. document.body.appendChild(link);
  433. link.click();
  434. link.remove();
  435. window.URL.revokeObjectURL(url); //释放掉blob对象
  436. this.$message.success(`导出成功!`);
  437. setTimeout(() => {
  438. this.loading = false;
  439. }, 500);
  440. } else {
  441. this.$message.error(res.data.message);
  442. setTimeout(() => {
  443. this.loading = false;
  444. }, 500);
  445. }
  446. })
  447. .catch((error) => {
  448. console.log(error);
  449. this.loading = false;
  450. });
  451. }
  452. },
  453. },
  454. };
  455. </script>
  456. <style lang="scss" scoped>
  457. .purchaseOrder {
  458. // text-align: right;
  459. }
  460. /deep/ .el-dialog {
  461. width: 80%;
  462. // height: 50vh;
  463. min-width: 800px;
  464. min-height: 500px;
  465. }
  466. </style>