ProductStatistics.vue 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <template>
  2. <div
  3. v-loading="loading"
  4. class="main-container">
  5. <filtrate-handle-view
  6. title="产品销售情况统计"
  7. class="filtrate-bar"
  8. module-type="product"
  9. @load="loading=true"
  10. @change="getProductDatalist">
  11. <el-button
  12. class="export-button"
  13. type="primary"
  14. @click.native="exportClick">导出</el-button>
  15. </filtrate-handle-view>
  16. <div class="content">
  17. <el-table
  18. id="crm-table"
  19. ref="tableRef"
  20. :data="list"
  21. :height="tableHeight"
  22. :cell-class-name="cellClassName"
  23. :summary-method="getSummaries"
  24. show-summary
  25. border
  26. @row-click="handleRowClick">
  27. <el-table-column
  28. v-for="(item, index) in headFieldList"
  29. :key="index"
  30. :prop="item.field"
  31. :label="item.name"
  32. align="center"
  33. header-align="center"
  34. show-overflow-tooltip/>
  35. </el-table>
  36. <div class="p-contianer">
  37. <el-pagination
  38. :current-page="currentPage"
  39. :page-sizes="pageSizes"
  40. :page-size.sync="pageSize"
  41. :total="total"
  42. :pager-count="5"
  43. class="p-bar"
  44. background
  45. layout="prev, pager, next, sizes, total, jumper"
  46. @size-change="handleSizeChange"
  47. @current-change="handleCurrentChange"/>
  48. </div>
  49. </div>
  50. <!-- 预览合同 -->
  51. <report-list
  52. :show.sync="reportListShow"
  53. :title="reportData.title"
  54. :placeholder="reportData.placeholder"
  55. :request="reportData.request"
  56. :params="reportData.params"
  57. crm-type="contract"/>
  58. </div>
  59. </template>
  60. <script>
  61. import { biProductStatisticsAPI, biProductStatisticsExportAPI } from '@/api/bi/bi'
  62. import { crmContractQueryListByProductIdAPI } from '@/api/crm/contract'
  63. import ReportList from '@/views/crm/workbench/components/ReportList'
  64. import BaseMixin from '../mixins/Base'
  65. export default {
  66. /** 产品销售情况统计 */
  67. name: 'ProductStatistics',
  68. components: {
  69. ReportList
  70. },
  71. mixins: [BaseMixin],
  72. data() {
  73. return {
  74. loading: false,
  75. tableHeight: document.documentElement.clientHeight - 220,
  76. currentPage: 1,
  77. pageSize: 15,
  78. pageSizes: [15, 30, 60, 100],
  79. total: 0,
  80. postParams: {}, // 筛选参数
  81. headFieldList: [
  82. { field: 'category_id_info', name: '产品分类', width: '115px' },
  83. { field: 'product_name', name: '产品名称', width: '115px' },
  84. { field: 'contract_product_sum', name: '合同数', width: '115px' },
  85. { field: 'product_sum', name: '数量合计', width: '115px' },
  86. { field: 'contract_money', name: '订单产品小计', width: '115px' }
  87. // { field: 'category_id_info', name: '产品分类', width: '115px' },
  88. // { field: 'product_name', name: '产品名称', width: '115px' },
  89. // { field: 'contract_product_sum', name: '合同编号', width: '115px' },
  90. // { field: 'owner_user_name', name: '负责人', width: '115px' },
  91. // { field: 'contract_name', name: '客户名称', width: '115px' },
  92. // { field: 'price', name: '销售单价', width: '115px' },
  93. // { field: 'product_sum', name: '数量', width: '115px' },
  94. // { field: 'subtotal', name: '订单产品小计', width: '115px' }
  95. ],
  96. list: [],
  97. //
  98. extraData: {
  99. contract_product_sum: 0,
  100. product_sum: 0,
  101. contract_money: 0
  102. },
  103. reportListShow: false,
  104. reportData: {
  105. title: '',
  106. placeholder: '',
  107. request: null,
  108. params: null
  109. }
  110. }
  111. },
  112. computed: {},
  113. mounted() {
  114. /** 控制table的高度 */
  115. window.onresize = () => {
  116. const offsetHei = document.documentElement.clientHeight
  117. this.tableHeight = offsetHei - 220
  118. }
  119. },
  120. methods: {
  121. /**
  122. * 通过回调控制class
  123. */
  124. cellClassName({ row, column, rowIndex, columnIndex }) {
  125. if (column.property === 'contract_product_sum') {
  126. return 'can-visit--underline'
  127. } else {
  128. return ''
  129. }
  130. },
  131. /**
  132. * 更改每页展示数量
  133. */
  134. handleSizeChange(val) {
  135. this.pageSize = val
  136. this.getProductDatalist()
  137. },
  138. /**
  139. * 更改当前页数
  140. */
  141. handleCurrentChange(val) {
  142. this.currentPage = val
  143. this.getProductDatalist()
  144. },
  145. /**
  146. * 当某一行被点击时会触发该事件
  147. */
  148. handleRowClick(row, column, event) {
  149. if (column.property === 'contract_product_sum') {
  150. this.reportData.title = `${column.label}详情`
  151. this.reportData.request = crmContractQueryListByProductIdAPI
  152. this.reportData.placeholder = '请输入客户名称/合同编号/合同名称'
  153. const params = { ...this.postParams, product_id: row.product_id }
  154. this.reportData.params = params
  155. this.reportListShow = true
  156. }
  157. },
  158. /** 获取部门业绩完成信息 */
  159. getProductDatalist(params) {
  160. if (params) {
  161. this.postParams = params
  162. }
  163. this.loading = true
  164. biProductStatisticsAPI({
  165. ...this.postParams,
  166. page: this.currentPage,
  167. limit: this.pageSize
  168. })
  169. .then(res => {
  170. const resData = res.data || {}
  171. this.list = resData.list || []
  172. this.extraData = resData.total || { extraData: 0,
  173. product_sum: 0,
  174. contract_money: 0 }
  175. this.total = resData.count
  176. this.loading = false
  177. })
  178. .catch(() => {
  179. this.loading = false
  180. })
  181. },
  182. /**
  183. * 合计
  184. */
  185. getSummaries(param) {
  186. this.$nextTick(() => {
  187. this.$refs.tableRef.doLayout()
  188. })
  189. return ['合计', '', this.extraData.contract_product_sum, this.extraData.product_sum, this.extraData.contract_money]
  190. },
  191. /**
  192. * 导出点击
  193. */
  194. exportClick() {
  195. this.requestExportInfo(biProductStatisticsExportAPI, this.postParams, 'statistics')
  196. }
  197. }
  198. }
  199. </script>
  200. <style rel="stylesheet/scss" lang="scss" scoped>
  201. @import '../styles/detail.scss';
  202. @import '@/views/crm/styles/detailview.scss';
  203. .content {
  204. overflow: hidden;
  205. }
  206. .table-header {
  207. background-color: #f2f2f2;
  208. .header-item {
  209. text-align: center;
  210. height: 40px;
  211. line-height: 40px;
  212. border-left: 1px solid #e6e6e6;
  213. }
  214. .header-item:first-child {
  215. border-left: none;
  216. }
  217. }
  218. /** cell 信息 */
  219. .table-cell {
  220. div {
  221. text-align: center;
  222. }
  223. }
  224. .series-info {
  225. .series-name {
  226. width: 115px;
  227. height: 100%;
  228. }
  229. .series-body {
  230. border-left: 1px solid #e6e6e6;
  231. flex: 1;
  232. }
  233. }
  234. .product-info {
  235. .product-name {
  236. width: 115px;
  237. }
  238. .product-body {
  239. border-left: 1px solid #e6e6e6;
  240. flex: 1;
  241. }
  242. }
  243. .money-cells {
  244. .money-cell {
  245. border-left: 1px solid #e6e6e6;
  246. width: 115px;
  247. height: 40px;
  248. line-height: 40px;
  249. }
  250. .money-cell:first-child {
  251. border-left: none;
  252. }
  253. }
  254. /deep/ .el-table {
  255. tr td:first-child, tr td:nth-child(2) {
  256. border-right: 1px solid #e6e6e6;
  257. }
  258. tr td:first-child[rowspan='1'], tr td:nth-child(2)[rowspan='1'] {
  259. border-right: 0 none !important;
  260. }
  261. overflow:visible !important;
  262. }
  263. </style>