purchaseReceiptOrder.vue 9.1 KB

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