list.vue 11 KB

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