purchaseReceiptDetail.vue 9.8 KB

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