list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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 id="receivedSendStorageReportList-time" ref="rangeDate" :value="queryParam.time" @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" id="receivedSendStorageReportList-advanced">
  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.putQty || totalData.putQty==0)) ? totalData.putQty : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  78. 收入金额:{{ (totalData && (totalData.putAmount || totalData.putAmount==0)) ? toThousands(totalData.putAmount) : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  79. 发出数量:{{ (totalData && (totalData.outQty || totalData.outQty==0)) ? totalData.outQty : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  80. 发出金额:{{ (totalData && (totalData.outAmount || totalData.outAmount==0)) ? toThousands(totalData.outAmount) : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  81. 结存数量:{{ (totalData && (totalData.endQty || totalData.endQty==0)) ? totalData.endQty : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  82. 结存金额:{{ (totalData && (totalData.endAmount || totalData.endAmount==0)) ? toThousands(totalData.endAmount) : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  83. <!-- 冻结数量:{{ (totalData && (totalData.freezeQty || totalData.freezeQty==0)) ? totalData.freezeQty : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  84. 冻结金额:{{ (totalData && (totalData.freezeAmount || totalData.freezeAmount==0)) ? toThousands(totalData.freezeAmount) : '--' }} -->
  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 getDate from '@/libs/getDate.js'
  95. import rangeDate from '@/views/common/rangeDate.vue'
  96. import { downloadExcel } from '@/libs/JGPrint.js'
  97. import ProductType from '../../common/productType.js'
  98. import ProductBrand from '../../common/productBrand.js'
  99. import moment from 'moment'
  100. import { reportPageList, reportStockPutOutCount, reportStockPutOutExport } from '@/api/reportData'
  101. export default {
  102. components: { STable, VSelect, rangeDate, ProductType, ProductBrand },
  103. mixins: [commonMixin],
  104. data () {
  105. const _this = this
  106. return {
  107. advanced: true, // 高级搜索 展开/关闭
  108. spinning: false,
  109. tableHeight: 0,
  110. queryParam: { // 查询条件
  111. time: [ // 时间
  112. // getDate.getMonthDays(3).starttime,
  113. // getDate.getMonthDays(3).endtime
  114. ],
  115. // beginDate: getDate.getMonthDays(3).starttime,
  116. // endDate: getDate.getMonthDays(3).endtime,
  117. beginDate: '', // 开始时间
  118. endDate: '', // 结束时间
  119. productEntity: {
  120. code: '', // 产品编码
  121. name: '', // 产品名称
  122. productBrandSn: undefined, // 产品品牌
  123. productTypeSn1: '', // 产品一级分类
  124. productTypeSn2: '', // 产品二级分类
  125. productTypeSn3: '' // 产品三级分类
  126. }
  127. },
  128. labelCol: { span: 8 },
  129. wrapperCol: { span: 16 },
  130. rules: {
  131. 'time': [{ required: true, message: '请选择日期(最多查看一年)', trigger: 'change' }]
  132. },
  133. disabled: false, // 查询、重置按钮是否可操作
  134. exportLoading: false,
  135. columns: [
  136. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  137. { title: '产品编码', dataIndex: 'productCode', width: 120, align: 'left', customRender: function (text) { return text || '--' }, sorter: true },
  138. { title: '产品名称', dataIndex: 'productEntity.name', width: 150, align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  139. { title: '品牌', dataIndex: 'productEntity.productBrandName', width: 130, align: 'left', customRender: function (text) { return text || '--' } },
  140. { title: '三级分类', dataIndex: 'productEntity.productTypeName3', width: 130, align: 'left', customRender: function (text) { return text || '--' } },
  141. { title: '原厂编码', dataIndex: 'productEntity.origCode', width: 120, align: 'left', customRender: function (text) { return text || '--' } },
  142. { title: '单位', dataIndex: 'productEntity.unit', width: 50, align: 'center', customRender: function (text) { return text || '--' } },
  143. { title: '收入数量', dataIndex: 'putQty', width: 80, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  144. { title: '收入单价', dataIndex: 'putPrice', width: 100, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  145. { title: '收入金额', dataIndex: 'putAmount', width: 100, align: 'right', sorter: true, customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  146. { title: '发出数量(含冻结)', dataIndex: 'outQty', width: 80, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  147. { title: '发出单价', dataIndex: 'outPrice', width: 100, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  148. { title: '发出金额(含冻结)', dataIndex: 'outAmount', width: 100, align: 'right', sorter: true, customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  149. { title: '结存数量(含冻结)', dataIndex: 'endQty', width: 80, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  150. { title: '结存单价', dataIndex: 'endPrice', width: 100, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  151. { title: '结存金额(含冻结)', dataIndex: 'endAmount', width: 100, align: 'right', sorter: true, customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  152. { title: '冻结数量', dataIndex: 'freezeQty', width: 80, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  153. { title: '冻结单价', dataIndex: 'freezePrice', width: 100, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  154. { title: '冻结金额', dataIndex: 'freezeAmount', width: 100, align: 'right', sorter: true, customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  155. ],
  156. // 加载数据方法 必须为 Promise 对象
  157. loadData: parameter => {
  158. this.disabled = true
  159. const params = Object.assign(parameter, this.queryParam)
  160. this.spinning = true
  161. if (this.queryParam.beginDate) {
  162. return reportPageList(params).then(res => {
  163. let data
  164. if (res.status == 200) {
  165. data = res.data
  166. // 总计
  167. this.getCount(params)
  168. const no = (data.pageNo - 1) * data.pageSize
  169. for (var i = 0; i < data.list.length; i++) {
  170. data.list[i].no = no + i + 1
  171. }
  172. this.disabled = false
  173. }
  174. this.spinning = false
  175. return data
  176. })
  177. } else {
  178. const _this = this
  179. return new Promise(function (resolve, reject) {
  180. const data = {
  181. pageNo: 1,
  182. pageSize: 10,
  183. list: [],
  184. count: 0
  185. }
  186. _this.disabled = false
  187. _this.spinning = false
  188. _this.$message.info('请选择日期')
  189. resolve(data)
  190. })
  191. }
  192. },
  193. productType: [], // 产品分类
  194. totalData: {} // 合计
  195. }
  196. },
  197. methods: {
  198. // 时间 change
  199. dateChange (date) {
  200. this.queryParam.time = date
  201. this.queryParam.beginDate = date[0] || ''
  202. this.queryParam.endDate = date[1] || ''
  203. },
  204. // 查询
  205. handleSearch () {
  206. this.$refs.ruleForm.validate(valid => {
  207. if (valid) {
  208. const a = moment(this.queryParam.beginDate)
  209. const b = moment(this.queryParam.endDate).subtract(1, 'days')
  210. if (b.diff(a, 'days') > 365) {
  211. this.$message.info('最多只能查询一年')
  212. return false
  213. }
  214. this.$refs.table.refresh(true)
  215. } else {
  216. console.log('error submit!!')
  217. return false
  218. }
  219. })
  220. },
  221. // 查询总计
  222. getCount (params) {
  223. reportStockPutOutCount(params).then(res => {
  224. if (res.status == 200 && res.data) {
  225. this.totalData = res.data
  226. } else {
  227. this.totalData = null
  228. }
  229. })
  230. },
  231. // 重置
  232. resetSearchForm () {
  233. // this.$refs.rangeDate.resetDate(this.queryParam.time)
  234. // this.queryParam.beginDate = getDate.getMonthDays(3).starttime
  235. // this.queryParam.endDate = getDate.getMonthDays(3).endtime
  236. this.$refs.rangeDate.resetDate()
  237. this.queryParam.beginDate = ''
  238. this.queryParam.endDate = ''
  239. this.queryParam.productEntity.code = ''
  240. this.queryParam.productEntity.name = ''
  241. this.queryParam.productEntity.productBrandSn = undefined
  242. this.queryParam.productEntity.productTypeSn1 = ''
  243. this.queryParam.productEntity.productTypeSn2 = ''
  244. this.queryParam.productEntity.productTypeSn3 = ''
  245. this.productType = []
  246. this.totalData = null
  247. this.$refs.table.clearTable()
  248. this.$refs.ruleForm.resetFields()
  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. reportStockPutOutExport(params).then(res => {
  259. downloadExcel(res, '收发存报表')
  260. _this.exportLoading = false
  261. _this.spinning = false
  262. })
  263. } else {
  264. return false
  265. }
  266. })
  267. },
  268. // 产品分类 change
  269. changeProductType (val, opt) {
  270. this.queryParam.productEntity.productTypeSn1 = val[0] ? val[0] : ''
  271. this.queryParam.productEntity.productTypeSn2 = val[1] ? val[1] : ''
  272. this.queryParam.productEntity.productTypeSn3 = val[2] ? val[2] : ''
  273. },
  274. pageInit () {
  275. }
  276. },
  277. mounted () {
  278. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  279. this.resetSearchForm()
  280. }
  281. },
  282. activated () {
  283. // 如果是新页签打开,则重置当前页面
  284. if (this.$store.state.app.isNewTab) {
  285. this.resetSearchForm()
  286. }
  287. },
  288. beforeRouteEnter (to, from, next) {
  289. next(vm => {})
  290. }
  291. }
  292. </script>