dealerDetails.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <view class="dealerDetails">
  3. <view class="top">
  4. <view class="head">
  5. 经销商详细信息
  6. </view>
  7. <view class="content">
  8. <view class="">
  9. 经销商名称: {{dealer.name}}
  10. </view>
  11. <view class="">
  12. 所属地区: {{dealer.region}}
  13. </view>
  14. <view class="">
  15. 负责人姓名: {{dealer.respName}}
  16. </view>
  17. <view class="">
  18. 负责人电话: {{dealer.respPhone}}
  19. </view>
  20. </view>
  21. </view>
  22. <view class="bom">
  23. <view class="pie">
  24. <view class="text">
  25. <view class="left" @click="unit = !unit">
  26. {{ unit ? '单位: 箱' : '单位: 吨'}}
  27. </view>
  28. <view class="center">
  29. {{date}}
  30. </view>
  31. <view class="right">
  32. <picker mode="date" fields="month" :value="date" @change="bindDateChange">
  33. <view class="uni-input">月份</view>
  34. </picker>
  35. </view>
  36. </view>
  37. <qiun-data-charts type="pie" :opts="opts" :tapLegend='false' :chartData="data" />
  38. <view class="legend" v-if="chartData">
  39. <view class="btn" v-for="(v,i) in chartData" :key="i" :style="{backgroundColor: opts.color[i]}"
  40. @click="$goBack(2,'/pages/dealer/parric?name='+ v.typeName + '&date=' + date + '&dealerName=' + dealer.name)">
  41. <view class="">
  42. {{v.typeName}}
  43. </view>
  44. <view class="">
  45. {{ unit ? v.sendBox : v.ton.toFixed(2) }}
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. import {detail,purchase} from '../../api/dealer.js'
  55. export default {
  56. data() {
  57. return {
  58. // 月份
  59. date: this.getCurrentMonth(),
  60. unit: true,
  61. dealer: '',
  62. id:'',
  63. name: '',
  64. chartData: [],
  65. data: {
  66. series: [{
  67. data: [{}]
  68. }]
  69. },
  70. opts: {
  71. color: ["#1890FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4",
  72. "#ea7ccc"
  73. ],
  74. dataPointShape: false,
  75. dataLabel: false,
  76. padding: [5, 5, 5, 5],
  77. enableScroll: false,
  78. legend: {
  79. show: false
  80. },
  81. extra: {
  82. pie: {
  83. activeOpacity: 0.5,
  84. activeRadius: 10,
  85. offsetAngle: 0,
  86. labelWidth: 15,
  87. border: false,
  88. borderWidth: 3,
  89. borderColor: "#FFFFFF"
  90. }
  91. }
  92. }
  93. };
  94. },
  95. onLoad(opites) {
  96. this.id = opites.id
  97. this.name = opites.name
  98. this.getData()
  99. },
  100. mounted() {
  101. this.getStock()
  102. },
  103. methods: {
  104. // 获取经销商详情
  105. async getData(){
  106. let res = await detail({
  107. Id: this.id,
  108. accessToken: uni.getStorageSync('tokenInfo'),
  109. account: uni.getStorageSync('account')
  110. })
  111. this.dealer = res.data.data
  112. },
  113. // 获取进货数据
  114. async getStock(){
  115. uni.showLoading({
  116. title: '加载中'
  117. });
  118. let res = await purchase({
  119. name: this.name,
  120. month: this.date,
  121. accessToken: uni.getStorageSync('tokenInfo'),
  122. account: uni.getStorageSync('account')
  123. })
  124. uni.hideLoading();
  125. this.chartData = res.data.list
  126. this.setdata(res.data.list)
  127. },
  128. // 更改时间
  129. bindDateChange(e) {
  130. this.date = e.target.value
  131. this.getStock()
  132. },
  133. //整理数据
  134. setdata(list) {
  135. let that = this
  136. let Data = []
  137. list.forEach(v => {
  138. Data.push({
  139. name: v.typeName,
  140. value: v.sendBox
  141. })
  142. })
  143. that.data.series = [{
  144. data: Data
  145. }]
  146. },
  147. // 时间格式化
  148. getCurrentMonth() {
  149. const date = new Date()
  150. let year = date.getFullYear()
  151. let month = date.getMonth() + 1
  152. month = month > 9 ? month : '0' + month
  153. return `${year}-${month}`
  154. }
  155. }
  156. }
  157. </script>
  158. <style lang="scss">
  159. .dealerDetails {
  160. height: 100%;
  161. .top {
  162. height: 240rpx;
  163. padding: 30rpx;
  164. border-bottom: 1rpx solid #cecece;
  165. text-align: center;
  166. .head {
  167. width: 50%;
  168. margin: 0 auto;
  169. background-color: #9f75b5;
  170. color: #fff;
  171. margin-bottom: 30rpx;
  172. padding: 8rpx 0;
  173. border-radius: 4rpx;
  174. }
  175. .content {
  176. text-align: left;
  177. margin-left: 25%;
  178. view {
  179. margin-bottom: 10rpx;
  180. }
  181. }
  182. }
  183. .bom {
  184. height: calc(100% -240rpx);
  185. padding: 30rpx;
  186. .pie {
  187. height: 50%;
  188. .text {
  189. display: flex;
  190. align-items: center;
  191. justify-content: space-between;
  192. margin-bottom: 20rpx;
  193. .left{
  194. color: #4f9ce3;
  195. }
  196. .center{
  197. }
  198. .right{
  199. width: 120rpx;
  200. background-color: #f6b46a;
  201. border-radius: 50rpx;
  202. padding: 10rpx 0;
  203. text-align: center;
  204. color: #fff;
  205. }
  206. }
  207. .legend {
  208. margin-top: 40rpx;
  209. display: flex;
  210. justify-content: center;
  211. flex-wrap: wrap;
  212. .btn {
  213. padding: 5rpx 30rpx;
  214. text-align: center;
  215. color: #fff;
  216. border-radius: 10rpx;
  217. margin-right: 20rpx;
  218. margin-top: 20rpx;
  219. &:last-child {
  220. margin-right: 0;
  221. }
  222. }
  223. }
  224. }
  225. }
  226. }
  227. </style>