table14.vue 9.7 KB

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