list.vue 11 KB

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