purchaseReceiptDetail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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 { commonMixin } from '@/utils/mixin'
  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. mixins: [commonMixin],
  110. data () {
  111. return {
  112. labelCol: { span: 8 },
  113. wrapperCol: { span: 16 },
  114. queryParam: { // 查询条件
  115. tenantId: undefined,
  116. time: [],
  117. beginDate: '',
  118. endDate: '',
  119. productEntity: {
  120. productBrandSn: undefined,
  121. productTypeSn1: undefined,
  122. productTypeSn2: undefined,
  123. productTypeSn3: undefined,
  124. code: '',
  125. name: ''
  126. }
  127. },
  128. productType: [],
  129. rules: {
  130. 'tenantId': [{ required: true, message: '请选择连锁店', trigger: 'change' }],
  131. 'time': [{ required: true, message: '请选择财务审核时间', trigger: 'change' }]
  132. },
  133. disabled: false, // 查询、重置按钮是否可操作
  134. advanced: true, // 高级搜索 展开/关闭
  135. exportLoading: false,
  136. columns: [
  137. { title: '采购单号', dataIndex: 'purchaseBillNo', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
  138. { title: '采购入库单号', dataIndex: 'receivingBillNo', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
  139. { title: '产品编码', dataIndex: 'productEntity.code', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  140. { title: '产品名称', dataIndex: 'productEntity.name', width: '16%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  141. { title: '单位', dataIndex: 'productEntity.unit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  142. { title: '采购数量', dataIndex: 'qty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  143. { title: '入库数量', dataIndex: 'putQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  144. { title: '采购成本', dataIndex: 'totalAmount', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  145. { title: '入库成本', dataIndex: 'putAmount', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  146. { title: '财务审核时间', dataIndex: 'auditTime', width: '12%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  147. ],
  148. // 加载数据方法 必须为 Promise 对象
  149. loadData: parameter => {
  150. this.disabled = true
  151. const params = Object.assign(parameter, this.queryParam)
  152. this.$emit('spinning', true)
  153. delete params.time
  154. if (params.beginDate) {
  155. return reportChainReceivingBillDetailList(params).then(res => {
  156. let data
  157. if (res.status == 200) {
  158. data = res.data
  159. // 总计
  160. this.getCount(params)
  161. const no = (data.pageNo - 1) * data.pageSize
  162. for (var i = 0; i < data.list.length; i++) {
  163. data.list[i].no = no + i + 1
  164. }
  165. this.disabled = false
  166. }
  167. this.$emit('spinning', false)
  168. return data
  169. })
  170. } else {
  171. const _this = this
  172. return new Promise(function (resolve, reject) {
  173. const data = {
  174. pageNo: 1,
  175. pageSize: 10,
  176. list: [],
  177. count: 0
  178. }
  179. _this.disabled = false
  180. _this.$emit('spinning', false)
  181. _this.$message.info('请选择财务审核时间')
  182. resolve(data)
  183. })
  184. }
  185. },
  186. totalData: null, // 合计
  187. linkageGroupData: []
  188. }
  189. },
  190. methods: {
  191. // 合计
  192. getCount (params) {
  193. reportChainReceivingBillDetailCount(params).then(res => {
  194. if (res.status == 200) {
  195. this.totalData = res.data
  196. } else {
  197. this.totalData = null
  198. }
  199. })
  200. },
  201. // 创建时间 change
  202. dateChange (date) {
  203. this.queryParam.time = date
  204. this.queryParam.beginDate = date[0] || ''
  205. this.queryParam.endDate = date[1] || ''
  206. },
  207. // 查询
  208. handleSearch () {
  209. this.$refs.ruleForm.validate(valid => {
  210. if (valid) {
  211. this.$refs.table.refresh(true)
  212. } else {
  213. console.log('error submit!!')
  214. return false
  215. }
  216. })
  217. },
  218. // 重置
  219. resetSearchForm () {
  220. this.queryParam.tenantId = undefined
  221. this.$refs.rangeDate.resetDate()
  222. this.queryParam.time = []
  223. this.queryParam.beginDate = ''
  224. this.queryParam.endDate = ''
  225. this.queryParam.productEntity.productBrandSn = undefined
  226. this.queryParam.productEntity.productTypeSn1 = ''
  227. this.queryParam.productEntity.productTypeSn2 = ''
  228. this.queryParam.productEntity.productTypeSn3 = ''
  229. this.queryParam.productEntity.code = ''
  230. this.queryParam.productEntity.name = ''
  231. this.productType = []
  232. this.$refs.ruleForm.resetFields()
  233. this.totalData = null
  234. this.$refs.table.clearTable()
  235. },
  236. filterOption (input, option) {
  237. return (
  238. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  239. )
  240. },
  241. // 产品分类 change
  242. changeProductType (val, opt) {
  243. this.queryParam.productEntity.productTypeSn1 = val[0] ? val[0] : ''
  244. this.queryParam.productEntity.productTypeSn2 = val[1] ? val[1] : ''
  245. this.queryParam.productEntity.productTypeSn3 = val[2] ? val[2] : ''
  246. },
  247. // 导出
  248. handleExport () {
  249. const _this = this
  250. this.$refs.ruleForm.validate(valid => {
  251. if (valid) {
  252. const params = _this.queryParam
  253. _this.exportLoading = true
  254. _this.spinning = true
  255. reportReceivingBillDetailExport(params).then(res => {
  256. downloadExcel(res, '连锁采购入库明细报表')
  257. _this.exportLoading = false
  258. _this.spinning = false
  259. })
  260. } else {
  261. return false
  262. }
  263. })
  264. },
  265. // 连锁店
  266. getLinkageGroup () {
  267. linkageGroupList({}).then(res => {
  268. if (res.status == 200) {
  269. this.linkageGroupData = res.data || []
  270. } else {
  271. this.linkageGroupData = []
  272. }
  273. })
  274. }
  275. },
  276. mounted () {
  277. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  278. this.getLinkageGroup()
  279. this.resetSearchForm()
  280. }
  281. },
  282. activated () {
  283. // 如果是新页签打开,则重置当前页面
  284. if (this.$store.state.app.isNewTab) {
  285. this.getLinkageGroup()
  286. this.resetSearchForm()
  287. }
  288. },
  289. beforeRouteEnter (to, from, next) {
  290. next(vm => {})
  291. }
  292. }
  293. </script>
  294. <style>
  295. </style>