table19.vue 9.1 KB

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