list.vue 10 KB

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