purchaseReceiptOrder.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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 moment from 'moment'
  62. import { STable, VSelect } from '@/components'
  63. import rangeDate from '@/views/common/rangeDate.vue'
  64. import { downloadExcel } from '@/libs/JGPrint.js'
  65. import { reportReceivingBillList, reportReceivingBillCount, reportReceivingBillExport } from '@/api/reportData'
  66. export default {
  67. components: { STable, VSelect, rangeDate },
  68. data () {
  69. return {
  70. labelCol: { span: 8 },
  71. wrapperCol: { span: 16 },
  72. queryParam: { // 查询条件
  73. time: [],
  74. beginDate: '',
  75. endDate: ''
  76. },
  77. productType: [],
  78. rules: {
  79. 'time': [{ required: true, message: '请选择财务审核时间', trigger: 'change' }]
  80. },
  81. disabled: false, // 查询、重置按钮是否可操作
  82. exportLoading: false,
  83. columns: [
  84. { title: '采购入库单号', dataIndex: 'receivingBillNo', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
  85. { title: '入库款数', dataIndex: 'totalPutCategory', width: '13%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  86. { title: '采购数量', dataIndex: 'totalQty', width: '13%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  87. { title: '入库数量', dataIndex: 'totalPutQty', width: '13%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  88. { title: '采购成本', dataIndex: 'totalAmount', width: '13%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  89. { title: '入库成本', dataIndex: 'totalPutAmount', width: '13%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  90. { title: '财务审核时间', dataIndex: 'auditTime', width: '17%', 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. // 总计
  101. this.getCount(params)
  102. const data = res.data
  103. const no = (data.pageNo - 1) * data.pageSize
  104. for (var i = 0; i < data.list.length; i++) {
  105. data.list[i].no = no + i + 1
  106. }
  107. this.disabled = false
  108. this.$emit('spinning', false)
  109. return data
  110. })
  111. } else {
  112. const _this = this
  113. return new Promise(function (resolve, reject) {
  114. const data = {
  115. pageNo: 1,
  116. pageSize: 10,
  117. list: [],
  118. count: 0
  119. }
  120. _this.disabled = false
  121. _this.$emit('spinning', false)
  122. _this.$message.info('请选择财务审核时间')
  123. resolve(data)
  124. })
  125. }
  126. },
  127. totalData: null // 合计
  128. }
  129. },
  130. methods: {
  131. // 合计
  132. getCount (params) {
  133. reportReceivingBillCount(params).then(res => {
  134. if (res.status == 200) {
  135. this.totalData = res.data
  136. } else {
  137. this.totalData = null
  138. }
  139. })
  140. },
  141. // 创建时间 change
  142. dateChange (date) {
  143. this.queryParam.time = date
  144. this.queryParam.beginDate = date[0] || ''
  145. this.queryParam.endDate = date[1] || ''
  146. },
  147. // 查询
  148. handleSearch () {
  149. this.$refs.ruleForm.validate(valid => {
  150. if (valid) {
  151. this.$refs.table.refresh(true)
  152. } else {
  153. console.log('error submit!!')
  154. return false
  155. }
  156. })
  157. },
  158. // 重置
  159. resetSearchForm () {
  160. this.$refs.rangeDate.resetDate()
  161. this.queryParam.time = []
  162. this.queryParam.beginDate = ''
  163. this.queryParam.endDate = ''
  164. this.$refs.ruleForm.resetFields()
  165. this.totalData = null
  166. this.$refs.table.clearTable()
  167. },
  168. // 导出
  169. handleExport () {
  170. const _this = this
  171. this.$refs.ruleForm.validate(valid => {
  172. if (valid) {
  173. const params = _this.queryParam
  174. _this.exportLoading = true
  175. _this.spinning = true
  176. reportReceivingBillExport(params).then(res => {
  177. const fileName = '采购入库单报表' + moment().format('YYYYMMDDHHmmss')
  178. downloadExcel(res, fileName)
  179. _this.exportLoading = false
  180. _this.spinning = false
  181. })
  182. } else {
  183. return false
  184. }
  185. })
  186. }
  187. },
  188. mounted () {
  189. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  190. this.resetSearchForm()
  191. }
  192. },
  193. activated () {
  194. // 如果是新页签打开,则重置当前页面
  195. if (this.$store.state.app.isNewTab) {
  196. this.resetSearchForm()
  197. }
  198. },
  199. beforeRouteEnter (to, from, next) {
  200. next(vm => {})
  201. }
  202. }
  203. </script>
  204. <style>
  205. </style>