list.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <a-card size="small" :bordered="false" class="warehousingOrderList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper">
  6. <a-form-model
  7. id="warehousingOrderList-form"
  8. ref="ruleForm"
  9. class="form-model-con"
  10. layout="inline"
  11. :model="queryParam"
  12. :rules="rules"
  13. @keyup.enter.native="handleSearch">
  14. <a-row :gutter="15">
  15. <a-col :md="6" :sm="24">
  16. <a-form-model-item label="完成日期" prop="time">
  17. <rangeDateTime ref="rangeDate" :value="queryParam.time" @change="dateChange" />
  18. </a-form-model-item>
  19. </a-col>
  20. <a-col :md="5" :sm="24">
  21. <a-form-model-item label="入库单号">
  22. <a-input id="warehousingOrderList-stockPutNo" v-model.trim="queryParam.stockPutNo" allowClear placeholder="请输入入库单号"/>
  23. </a-form-model-item>
  24. </a-col>
  25. <a-col :md="5" :sm="24">
  26. <a-form-model-item label="入库类型">
  27. <v-select
  28. v-model="queryParam.putBizType"
  29. ref="putBizType"
  30. id="warehousingOrderList-putBizType"
  31. code="PUT_STOCK_TYPE_REPORT"
  32. placeholder="请选择入库类型"
  33. allowClear></v-select>
  34. </a-form-model-item>
  35. </a-col>
  36. <template v-if="advanced">
  37. <a-col :md="8" :sm="24">
  38. <a-form-model-item label="散件入库子类型">
  39. <v-select
  40. v-model="queryParam.sparePartsType"
  41. ref="sparePartsType"
  42. id="warehousingOrderList-sparePartsType"
  43. code="SPARE_PARTS_TYPE"
  44. placeholder="请选择散件入库子类型"
  45. allowClear></v-select>
  46. </a-form-model-item>
  47. </a-col>
  48. </template>
  49. <a-col :md="8" :sm="24" style="margin-bottom: 10px;">
  50. <a-button
  51. type="primary"
  52. class="button-info"
  53. size="small"
  54. @click="handleStock"
  55. id="warehousingOrderList-stockDate">盘点区间日期</a-button>
  56. <a-button style="margin-left: 5px" type="primary" @click="handleSearch" :disabled="disabled" id="warehousingOrderList-refresh">查询</a-button>
  57. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="warehousingOrderList-reset">重置</a-button>
  58. <a-button
  59. style="margin-left: 5px"
  60. type="primary"
  61. class="button-warning"
  62. @click="handleExport"
  63. :disabled="disabled"
  64. :loading="exportLoading"
  65. v-if="$hasPermissions('B_warehousingOrderExport')"
  66. id="warehousingOrderList-export">导出</a-button>
  67. <a @click="advanced=!advanced" style="margin-left: 5px">
  68. {{ advanced ? '收起' : '展开' }}
  69. <a-icon :type="advanced ? 'up' : 'down'"/>
  70. </a>
  71. </a-col>
  72. </a-row>
  73. </a-form-model>
  74. </div>
  75. <!-- 列表 -->
  76. <s-table
  77. class="sTable"
  78. ref="table"
  79. size="small"
  80. :rowKey="(record) => record.id"
  81. :columns="columns"
  82. :data="loadData"
  83. :defaultLoadData="false"
  84. bordered>
  85. <template slot="footer">
  86. <a-row :gutter="15">
  87. <a-col :md="4" :sm="24">
  88. 总数量:{{ (totalData && (totalData.productTotalQty || totalData.productTotalQty==0)) ? totalData.productTotalQty : '--' }}
  89. </a-col>
  90. <a-col :md="4" :sm="24" v-if="$hasPermissions('B_isShowCost')">
  91. 总金额:{{ (totalData && (totalData.productTotalCost || totalData.productTotalCost==0)) ? totalData.productTotalCost : '--' }}
  92. </a-col>
  93. </a-row>
  94. </template>
  95. </s-table>
  96. </a-spin>
  97. <!-- 导出提示框 -->
  98. <reportModal :visible="showExport" @close="showExport=false"></reportModal>
  99. </a-card>
  100. </template>
  101. <script>
  102. import { STable, VSelect } from '@/components'
  103. import rangeDateTime from '@/views/common/rangeDateTime.vue'
  104. import { hdExportExcel } from '@/libs/exportExcel'
  105. import reportModal from '@/views/common/reportModal.vue'
  106. import { reportStockPutList, reportStockPutCount, reportStockPutExport } from '@/api/reportData'
  107. export default {
  108. components: { STable, VSelect, rangeDateTime, reportModal },
  109. data () {
  110. return {
  111. spinning: false,
  112. advanced: false,
  113. tableHeight: 0,
  114. showExport: false,
  115. queryParam: { // 查询条件
  116. time: [],
  117. beginDate: '',
  118. endDate: '',
  119. stockPutNo: '',
  120. putBizType: undefined,
  121. sparePartsType: undefined
  122. },
  123. rules: {
  124. 'time': [{ required: true, message: '请选择完成日期', trigger: 'change' }]
  125. },
  126. disabled: false, // 查询、重置按钮是否可操作
  127. exportLoading: false,
  128. // 加载数据方法 必须为 Promise 对象
  129. loadData: parameter => {
  130. this.disabled = true
  131. this.spinning = true
  132. const params = Object.assign(parameter, this.queryParam)
  133. delete params.time
  134. return reportStockPutList(params).then(res => {
  135. let data
  136. if (res.status == 200) {
  137. data = res.data
  138. this.getCount(params)
  139. const no = (data.pageNo - 1) * data.pageSize
  140. for (var i = 0; i < data.list.length; i++) {
  141. data.list[i].no = no + i + 1
  142. }
  143. this.disabled = false
  144. }
  145. this.spinning = false
  146. return data
  147. })
  148. },
  149. totalData: null
  150. }
  151. },
  152. computed: {
  153. columns () {
  154. const arr = [
  155. { title: '入库单号', dataIndex: 'stockPutNo', width: '21%', align: 'center', customRender: function (text) { return text || '--' } },
  156. { title: '入库开单日期', dataIndex: 'createDate', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  157. { title: '单位名称', dataIndex: 'supplierName', width: '22%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  158. { title: '入库数量', dataIndex: 'productTotalQty', width: '11%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  159. // { title: '入库金额', dataIndex: 'productTotalCost', width: '11%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  160. { title: '入库类型', dataIndex: 'putBizTypeDictValue', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  161. { title: '散件入库子类型', dataIndex: 'sparePartsTypeDictValue', width: '11%', align: 'center', customRender: function (text) { return text || '--' } }
  162. ]
  163. if (this.$hasPermissions('B_isShowCost')) { // 成本价权限
  164. arr.splice(4, 0, { title: '入库金额', dataIndex: 'productTotalCost', width: '11%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  165. }
  166. return arr
  167. }
  168. },
  169. methods: {
  170. // 盘点库存日期
  171. handleStock () {
  172. this.$message.info('无盘点区间的起始/终止时间,请自行选择日期区间查询!')
  173. },
  174. // 总计
  175. getCount (params) {
  176. reportStockPutCount(params).then(res => {
  177. if (res.status == 200 && res.data) {
  178. this.totalData = res.data
  179. } else {
  180. this.totalData = null
  181. }
  182. })
  183. },
  184. handleSearch () {
  185. const _this = this
  186. this.$refs.ruleForm.validate(valid => {
  187. if (valid) {
  188. _this.$refs.table.refresh(true)
  189. } else {
  190. return false
  191. }
  192. })
  193. },
  194. // 创建时间 change
  195. dateChange (date) {
  196. if (date[0] && date[1]) {
  197. this.queryParam.time = date
  198. } else {
  199. this.queryParam.time = []
  200. }
  201. this.queryParam.beginDate = date[0] || ''
  202. this.queryParam.endDate = date[1] || ''
  203. },
  204. // 重置
  205. resetSearchForm () {
  206. this.$refs.rangeDate.resetDate()
  207. this.queryParam.time = []
  208. this.queryParam.beginDate = ''
  209. this.queryParam.endDate = ''
  210. this.queryParam.stockPutNo = ''
  211. this.queryParam.putBizType = undefined
  212. this.queryParam.sparePartsType = undefined
  213. this.totalData = null
  214. this.$refs.ruleForm.resetFields()
  215. this.$refs.table.clearTable()
  216. },
  217. // 导出
  218. handleExport () {
  219. const _this = this
  220. this.$refs.ruleForm.validate(valid => {
  221. if (valid) {
  222. const params = _this.queryParam
  223. _this.showExport = true
  224. _this.exportLoading = true
  225. _this.spinning = true
  226. hdExportExcel(reportStockPutExport, params, '入库单报表', function () {
  227. _this.exportLoading = false
  228. _this.spinning = false
  229. })
  230. } else {
  231. return false
  232. }
  233. })
  234. },
  235. filterOption (input, option) {
  236. return (
  237. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  238. )
  239. },
  240. pageInit () {}
  241. },
  242. mounted () {
  243. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  244. this.pageInit()
  245. this.resetSearchForm()
  246. }
  247. },
  248. activated () {
  249. // 如果是新页签打开,则重置当前页面
  250. if (this.$store.state.app.isNewTab) {
  251. this.pageInit()
  252. this.resetSearchForm()
  253. }
  254. },
  255. beforeRouteEnter (to, from, next) {
  256. next(vm => {})
  257. }
  258. }
  259. </script>