list.vue 14 KB

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