list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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. <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.no"
  81. rowKeyName="no"
  82. :columns="columns"
  83. :data="loadData"
  84. :defaultLoadData="false"
  85. bordered>
  86. </s-table>
  87. </a-spin>
  88. </a-card>
  89. </div>
  90. </template>
  91. <script>
  92. import { commonMixin } from '@/utils/mixin'
  93. import { STable, VSelect } from '@/components'
  94. import rangeDate from '@/views/common/rangeDate.vue'
  95. import custList from '@/views/common/custList.vue'
  96. import AreaList from '@/views/common/areaList.js'
  97. import custType from '@/views/common/custType.js'
  98. // import { getArea } from '@/api/data'
  99. import { dealerProductTypeList } from '@/api/dealerProductType'
  100. import { reportBigCustomerList, reportBigCustomerCount } from '@/api/reportData'
  101. export default {
  102. mixins: [commonMixin],
  103. components: { STable, VSelect, rangeDate, custType, custList, AreaList },
  104. data () {
  105. return {
  106. spinning: false,
  107. labelCol: { span: 8 },
  108. wrapperCol: { span: 16 },
  109. advanced: true, // 高级搜索 展开/关闭
  110. tableHeight: 0,
  111. queryParam: { // 查询条件
  112. time: [],
  113. beginDate: '',
  114. endDate: '',
  115. productTypeSn1: '', // 产品一级分类
  116. productTypeSn2: '', // 产品二级分类
  117. productTypeSn3: '', // 产品三级分类
  118. provinceSn: undefined, // 省
  119. citySn: undefined, // 市
  120. countySn: undefined, // 区
  121. customerTypeSn: undefined, // 客户类型,
  122. customerName: undefined,
  123. customerSn: undefined
  124. },
  125. productType: [],
  126. rules: {
  127. 'time': [{ required: true, message: '请选择添加时间', trigger: 'change' }]
  128. },
  129. disabled: false, // 查询、重置按钮是否可操作
  130. exportLoading: false,
  131. // 加载数据方法 必须为 Promise 对象
  132. loadData: parameter => {
  133. this.disabled = true
  134. const params = Object.assign(parameter, this.queryParam)
  135. this.spinning = true
  136. delete params.time
  137. if (params.beginDate) {
  138. return reportBigCustomerList(params).then(res => {
  139. let data
  140. if (res.status == 200) {
  141. data = res.data
  142. // 总计
  143. this.getCount(params)
  144. const no = (data.pageNo - 1) * data.pageSize
  145. for (var i = 0; i < data.list.length; i++) {
  146. data.list[i].no = no + i + 1
  147. data.list[i].percentageUnit = data.list[i].percentage ? data.list[i].percentage + '%' : undefined
  148. }
  149. this.disabled = false
  150. }
  151. this.spinning = false
  152. return data
  153. })
  154. } else {
  155. const _this = this
  156. return new Promise(function (resolve, reject) {
  157. const data = {
  158. pageNo: 1,
  159. pageSize: 10,
  160. list: [],
  161. count: 0
  162. }
  163. _this.disabled = false
  164. _this.spinning = false
  165. _this.$message.info('请选择添加时间')
  166. resolve(data)
  167. })
  168. }
  169. },
  170. totalData: null, // 合计
  171. addrProvinceList: [], // 省下拉
  172. addrCityList: [], // 市下拉
  173. addrDistrictList: [], // 区下拉
  174. productTypeList: [] // 分类下拉数据
  175. }
  176. },
  177. computed: {
  178. columns () {
  179. const _this = this
  180. const arr = [
  181. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  182. { title: '客户名称', dataIndex: 'salesTargetName', width: '35%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true, sorter: true },
  183. { title: '客户类型', dataIndex: 'customerTypeName', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  184. { title: '交易金额', dataIndex: 'discountedAmount', width: '15%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') }, sorter: true }
  185. ]
  186. if (this.$hasPermissions('M_ShowAllCost')) {
  187. arr.splice(4, 0, { title: '毛利', dataIndex: 'totalGrossProfit', width: '15%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  188. arr.splice(5, 0, { title: '毛利率', dataIndex: 'percentageUnit', width: '15%', align: 'right', customRender: function (text) { return text || '--' }, sorter: true })
  189. }
  190. return arr
  191. }
  192. },
  193. methods: {
  194. areaChange (val) {
  195. this.queryParam.provinceSn = val[0] ? val[0] : ''
  196. this.queryParam.citySn = val[1] ? val[1] : ''
  197. this.queryParam.districtSn = val[2] ? val[2] : ''
  198. },
  199. // 合计
  200. getCount (params) {
  201. reportBigCustomerCount(params).then(res => {
  202. if (res.status == 200) {
  203. this.totalData = res.data
  204. } else {
  205. this.totalData = null
  206. }
  207. })
  208. },
  209. // 创建时间 change
  210. dateChange (date) {
  211. this.queryParam.time = date
  212. this.queryParam.beginDate = date[0] || ''
  213. this.queryParam.endDate = date[1] || ''
  214. },
  215. custSatelliteChange (v, row) {
  216. if (row && row.customerSn) {
  217. this.queryParam.customerSn = row.customerSn
  218. this.queryParam.customerName = row.customerName
  219. } else {
  220. this.queryParam.customerName = v
  221. this.queryParam.customerSn = undefined
  222. }
  223. },
  224. // 查询
  225. handleSearch () {
  226. this.$refs.ruleForm.validate(valid => {
  227. if (valid) {
  228. this.$refs.table.refresh(true)
  229. } else {
  230. this.$message.error('添加时间不能为空!')
  231. return false
  232. }
  233. })
  234. },
  235. // 重置
  236. resetSearchForm () {
  237. this.$refs.rangeDate.resetDate()
  238. this.queryParam.time = []
  239. this.queryParam.beginDate = ''
  240. this.queryParam.endDate = ''
  241. this.queryParam.productTypeSn1 = ''
  242. this.queryParam.productTypeSn2 = ''
  243. this.queryParam.productTypeSn3 = ''
  244. this.queryParam.provinceSn = undefined
  245. this.queryParam.citySn = undefined
  246. this.queryParam.countySn = undefined
  247. this.queryParam.customerTypeSn = undefined
  248. this.queryParam.customerSn = undefined
  249. this.queryParam.customerName = undefined
  250. this.productType = []
  251. this.$refs.ruleForm.resetFields()
  252. this.$refs.custSatelliteList.resetForm()
  253. this.totalData = null
  254. this.$refs.table.clearTable()
  255. },
  256. filterOption (input, option) {
  257. return (
  258. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  259. )
  260. },
  261. // 产品分类 change
  262. changeProductType (val, opt) {
  263. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  264. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  265. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  266. },
  267. // 产品分类 列表
  268. getProductType () {
  269. dealerProductTypeList({}).then(res => {
  270. if (res.status == 200) {
  271. this.productTypeList = res.data
  272. } else {
  273. this.productTypeList = []
  274. }
  275. })
  276. },
  277. pageInit () {
  278. this.getProductType()
  279. }
  280. },
  281. mounted () {
  282. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  283. this.pageInit()
  284. this.resetSearchForm()
  285. }
  286. },
  287. activated () {
  288. // 如果是新页签打开,则重置当前页面
  289. if (this.$store.state.app.isNewTab) {
  290. this.pageInit()
  291. this.resetSearchForm()
  292. }
  293. },
  294. beforeRouteEnter (to, from, next) {
  295. next(vm => {})
  296. }
  297. }
  298. </script>