list.vue 14 KB

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