list.vue 14 KB

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