list.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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. </a-card>
  98. </template>
  99. <script>
  100. import { STable, VSelect } from '@/components'
  101. import rangeDateTime from '@/views/common/rangeDateTime.vue'
  102. import { hdExportExcel } from '@/libs/exportExcel'
  103. import { reportStockPutList, reportStockPutCount, reportStockPutExport } from '@/api/reportData'
  104. export default {
  105. components: { STable, VSelect, rangeDateTime },
  106. data () {
  107. return {
  108. spinning: false,
  109. advanced: false,
  110. tableHeight: 0,
  111. queryParam: { // 查询条件
  112. time: [],
  113. beginDate: '',
  114. endDate: '',
  115. stockPutNo: '',
  116. putBizType: undefined,
  117. sparePartsType: undefined
  118. },
  119. rules: {
  120. 'time': [{ required: true, message: '请选择完成日期', trigger: 'change' }]
  121. },
  122. disabled: false, // 查询、重置按钮是否可操作
  123. exportLoading: false,
  124. // 加载数据方法 必须为 Promise 对象
  125. loadData: parameter => {
  126. this.disabled = true
  127. this.spinning = true
  128. const params = Object.assign(parameter, this.queryParam)
  129. delete params.time
  130. return reportStockPutList(params).then(res => {
  131. let data
  132. if (res.status == 200) {
  133. data = res.data
  134. this.getCount(params)
  135. const no = (data.pageNo - 1) * data.pageSize
  136. for (var i = 0; i < data.list.length; i++) {
  137. data.list[i].no = no + i + 1
  138. }
  139. this.disabled = false
  140. }
  141. this.spinning = false
  142. return data
  143. })
  144. },
  145. totalData: null
  146. }
  147. },
  148. computed: {
  149. columns () {
  150. const arr = [
  151. { title: '入库单号', dataIndex: 'stockPutNo', width: '21%', align: 'center', customRender: function (text) { return text || '--' } },
  152. { title: '入库开单日期', dataIndex: 'createDate', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  153. { title: '单位名称', dataIndex: 'supplierName', width: '22%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  154. { title: '入库数量', dataIndex: 'productTotalQty', width: '11%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  155. // { title: '入库金额', dataIndex: 'productTotalCost', width: '11%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  156. { title: '入库类型', dataIndex: 'putBizTypeDictValue', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  157. { title: '散件入库子类型', dataIndex: 'sparePartsTypeDictValue', width: '11%', align: 'center', customRender: function (text) { return text || '--' } }
  158. ]
  159. if (this.$hasPermissions('B_isShowCost')) { // 成本价权限
  160. arr.splice(4, 0, { title: '入库金额', dataIndex: 'productTotalCost', width: '11%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  161. }
  162. return arr
  163. }
  164. },
  165. methods: {
  166. // 盘点库存日期
  167. handleStock () {
  168. this.$message.info('无盘点区间的起始/终止时间,请自行选择日期区间查询!')
  169. },
  170. // 总计
  171. getCount (params) {
  172. reportStockPutCount(params).then(res => {
  173. if (res.status == 200 && res.data) {
  174. this.totalData = res.data
  175. } else {
  176. this.totalData = null
  177. }
  178. })
  179. },
  180. handleSearch () {
  181. const _this = this
  182. this.$refs.ruleForm.validate(valid => {
  183. if (valid) {
  184. _this.$refs.table.refresh(true)
  185. } else {
  186. return false
  187. }
  188. })
  189. },
  190. // 创建时间 change
  191. dateChange (date) {
  192. if (date[0] && date[1]) {
  193. this.queryParam.time = date
  194. } else {
  195. this.queryParam.time = []
  196. }
  197. this.queryParam.beginDate = date[0] || ''
  198. this.queryParam.endDate = date[1] || ''
  199. },
  200. // 重置
  201. resetSearchForm () {
  202. this.$refs.rangeDate.resetDate()
  203. this.queryParam.time = []
  204. this.queryParam.beginDate = ''
  205. this.queryParam.endDate = ''
  206. this.queryParam.stockPutNo = ''
  207. this.queryParam.putBizType = undefined
  208. this.queryParam.sparePartsType = undefined
  209. this.totalData = null
  210. this.$refs.ruleForm.resetFields()
  211. this.$refs.table.clearTable()
  212. },
  213. // 导出
  214. handleExport () {
  215. const _this = this
  216. this.$refs.ruleForm.validate(valid => {
  217. if (valid) {
  218. const params = _this.queryParam
  219. _this.exportLoading = true
  220. _this.spinning = true
  221. hdExportExcel(reportStockPutExport, params, '入库单报表', function () {
  222. _this.exportLoading = false
  223. _this.spinning = false
  224. })
  225. } else {
  226. return false
  227. }
  228. })
  229. },
  230. filterOption (input, option) {
  231. return (
  232. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  233. )
  234. },
  235. pageInit () {}
  236. },
  237. mounted () {
  238. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  239. this.pageInit()
  240. this.resetSearchForm()
  241. }
  242. },
  243. activated () {
  244. // 如果是新页签打开,则重置当前页面
  245. if (this.$store.state.app.isNewTab) {
  246. this.pageInit()
  247. this.resetSearchForm()
  248. }
  249. },
  250. beforeRouteEnter (to, from, next) {
  251. next(vm => {})
  252. }
  253. }
  254. </script>