purchaseReceiptDetail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <template>
  2. <div>
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form-model
  6. id="chainPurchaseReceiptDetailList-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="chainPurchaseReceiptDetailList-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">
  36. <a-form-item label="产品品牌">
  37. <ProductBrand id="chainPurchaseReceiptDetailList-productBrandSn" v-model="queryParam.productEntity.productBrandSn"></ProductBrand>
  38. </a-form-item>
  39. </a-col>
  40. <template v-if="advanced">
  41. <a-col :md="6" :sm="24">
  42. <a-form-model-item label="产品分类">
  43. <ProductType id="chainPurchaseReceiptDetailList-productType" @change="changeProductType" v-model="productType"></ProductType>
  44. </a-form-model-item>
  45. </a-col>
  46. <a-col :md="6" :sm="24">
  47. <a-form-model-item label="产品编码">
  48. <a-input id="salesDetailReportList-code" v-model.trim="queryParam.productEntity.code" allowClear placeholder="请输入产品编码"/>
  49. </a-form-model-item>
  50. </a-col>
  51. <a-col :md="6" :sm="24">
  52. <a-form-model-item label="产品名称">
  53. <a-input id="salesDetailReportList-name" v-model.trim="queryParam.productEntity.name" allowClear placeholder="请输入产品名称"/>
  54. </a-form-model-item>
  55. </a-col>
  56. </template>
  57. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  58. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="chainPurchaseReceiptDetailList-refresh">查询</a-button>
  59. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="chainPurchaseReceiptDetailList-reset">重置</a-button>
  60. <a-button
  61. style="margin-left: 5px"
  62. type="primary"
  63. class="button-warning"
  64. @click="handleExport"
  65. :disabled="disabled"
  66. :loading="exportLoading"
  67. v-if="$hasPermissions('B_chainPurchaseReceiptReportExport')"
  68. id="chainPurchaseReceiptDetailList-export">导出</a-button>
  69. <a @click="advanced=!advanced" style="margin-left: 5px">
  70. {{ advanced ? '收起' : '展开' }}
  71. <a-icon :type="advanced ? 'up' : 'down'"/>
  72. </a>
  73. </a-col>
  74. </a-row>
  75. </a-form-model>
  76. </div>
  77. <!-- 合计 -->
  78. <a-alert type="info" style="margin-bottom:10px">
  79. <div class="ftext" slot="message">
  80. 采购总数量:<strong>{{ (totalData && (totalData.qty || totalData.qty==0)) ? totalData.qty : '--' }}</strong>;
  81. 采购总成本:<strong>{{ (totalData && (totalData.totalAmount || totalData.totalAmount==0)) ? '¥'+totalData.totalAmount : '--' }}</strong>;
  82. 入库总数量:<strong>{{ (totalData && (totalData.putQty || totalData.putQty==0)) ? totalData.putQty : '--' }}</strong>;
  83. 入库总成本:<strong>{{ (totalData && (totalData.putAmount || totalData.putAmount==0)) ? '¥'+totalData.putAmount : '--' }}</strong>;
  84. </div>
  85. </a-alert>
  86. <!-- 列表 -->
  87. <s-table
  88. class="sTable"
  89. ref="table"
  90. size="small"
  91. :rowKey="(record) => record.receivingBillSn"
  92. :columns="columns"
  93. :data="loadData"
  94. :defaultLoadData="false"
  95. bordered>
  96. </s-table>
  97. </div>
  98. </template>
  99. <script>
  100. import moment from 'moment'
  101. import { STable, VSelect } from '@/components'
  102. import rangeDate from '@/views/common/rangeDate.vue'
  103. import ProductType from '../../common/productType.js'
  104. import ProductBrand from '../../common/productBrand.js'
  105. import { downloadExcel } from '@/libs/JGPrint.js'
  106. import { reportChainReceivingBillDetailList, reportChainReceivingBillDetailCount, reportReceivingBillDetailExport, linkageGroupList } from '@/api/reportData'
  107. export default {
  108. components: { STable, VSelect, rangeDate, ProductType, ProductBrand },
  109. data () {
  110. return {
  111. labelCol: { span: 8 },
  112. wrapperCol: { span: 16 },
  113. queryParam: { // 查询条件
  114. tenantId: undefined,
  115. time: [],
  116. beginDate: '',
  117. endDate: '',
  118. productEntity: {
  119. productBrandSn: undefined,
  120. productTypeSn1: undefined,
  121. productTypeSn2: undefined,
  122. productTypeSn3: undefined,
  123. code: '',
  124. name: ''
  125. }
  126. },
  127. productType: [],
  128. rules: {
  129. 'tenantId': [{ required: true, message: '请选择连锁店', trigger: 'change' }],
  130. 'time': [{ required: true, message: '请选择财务审核时间', trigger: 'change' }]
  131. },
  132. disabled: false, // 查询、重置按钮是否可操作
  133. advanced: true, // 高级搜索 展开/关闭
  134. exportLoading: false,
  135. columns: [
  136. { title: '采购单号', dataIndex: 'purchaseBillNo', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
  137. { title: '采购入库单号', dataIndex: 'receivingBillNo', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
  138. { title: '产品编码', dataIndex: 'productEntity.code', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  139. { title: '产品名称', dataIndex: 'productEntity.name', width: '16%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  140. { title: '单位', dataIndex: 'productEntity.unit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  141. { title: '采购数量', dataIndex: 'qty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  142. { title: '入库数量', dataIndex: 'putQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  143. { title: '采购成本', dataIndex: 'totalAmount', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  144. { title: '入库成本', dataIndex: 'putAmount', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  145. { title: '财务审核时间', dataIndex: 'auditTime', width: '12%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  146. ],
  147. // 加载数据方法 必须为 Promise 对象
  148. loadData: parameter => {
  149. this.disabled = true
  150. const params = Object.assign(parameter, this.queryParam)
  151. this.$emit('spinning', true)
  152. delete params.time
  153. if (params.beginDate) {
  154. return reportChainReceivingBillDetailList(params).then(res => {
  155. // 总计
  156. this.getCount(params)
  157. const data = res.data
  158. const no = (data.pageNo - 1) * data.pageSize
  159. for (var i = 0; i < data.list.length; i++) {
  160. data.list[i].no = no + i + 1
  161. }
  162. this.disabled = false
  163. this.$emit('spinning', false)
  164. return data
  165. })
  166. } else {
  167. const _this = this
  168. return new Promise(function (resolve, reject) {
  169. const data = {
  170. pageNo: 1,
  171. pageSize: 10,
  172. list: [],
  173. count: 0
  174. }
  175. _this.disabled = false
  176. _this.$emit('spinning', false)
  177. _this.$message.info('请选择财务审核时间')
  178. resolve(data)
  179. })
  180. }
  181. },
  182. totalData: null, // 合计
  183. linkageGroupData: []
  184. }
  185. },
  186. methods: {
  187. // 合计
  188. getCount (params) {
  189. reportChainReceivingBillDetailCount(params).then(res => {
  190. if (res.status == 200) {
  191. this.totalData = res.data
  192. } else {
  193. this.totalData = null
  194. }
  195. })
  196. },
  197. // 创建时间 change
  198. dateChange (date) {
  199. this.queryParam.time = date
  200. this.queryParam.beginDate = date[0] || ''
  201. this.queryParam.endDate = date[1] || ''
  202. },
  203. // 查询
  204. handleSearch () {
  205. this.$refs.ruleForm.validate(valid => {
  206. if (valid) {
  207. this.$refs.table.refresh(true)
  208. } else {
  209. console.log('error submit!!')
  210. return false
  211. }
  212. })
  213. },
  214. // 重置
  215. resetSearchForm () {
  216. this.queryParam.tenantId = undefined
  217. this.$refs.rangeDate.resetDate()
  218. this.queryParam.time = []
  219. this.queryParam.beginDate = ''
  220. this.queryParam.endDate = ''
  221. this.queryParam.productEntity.productBrandSn = undefined
  222. this.queryParam.productEntity.productTypeSn1 = ''
  223. this.queryParam.productEntity.productTypeSn2 = ''
  224. this.queryParam.productEntity.productTypeSn3 = ''
  225. this.queryParam.productEntity.code = ''
  226. this.queryParam.productEntity.name = ''
  227. this.productType = []
  228. this.$refs.ruleForm.resetFields()
  229. this.totalData = null
  230. this.$refs.table.clearTable()
  231. },
  232. filterOption (input, option) {
  233. return (
  234. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  235. )
  236. },
  237. // 产品分类 change
  238. changeProductType (val, opt) {
  239. this.queryParam.productEntity.productTypeSn1 = val[0] ? val[0] : ''
  240. this.queryParam.productEntity.productTypeSn2 = val[1] ? val[1] : ''
  241. this.queryParam.productEntity.productTypeSn3 = val[2] ? val[2] : ''
  242. },
  243. // 导出
  244. handleExport () {
  245. const _this = this
  246. this.$refs.ruleForm.validate(valid => {
  247. if (valid) {
  248. const params = _this.queryParam
  249. _this.exportLoading = true
  250. _this.spinning = true
  251. reportReceivingBillDetailExport(params).then(res => {
  252. const fileName = '连锁采购入库明细报表' + moment().format('YYYYMMDDHHmmss')
  253. downloadExcel(res, fileName)
  254. _this.exportLoading = false
  255. _this.spinning = false
  256. })
  257. } else {
  258. return false
  259. }
  260. })
  261. },
  262. // 连锁店
  263. getLinkageGroup () {
  264. linkageGroupList({}).then(res => {
  265. if (res.status == 200) {
  266. this.linkageGroupData = res.data || []
  267. } else {
  268. this.linkageGroupData = []
  269. }
  270. })
  271. }
  272. },
  273. mounted () {
  274. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  275. this.getLinkageGroup()
  276. this.resetSearchForm()
  277. }
  278. },
  279. activated () {
  280. // 如果是新页签打开,则重置当前页面
  281. if (this.$store.state.app.isNewTab) {
  282. this.getLinkageGroup()
  283. this.resetSearchForm()
  284. }
  285. },
  286. beforeRouteEnter (to, from, next) {
  287. next(vm => {})
  288. }
  289. }
  290. </script>
  291. <style>
  292. </style>