list.vue 11 KB

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