list.vue 15 KB

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