downloadbinlist.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <template>
  2. <div>
  3. <transition appear enter-active-class="animated fadeIn">
  4. <q-table
  5. class="shadow-24"
  6. :data="table_list"
  7. row-key="id"
  8. :separator="separator"
  9. :loading="loading"
  10. :columns="columns"
  11. hide-bottom
  12. :pagination.sync="pagination"
  13. no-data-label="No data"
  14. no-results-label="No data you want"
  15. :table-style="{ height: height }"
  16. flat
  17. bordered
  18. >
  19. <template v-slot:top>
  20. <div class="flex items-center">
  21. <div class="q-mr-md">{{ $t("download_center.createTime") }}</div>
  22. <q-input
  23. readonly
  24. outlined
  25. dense
  26. v-model="createDate2"
  27. :placeholder="interval"
  28. >
  29. <template v-slot:append>
  30. <q-icon name="event" class="cursor-pointer">
  31. <q-popup-proxy
  32. ref="qDateProxy"
  33. transition-show="scale"
  34. transition-hide="scale"
  35. ><q-date v-model="createDate1" range
  36. /></q-popup-proxy>
  37. </q-icon>
  38. </template>
  39. </q-input>
  40. <q-btn-group push class="q-ml-md">
  41. <q-btn
  42. :label="$t('download_center.reset')"
  43. icon="img:statics/downloadcenter/reset.svg"
  44. @click="reset()"
  45. >
  46. </q-btn>
  47. <q-btn
  48. :label="$t('downloadasnlist')"
  49. icon="cloud_download"
  50. @click="downloadlistData()"
  51. >
  52. </q-btn>
  53. </q-btn-group>
  54. </div>
  55. </template>
  56. <template v-slot:body="props">
  57. <q-tr :props="props">
  58. <q-td key="bin_name" :props="props">{{ props.row.bin_name }}</q-td>
  59. <q-td key="goods_code" :props="props">{{
  60. props.row.goods_code
  61. }}</q-td>
  62. <q-td key="goods_desc" :props="props">{{
  63. props.row.goods_desc
  64. }}</q-td>
  65. <q-td key="goods_qty" :props="props">{{
  66. props.row.goods_qty
  67. }}</q-td>
  68. <q-td key="pick_qty" :props="props">{{ props.row.pick_qty }}</q-td>
  69. <q-td key="picked_qty" :props="props">{{
  70. props.row.picked_qty
  71. }}</q-td>
  72. <q-td key="bin_size" :props="props">{{ props.row.bin_size }}</q-td>
  73. <q-td key="bin_property" :props="props">{{
  74. props.row.bin_property
  75. }}</q-td>
  76. <q-td key="create_time" :props="props">{{
  77. props.row.create_time
  78. }}</q-td>
  79. <q-td key="update_time" :props="props">{{
  80. props.row.update_time
  81. }}</q-td>
  82. </q-tr>
  83. </template>
  84. </q-table>
  85. </transition>
  86. <template>
  87. <div v-show="max !== 0" class="q-pa-lg flex flex-center">
  88. <div>{{ total }} </div>
  89. <q-pagination
  90. v-model="current"
  91. color="black"
  92. :max="max"
  93. :max-pages="6"
  94. boundary-links
  95. @click="getList()"
  96. />
  97. <div>
  98. <input
  99. v-model="paginationIpt"
  100. @blur="changePageEnter"
  101. @keyup.enter="changePageEnter"
  102. style="width: 60px; text-align: center"
  103. />
  104. </div>
  105. </div>
  106. <div v-show="max === 0" class="q-pa-lg flex flex-center">
  107. <q-btn flat push color="dark" :label="$t('no_data')"></q-btn>
  108. </div>
  109. </template>
  110. </div>
  111. </template>
  112. <router-view />
  113. <script>
  114. import { getauth, getfile } from 'boot/axios_request'
  115. import { date, exportFile, LocalStorage } from 'quasar'
  116. export default {
  117. name: 'Pagebindownload',
  118. data () {
  119. return {
  120. login_name: '',
  121. authin: '0',
  122. pathname: 'stock/',
  123. pathname_previous: '',
  124. pathname_next: '',
  125. separator: 'cell',
  126. loading: false,
  127. height: '',
  128. table_list: [],
  129. columns: [
  130. { name: 'bin_name', required: true, label: this.$t('warehouse.view_binset.bin_name'), align: 'left', field: 'bin_name' },
  131. { name: 'goods_code', label: this.$t('stock.view_stocklist.goods_code'), field: 'goods_code', align: 'center' },
  132. { name: 'goods_desc', label: this.$t('stock.view_stocklist.goods_desc'), field: 'onhand_stock', align: 'center' },
  133. { name: 'goods_qty', label: this.$t('stock.view_stocklist.onhand_stock'), field: 'goods_qty', align: 'center' },
  134. { name: 'pick_qty', label: this.$t('stock.view_stocklist.pick_stock'), field: 'pick_qty', align: 'center' },
  135. { name: 'picked_qty', label: this.$t('stock.view_stocklist.picked_stock'), field: 'picked_qty', align: 'center' },
  136. { name: 'bin_size', label: this.$t('warehouse.view_binset.bin_size'), field: 'bin_size', align: 'center' },
  137. { name: 'bin_property', label: this.$t('warehouse.view_binset.bin_property'), field: 'bin_property', align: 'center' },
  138. { name: 'create_time', label: this.$t('createtime'), field: 'create_time', align: 'center' },
  139. { name: 'update_time', label: this.$t('updatetime'), field: 'update_time', align: 'right' }
  140. ],
  141. pagination: {
  142. page: 1,
  143. rowsPerPage: 11
  144. },
  145. createDate1: '',
  146. createDate2: '',
  147. date_range: '',
  148. searchUrl: '',
  149. downloadhUrl: 'stock/filebinlist/',
  150. current: 1,
  151. max: 0,
  152. total: 0,
  153. paginationIpt: 1
  154. }
  155. },
  156. computed: {
  157. interval () {
  158. return this.$t('download_center.start') + ' - ' + this.$t('download_center.end')
  159. }
  160. },
  161. watch: {
  162. createDate1 (val) {
  163. if (val) {
  164. if (val.to) {
  165. this.createDate2 = `${val.from} - ${val.to}`
  166. this.date_range = `${val.from},${val.to} 23:59:59`
  167. this.searchUrl = this.pathname + 'bin/?' + 'create_time__range=' + this.date_range
  168. this.downloadhUrl = this.pathname + 'filebinlist/?' + 'create_time__range=' + this.date_range
  169. } else {
  170. this.createDate2 = `${val}`
  171. this.dateArray = val.split('/')
  172. this.searchUrl = this.pathname + 'bin/?' + 'create_time__year=' + this.dateArray[0] + '&' + 'create_time__month=' + this.dateArray[1] + '&' + 'create_time__day=' + this.dateArray[2]
  173. this.downloadhUrl = this.pathname + 'filebinlist/?' + 'create_time__year=' + this.dateArray[0] + '&' + 'create_time__month=' + this.dateArray[1] + '&' + 'create_time__day=' + this.dateArray[2]
  174. }
  175. this.date_range = this.date_range.replace(/\//g, '-')
  176. this.getSearchList()
  177. this.$refs.qDateProxy.hide()
  178. }
  179. }
  180. },
  181. methods: {
  182. getList () {
  183. var _this = this
  184. getauth(_this.pathname + 'bin/' + '?page=' + '' + _this.current)
  185. .then(res => {
  186. _this.table_list = res.results
  187. _this.total = res.count
  188. if (res.count === 0) {
  189. _this.max = 0
  190. } else {
  191. if (Math.ceil(res.count / _this.pagination.rowsPerPage) === 1) {
  192. _this.max = 0
  193. } else {
  194. _this.max = Math.ceil(res.count / _this.pagination.rowsPerPage)
  195. }
  196. }
  197. _this.pathname_previous = res.previous
  198. _this.pathname_next = res.next
  199. })
  200. .catch(err => {
  201. _this.$q.notify({
  202. message: err.detail,
  203. icon: 'close',
  204. color: 'negative'
  205. })
  206. })
  207. },
  208. changePageEnter(e) {
  209. if (Number(this.paginationIpt) < 1) {
  210. this.current = 1;
  211. this.paginationIpt = 1;
  212. } else if (Number(this.paginationIpt) > this.max) {
  213. this.current = this.max;
  214. this.paginationIpt = this.max;
  215. } else {
  216. this.current = Number(this.paginationIpt);
  217. }
  218. this.getList();
  219. },
  220. getSearchList () {
  221. var _this = this
  222. _this.current = 1
  223. _this.paginationIpt = 1
  224. getauth(_this.searchUrl + '&page=' + '' + _this.current)
  225. .then(res => {
  226. _this.table_list = res.results
  227. _this.total = res.count
  228. if (res.count === 0) {
  229. _this.max = 0
  230. } else {
  231. if (Math.ceil(res.count / _this.pagination.rowsPerPage) === 1) {
  232. _this.max = 0
  233. } else {
  234. _this.max = Math.ceil(res.count / _this.pagination.rowsPerPage)
  235. }
  236. }
  237. _this.pathname_previous = res.previous
  238. _this.pathname_next = res.next
  239. })
  240. .catch(err => {
  241. _this.$q.notify({
  242. message: err.detail,
  243. icon: 'close',
  244. color: 'negative'
  245. })
  246. })
  247. },
  248. getListPrevious () {
  249. var _this = this
  250. getauth(_this.pathname_previous, {})
  251. .then(res => {
  252. _this.table_list = res.results
  253. _this.pathname_previous = res.previous
  254. _this.pathname_next = res.next
  255. })
  256. .catch(err => {
  257. _this.$q.notify({
  258. message: err.detail,
  259. icon: 'close',
  260. color: 'negative'
  261. })
  262. })
  263. },
  264. getListNext () {
  265. var _this = this
  266. getauth(_this.pathname_next, {})
  267. .then(res => {
  268. _this.table_list = res.results
  269. _this.pathname_previous = res.previous
  270. _this.pathname_next = res.next
  271. })
  272. .catch(err => {
  273. _this.$q.notify({
  274. message: err.detail,
  275. icon: 'close',
  276. color: 'negative'
  277. })
  278. })
  279. },
  280. downloadlistData () {
  281. var _this = this
  282. console.log(_this.downloadhUrl)
  283. getfile(_this.downloadhUrl).then(res => {
  284. var timeStamp = Date.now()
  285. var formattedString = date.formatDate(timeStamp, 'YYYYMMDDHHmmssSSS')
  286. const status = exportFile(_this.pathname + 'list' + formattedString + '.csv', '\uFEFF' + res.data, 'text/csv')
  287. if (status !== true) {
  288. _this.$q.notify({
  289. message: 'Browser denied file download...',
  290. color: 'negative',
  291. icon: 'warning'
  292. })
  293. }
  294. })
  295. },
  296. reset () {
  297. this.getList()
  298. this.downloadUrl = 'stock/filebinlist/'
  299. this.createDate2 = ''
  300. }
  301. },
  302. created () {
  303. var _this = this
  304. if (LocalStorage.has('openid')) {
  305. _this.openid = LocalStorage.getItem('openid')
  306. } else {
  307. _this.openid = ''
  308. LocalStorage.set('openid', '')
  309. }
  310. if (LocalStorage.has('login_name')) {
  311. _this.login_name = LocalStorage.getItem('login_name')
  312. } else {
  313. _this.login_name = ''
  314. LocalStorage.set('login_name', '')
  315. }
  316. if (LocalStorage.has('auth')) {
  317. _this.authin = '1'
  318. _this.getList()
  319. } else {
  320. _this.authin = '0'
  321. }
  322. },
  323. mounted () {
  324. var _this = this
  325. if (_this.$q.platform.is.electron) {
  326. _this.height = String(_this.$q.screen.height - 290) + 'px'
  327. } else {
  328. _this.height = _this.$q.screen.height - 290 + '' + 'px'
  329. }
  330. },
  331. updated () {},
  332. destroyed () {}
  333. }
  334. </script>