table9.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <template>
  2. <div>
  3. <ex-table
  4. v-loading="loading"
  5. :table="table"
  6. :data="tableData"
  7. :columns="table9"
  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 type="primary" style="margin-left:30px;" @click="download" :size="searchSize" class="fr">
  39. 导出
  40. </el-button>
  41. </el-col>
  42. <el-col :span="3" style="width: 66px; float: right">
  43. <el-button
  44. :size="searchSize"
  45. type="primary"
  46. style="float: right; margin-left: 5px"
  47. @click="searchList"
  48. >
  49. 刷新
  50. </el-button>
  51. </el-col>
  52. </el-row>
  53. <el-row style="padding: 10px 0 0 0">
  54. <el-col :span="6" style="width: 463px;">
  55. <periodDatePickerActive
  56. :start="parmValue.start_date22"
  57. :end="parmValue.end_date22"
  58. :placeholder="'修改供应商'"
  59. :width="'205px'"
  60. :size="searchSize"
  61. @timeReturned="time2"
  62. />
  63. </el-col>
  64. <el-col :span="4" style="width: 66px; float: right">
  65. <el-button
  66. type="warning"
  67. class="fr"
  68. :size="searchSize"
  69. @click="restSearch"
  70. >
  71. 重置
  72. </el-button>
  73. </el-col>
  74. </el-row>
  75. </div>
  76. </template>
  77. </ex-table>
  78. </div>
  79. </template>
  80. <script>
  81. import mixinPage from "@/mixins/elPaginationHandle";
  82. import resToken from "@/mixins/resToken";
  83. import urlConfig from "@/apis/url-config";
  84. import asyncRequest from "@/apis/service/reportQuery/purchaseReport";
  85. import periodDatePickerActive from "../period-date-picker/main.vue";
  86. import { table9} from "./columns";
  87. import { mapGetters } from "vuex";
  88. export default {
  89. name: "purchaseOrder",
  90. mixins: [mixinPage, resToken],
  91. components: {
  92. periodDatePickerActive
  93. },
  94. computed: {
  95. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  96. },
  97. data() {
  98. return {
  99. //选中数组
  100. changeList: [],
  101. //全局url
  102. fileUrl: urlConfig.baseURL,
  103. //loading
  104. loading: false,
  105. //请求参数集合
  106. parmValue: {
  107. start_date: "", //起始时间
  108. end_date: "", // 结束时间
  109. update_start_date: "", //起始时间22
  110. update_end_date: "", // 结束时间22
  111. page: 1, // 页码
  112. size: 15, // 每页显示条数
  113. },
  114. // 表格 - 数据集合
  115. tableData: [],
  116. // 表格 - 参数
  117. table: {
  118. stripe: true,
  119. border: true,
  120. _defaultHeader_: ["setcol"],
  121. },
  122. // 表格 - 分页
  123. pageInfo: {
  124. size: 15,
  125. curr: 1,
  126. total: 0,
  127. },
  128. // 表格表头 - 列参数
  129. table9: table9,
  130. };
  131. },
  132. mounted() {
  133. this.searchList();
  134. },
  135. methods: {
  136. //初始化http请求
  137. async searchList() {
  138. if (
  139. (this.parmValue.start_date !== "" && this.parmValue.end_date === "") ||
  140. (this.parmValue.start_date === "" && this.parmValue.end_date !== "")
  141. ) {
  142. this.$message.warning("时间区间不完整!");
  143. return;
  144. }
  145. if (
  146. (this.parmValue.update_start_date !== "" && this.parmValue.update_end_date === "") ||
  147. (this.parmValue.update_start_date === "" && this.parmValue.update_end_date !== "")
  148. ) {
  149. this.$message.warning("时间区间不完整!");
  150. return;
  151. }
  152. // return;
  153. this.loading = true;
  154. const res = await asyncRequest.reportsupplierlist(this.parmValue);
  155. if (res && res.code === 0 && res.data) {
  156. this.tableData = res.data.list;
  157. this.pageInfo.total = Number(res.data.count);
  158. } else if (res && res.code >= 100 && res.code <= 104) {
  159. await this.logout();
  160. } else {
  161. this.tableData = [];
  162. this.pageInfo.total = 0;
  163. }
  164. this.loading = false;
  165. },
  166. //重置
  167. restSearch() {
  168. this.parmValue = {
  169. start_date: "", //起始时间
  170. end_date: "", // 结束时间
  171. update_start_date: "", //起始时间22
  172. update_end_date: "", // 结束时间22
  173. page: 1, // 页码
  174. size: 15, // 每页显示条数
  175. };
  176. // 表格 - 分页
  177. this.pageInfo = {
  178. size: 15,
  179. curr: 1,
  180. total: 0,
  181. };
  182. this.searchList();
  183. },
  184. // 时间函数
  185. async time(e) {
  186. this.parmValue.start_date = e.startTime || "";
  187. this.parmValue.end_date = e.endTime || "";
  188. if (
  189. (this.parmValue.start_date !== "" && this.parmValue.end_date === "") ||
  190. (this.parmValue.start_date === "" && this.parmValue.end_date !== "")
  191. ) {
  192. this.$message.warning("时间区间不完整!");
  193. return;
  194. }
  195. this.pageInfo.curr = 1;
  196. this.parmValue.page = 1;
  197. await this.searchList();
  198. },
  199. async time2(e) {
  200. this.parmValue.update_start_date = e.startTime || "";
  201. this.parmValue.update_end_date = e.endTime || "";
  202. if (
  203. (this.parmValue.update_start_date !== "" && this.parmValue.update_end_date === "") ||
  204. (this.parmValue.update_start_date === "" && this.parmValue.update_end_date !== "")
  205. ) {
  206. this.$message.warning("时间区间不完整!");
  207. return;
  208. }
  209. this.pageInfo.curr = 1;
  210. this.parmValue.page = 1;
  211. await this.searchList();
  212. },
  213. //选中触发函数
  214. selection_change(e) {
  215. const { list } = e;
  216. //选中的数组集合
  217. this.changeList = list.length > 0 ? JSON.parse(JSON.stringify(list)) : [];
  218. },
  219. //导出文件
  220. async download() {
  221. // if(this.changeList.length<=0){
  222. // this.$message.warning("请选择有效数据")
  223. // return;
  224. // }
  225. if (
  226. (this.parmValue.start_date !== "" && this.parmValue.end_date === "") ||
  227. (this.parmValue.start_date === "" && this.parmValue.end_date !== "")
  228. ) {
  229. this.$message.warning("时间区间不完整!");
  230. return;
  231. }
  232. if (
  233. (this.parmValue.update_start_date !== "" && this.parmValue.update_end_date === "") ||
  234. (this.parmValue.update_start_date === "" && this.parmValue.update_end_date !== "")
  235. ) {
  236. this.$message.warning("时间区间不完整!");
  237. return;
  238. }
  239. if((this.parmValue.start_date != "" && this.parmValue.end_date != "") || (this.parmValue.update_start_date != "" && this.parmValue.update_end_date != "")){
  240. let start_date = new Date(this.parmValue.start_date).valueOf() || new Date(this.parmValue.update_start_date).valueOf() ;
  241. let end_date = new Date(this.parmValue.end_date).valueOf() || new Date(this.parmValue.update_end_date).valueOf() ;
  242. let start_date2 = new Date(this.parmValue.update_start_date).valueOf() ;
  243. let end_date2 = new Date(this.parmValue.update_end_date).valueOf() ;
  244. let flag = (end_date - start_date > 30 * 24 * 60 * 60 * 1000) || (end_date2 - start_date2 > 30 * 24 * 60 * 60 * 1000) ;
  245. if(flag){
  246. this.$message.warning("导出文件的时间区间不能超过30天")
  247. return;
  248. }
  249. }else{
  250. this.$message.warning("请选择至少一种导出文件的时间区间")
  251. return;
  252. }
  253. let model = JSON.parse(JSON.stringify(this.parmValue))
  254. // model.is_export = 1;
  255. if (!this.loading) {
  256. this.loading = true;
  257. let httpType = `aplication/zip`;
  258. axios({
  259. method: "post",
  260. url: this.fileUrl + "admin/reportsupplierlistexport",
  261. responseType: "blob",
  262. data: model,
  263. headers: {
  264. // 'Content-Type': 'multipart/form-data',
  265. // Accept: "application/vnd.ms-excel"
  266. Accept: httpType,
  267. },
  268. })
  269. .then((res) => {
  270. // console.log(res)
  271. // console.log(this.fileUrl)
  272. // return;
  273. if (res && res.status == 200 && res.data) {
  274. let url = window.URL.createObjectURL(
  275. new Blob([res.data], {
  276. // type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8",
  277. type: httpType
  278. })
  279. );
  280. let link = document.createElement("a");
  281. link.style.display = "none";
  282. link.href = url;
  283. let excelName = "每日录入供应商报表.zip";
  284. link.setAttribute("download", excelName);
  285. document.body.appendChild(link);
  286. link.click();
  287. link.remove();
  288. window.URL.revokeObjectURL(url); //释放掉blob对象
  289. this.$message.success(`导出成功!`);
  290. setTimeout(() => {
  291. this.loading = false;
  292. }, 500);
  293. } else {
  294. this.$message.error(res.data.message);
  295. setTimeout(() => {
  296. this.loading = false;
  297. }, 500);
  298. }
  299. })
  300. .catch((error) => {
  301. console.log(error);
  302. this.loading = false;
  303. });
  304. }
  305. },
  306. },
  307. };
  308. </script>
  309. <style lang="scss" scoped>
  310. .purchaseOrder {
  311. // text-align: right;
  312. }
  313. </style>