manage-client 3.3.105 → 3.3.107

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "manage-client",
3
- "version": "3.3.105",
3
+ "version": "3.3.107",
4
4
  "description": "经营管控模块前台组件",
5
5
  "main": "src/index.js",
6
6
  "directories": {
@@ -0,0 +1,270 @@
1
+ <template>
2
+ <div class="EchartsWarp">
3
+ <div v-if="data" :id="`canvas`+key"></div>
4
+ </div>
5
+ </template>
6
+
7
+ <script>
8
+
9
+ export default {
10
+ name: 'ChartTypeBase',
11
+ props: {
12
+ // key 默认随机数s
13
+ key: {
14
+ type: String,
15
+ default: ()=>{
16
+ return Math.random().toString(36).substr(2)
17
+ }
18
+ },
19
+ type: {
20
+ type: String,
21
+ default: 'bar'
22
+ },
23
+ /**
24
+ // 示例数据 普通柱状图/普通折线图 {key,value} or {key,{value:value,其他数据}
25
+ // {
26
+ // Mon: 100,
27
+ // Tue: {
28
+ // itemStyle: {
29
+ // color: '#5470c6'
30
+ // },
31
+ // value :200
32
+ // }
33
+ // }
34
+ // 柱状堆叠 / 折线堆叠
35
+ // product 代表每组的名称 / product 代表每条线的名称
36
+ // [{ product: 'Matcha Latte', key1: 43.3, key2: 85.8, key3: 93.7 }]
37
+ **/
38
+ data: {
39
+ type: [Object, Array],
40
+ default: () => {
41
+ return undefined
42
+ }
43
+ },
44
+ color: {
45
+ type: Array,
46
+ default: () => {
47
+ return undefined
48
+ }
49
+ },
50
+ title: {
51
+ type: String,
52
+ default: ''
53
+ },
54
+ subtext: {
55
+ type: String,
56
+ default: ''
57
+ },
58
+ left: {
59
+ type: String,
60
+ default: 'left'
61
+ },
62
+ // 折线图是否平滑
63
+ smooth: {
64
+ type: Boolean,
65
+ default: true
66
+ },
67
+ // 圆饼图尺寸
68
+ radius: {
69
+ type: [String, Array],
70
+ default: () => {
71
+ return ['50%', '0%']
72
+ }
73
+ },
74
+ // 圆饼图是否改为玫瑰图
75
+ rosetype: {
76
+ type: String,
77
+ default: ''
78
+ },
79
+ // 自定义传参
80
+ mixinsdata: {
81
+ type: Object,
82
+ default: () => {
83
+ return {}
84
+ }
85
+ },
86
+ // 自定义传参
87
+ mixinslegend: {
88
+ type: Object,
89
+ default: () => {
90
+ return {}
91
+ }
92
+ },
93
+ // 自定义传参
94
+ mixinsitemstyle: {
95
+ type: Object,
96
+ default: () => {
97
+ return {}
98
+ }
99
+ },
100
+ },
101
+ data() {
102
+ return {
103
+ myChart: undefined
104
+ }
105
+ },
106
+ watch: {
107
+ data: {
108
+ handler: function (val, oldVal) {
109
+ this.myEcharts();
110
+ },
111
+ deep: true
112
+ }
113
+ },
114
+ methods: {
115
+ myEcharts() {
116
+ if (this.data) {
117
+ if (!this.myChart) {
118
+ this.myChart = this.$echarts.init(document.getElementById('canvas'+ this.key));
119
+ }
120
+ this.myChart.setOption(this.getOption());
121
+ }
122
+ },
123
+ getOption() {
124
+ let _option = {
125
+ title: {
126
+ text: this.title,
127
+ subtext: this.subtext,
128
+ left: this.left
129
+ },
130
+ xAxis: {type: 'category'},
131
+ yAxis: {
132
+ type: 'value'
133
+ },
134
+ tooltip: {
135
+ trigger: 'axis',
136
+ axisPointer: {
137
+ type: 'shadow'
138
+ }
139
+ },
140
+ }
141
+ if (this.color) {
142
+ Object.assign(_option, {
143
+ color: this.color
144
+ })
145
+ }
146
+ // 如果data是数组类型
147
+ if (this.type === 'bar' && Array.isArray(this.data)) {
148
+ Object.assign(_option, this.getOptionBarStack())
149
+ } else if (this.type === 'line' && Array.isArray(this.data)) {
150
+ Object.assign(_option, this.getOptionLineStack())
151
+ } else if (this.type === 'pie') {
152
+ Object.assign(_option, this.getOptionPie())
153
+ } else {
154
+ Object.assign(_option, this.getOptionBase())
155
+ }
156
+ console.log(_option)
157
+ return Object.assign(_option, this.mixinsdata)
158
+ },
159
+ // 圆饼图
160
+ getOptionPie() {
161
+ return {
162
+ tooltip: {
163
+ trigger: 'item'
164
+ },
165
+ legend: Object.assign({
166
+ bottom: '10%',
167
+ left: 'center'
168
+ }, this.mixinslegend),
169
+ series: {
170
+ type: 'pie',
171
+ radius: this.radius[1] === '0%' ? this.radius[0] : this.radius,
172
+ roseType: this.rosetype,
173
+ emphasis: {
174
+ itemStyle: Object.assign({
175
+ shadowBlur: 10,
176
+ shadowOffsetX: 0,
177
+ shadowColor: 'rgba(0, 0, 0, 0.5)',
178
+ borderRadius: 10,
179
+ // borderColor: '#fff',
180
+ // borderWidth: 2
181
+ }, this.mixinsitemstyle)
182
+ },
183
+ data: Object.keys(this.data).map(h => {
184
+ return {
185
+ name: h,
186
+ value: this.data[h]
187
+ }
188
+ })
189
+ }
190
+ }
191
+ },
192
+ // 柱状图
193
+ getOptionBase() {
194
+ return {
195
+ xAxis: {
196
+ type: 'category',
197
+ data: Object.keys(this.data),
198
+ axisTick: {
199
+ alignWithLabel: true
200
+ }
201
+ },
202
+ series: [
203
+ {
204
+ data: Object.values(this.data),
205
+ type: this.type,
206
+ smooth: this.smooth
207
+ }
208
+ ]
209
+ }
210
+ },
211
+ // 堆叠柱状图
212
+ getOptionBarStack() {
213
+ return {
214
+ dataset: {
215
+ source: [
216
+ Object.keys(this.data[0]),
217
+ ...this.data.map(
218
+ h => {
219
+ return Object.values(h)
220
+ }
221
+ )
222
+ ]
223
+ },
224
+ yAxis: {},
225
+ series: [...Object.keys(this.data[0]).map(
226
+ h => {
227
+ return {type: this.type}
228
+ }
229
+ )].splice(1)
230
+ }
231
+ },
232
+ // 折线图
233
+ getOptionLine() {
234
+ return {}
235
+ },
236
+ // 堆叠折线图 [{ product: 'Matcha Latte', key1: 43.3, key2: 85.8, key3: 93.7 }]
237
+ getOptionLineStack() {
238
+ return {
239
+ legend: {
240
+ data: this.data.map(h => h.product)
241
+ },
242
+ xAxis: {
243
+ type: 'category',
244
+ boundaryGap: false,
245
+ data: Object.keys(this.data[0]).splice(1)
246
+ },
247
+ series: [...this.data.map(
248
+ h => {
249
+ return {
250
+ name: h.product,
251
+ type: 'line',
252
+ stack: 'Total',
253
+ data: Object.values(h).splice(1)
254
+ }
255
+ }
256
+ )]
257
+ }
258
+ }
259
+ },
260
+ ready() {
261
+ this.myEcharts();
262
+ }
263
+ }
264
+ </script>
265
+
266
+ <style>
267
+ .EchartsWarp div:first-child div:last-child {
268
+ height: auto;
269
+ }
270
+ </style>
@@ -18,7 +18,7 @@
18
18
  </template>
19
19
 
20
20
  <script>
21
- import ChartTypeBase from 'vue-client/src/components/echarts/ChartTypeBase.vue'
21
+ import ChartTypeBase from '../ChartTypeBase.vue'
22
22
  import {HttpResetClass} from "vue-client";
23
23
 
24
24
  export default {
@@ -14,7 +14,7 @@
14
14
  </template>
15
15
 
16
16
  <script>
17
- import ChartTypeBase from 'vue-client/src/components/echarts/ChartTypeBase.vue'
17
+ import ChartTypeBase from '../ChartTypeBase.vue'
18
18
  import {HttpResetClass} from "vue-client";
19
19
 
20
20
  export default {