list.vue 15 KB

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