table4.vue 11 KB

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