purchaseReceiptOrder.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <div>
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form-model
  6. id="purchaseReceiptOrderList-form"
  7. ref="ruleForm"
  8. class="form-model-con"
  9. layout="inline"
  10. :model="queryParam"
  11. :rules="rules"
  12. :labelCol="labelCol"
  13. :wrapperCol="wrapperCol"
  14. @keyup.enter.native="handleSearch" >
  15. <a-row :gutter="15">
  16. <a-col :md="6" :sm="24">
  17. <a-form-model-item label="财务审核时间" prop="time">
  18. <rangeDate ref="rangeDate" @change="dateChange" />
  19. </a-form-model-item>
  20. </a-col>
  21. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  22. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="purchaseReceiptOrderList-refresh">查询</a-button>
  23. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="purchaseReceiptOrderList-reset">重置</a-button>
  24. <a-button
  25. style="margin-left: 5px"
  26. type="primary"
  27. class="button-warning"
  28. @click="handleExport"
  29. :disabled="disabled"
  30. :loading="exportLoading"
  31. v-if="$hasPermissions('B_purchaseReceiptReportExport')"
  32. id="purchaseReceiptOrderList-export">导出</a-button>
  33. </a-col>
  34. </a-row>
  35. </a-form-model>
  36. </div>
  37. <!-- 合计 -->
  38. <a-alert type="info" style="margin-bottom:10px">
  39. <div class="ftext" slot="message">
  40. 总单数:<strong>{{ (totalData && (totalData.totalPutCategory || totalData.totalPutCategory==0)) ? totalData.totalPutCategory : '--' }}</strong>;
  41. 采购总数量:<strong>{{ (totalData && (totalData.totalQty || totalData.totalQty==0)) ? totalData.totalQty : '--' }}</strong>;
  42. 采购总成本:<strong>{{ (totalData && (totalData.totalAmount || totalData.totalAmount==0)) ? '¥'+totalData.totalAmount : '--' }}</strong>;
  43. 入库总数量:<strong>{{ (totalData && (totalData.totalPutQty || totalData.totalPutQty==0)) ? totalData.totalPutQty : '--' }}</strong>;
  44. 入库总成本:<strong>{{ (totalData && (totalData.totalPutAmount || totalData.totalPutAmount==0)) ? '¥'+totalData.totalPutAmount : '--' }}</strong>;
  45. </div>
  46. </a-alert>
  47. <!-- 列表 -->
  48. <s-table
  49. class="sTable"
  50. ref="table"
  51. size="small"
  52. :rowKey="(record) => record.receivingBillSn"
  53. :columns="columns"
  54. :data="loadData"
  55. :defaultLoadData="false"
  56. bordered>
  57. </s-table>
  58. </div>
  59. </template>
  60. <script>
  61. import { STable, VSelect } from '@/components'
  62. import rangeDate from '@/views/common/rangeDate.vue'
  63. import { downloadExcel } from '@/libs/JGPrint.js'
  64. import { reportReceivingBillList, reportReceivingBillCount, reportReceivingBillExport } from '@/api/reportData'
  65. export default {
  66. components: { STable, VSelect, rangeDate },
  67. data () {
  68. return {
  69. labelCol: { span: 8 },
  70. wrapperCol: { span: 16 },
  71. queryParam: { // 查询条件
  72. time: [],
  73. beginDate: '',
  74. endDate: ''
  75. },
  76. productType: [],
  77. rules: {
  78. 'time': [{ required: true, message: '请选择财务审核时间', trigger: 'change' }]
  79. },
  80. disabled: false, // 查询、重置按钮是否可操作
  81. exportLoading: false,
  82. columns: [
  83. { title: '采购单号', dataIndex: 'purchaseBillNo', width: '17%', align: 'center', customRender: function (text) { return text || '--' } },
  84. { title: '采购入库单号', dataIndex: 'receivingBillNo', width: '17%', align: 'center', customRender: function (text) { return text || '--' } },
  85. { title: '入库款数', dataIndex: 'totalPutCategory', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  86. { title: '采购数量', dataIndex: 'totalQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  87. { title: '入库数量', dataIndex: 'totalPutQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  88. { title: '采购成本', dataIndex: 'totalAmount', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  89. { title: '入库成本', dataIndex: 'totalPutAmount', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  90. { title: '财务审核时间', dataIndex: 'auditTime', width: '16%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  91. ],
  92. // 加载数据方法 必须为 Promise 对象
  93. loadData: parameter => {
  94. this.disabled = true
  95. const params = Object.assign(parameter, this.queryParam)
  96. this.$emit('spinning', true)
  97. delete params.time
  98. if (params.beginDate) {
  99. return reportReceivingBillList(params).then(res => {
  100. let data
  101. if (res.status == 200) {
  102. data = res.data
  103. // 总计
  104. this.getCount(params)
  105. const no = (data.pageNo - 1) * data.pageSize
  106. for (var i = 0; i < data.list.length; i++) {
  107. data.list[i].no = no + i + 1
  108. }
  109. this.disabled = false
  110. }
  111. this.$emit('spinning', false)
  112. return data
  113. })
  114. } else {
  115. const _this = this
  116. return new Promise(function (resolve, reject) {
  117. const data = {
  118. pageNo: 1,
  119. pageSize: 10,
  120. list: [],
  121. count: 0
  122. }
  123. _this.disabled = false
  124. _this.$emit('spinning', false)
  125. _this.$message.info('请选择财务审核时间')
  126. resolve(data)
  127. })
  128. }
  129. },
  130. totalData: null // 合计
  131. }
  132. },
  133. methods: {
  134. // 合计
  135. getCount (params) {
  136. reportReceivingBillCount(params).then(res => {
  137. if (res.status == 200) {
  138. this.totalData = res.data
  139. } else {
  140. this.totalData = null
  141. }
  142. })
  143. },
  144. // 创建时间 change
  145. dateChange (date) {
  146. this.queryParam.time = date
  147. this.queryParam.beginDate = date[0] || ''
  148. this.queryParam.endDate = date[1] || ''
  149. },
  150. // 查询
  151. handleSearch () {
  152. this.$refs.ruleForm.validate(valid => {
  153. if (valid) {
  154. this.$refs.table.refresh(true)
  155. } else {
  156. console.log('error submit!!')
  157. return false
  158. }
  159. })
  160. },
  161. // 重置
  162. resetSearchForm () {
  163. this.$refs.rangeDate.resetDate()
  164. this.queryParam.time = []
  165. this.queryParam.beginDate = ''
  166. this.queryParam.endDate = ''
  167. this.$refs.ruleForm.resetFields()
  168. this.totalData = null
  169. this.$refs.table.clearTable()
  170. },
  171. // 导出
  172. handleExport () {
  173. const _this = this
  174. this.$refs.ruleForm.validate(valid => {
  175. if (valid) {
  176. const params = _this.queryParam
  177. _this.exportLoading = true
  178. _this.spinning = true
  179. reportReceivingBillExport(params).then(res => {
  180. downloadExcel(res, '采购入库单报表')
  181. _this.exportLoading = false
  182. _this.spinning = false
  183. })
  184. } else {
  185. return false
  186. }
  187. })
  188. }
  189. },
  190. mounted () {
  191. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  192. this.resetSearchForm()
  193. }
  194. },
  195. activated () {
  196. // 如果是新页签打开,则重置当前页面
  197. if (this.$store.state.app.isNewTab) {
  198. this.resetSearchForm()
  199. }
  200. },
  201. beforeRouteEnter (to, from, next) {
  202. next(vm => {})
  203. }
  204. }
  205. </script>
  206. <style>
  207. </style>