list.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <div class="jg-page-wrap customerReportList-wrap">
  3. <a-card size="small" :bordered="false" class="table-page-search-wrapper">
  4. <!-- 搜索条件 -->
  5. <a-form-model
  6. id="customerReportList-form"
  7. ref="ruleForm"
  8. class="form-model-con"
  9. layout="inline"
  10. :model="queryParam"
  11. :rules="rules"
  12. :labelCol="labelCol"
  13. :wrapperCol="wrapperCol"
  14. @keyup.enter.native="handleSearch" >
  15. <a-row :gutter="15">
  16. <a-col :md="6" :sm="24">
  17. <a-form-model-item label="添加时间" prop="time">
  18. <rangeDate ref="rangeDate" @change="dateChange" />
  19. </a-form-model-item>
  20. </a-col>
  21. <a-col :md="6" :sm="24">
  22. <a-form-model-item label="客户名称">
  23. <custList id="chainSalesReportList-salesTargetName" ref="custSatelliteList" @change="custSatelliteChange"></custList>
  24. </a-form-model-item>
  25. </a-col>
  26. <a-col :md="6" :sm="24">
  27. <a-form-item label="客户类型">
  28. <custType v-model="queryParam.customerTypeSn" allowClear placeholder="请选择客户类型"></custType>
  29. </a-form-item>
  30. </a-col>
  31. <template v-if="advanced">
  32. <a-col :md="6" :sm="24">
  33. <a-form-item label="客户所在区">
  34. <AreaList id="chainSalesReportList-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
  35. </a-form-item>
  36. </a-col>
  37. <a-col :md="6" :sm="24">
  38. <a-form-model-item label="产品分类">
  39. <ProductType id="chainSalesReportList-productType" placeholder="请选择产品分类" @change="changeProductType" v-model="productType"></ProductType>
  40. </a-form-model-item>
  41. </a-col>
  42. </template>
  43. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  44. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="customerReportList-refresh">查询</a-button>
  45. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="customerReportList-reset">重置</a-button>
  46. <a @click="advanced=!advanced" style="margin-left: 8px">
  47. {{ advanced ? '收起' : '展开' }}
  48. <a-icon :type="advanced ? 'up' : 'down'"/>
  49. </a>
  50. </a-col>
  51. </a-row>
  52. </a-form-model>
  53. </a-card>
  54. <a-card size="small" :bordered="false">
  55. <a-spin :spinning="spinning" tip="Loading...">
  56. <!-- 合计 -->
  57. <div class="table-operator">
  58. <div class="alert-message">
  59. 总交易金额:<strong>{{ (totalData && (totalData.discountedAmount || totalData.discountedAmount==0)) ? toThousands(totalData.discountedAmount) : '--' }}</strong>;
  60. <div style="display: inline-block;" v-if="$hasPermissions('M_ShowAllCost')">
  61. 总毛利:<strong>{{ (totalData && totalData.totalGrossProfit) ? toThousands(totalData.totalGrossProfit) : '--' }}</strong>;
  62. 总毛利率:<strong>{{ (totalData && totalData.percentage) ? totalData.percentage+'%' : '--' }}</strong>;
  63. </div>
  64. </div>
  65. </div>
  66. <!-- 列表 -->
  67. <s-table
  68. class="sTable"
  69. ref="table"
  70. size="small"
  71. :rowKey="(record) => record.no"
  72. rowKeyName="no"
  73. :columns="columns"
  74. :data="loadData"
  75. :defaultLoadData="false"
  76. bordered>
  77. </s-table>
  78. </a-spin>
  79. </a-card>
  80. </div>
  81. </template>
  82. <script>
  83. import { commonMixin } from '@/utils/mixin'
  84. import { STable, VSelect } from '@/components'
  85. import rangeDate from '@/views/common/rangeDate.vue'
  86. import custList from '@/views/common/custList.vue'
  87. import AreaList from '@/views/common/areaList.js'
  88. import custType from '@/views/common/custType.js'
  89. import ProductType from '@/views/common/productType.js'
  90. import { reportBigCustomerList, reportBigCustomerCount } from '@/api/reportData'
  91. export default {
  92. mixins: [commonMixin],
  93. name: 'CustomerReport',
  94. components: { STable, VSelect, rangeDate, custType, custList, AreaList, ProductType },
  95. data () {
  96. return {
  97. spinning: false,
  98. labelCol: { span: 8 },
  99. wrapperCol: { span: 16 },
  100. advanced: true, // 高级搜索 展开/关闭
  101. tableHeight: 0,
  102. queryParam: { // 查询条件
  103. time: [],
  104. beginDate: '',
  105. endDate: '',
  106. productTypeSn1: '', // 产品一级分类
  107. productTypeSn2: '', // 产品二级分类
  108. productTypeSn3: '', // 产品三级分类
  109. provinceSn: undefined, // 省
  110. citySn: undefined, // 市
  111. countySn: undefined, // 区
  112. customerTypeSn: undefined, // 客户类型,
  113. customerName: undefined,
  114. customerSn: undefined
  115. },
  116. productType: [],
  117. rules: {
  118. 'time': [{ required: true, message: '请选择添加时间', trigger: 'change' }]
  119. },
  120. disabled: false, // 查询、重置按钮是否可操作
  121. exportLoading: false,
  122. // 加载数据方法 必须为 Promise 对象
  123. loadData: parameter => {
  124. this.disabled = true
  125. const params = Object.assign(parameter, this.queryParam)
  126. this.spinning = true
  127. delete params.time
  128. if (params.beginDate) {
  129. return reportBigCustomerList(params).then(res => {
  130. let data
  131. if (res.status == 200) {
  132. data = res.data
  133. // 总计
  134. this.getCount(params)
  135. const no = (data.pageNo - 1) * data.pageSize
  136. for (var i = 0; i < data.list.length; i++) {
  137. data.list[i].no = no + i + 1
  138. data.list[i].percentageUnit = data.list[i].percentage ? data.list[i].percentage + '%' : undefined
  139. }
  140. this.disabled = false
  141. }
  142. this.spinning = false
  143. return data
  144. })
  145. } else {
  146. const _this = this
  147. return new Promise(function (resolve, reject) {
  148. const data = {
  149. pageNo: 1,
  150. pageSize: 10,
  151. list: [],
  152. count: 0
  153. }
  154. _this.disabled = false
  155. _this.spinning = false
  156. _this.$message.info('请选择添加时间')
  157. resolve(data)
  158. })
  159. }
  160. },
  161. totalData: null, // 合计
  162. addrProvinceList: [], // 省下拉
  163. addrCityList: [], // 市下拉
  164. addrDistrictList: [] // 区下拉
  165. }
  166. },
  167. computed: {
  168. columns () {
  169. const _this = this
  170. const arr = [
  171. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  172. { title: '客户名称', dataIndex: 'salesTargetName', width: '35%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true, sorter: true },
  173. { title: '客户类型', dataIndex: 'customerTypeName', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  174. { title: '交易金额', dataIndex: 'discountedAmount', width: '15%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') }, sorter: true }
  175. ]
  176. if (this.$hasPermissions('M_ShowAllCost')) {
  177. arr.splice(4, 0, { title: '毛利', dataIndex: 'totalGrossProfit', width: '15%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  178. arr.splice(5, 0, { title: '毛利率', dataIndex: 'percentageUnit', width: '15%', align: 'right', customRender: function (text) { return text || '--' }, sorter: true })
  179. }
  180. return arr
  181. }
  182. },
  183. methods: {
  184. areaChange (val) {
  185. this.queryParam.provinceSn = val[0] ? val[0] : ''
  186. this.queryParam.citySn = val[1] ? val[1] : ''
  187. this.queryParam.districtSn = val[2] ? val[2] : ''
  188. },
  189. // 合计
  190. getCount (params) {
  191. reportBigCustomerCount(params).then(res => {
  192. if (res.status == 200) {
  193. this.totalData = res.data
  194. } else {
  195. this.totalData = null
  196. }
  197. })
  198. },
  199. // 创建时间 change
  200. dateChange (date) {
  201. this.queryParam.time = date
  202. this.queryParam.beginDate = date[0] || ''
  203. this.queryParam.endDate = date[1] || ''
  204. },
  205. custSatelliteChange (v, row) {
  206. if (row && row.customerSn) {
  207. this.queryParam.customerSn = row.customerSn
  208. this.queryParam.customerName = row.customerName
  209. } else {
  210. this.queryParam.customerName = v
  211. this.queryParam.customerSn = undefined
  212. }
  213. },
  214. // 查询
  215. handleSearch () {
  216. this.$refs.ruleForm.validate(valid => {
  217. if (valid) {
  218. this.$refs.table.refresh(true)
  219. } else {
  220. this.$message.error('添加时间不能为空!')
  221. return false
  222. }
  223. })
  224. },
  225. // 重置
  226. resetSearchForm () {
  227. this.$refs.rangeDate.resetDate()
  228. this.queryParam.time = []
  229. this.queryParam.beginDate = ''
  230. this.queryParam.endDate = ''
  231. this.queryParam.productTypeSn1 = ''
  232. this.queryParam.productTypeSn2 = ''
  233. this.queryParam.productTypeSn3 = ''
  234. this.queryParam.provinceSn = undefined
  235. this.queryParam.citySn = undefined
  236. this.queryParam.countySn = undefined
  237. this.queryParam.customerTypeSn = undefined
  238. this.queryParam.customerSn = undefined
  239. this.queryParam.customerName = undefined
  240. this.productType = []
  241. this.$refs.ruleForm.resetFields()
  242. this.$refs.custSatelliteList.resetForm()
  243. if (this.advanced) {
  244. this.$refs.areaList.clearData()
  245. }
  246. this.totalData = null
  247. this.$refs.table.clearTable()
  248. },
  249. filterOption (input, option) {
  250. return (
  251. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  252. )
  253. },
  254. // 产品分类 change
  255. changeProductType (val, opt) {
  256. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  257. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  258. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  259. }
  260. },
  261. mounted () {
  262. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  263. this.resetSearchForm()
  264. }
  265. },
  266. activated () {
  267. // 如果是新页签打开,则重置当前页面
  268. if (this.$store.state.app.isNewTab) {
  269. this.resetSearchForm()
  270. }
  271. },
  272. beforeRouteEnter (to, from, next) {
  273. next(vm => {})
  274. }
  275. }
  276. </script>