chart.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <view class="scoped-stat">
  3. <!-- <view class="ss-top" @click="openDeptPopup">
  4. <view class="label">
  5. 当前:<view class="v">{{ curDeptObj ? curDeptObj.deptName : '未知' }}</view>
  6. </view>
  7. <image class="sign" :src="rightIconPath2" mode="aspectFill"></image>
  8. </view> -->
  9. <view class="ss-op" v-if="!isdeptShow">
  10. <view class="so-title">
  11. <view class="sot-tips">
  12. <view :class="searchData.store_name === item.val ? 'op cur' : 'op'" v-for="(item, index) in storeTypeList" :key="index" @click="navHandle(item)">{{ item.key }}</view>
  13. </view>
  14. </view>
  15. <!-- :style="'height: ' + chartBoxHeight" -->
  16. <view class="so-main charts-box">
  17. <qiun-data-charts
  18. type="bar"
  19. :opts="opts"
  20. :chartData="chartData"
  21. />
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. export default {
  28. data() {
  29. return {
  30. storeTypeList: [],
  31. searchData: {store_name: ''},
  32. chartData: {},
  33. opts: {
  34. color: ["#1890FF","#91CB74","#FAC858","#EE6666","#73C0DE","#3CA272","#FC8452","#9A60B4","#ea7ccc"],
  35. padding: [15,30,0,5],
  36. enableScroll: false,
  37. legend: {},
  38. xAxis: {
  39. boundaryGap: "justify",
  40. disableGrid: false,
  41. min: 0,
  42. axisLine: false,
  43. // interval: Math.ceil(Math.max.apply(null, valueDataAll) / 5) || 1,
  44. // max: Math.ceil(Math.max.apply(null, valueDataAll) / 5) * 5 || 5,
  45. // max: 10
  46. },
  47. yAxis: {},
  48. extra: {
  49. bar: {
  50. type: "group",
  51. width: 30,
  52. meterBorde: 1,
  53. meterFillColor: "#FFFFFF",
  54. activeBgColor: "#000000",
  55. activeBgOpacity: 0.08,
  56. linearType: "custom",
  57. barBorderCircle: true,
  58. seriesGap: 2,
  59. categoryGap: 2
  60. }
  61. }
  62. },
  63. }
  64. },
  65. onLoad(params) {
  66. },
  67. created() {
  68. const dictObj = uni.getStorageSync('MD_dict')
  69. let store_type = dictObj.store_type || []
  70. let storeTypeList = [{key: '全部', val: ''}]
  71. const userInfo2 = uni.getStorageSync('MD_userInfo2')
  72. if (userInfo2.roles == 1 || userInfo2.roles == 5) {
  73. store_type.forEach(item => {
  74. if (item.key !== '其它') {
  75. storeTypeList.push(item)
  76. }
  77. })
  78. }
  79. this.storeTypeList = [...storeTypeList]
  80. this.getDtl()
  81. },
  82. methods: {
  83. navHandle (obj) {
  84. this.searchData = {
  85. store_name: obj.val
  86. }
  87. this.getDtl()
  88. },
  89. getDtl () {
  90. uni.api.estate.apistorechart({...this.searchData, action: '报备'}).then(res => {
  91. let chartData = {}
  92. chartData.categories = res.categories
  93. chartData.series = [res.series]
  94. let valueDataAll = res.series.data
  95. uni.api.estate.apistorechart({...this.searchData, action: '带访'}).then(two => {
  96. chartData.series.push(two.series)
  97. this.chartData = JSON.parse(JSON.stringify(chartData))
  98. valueDataAll = [...valueDataAll, ...two.series.data]
  99. let opts = {...this.opts}
  100. opts.xAxis = {
  101. ...opts.xAxis,
  102. interval: Math.ceil(Math.max.apply(null, valueDataAll) / 5) || 1,
  103. max: Math.ceil(Math.max.apply(null, valueDataAll) / 5) * 5 || 5,
  104. }
  105. this.opts = JSON.parse(JSON.stringify(opts))
  106. })
  107. })
  108. },
  109. openDeptPopup () {
  110. this.isdeptShow = true
  111. },
  112. closeDeptPopup (obj) {
  113. this.isdeptShow = false
  114. if (obj && obj.indexs) {
  115. this.curDeptIndex = obj.indexs[0]
  116. this.curDeptObj = this.deptList[this.curDeptIndex]
  117. this.getDtl()
  118. }
  119. },
  120. },
  121. };
  122. </script>
  123. <style lang="scss" scoped>
  124. .charts-box {
  125. width: 100%;
  126. height: calc(100vh - 100px);
  127. }
  128. .scoped-stat {
  129. background: #f4f6f9;
  130. height: calc(100vh);
  131. }
  132. .ss-top {
  133. height: 90rpx;
  134. display: flex;
  135. padding: 0 30rpx;
  136. justify-content: space-between;
  137. align-items: center;
  138. background: #fff;
  139. margin-bottom: 20rpx;
  140. .label {
  141. color: #666;
  142. font-size: 30rpx;
  143. .v {
  144. display: inline-block;
  145. color: #000;
  146. }
  147. }
  148. .sign {
  149. width: 11rpx;
  150. height: 20rpx;
  151. }
  152. }
  153. .ss-op {
  154. background: #fff;
  155. margin-bottom: 20rpx;
  156. padding: 20rpx 30rpx 40rpx;
  157. height: calc(100vh);
  158. .so-title {
  159. font-size: 32rpx;
  160. color: #333;
  161. font-weight: bold;
  162. padding-bottom: 30rpx;
  163. }
  164. .so-main {
  165. min-height: 180rpx;
  166. }
  167. .so-count {
  168. width: 100%;
  169. height: 180rpx;
  170. line-height: 180rpx;
  171. text-align: center;
  172. color: #007dff;
  173. background: #f6fbff;
  174. font-size: 50rpx;
  175. font-weight: bold;
  176. &.t2 {
  177. color: #f00;
  178. background: #fff7f6;
  179. }
  180. }
  181. .sot-tips {
  182. display: inline-block;
  183. .op {
  184. margin-right: 20rpx;
  185. display: inline-block;
  186. border: 1PX solid #eee;
  187. border-radius: 10rpx;
  188. padding: 6rpx 20rpx;
  189. color: #999;
  190. &.cur {
  191. border-color: #007dff;
  192. color: #007dff;
  193. }
  194. }
  195. }
  196. }
  197. </style>