table15.vue 11 KB

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