list.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <template>
  2. <a-card size="small" :bordered="false" class="priceDifferenceDetailList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form-model
  7. id="priceDifferenceDetailList-form"
  8. ref="ruleForm"
  9. class="form-model-con"
  10. layout="inline"
  11. :model="queryParam"
  12. :rules="rules"
  13. @keyup.enter.native="handleSearch">
  14. <a-row :gutter="15">
  15. <a-col :md="4" :sm="24">
  16. <a-form-model-item label="所在区域">
  17. <subarea v-model="queryParam.subareaSn"></subarea>
  18. </a-form-model-item>
  19. </a-col>
  20. <a-col :md="6" :sm="24">
  21. <a-form-model-item label="日期" prop="time">
  22. <rangeDate ref="rangeDate" :value="queryParam.time" @change="dateChange" />
  23. </a-form-model-item>
  24. </a-col>
  25. <a-col :md="3" :sm="24">
  26. <a-form-model-item label="省份" prop="provinceSn">
  27. <a-select v-model="queryParam.provinceSn" allowClear placeholder="请选择省">
  28. <a-select-option v-for="item in addrProvinceList" :value="item.id" :key="item.id + 'a'">{{ item.name }}</a-select-option>
  29. </a-select>
  30. </a-form-model-item>
  31. </a-col>
  32. <a-col :md="5" :sm="24">
  33. <a-form-model-item label="记账门店">
  34. <custList id="priceDifferenceDetailList-rebateDealer" ref="rebateDealerList" @change="rebateDealerChange"></custList>
  35. </a-form-model-item>
  36. </a-col>
  37. <template v-if="advanced">
  38. <a-col :md="5" :sm="24">
  39. <a-form-model-item label="客户名称">
  40. <custList id="priceDifferenceDetailList-custList" ref="custList" :itemSn="queryParam.dealerSn" @change="custChange"></custList>
  41. </a-form-model-item>
  42. </a-col>
  43. </template>
  44. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  45. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="priceDifferenceDetailList-refresh">查询</a-button>
  46. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="priceDifferenceDetailList-reset">重置</a-button>
  47. <a-button
  48. style="margin-left: 5px"
  49. type="primary"
  50. class="button-warning"
  51. @click="handleExport"
  52. :disabled="disabled"
  53. :loading="exportLoading"
  54. v-if="$hasPermissions('B_priceDifferenceDetail_Export')"
  55. id="allocationDetailsList-export">导出</a-button>
  56. <a @click="advanced=!advanced" style="margin-left: 5px">
  57. {{ advanced ? '收起' : '展开' }}
  58. <a-icon :type="advanced ? 'up' : 'down'"/>
  59. </a>
  60. </a-col>
  61. </a-row>
  62. </a-form-model>
  63. </div>
  64. <!-- 列表 -->
  65. <s-table
  66. class="sTable"
  67. ref="table"
  68. size="small"
  69. :rowKey="(record) => record.id"
  70. :columns="columns"
  71. :data="loadData"
  72. :defaultLoadData="false"
  73. bordered>
  74. <template slot="footer">
  75. <a-row :gutter="15">
  76. <a-col :md="6" :sm="24" v-if="$hasPermissions('B_isShowPrice')">实售金额:{{ (totalData && (totalData.totalRealAmount || totalData.totalRealAmount==0)) ? totalData.totalRealAmount : '--' }}</a-col>
  77. <a-col :md="6" :sm="24" v-if="$hasPermissions('B_isShowPrice')">开单金额:{{ (totalData && (totalData.totalAmount || totalData.totalAmount==0)) ? totalData.totalAmount : '--' }}</a-col>
  78. <a-col :md="6" :sm="24" v-if="$hasPermissions('B_isShowPrice')">直接差额:{{ (totalData && (totalData.rebateAmount || totalData.rebateAmount==0)) ? totalData.rebateAmount : '--' }}</a-col>
  79. </a-row>
  80. </template>
  81. </s-table>
  82. </a-spin>
  83. <!-- 导出提示框 -->
  84. <reportModal :visible="showExport" @close="showExport=false"></reportModal>
  85. </a-card>
  86. </template>
  87. <script>
  88. import { commonMixin } from '@/utils/mixin'
  89. import getDate from '@/libs/getDate.js'
  90. import { STable, VSelect } from '@/components'
  91. import custList from '@/views/common/custList.vue'
  92. import { getArea } from '@/api/data'
  93. import subarea from '@/views/common/subarea.js'
  94. import rangeDate from '@/views/common/rangeDate.vue'
  95. import reportModal from '@/views/common/reportModal.vue'
  96. import { hdExportExcel } from '@/libs/exportExcel'
  97. import { reportRebateReportList, reportRebateCount, reportRebateExport } from '@/api/reportData'
  98. export default {
  99. name: 'PriceDifferenceDetailReportList',
  100. mixins: [commonMixin],
  101. components: { STable, VSelect, custList, subarea, rangeDate, reportModal },
  102. data () {
  103. return {
  104. spinning: false,
  105. advanced: false, // 高级搜索 展开/关闭
  106. exportLoading: false,
  107. showExport: false,
  108. queryParam: { // 查询条件
  109. time: [
  110. getDate.getCurrMonthDays().starttime,
  111. getDate.getCurrMonthDays().endtime
  112. ],
  113. beginDate: getDate.getCurrMonthDays().starttime,
  114. endDate: getDate.getCurrMonthDays().endtime,
  115. provinceSn: undefined,
  116. rebateDealerSn: undefined,
  117. dealerSn: undefined,
  118. subareaSn: undefined
  119. },
  120. rules: {
  121. 'time': [{ required: true, message: '请选择日期', trigger: 'change' }]
  122. // 'provinceSn': [{ required: true, message: '请选择省份', trigger: 'change' }]
  123. },
  124. disabled: false, // 查询、重置按钮是否可操作
  125. addrProvinceList: [], // 省下拉
  126. // 加载数据方法 必须为 Promise 对象
  127. loadData: parameter => {
  128. this.disabled = true
  129. const params = Object.assign(parameter, this.queryParam)
  130. delete params.time
  131. this.spinning = true
  132. return reportRebateReportList(params).then(res => {
  133. let data
  134. if (res.status == 200) {
  135. data = res.data
  136. // 总计
  137. this.getCount(params)
  138. const no = (data.pageNo - 1) * data.pageSize
  139. for (var i = 0; i < data.list.length; i++) {
  140. data.list[i].no = no + i + 1
  141. }
  142. this.disabled = false
  143. }
  144. this.spinning = false
  145. return data
  146. })
  147. },
  148. totalData: null
  149. }
  150. },
  151. computed: {
  152. columns () {
  153. const arr = [
  154. { title: '区域', dataIndex: 'dealerSubareaNameSet', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  155. { title: '日期', dataIndex: 'createDate', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  156. { title: '省份', dataIndex: 'provinceName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  157. { title: '记账门店', dataIndex: 'rebateDealerName', width: '15%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  158. { title: '客户名称', dataIndex: 'dealerName', width: '16%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  159. { title: '产品品牌+二级分类', dataIndex: 'productBrandAndType2', width: '15%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  160. { title: '类型', dataIndex: 'bizType', width: '10%', align: 'center', customRender: function (text) { return text || '--' } }
  161. ]
  162. if (this.$hasPermissions('B_isShowPrice')) { // 售价权限
  163. arr.splice(5, 0, { title: '实售金额', dataIndex: 'totalRealAmount', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  164. arr.splice(6, 0, { title: '开单金额', dataIndex: 'totalAmount', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  165. arr.splice(7, 0, { title: '直接差额', dataIndex: 'rebateAmount', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  166. }
  167. return arr
  168. }
  169. },
  170. methods: {
  171. // 创建时间 change
  172. dateChange (date) {
  173. if (date[0] && date[1]) {
  174. this.queryParam.time = date
  175. } else {
  176. this.queryParam.time = []
  177. }
  178. this.queryParam.beginDate = date[0] || ''
  179. this.queryParam.endDate = date[1] || ''
  180. },
  181. // 合计
  182. getCount (params) {
  183. reportRebateCount(params).then(res => {
  184. if (res.status == 200) {
  185. this.totalData = res.data
  186. } else {
  187. this.totalData = null
  188. }
  189. })
  190. },
  191. // 查询
  192. handleSearch () {
  193. const _this = this
  194. this.$refs.ruleForm.validate(valid => {
  195. if (valid) {
  196. _this.$refs.table.refresh(true)
  197. } else {
  198. console.log('error submit!!')
  199. return false
  200. }
  201. })
  202. },
  203. rebateDealerChange (val) {
  204. this.queryParam.rebateDealerSn = val.key
  205. },
  206. custChange (val) {
  207. this.queryParam.dealerSn = val.key
  208. },
  209. // 省/市/区
  210. getArea (leve, sn) {
  211. let params
  212. if (leve == 'province') {
  213. params = { type: '2' }
  214. } else {
  215. params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
  216. }
  217. getArea(params).then(res => {
  218. if (res.status == 200) {
  219. if (leve == 'province') {
  220. this.addrProvinceList = res.data || []
  221. } else if (leve == 'city') {
  222. this.addrCityList = res.data || []
  223. } else if (leve == 'district') {
  224. this.addrDistrictList = res.data || []
  225. }
  226. } else {
  227. if (leve == 'province') {
  228. this.addrProvinceList = []
  229. } else if (leve == 'city') {
  230. this.addrCityList = []
  231. } else if (leve == 'district') {
  232. this.addrDistrictList = []
  233. }
  234. }
  235. })
  236. },
  237. // 重置
  238. resetSearchForm () {
  239. this.queryParam.time = [
  240. getDate.getCurrMonthDays().starttime,
  241. getDate.getCurrMonthDays().endtime
  242. ]
  243. this.$refs.rangeDate.resetDate(this.queryParam.time)
  244. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  245. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  246. this.queryParam.provinceSn = undefined
  247. this.queryParam.rebateDealerSn = undefined
  248. this.queryParam.dealerSn = undefined
  249. this.queryParam.subareaSn = undefined
  250. this.$refs.rebateDealerList.resetForm()
  251. this.totalData = null
  252. if (this.advanced) {
  253. this.$refs.custList.resetForm()
  254. }
  255. this.$refs.ruleForm.resetFields()
  256. this.$refs.table.clearTable()
  257. },
  258. // 导出
  259. handleExport () {
  260. const _this = this
  261. this.$refs.ruleForm.validate(valid => {
  262. if (valid) {
  263. const params = _this.queryParam
  264. _this.showExport = true
  265. _this.exportLoading = true
  266. _this.spinning = true
  267. hdExportExcel(reportRebateExport, params, '差价明细报表', function () {
  268. _this.exportLoading = false
  269. _this.spinning = false
  270. })
  271. } else {
  272. return false
  273. }
  274. })
  275. },
  276. pageInit () {
  277. this.getArea('province')
  278. }
  279. },
  280. mounted () {
  281. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  282. this.pageInit()
  283. this.resetSearchForm()
  284. }
  285. },
  286. activated () {
  287. // 如果是新页签打开,则重置当前页面
  288. if (this.$store.state.app.isNewTab) {
  289. this.pageInit()
  290. this.resetSearchForm()
  291. }
  292. },
  293. beforeRouteEnter (to, from, next) {
  294. next(vm => {})
  295. }
  296. }
  297. </script>