list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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)) ? toThousands(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)) ? toThousands(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)) ? toThousands(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)) ? toThousands(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. const _this = this
  118. return {
  119. moment,
  120. spinning: false,
  121. advanced: true, // 高级搜索 展开/关闭
  122. tableHeight: 0,
  123. queryParam: { // 查询条件
  124. auditDate: moment().format('YYYY-MM'),
  125. tenantId: undefined,
  126. productEntity: {
  127. code: '', // 产品编码
  128. name: '', // 产品名称
  129. productBrandSn: undefined, // 产品品牌
  130. productTypeSn1: '', // 产品一级分类
  131. productTypeSn2: '', // 产品二级分类
  132. productTypeSn3: '' // 产品三级分类
  133. }
  134. },
  135. labelCol: { span: 8 },
  136. wrapperCol: { span: 16 },
  137. rules: {
  138. 'tenantId': [{ required: true, message: '请选择连锁店', trigger: 'change' }],
  139. 'auditDate': [{ required: true, message: '请选择日期', trigger: 'change' }]
  140. },
  141. disabled: false, // 查询、重置按钮是否可操作
  142. exportLoading: false,
  143. columns: [
  144. { title: '产品编码', dataIndex: 'productCode', width: 120, align: 'left', customRender: function (text) { return text || '--' }, sorter: true },
  145. { title: '产品名称', dataIndex: 'productEntity.name', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  146. { title: '品牌', dataIndex: 'productEntity.productBrandName', width: 130, align: 'left', customRender: function (text) { return text || '--' } },
  147. { title: '三级分类', dataIndex: 'productEntity.productTypeName3', width: 130, align: 'left', customRender: function (text) { return text || '--' } },
  148. { title: '原厂编码', dataIndex: 'productEntity.origCode', width: 130, align: 'left', customRender: function (text) { return text || '--' } },
  149. { title: '单位', dataIndex: 'productEntity.unit', width: 50, align: 'center', customRender: function (text) { return text || '--' } },
  150. { title: '期初数量', dataIndex: 'beginQty', width: 80, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  151. { title: '期初单价(¥)', dataIndex: 'beginPrice', width: 100, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  152. { title: '期初金额(¥)', dataIndex: 'beginAmount', width: 100, align: 'right', sorter: true, customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  153. { title: '收入数量', dataIndex: 'putQty', width: 80, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  154. { title: '收入单价(¥)', dataIndex: 'putPrice', width: 100, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  155. { title: '收入金额(¥)', dataIndex: 'putAmount', width: 100, align: 'right', sorter: true, customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  156. { title: '发出数量', dataIndex: 'outQty', width: 80, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  157. { title: '发出单价(¥)', dataIndex: 'outPrice', width: 100, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  158. { title: '发出金额(¥)', dataIndex: 'outAmount', width: 100, align: 'right', sorter: true, customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  159. { title: '结存数量', dataIndex: 'endQty', width: 80, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  160. { title: '结存单价(¥)', dataIndex: 'endPrice', width: 100, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  161. { title: '结存金额(¥)', dataIndex: 'endAmount', width: 100, align: 'right', sorter: true, customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  162. ],
  163. // 加载数据方法 必须为 Promise 对象
  164. loadData: parameter => {
  165. this.disabled = true
  166. const params = Object.assign(parameter, this.queryParam)
  167. this.spinning = true
  168. if (this.queryParam.auditDate && this.queryParam.tenantId) {
  169. params.auditDate = this.queryParam.auditDate + '-01'
  170. // 总计
  171. this.getCount(params)
  172. return linkageReportPageList(params).then(res => {
  173. let data
  174. if (res.status == 200) {
  175. data = res.data
  176. const no = (data.pageNo - 1) * data.pageSize
  177. for (var i = 0; i < data.list.length; i++) {
  178. data.list[i].no = no + i + 1
  179. }
  180. this.disabled = false
  181. }
  182. this.spinning = false
  183. return data
  184. })
  185. } else {
  186. const _this = this
  187. return new Promise(function (resolve, reject) {
  188. const data = {
  189. pageNo: 1,
  190. pageSize: 10,
  191. list: [],
  192. count: 0
  193. }
  194. _this.disabled = false
  195. _this.spinning = false
  196. _this.$message.info('请选择连锁店和日期')
  197. resolve(data)
  198. })
  199. }
  200. },
  201. productType: [],
  202. linkageGroupData: [],
  203. totalData: null // 合计
  204. }
  205. },
  206. methods: {
  207. // 月份 change
  208. onChange (date, dateString) {
  209. this.queryParam.auditDate = dateString || null
  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. linkageReportPageTotal(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.queryParam.tenantId = undefined
  235. this.queryParam.auditDate = moment().format('YYYY-MM')
  236. this.queryParam.productEntity.code = ''
  237. this.queryParam.productEntity.name = ''
  238. this.queryParam.productEntity.productBrandSn = undefined
  239. this.queryParam.productEntity.productTypeSn1 = ''
  240. this.queryParam.productEntity.productTypeSn2 = ''
  241. this.queryParam.productEntity.productTypeSn3 = ''
  242. this.productType = []
  243. this.$refs.ruleForm.resetFields()
  244. this.totalData = null
  245. this.$refs.table.clearTable()
  246. },
  247. // 导出
  248. handleExport () {
  249. const _this = this
  250. this.$refs.ruleForm.validate(valid => {
  251. if (valid) {
  252. const params = _this.queryParam
  253. params.auditDate = params.auditDate + '-01'
  254. _this.exportLoading = true
  255. _this.spinning = true
  256. reportChainStockPutOutExport(params).then(res => {
  257. downloadExcel(res, '连锁收发存报表')
  258. _this.exportLoading = false
  259. _this.spinning = false
  260. })
  261. } else {
  262. return false
  263. }
  264. })
  265. },
  266. // 产品分类 change
  267. changeProductType (val, opt) {
  268. this.queryParam.productEntity.productTypeSn1 = val[0] ? val[0] : ''
  269. this.queryParam.productEntity.productTypeSn2 = val[1] ? val[1] : ''
  270. this.queryParam.productEntity.productTypeSn3 = val[2] ? val[2] : ''
  271. },
  272. filterOption (input, option) {
  273. return (
  274. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  275. )
  276. },
  277. // 连锁店
  278. getLinkageGroup () {
  279. linkageGroupList({}).then(res => {
  280. if (res.status == 200) {
  281. const data = res.data || []
  282. if (data.length > 0) {
  283. this.linkageGroupData = data
  284. } else {
  285. this.linkageGroupData = []
  286. }
  287. } else {
  288. this.linkageGroupData = []
  289. }
  290. })
  291. },
  292. pageInit () {
  293. this.getLinkageGroup()
  294. }
  295. },
  296. mounted () {
  297. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  298. this.pageInit()
  299. this.resetSearchForm()
  300. }
  301. },
  302. activated () {
  303. // 如果是新页签打开,则重置当前页面
  304. if (this.$store.state.app.isNewTab) {
  305. this.pageInit()
  306. this.resetSearchForm()
  307. }
  308. },
  309. beforeRouteEnter (to, from, next) {
  310. next(vm => {})
  311. }
  312. }
  313. </script>