list.vue 13 KB

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