table1.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <template>
  2. <div style="padding:10px">
  3. <div v-if="powers.some((i) => i == '001')">
  4. <div style="width: 100%">
  5. <el-row style="width: 100%;margin-top: 10px;">
  6. <el-col :span="6" style="width: 443px;">
  7. <periodDatePickerActive
  8. :start="parmValue.start_day"
  9. :end="parmValue.end_day"
  10. picker-type="month"
  11. :width="'205px'"
  12. :size="searchSize"
  13. @timeReturned="time"
  14. />
  15. </el-col>
  16. <el-col :span="4" style="width: 350px">
  17. <search-supplier
  18. :size="'mini'"
  19. :value="parmValue.supplierNo"
  20. :disabled="false"
  21. :placeholder="'供应商名称'"
  22. :names="parmValue.supplierName"
  23. :is-detail="true"
  24. :no-disabled="true"
  25. @searchChange="supplierChange"
  26. />
  27. </el-col>
  28. <el-col :span="4" style="width: 66px; float: right">
  29. <el-button
  30. type="primary"
  31. style="margin-left: 30px"
  32. :size="searchSize"
  33. class="fr"
  34. @click="download"
  35. >导出</el-button>
  36. </el-col>
  37. <el-col :span="3" style="width: 66px; float: right">
  38. <el-button
  39. :size="searchSize"
  40. type="primary"
  41. style="float: right; margin-left: 5px"
  42. @click="searchList"
  43. >刷新</el-button>
  44. </el-col>
  45. <el-col :span="4" style="width: 66px; float: right">
  46. <el-button type="warning" class="fr" :size="searchSize" @click="restSearch">重置</el-button>
  47. </el-col>
  48. </el-row>
  49. </div>
  50. <el-table v-loading="loading" size="mini" :data="tableData" border style="margin-top:10px">
  51. <el-table-column prop="supplier_name" label="供应商名称" width="180px" show-overflow-tooltip />
  52. <el-table-column prop="is_supplier" label="是否开通供应商端" width="120px" />
  53. <el-table-column prop="person" label="供应商负责人" width="95px" />
  54. <el-table-column prop="total_fee" label="采购订单总金额" width="110px" />
  55. <el-table-column prop="total_cgd" label="采购订单总量" width="95px" />
  56. <el-table-column label="待与供应商确认" align="center">
  57. <el-table-column label="采购订单总金额" prop="dtotal_fee" min-width="105px" />
  58. <el-table-column label="采购单数量" prop="dtotal_cgd" min-width="85px" />
  59. </el-table-column>
  60. <el-table-column label="待入库" align="center">
  61. <el-table-column label="采购订单总金额" prop="wtotal_fee" min-width="105px" />
  62. <el-table-column label="采购单数量" prop="wtotal_cgd" min-width="85px" />
  63. </el-table-column>
  64. <el-table-column label="按商品类型统计订单数量" align="center">
  65. <el-table-column label="备库商品" prop="tag_1" min-width="85px" />
  66. <el-table-column label="非库存商品" prop="tag_2" min-width="105px" />
  67. <el-table-column label="采返商品" prop="tag_zx" min-width="85px" />
  68. </el-table-column>
  69. <el-table-column label="平台类型" align="center">
  70. <el-table-column label="ToC平台" prop="tag_c" />
  71. <el-table-column label="ToB平台" prop="tag_b" />
  72. </el-table-column>
  73. </el-table>
  74. </div>
  75. <div v-else>
  76. <no-auth></no-auth>
  77. </div>
  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/newReport'
  85. import periodDatePickerActive from './period-date-picker/main.vue'
  86. import { table1 } from './columns'
  87. import { mapGetters } from 'vuex'
  88. import { xs_order_type_options } from '@/assets/js/statusList'
  89. import * as dayjs from 'dayjs'
  90. export default {
  91. name: 'PurchaseOrder',
  92. components: {
  93. periodDatePickerActive
  94. },
  95. mixins: [mixinPage, resToken],
  96. computed: {
  97. ...mapGetters(['tablebtnSize', 'searchSize', 'size']),
  98. powers() {
  99. const tran =
  100. this.$store.getters.btnList.find((i) => i.menu_route == "reportTableOne") || {};
  101. const { action } = tran ?? {};
  102. return action ?? [];
  103. },
  104. },
  105. data() {
  106. return {
  107. // 选中数组
  108. changeList: [],
  109. // 全局url
  110. fileUrl: urlConfig.baseURL,
  111. // loading
  112. loading: false,
  113. // 请求参数集合
  114. parmValue: {
  115. supplierNo: [],
  116. supplier_name: '',
  117. start_day: dayjs(this.getStartDate()).format('YYYY-MM-DD'), // 起始时间
  118. end_day: dayjs(new Date()).format('YYYY-MM-DD') // 结束时间
  119. },
  120. // 表格 - 数据集合
  121. tableData: [],
  122. xs_order_type_options,
  123. // 表格 - 参数
  124. table: {
  125. stripe: true,
  126. border: true,
  127. _defaultHeader_: ['setcol']
  128. },
  129. // 表格表头 - 列参数
  130. table1
  131. }
  132. },
  133. mounted() {
  134. this.parmValue.start_day = dayjs().subtract(0, 'day').format('YYYY-MM-DD')
  135. this.parmValue.end_day = dayjs().subtract(-1, 'day').format('YYYY-MM-DD')
  136. this.searchList()
  137. },
  138. methods: {
  139. async supplierChange(e) {
  140. const { code, label } = e
  141. this.parmValue.supplierNo = code ? [code] : []
  142. this.searchList()
  143. },
  144. // 初始化http请求
  145. async searchList() {
  146. if (!this.parmValue.start_day || !this.parmValue.end_day) {
  147. this.$message.warning('请选择时间区间')
  148. this.tableData = []
  149. return
  150. }
  151. if (!this.diffDays(31)) {
  152. this.$message.warning('时间区间不能超过31天')
  153. return
  154. }
  155. this.loading = true
  156. const { code, data, message } = await asyncRequest.pom({
  157. ...this.parmValue,
  158. supplierNo: Array.isArray(this.parmValue.supplierNo) ? this.parmValue.supplierNo[0] : this.parmValue.supplierNo
  159. })
  160. if (code === 0) {
  161. // const { list, count } = data;
  162. this.tableData = data
  163. } else if (code >= 100 && code <= 104) {
  164. await this.logout()
  165. } else {
  166. this.tableData = []
  167. }
  168. this.loading = false
  169. },
  170. getStartDate() {
  171. const myDate = new Date()
  172. myDate.setDate(myDate.getDate() - 29)
  173. return myDate
  174. },
  175. diffDays(days) {
  176. const step = 24 * 3600 * 1000
  177. const sDay = new Date(this.parmValue.start_day).valueOf()
  178. const eDay = new Date(this.parmValue.end_day).valueOf()
  179. let isok = true
  180. if (eDay - sDay > step * days) {
  181. isok = false
  182. }
  183. return isok
  184. },
  185. // 重置
  186. restSearch() {
  187. this.parmValue = {
  188. supplier_name: '',
  189. supplierNo: [],
  190. start_day: dayjs().subtract(0, 'day').format('YYYY-MM-DD'),
  191. end_day: dayjs().subtract(-1, 'day').format('YYYY-MM-DD'),
  192. page: 1, // 页码
  193. size: 15 // 每页显示条数
  194. }
  195. this.searchList()
  196. },
  197. // 选中触发函数
  198. selection_change(e) {
  199. const { list } = e
  200. // 选中的数组集合
  201. this.changeList = list.length > 0 ? JSON.parse(JSON.stringify(list)) : []
  202. },
  203. // 时间函数
  204. async time(e) {
  205. this.parmValue.start_day = e.startTime || ''
  206. this.parmValue.end_day = e.endTime || ''
  207. if (
  208. (this.parmValue.start_day !== '' && this.parmValue.end_day === '') ||
  209. (this.parmValue.start_day === '' && this.parmValue.end_day !== '')
  210. ) {
  211. this.$message.warning('时间区间不完整!')
  212. return
  213. }
  214. if (!this.diffDays(31)) {
  215. this.$message.warning('时间区间不能超过31天')
  216. return
  217. }
  218. await this.searchList()
  219. },
  220. // getTimeParam() {
  221. // const { start_day: start, end_day: end } = this.parmValue;
  222. // if (!start || !end) {
  223. // return {
  224. // start_day: "",
  225. // end_day: ""
  226. // };
  227. // }
  228. // const start_date_chunks = start.split("-");
  229. // const end_date_chunks = end.split("-");
  230. // start_date_chunks[2] = "01";
  231. // const [year, month] = end_date_chunks;
  232. // const end_last_day = new Date(year, month, 0).getDate();
  233. // end_date_chunks[2] = end_last_day;
  234. // return {
  235. // start_day: start_date_chunks.join("-"),
  236. // end_day: end_date_chunks.join("-")
  237. // };
  238. // },
  239. // 导出文件
  240. async download() {
  241. if (
  242. (this.parmValue.start_day !== '' && this.parmValue.end_day === '') ||
  243. (this.parmValue.start_day === '' && this.parmValue.end_day !== '')
  244. ) {
  245. this.$message.warning('时间区间不完整!')
  246. return
  247. }
  248. if (!this.diffDays(31)) {
  249. this.$message.warning('时间区间不能超过31天')
  250. return
  251. }
  252. const model = JSON.parse(
  253. JSON.stringify(this.parmValue)
  254. )
  255. if (!this.loading) {
  256. this.loading = true
  257. const httpType = `aplication/zip`
  258. axios({
  259. method: 'post',
  260. url: this.fileUrl + 'admin/pome',
  261. responseType: 'blob',
  262. data: {
  263. ...this.parmValue,
  264. supplierNo: Array.isArray(this.parmValue.supplierNo) ? this.parmValue.supplierNo[0] : this.parmValue.supplierNo
  265. },
  266. headers: {
  267. Accept: httpType
  268. }
  269. })
  270. .then(res => {
  271. if (res && res.status == 200 && res.data) {
  272. const url = window.URL.createObjectURL(
  273. new Blob([res.data], {
  274. type: httpType
  275. })
  276. )
  277. const link = document.createElement('a')
  278. link.style.display = 'none'
  279. link.href = url
  280. const excelName = '本月供应商采购订单情况.zip'
  281. link.setAttribute('download', excelName)
  282. document.body.appendChild(link)
  283. link.click()
  284. link.remove()
  285. window.URL.revokeObjectURL(url) // 释放掉blob对象
  286. this.$message.success(`导出成功!`)
  287. setTimeout(() => {
  288. this.loading = false
  289. }, 500)
  290. } else {
  291. this.$message.error(res.data.message)
  292. setTimeout(() => {
  293. this.loading = false
  294. }, 500)
  295. }
  296. })
  297. .catch(error => {
  298. console.log(error)
  299. this.loading = false
  300. })
  301. }
  302. }
  303. }
  304. }
  305. </script>
  306. <style lang="scss" scoped>
  307. .purchaseOrder {
  308. // text-align: right;
  309. }
  310. </style>