purchaseReceiptOrder.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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" :id="item.dealerSn" :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 id="chainPurchaseReceiptOrderList-time" 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)) ? toThousands(totalData.totalAmount) : '--' }}</strong>;
  57. 入库总数量:<strong>{{ (totalData && (totalData.totalPutQty || totalData.totalPutQty==0)) ? totalData.totalPutQty : '--' }}</strong>;
  58. 入库总成本:<strong>{{ (totalData && (totalData.totalPutAmount || totalData.totalPutAmount==0)) ? toThousands(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. const _this = this
  85. return {
  86. labelCol: { span: 8 },
  87. wrapperCol: { span: 16 },
  88. queryParam: { // 查询条件
  89. tenantId: undefined, // 连锁店id
  90. time: [],
  91. beginDate: '',
  92. endDate: ''
  93. },
  94. productType: [],
  95. rules: {
  96. 'tenantId': [{ required: true, message: '请选择连锁店', trigger: 'change' }],
  97. 'time': [{ required: true, message: '请选择财务审核时间', trigger: 'change' }]
  98. },
  99. disabled: false, // 查询、重置按钮是否可操作
  100. exportLoading: false,
  101. columns: [
  102. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  103. { title: '采购单号', dataIndex: 'purchaseBillNo', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
  104. { title: '采购入库单号', dataIndex: 'receivingBillNo', width: '16%', align: 'center', customRender: function (text) { return text || '--' } },
  105. { title: '入库款数', dataIndex: 'totalPutCategory', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  106. { title: '采购数量', dataIndex: 'totalQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  107. { title: '入库数量', dataIndex: 'totalPutQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  108. { title: '采购成本', dataIndex: 'totalAmount', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  109. { title: '入库成本', dataIndex: 'totalPutAmount', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  110. { title: '财务审核时间', dataIndex: 'auditTime', width: '16%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  111. ],
  112. // 加载数据方法 必须为 Promise 对象
  113. loadData: parameter => {
  114. this.disabled = true
  115. const params = Object.assign(parameter, this.queryParam)
  116. this.$emit('spinning', true)
  117. delete params.time
  118. if (params.beginDate) {
  119. return reportChainReceivingBillList(params).then(res => {
  120. let data
  121. if (res.status == 200) {
  122. data = res.data
  123. // 总计
  124. this.getCount(params)
  125. const no = (data.pageNo - 1) * data.pageSize
  126. for (var i = 0; i < data.list.length; i++) {
  127. data.list[i].no = no + i + 1
  128. }
  129. this.disabled = false
  130. }
  131. this.$emit('spinning', false)
  132. return data
  133. })
  134. } else {
  135. const _this = this
  136. return new Promise(function (resolve, reject) {
  137. const data = {
  138. pageNo: 1,
  139. pageSize: 10,
  140. list: [],
  141. count: 0
  142. }
  143. _this.disabled = false
  144. _this.$emit('spinning', false)
  145. _this.$message.info('请选择财务审核时间')
  146. resolve(data)
  147. })
  148. }
  149. },
  150. totalData: null, // 合计
  151. linkageGroupData: [] // 连锁店列表
  152. }
  153. },
  154. methods: {
  155. // 合计
  156. getCount (params) {
  157. reportChainReceivingBillCount(params).then(res => {
  158. if (res.status == 200) {
  159. this.totalData = res.data
  160. } else {
  161. this.totalData = null
  162. }
  163. })
  164. },
  165. // 创建时间 change
  166. dateChange (date) {
  167. this.queryParam.time = date
  168. this.queryParam.beginDate = date[0] || ''
  169. this.queryParam.endDate = date[1] || ''
  170. },
  171. // 查询
  172. handleSearch () {
  173. this.$refs.ruleForm.validate(valid => {
  174. if (valid) {
  175. this.$refs.table.refresh(true)
  176. } else {
  177. console.log('error submit!!')
  178. return false
  179. }
  180. })
  181. },
  182. // 重置
  183. resetSearchForm () {
  184. this.queryParam.tenantId = undefined
  185. this.$refs.rangeDate.resetDate()
  186. this.queryParam.time = []
  187. this.queryParam.beginDate = ''
  188. this.queryParam.endDate = ''
  189. this.$refs.ruleForm.resetFields()
  190. this.totalData = null
  191. this.$refs.table.clearTable()
  192. },
  193. // 连锁店筛选
  194. filterOption (input, option) {
  195. return (
  196. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  197. )
  198. },
  199. // 导出
  200. handleExport () {
  201. const _this = this
  202. this.$refs.ruleForm.validate(valid => {
  203. if (valid) {
  204. const params = _this.queryParam
  205. _this.exportLoading = true
  206. _this.spinning = true
  207. reportReceivingBillExport(params).then(res => {
  208. downloadExcel(res, '连锁采购入库单报表')
  209. _this.exportLoading = false
  210. _this.spinning = false
  211. })
  212. } else {
  213. return false
  214. }
  215. })
  216. },
  217. // 连锁店
  218. getLinkageGroup () {
  219. linkageGroupList({}).then(res => {
  220. if (res.status == 200) {
  221. this.linkageGroupData = res.data || []
  222. } else {
  223. this.linkageGroupData = []
  224. }
  225. })
  226. }
  227. },
  228. mounted () {
  229. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  230. this.getLinkageGroup()
  231. this.resetSearchForm()
  232. }
  233. },
  234. activated () {
  235. // 如果是新页签打开,则重置当前页面
  236. if (this.$store.state.app.isNewTab) {
  237. this.getLinkageGroup()
  238. this.resetSearchForm()
  239. }
  240. },
  241. beforeRouteEnter (to, from, next) {
  242. next(vm => {})
  243. }
  244. }
  245. </script>
  246. <style>
  247. </style>