purchaseReceiptDetail.vue 12 KB

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