list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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. <a-select
  36. placeholder="请选择产品品牌"
  37. id="receivedSendStorageReportList-productBrandSn"
  38. allowClear
  39. v-model="queryParam.productEntity.productBrandSn"
  40. :showSearch="true"
  41. option-filter-prop="children"
  42. :filter-option="filterOption">
  43. <a-select-option v-for="item in productBrandList" :key="item.brandSn" :value="item.brandSn">{{ item.brandName }}</a-select-option>
  44. </a-select>
  45. </a-form-model-item>
  46. </a-col>
  47. <a-col :md="6" :sm="24">
  48. <a-form-model-item label="产品分类">
  49. <a-cascader
  50. @change="changeProductType"
  51. change-on-select
  52. v-model="productType"
  53. expand-trigger="hover"
  54. :options="productTypeList"
  55. :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
  56. id="receivedSendStorageReportList-productType"
  57. placeholder="请选择产品分类"
  58. allowClear />
  59. </a-form-model-item>
  60. </a-col>
  61. </template>
  62. <a-col :md="6" :sm="24">
  63. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="receivedSendStorageReportList-refresh">查询</a-button>
  64. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="receivedSendStorageReportList-reset">重置</a-button>
  65. <a-button
  66. style="margin-left: 5px"
  67. type="primary"
  68. class="button-warning"
  69. @click="handleExport"
  70. v-if="$hasPermissions('B_receivedSendStorageReportExport')"
  71. :disabled="disabled"
  72. :loading="exportLoading"
  73. id="receivedSendStorageReportList-export">导出</a-button>
  74. <a @click="advanced=!advanced" style="margin-left: 5px">
  75. {{ advanced ? '收起' : '展开' }}
  76. <a-icon :type="advanced ? 'up' : 'down'"/>
  77. </a>
  78. </a-col>
  79. </a-row>
  80. </a-form-model>
  81. </div>
  82. <!-- 列表 -->
  83. <s-table
  84. class="sTable"
  85. ref="table"
  86. size="small"
  87. :rowKey="(record) => record.id"
  88. :columns="columns"
  89. :data="loadData"
  90. :scroll="{ x: 1820 }"
  91. :defaultLoadData="false"
  92. bordered>
  93. <template slot="footer">
  94. <span>
  95. 合计: 期初数量:{{ (totalData && (totalData.beginQty || totalData.beginQty==0)) ? totalData.beginQty : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  96. 期初金额:{{ (totalData && (totalData.beginAmount || totalData.beginAmount==0)) ? totalData.beginAmount : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  97. 收入数量:{{ (totalData && (totalData.putQty || totalData.putQty==0)) ? totalData.putQty : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  98. 收入金额:{{ (totalData && (totalData.putAmount || totalData.putAmount==0)) ? totalData.putAmount : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  99. 发出数量:{{ (totalData && (totalData.outQty || totalData.outQty==0)) ? totalData.outQty : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  100. 发出金额:{{ (totalData && (totalData.outAmount || totalData.outAmount==0)) ? totalData.outAmount : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  101. 结存数量:{{ (totalData && (totalData.endQty || totalData.endQty==0)) ? totalData.endQty : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  102. 结存金额:{{ (totalData && (totalData.endAmount || totalData.endAmount==0)) ? totalData.endAmount : '--' }}
  103. </span>
  104. </template>
  105. </s-table>
  106. </a-spin>
  107. </a-card>
  108. </template>
  109. <script>
  110. import moment from 'moment'
  111. import { STable, VSelect } from '@/components'
  112. import { dealerProductBrandQuery } from '@/api/dealerProductBrand'
  113. import { dealerProductTypeList } from '@/api/dealerProductType'
  114. import rangeDate from '@/views/common/rangeDate.vue'
  115. import { downloadExcel } from '@/libs/JGPrint.js'
  116. import { reportPageList, reportStockPutOutCount, reportStockPutOutExport } from '@/api/reportData'
  117. export default {
  118. components: { STable, VSelect, rangeDate },
  119. data () {
  120. return {
  121. advanced: true, // 高级搜索 展开/关闭
  122. spinning: false,
  123. tableHeight: 0,
  124. queryParam: { // 查询条件
  125. time: [],
  126. beginDate: '',
  127. endDate: '',
  128. productEntity: {
  129. code: '', // 产品编码
  130. name: '', // 产品名称
  131. productBrandSn: undefined, // 产品品牌
  132. productTypeSn1: '', // 产品一级分类
  133. productTypeSn2: '', // 产品二级分类
  134. productTypeSn3: '' // 产品三级分类
  135. }
  136. },
  137. labelCol: { span: 8 },
  138. wrapperCol: { span: 16 },
  139. rules: {
  140. 'time': [{ required: true, message: '请选择日期', trigger: 'change' }]
  141. },
  142. disabled: false, // 查询、重置按钮是否可操作
  143. exportLoading: false,
  144. columns: [
  145. { title: '产品编码', dataIndex: 'productCode', width: 120, align: 'left', customRender: function (text) { return text || '--' }, sorter: true },
  146. { title: '产品名称', dataIndex: 'productEntity.name', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  147. { title: '品牌', dataIndex: 'productEntity.productBrandName', width: 130, align: 'left', customRender: function (text) { return text || '--' } },
  148. { title: '三级分类', dataIndex: 'productEntity.productTypeName3', width: 130, align: 'left', customRender: function (text) { return text || '--' } },
  149. { title: '原厂编码', dataIndex: 'productEntity.origCode', width: 120, align: 'left', customRender: function (text) { return text || '--' } },
  150. { title: '单位', dataIndex: 'productEntity.unit', width: 50, align: 'center', customRender: function (text) { return text || '--' } },
  151. { title: '期初数量', dataIndex: 'beginQty', width: 80, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  152. { title: '期初单价(¥)', dataIndex: 'beginPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  153. { title: '期初金额(¥)', dataIndex: 'beginAmount', width: 100, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  154. { title: '收入数量', dataIndex: 'putQty', width: 80, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  155. { title: '收入单价(¥)', dataIndex: 'putPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  156. { title: '收入金额(¥)', dataIndex: 'putAmount', width: 100, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  157. { title: '发出数量', dataIndex: 'outQty', width: 80, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  158. { title: '发出单价(¥)', dataIndex: 'outPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  159. { title: '发出金额(¥)', dataIndex: 'outAmount', width: 100, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  160. { title: '结存数量', dataIndex: 'endQty', width: 80, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  161. { title: '结存单价(¥)', dataIndex: 'endPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  162. { title: '结存金额(¥)', dataIndex: 'endAmount', width: 100, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  163. ],
  164. // 加载数据方法 必须为 Promise 对象
  165. loadData: parameter => {
  166. this.disabled = true
  167. const params = Object.assign(parameter, this.queryParam)
  168. this.spinning = true
  169. if (this.queryParam.beginDate) {
  170. return reportPageList(params).then(res => {
  171. // 总计
  172. this.getCount(params)
  173. const data = res.data
  174. const no = (data.pageNo - 1) * data.pageSize
  175. for (var i = 0; i < data.list.length; i++) {
  176. data.list[i].no = no + i + 1
  177. }
  178. this.disabled = false
  179. this.spinning = false
  180. return data
  181. })
  182. } else {
  183. const _this = this
  184. return new Promise(function (resolve, reject) {
  185. const data = {
  186. pageNo: 1,
  187. pageSize: 10,
  188. list: [],
  189. count: 0
  190. }
  191. _this.disabled = false
  192. _this.spinning = false
  193. _this.$message.info('请选择日期')
  194. resolve(data)
  195. })
  196. }
  197. },
  198. productType: [],
  199. productBrandList: [], // 品牌下拉数据
  200. productTypeList: [], // 分类下拉数据
  201. totalData: {} // 合计
  202. }
  203. },
  204. methods: {
  205. // 时间 change
  206. dateChange (date) {
  207. this.queryParam.time = date
  208. this.queryParam.beginDate = date[0] || ''
  209. this.queryParam.endDate = date[1] || ''
  210. },
  211. // 查询
  212. handleSearch () {
  213. this.$refs.ruleForm.validate(valid => {
  214. if (valid) {
  215. this.$refs.table.refresh(true)
  216. } else {
  217. console.log('error submit!!')
  218. return false
  219. }
  220. })
  221. },
  222. // 查询总计
  223. getCount (params) {
  224. reportStockPutOutCount(params).then(res => {
  225. if (res.status == 200 && res.data) {
  226. this.totalData = res.data
  227. } else {
  228. this.totalData = null
  229. }
  230. })
  231. },
  232. // 重置
  233. resetSearchForm () {
  234. this.$refs.rangeDate.resetDate()
  235. this.queryParam.time = []
  236. this.queryParam.beginDate = ''
  237. this.queryParam.endDate = ''
  238. this.queryParam.productEntity.code = ''
  239. this.queryParam.productEntity.name = ''
  240. this.queryParam.productEntity.productBrandSn = undefined
  241. this.queryParam.productEntity.productTypeSn1 = ''
  242. this.queryParam.productEntity.productTypeSn2 = ''
  243. this.queryParam.productEntity.productTypeSn3 = ''
  244. this.productType = []
  245. this.$refs.ruleForm.resetFields()
  246. this.totalData = null
  247. this.$refs.table.clearTable()
  248. },
  249. // 导出
  250. handleExport () {
  251. const _this = this
  252. this.$refs.ruleForm.validate(valid => {
  253. if (valid) {
  254. const params = _this.queryParam
  255. _this.exportLoading = true
  256. _this.spinning = true
  257. reportStockPutOutExport(params).then(res => {
  258. const fileName = '收发存报表' + moment().format('YYYYMMDDHHmmss')
  259. downloadExcel(res, fileName)
  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. // 产品品牌 列表
  275. getProductBrand () {
  276. dealerProductBrandQuery({}).then(res => {
  277. if (res.status == 200) {
  278. this.productBrandList = res.data
  279. } else {
  280. this.productBrandList = []
  281. }
  282. })
  283. },
  284. // 产品分类 列表
  285. getProductType () {
  286. dealerProductTypeList({}).then(res => {
  287. if (res.status == 200) {
  288. this.productTypeList = res.data
  289. } else {
  290. this.productTypeList = []
  291. }
  292. })
  293. },
  294. filterOption (input, option) {
  295. return (
  296. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  297. )
  298. },
  299. pageInit () {
  300. this.getProductBrand()
  301. this.getProductType()
  302. }
  303. },
  304. mounted () {
  305. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  306. this.pageInit()
  307. this.resetSearchForm()
  308. }
  309. },
  310. activated () {
  311. // 如果是新页签打开,则重置当前页面
  312. if (this.$store.state.app.isNewTab) {
  313. this.pageInit()
  314. this.resetSearchForm()
  315. }
  316. },
  317. beforeRouteEnter (to, from, next) {
  318. next(vm => {})
  319. }
  320. }
  321. </script>