purchaseReceiptDetail.vue 11 KB

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