tiresalesStatistics.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <div style="padding-bottom: 40rpx;">
  3. <view
  4. style="background-color: #FD4B09;
  5. font-size: 28rpx;color: #fff;padding:20rpx 0;
  6. text-align: center;margin-bottom: 20rpx;display: flex;align-items: center;justify-content: space-around;">
  7. <span style="font-weight: 700;font-size: 32rpx;">{{form.statusDate?form.statusDate.slice(0,7):''}}</span>
  8. <view style="width: 30%;border: 2rpx solid #fff;padding: 5rpx 0;border-radius: 10rpx;"
  9. @click="openDate">
  10. 请选择月份
  11. </view>
  12. </view>
  13. <view
  14. style="display: flex;width: 96%;
  15. justify-content: space-between;
  16. margin: 0 auto;padding: 20rpx;
  17. border-radius: 20rpx;box-sizing: border-box;
  18. background-color: #fff;">
  19. <view style="width: 60%;text-align: center;border-right: 1rpx solid #ccc;">
  20. <view style="display: flex;justify-content: space-around;">
  21. <view>
  22. <view style="font-size: 20rpx;">月轮胎销量</view>
  23. <view style="color: #FD4B09;font-size: 48rpx;">{{customerForm.income}}</view>
  24. </view>
  25. <view>
  26. <view style="font-size: 20rpx;">月客户数量</view>
  27. <view style="color: #FD4B09;font-size: 48rpx;">{{Number(customerForm.corpsNumber).toFixed(0)}}</view>
  28. </view>
  29. </view>
  30. </view>
  31. <view style="width: 40%;display: flex;display: flex;justify-content: space-around;">
  32. <view>
  33. <view style="font-size: 20rpx;">平均客单价</view>
  34. <view style="color: #FD4B09;font-size: 48rpx;">¥{{customerForm.averageAmount}}</view>
  35. </view>
  36. </view>
  37. </view>
  38. <view class="qiunbox">
  39. <view class="charts-box">
  40. <qiun-data-charts
  41. type="ring"
  42. :opts="opts"
  43. :chartData="chartData"
  44. />
  45. </view>
  46. <view class="spanbzhu">备注:以实际出库为准</view>
  47. </view>
  48. <view class="qiunbox tableBox">
  49. <view style="font-size: 30rpx;color:#dd451b;">品牌月销量</view>
  50. <view class="flexbox" style="position: relative;" v-for="(item,index) of brandSalesData" :key="index">
  51. <view style="flex:1">{{index + 1}}</view>
  52. <view style="flex:4" class="shenglv">{{item.cname}}</view>
  53. <view style="flex:2">{{item.number}}条</view>
  54. <view style="flex:2">{{Number(item.percentage).toFixed(2)}}%</view>
  55. <view v-if="index != brandSalesData.length -1" style="position: absolute;width: 100vw;height: 1px;background: #f0f0f0;bottom: 0;left: -50rpx;"></view>
  56. </view>
  57. </view>
  58. <view class="qiunbox tableBox">
  59. <view style="font-size: 30rpx;color:#dd451b;">客户月销量</view>
  60. <view class="flexbox" style="position: relative;" v-for="(item,index) of corpsSalesData" :key="index">
  61. <view style="flex:1">{{index + 1}}</view>
  62. <view style="flex:4" class="shenglv">{{item.cname}}</view>
  63. <view style="flex:2">{{item.number}}条</view>
  64. <view style="flex:2">{{Number(item.percentage).toFixed(2)}}%</view>
  65. <view v-if="index != corpsSalesData.length -1" style="position: absolute;width: 100vw;height: 1px;background: #f0f0f0;bottom: 0;left: -50rpx;"></view>
  66. </view>
  67. </view>
  68. <u-datetime-picker :show="pickerShow" v-model="pickerValue" mode="year-month" @confirm="pickerConfirm"></u-datetime-picker>
  69. </div>
  70. </template>
  71. <script>
  72. import {
  73. salesVolumesStatistics,
  74. brandSalesVolume,
  75. corpsSalesVolume,
  76. sizeSalesVolumeProportion
  77. } from '@/api/views/record/index.js'
  78. import {
  79. dateFormat,
  80. onthelastDay
  81. } from '@/common/dateFormat'
  82. export default {
  83. data(){
  84. return {
  85. brandSalesData:[], // 品牌
  86. corpsSalesData:[], // 销量
  87. pickerShow:false, // 时间弹窗
  88. pickerValue:new Date(Date.now()), // 时间弹窗的绑定数据
  89. form:{
  90. statusDate:'',
  91. endDate:onthelastDay(new Date(Date.now())),
  92. },
  93. customerForm:{
  94. lossRate:0
  95. },
  96. dataForm:{},
  97. // Ucherts 展示的数据
  98. chartData: {},
  99. //您可以通过修改 config-ucharts.js 文件中下标为 ['ring'] 的节点来配置全局默认参数,如都是默认参数,此处可以不传 opts 。实际应用过程中 opts 只需传入与全局默认参数中不一致的【某一个属性】即可实现同类型的图表显示不同的样式,达到页面简洁的需求。
  100. opts: {
  101. fontSize:11,
  102. rotate: false,
  103. rotateLock: false,
  104. color: ["#f95959","#f27d0c","#f9b233","#f3e2a9","#D3D3D3"],
  105. padding: [5,5,5,5],
  106. dataLabel: false,
  107. enableScroll: false,
  108. legend: {
  109. show: true,
  110. position: "right",
  111. lineHeight: 25,
  112. },
  113. title: {
  114. name: "销售尺寸",
  115. fontSize: 15,
  116. color: "#dd451b"
  117. },
  118. subtitle: {
  119. name: "",
  120. fontSize: 25,
  121. color: "#7cb5ec"
  122. },
  123. extra: {
  124. ring: {
  125. ringWidth: 20,
  126. activeOpacity: 0.5,
  127. activeRadius: 10,
  128. offsetAngle: 0,
  129. labelWidth: 15,
  130. border: true,
  131. borderWidth: 3,
  132. customRadius:70,
  133. borderColor: "#FFFFFF"
  134. }
  135. }
  136. },
  137. }
  138. },
  139. onReady() {
  140. this.sizeSalesVolumeProportionfun();
  141. },
  142. onLoad() {
  143. this.form.statusDate = new Date(Date.now()).getFullYear() + '-' + (new Date(Date.now()).getMonth() + 1) + '-01 00:00:00'
  144. this.salesVolumesStatisticsfun()
  145. this.brandSalesVolumefun()
  146. this.corpsSalesVolumefun()
  147. },
  148. onShow() {
  149. },
  150. methods:{
  151. openDate(){
  152. this.pickerShow = true
  153. },
  154. // 时间弹窗点击确认
  155. pickerConfirm(data){
  156. this.form.statusDate = dateFormat(new Date(data.value))
  157. this.form.endDate = onthelastDay(new Date(data.value))
  158. this.pickerShow = false
  159. this.salesVolumesStatisticsfun()
  160. this.brandSalesVolumefun()
  161. this.corpsSalesVolumefun()
  162. this.sizeSalesVolumeProportionfun()
  163. },
  164. // 获取 销量/客户数量/平均客单价
  165. salesVolumesStatisticsfun(){
  166. salesVolumesStatistics(this.form).then(res=>{
  167. this.customerForm = res.data
  168. })
  169. },
  170. // 品牌销量
  171. brandSalesVolumefun(){
  172. brandSalesVolume(this.form).then(res=>{
  173. this.brandSalesData = res.data
  174. })
  175. },
  176. // 客户销量
  177. corpsSalesVolumefun(){
  178. corpsSalesVolume(this.form).then(res=>{
  179. this.corpsSalesData = res.data
  180. })
  181. },
  182. // 尺寸销量占比
  183. sizeSalesVolumeProportionfun(){
  184. sizeSalesVolumeProportion(this.form).then(res=>{
  185. let arr = []
  186. for (let item of res.data) {
  187. if (item.name == '>=19') {
  188. item.name = '19寸及以上'+ item.number +'条 占比' + Number(item.percentage).toFixed(2) + '%'
  189. }else if (item.name == '=18') {
  190. item.name = '18寸'+ item.number +'条 占比' + Number(item.percentage).toFixed(2) + '%'
  191. }else if (item.name == '=17') {
  192. item.name = '17寸'+ item.number +'条 占比' + Number(item.percentage).toFixed(2) + '%'
  193. }else if (item.name == '=16') {
  194. item.name = '16寸'+ item.number +'条 占比' + Number(item.percentage).toFixed(2) + '%'
  195. }else if (item.name == '<=15') {
  196. item.name = '15寸及以下'+ item.number +'条 占比' + Number(item.percentage).toFixed(2) + '%'
  197. }
  198. arr.unshift({
  199. name:item.name,
  200. value:Number(item.number)
  201. })
  202. }
  203. let chartres = {
  204. series: [
  205. {
  206. data: arr
  207. }
  208. ]
  209. }
  210. this.chartData = JSON.parse(JSON.stringify(chartres))
  211. })
  212. },
  213. }
  214. }
  215. </script>
  216. <style scoped>
  217. .qiunbox {
  218. background: #fff;
  219. width: 96%;
  220. margin: 0 auto;
  221. border-radius: 20rpx;
  222. margin-top: 20rpx;
  223. }
  224. /* 请根据实际需求修改父元素尺寸,组件自动识别宽高 */
  225. .charts-box {
  226. width: 100%;
  227. height: 100%;
  228. }
  229. .qiunbox {
  230. position: relative;
  231. }
  232. .spanbzhu {
  233. font-size: 23rpx;
  234. position: absolute;
  235. bottom: 20rpx;
  236. left: 50%;
  237. transform: translateX(-50%);
  238. }
  239. .tableBox {
  240. padding: 30rpx;
  241. box-sizing: border-box;
  242. }
  243. .flexbox {
  244. display: flex;
  245. align-items: center;
  246. font-size: 26rpx;
  247. padding: 20rpx 0;
  248. text-align: center;
  249. /* border-bottom: 1px solid #f0f0f0; */
  250. }
  251. .shenglv {
  252. overflow: hidden;
  253. white-space: nowrap;
  254. text-overflow: ellipsis;
  255. text-align: left;
  256. }
  257. </style>