table9.vue 10 KB

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