ss-echarts-compnents.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. // import { isNum, toStyleStr } from "../lib/tools.js";
  2. // import {eventBus,EVEN_VAR} from "../lib/EventBus.js";、
  3. import { debounce } from "./tools.js";
  4. export const MoneyStatistics = {
  5. name: 'MoneyStatistics',
  6. setup() {
  7. // 初始化响应式引用
  8. const chartInstance = Vue.ref(null);
  9. const chartOption = {
  10. xAxis: {
  11. type: "category",
  12. data: [
  13. "1万以下",
  14. "1-10万",
  15. "10-50万",
  16. "50-100万",
  17. "100-300万",
  18. "300-500万",
  19. "500-1000万",
  20. "1000-3000万",
  21. "3000万以上",
  22. ],
  23. },
  24. yAxis: {
  25. type: "value",
  26. },
  27. series: [
  28. {
  29. data: [6, 12, 18, 23, 25, 30, 12, 7, 3],
  30. type: "bar",
  31. },
  32. ],
  33. };
  34. const win = Vue.ref({ width: window.innerWidth }); // 假设宽度是浏览器窗口宽度
  35. const domStyle = Vue.computed(() => {
  36. const domWidth = (win.value.width - 140) / 2;
  37. const initSize = { width: 890, height: 378 };
  38. // 根据窗口大小调整宽高
  39. if (domWidth < initSize.width / 2 || domWidth > initSize.width) {
  40. return {
  41. width: initSize.width + "px",
  42. height: initSize.height + "px",
  43. };
  44. } else {
  45. return {
  46. width: domWidth + "px",
  47. height: (domWidth * initSize.height) / initSize.width + "px",
  48. };
  49. }
  50. });
  51. // 初始化图表和调整大小
  52. const initChart = () => {
  53. const element = document.getElementById("statistics-chart");
  54. if (element) {
  55. chartInstance.value = echarts.init(element);
  56. chartInstance.value.setOption(chartOption);
  57. }
  58. };
  59. const resizeChart = debounce(() => chartInstance.value?.resize?.(), 80);
  60. return {
  61. domStyle,
  62. initChart,
  63. resizeChart,
  64. onSetting: () => console.log("点击了设置按钮"),
  65. onRefresh: () => console.log("点击了刷新按钮"),
  66. };
  67. },
  68. mounted() {
  69. this.initChart();
  70. },
  71. render() {
  72. const HeaderContainer = Vue.resolveComponent('header-container');
  73. return Vue.h('div', { class: 'statistics-container', style: this.domStyle }, [
  74. Vue.h('div', { class: 'header' }, [
  75. Vue.h(HeaderContainer, { title: "金额分布", onSetting: this.onSetting, onRefresh: this.onRefresh })
  76. ]),
  77. Vue.h('div', { class: 'body' }, [
  78. Vue.h('div', { id: "statistics-chart", class: 'chart-container' })
  79. ])
  80. ]);
  81. }
  82. };
  83. export const DepartmentStatistics = {
  84. name: 'DepartmentStatistics',
  85. setup() {
  86. const chartInstance = Vue.ref(null);
  87. const chartOption = Vue.computed(() => ({
  88. title: {
  89. text: "Referer of a Website",
  90. subtext: "Fake Data",
  91. left: "center",
  92. },
  93. tooltip: {
  94. trigger: "item",
  95. },
  96. legend: {
  97. orient: "vertical",
  98. left: "left",
  99. },
  100. series: [
  101. {
  102. name: "Access From",
  103. type: "pie",
  104. radius: "50%",
  105. data: [
  106. { value: 1048, name: "Search Engine" },
  107. { value: 735, name: "Direct" },
  108. { value: 580, name: "Email" },
  109. { value: 484, name: "Union Ads" },
  110. { value: 300, name: "Video Ads" }
  111. ],
  112. emphasis: {
  113. itemStyle: {
  114. shadowBlur: 10,
  115. shadowOffsetX: 0,
  116. shadowColor: "rgba(0, 0, 0, 0.5)"
  117. }
  118. }
  119. }
  120. ]
  121. }));
  122. const win = Vue.ref({ width: window.innerWidth });
  123. const domStyle = Vue.computed(() => {
  124. const domWidth = (win.value.width - 140) / 2;
  125. const initSize = { width: 890, height: 378 };
  126. if (domWidth < initSize.width / 2 || domWidth > initSize.width) {
  127. return {
  128. width: initSize.width + "px",
  129. height: initSize.height + "px",
  130. };
  131. } else {
  132. return {
  133. width: domWidth + "px",
  134. height: (domWidth * initSize.height) / initSize.width + "px",
  135. };
  136. }
  137. });
  138. const initChart = () => {
  139. const element = document.getElementById("statistics-chart-department");
  140. if (element) {
  141. chartInstance.value = echarts.init(element);
  142. chartInstance.value.setOption(chartOption.value);
  143. }
  144. };
  145. const resizeChart = debounce(() => chartInstance.value?.resize?.(), 80);
  146. return {
  147. domStyle,
  148. initChart,
  149. resizeChart,
  150. onSetting: () => console.log("点击了设置按钮"),
  151. onRefresh: () => console.log("点击了刷新按钮"),
  152. };
  153. },
  154. mounted() {
  155. this.initChart();
  156. },
  157. render() {
  158. const HeaderContainer = Vue.resolveComponent('header-container');
  159. return Vue.h('div', { class: 'statistics-container', style: this.domStyle }, [
  160. Vue.h('div', { class: 'header' }, [
  161. Vue.h(HeaderContainer, { title: "省内项目主管部门分布", onSetting: this.onSetting, onRefresh: this.onRefresh })
  162. ]),
  163. Vue.h('div', { class: 'body' }, [
  164. Vue.h('div', { id: "statistics-chart-department", class: 'chart-container' })
  165. ])
  166. ]);
  167. }
  168. };
  169. export const ProjectReportStatistics = {
  170. name: 'ProjectReportStatistics',
  171. setup() {
  172. const win = Vue.ref({ width: window.innerWidth });
  173. const domStyle = Vue.computed(() => {
  174. const domWidth = (win.value.width - 140) / 2;
  175. const initSize = { width: 890, height: 444 };
  176. if (domWidth < initSize.width / 2 || domWidth > initSize.width) {
  177. return {
  178. width: initSize.width + "px",
  179. height: initSize.height + "px",
  180. };
  181. } else {
  182. return {
  183. width: domWidth + "px",
  184. height: (domWidth * initSize.height) / initSize.width + "px",
  185. };
  186. }
  187. });
  188. const list = Vue.ref([
  189. {
  190. title: "年度项目收付款情况",
  191. columns: [
  192. "客户名称", "项目", "项目状态", "负责人", "金额", "款项进度", "客户联系人", "联系电话"
  193. ]
  194. },
  195. {
  196. title: "年度项目合同情况汇总表",
  197. columns: [
  198. "客户名称", "名称", "状态", "金额", "签订日期", "到期日期", "业务负责人"
  199. ]
  200. },
  201. {
  202. title: "项目省内分布报表",
  203. columns: ["区域", "数量", "总金额", "项目", "客户", "状态"]
  204. }
  205. ]);
  206. return {
  207. domStyle,
  208. list,
  209. onSetting: () => console.log("点击了设置按钮"),
  210. onRefresh: () => console.log("点击了刷新按钮"),
  211. };
  212. },
  213. render() {
  214. const HeaderContainer = Vue.resolveComponent('header-container');
  215. return Vue.h('div', { class: 'statistics-container', style: this.domStyle }, [
  216. Vue.h('div', { class: 'header' }, [
  217. Vue.h(HeaderContainer, { title: "项目情况报表", onSetting: this.onSetting, onRefresh: this.onRefresh })
  218. ]),
  219. Vue.h('div', { class: 'body' }, this.list.map((item, i) =>
  220. Vue.h('div', { key: i, class: 'table-container' }, [
  221. Vue.h('div', { class: 'title' }, item.title),
  222. Vue.h('div', { class: 'table-columns' }, item.columns.map((tableItem, j) =>
  223. Vue.h('div', { key: j, class: 'table-item' }, tableItem)
  224. ))
  225. ])
  226. ))
  227. ]);
  228. }
  229. };
  230. export const IndustryStatistics = {
  231. name: 'IndustryStatistics',
  232. setup() {
  233. // Initialize reactive references
  234. const win = Vue.ref({ width: window.innerWidth });
  235. const chartInstance = Vue.ref(null);
  236. const domStyle = Vue.computed(() => {
  237. const domWidth = (win.value.width - 140) / 2;
  238. const initSize = { width: 890, height: 444 };
  239. if (domWidth < initSize.width / 2 || domWidth > initSize.width) {
  240. return {
  241. width: initSize.width + "px",
  242. height: initSize.height + "px",
  243. };
  244. } else {
  245. return {
  246. width: domWidth + "px",
  247. height: (domWidth * initSize.height) / initSize.width + "px",
  248. };
  249. }
  250. });
  251. const chartOption = {
  252. xAxis: {
  253. type: "category",
  254. data: [
  255. "1万以下", "1-10万", "10-50万", "50-100万", "100-300万",
  256. "300-500万", "500-1000万", "1000-3000万", "3000万以上"
  257. ]
  258. },
  259. yAxis: {
  260. type: "value"
  261. },
  262. series: [{
  263. data: [6, 12, 18, 23, 25, 30, 12, 7, 3],
  264. type: "bar"
  265. }]
  266. };
  267. const initChart = () => {
  268. chartInstance.value = echarts.init(document.getElementById("statistics-chart-industry"));
  269. chartInstance.value.setOption(chartOption);
  270. };
  271. const onSetting = () => console.log("Clicked on settings button");
  272. const onRefresh = () => console.log("Clicked on refresh button");
  273. const resizeChart = debounce(() => {
  274. chartInstance.value?.resize();
  275. }, 80);
  276. Vue.onMounted(() => {
  277. initChart();
  278. window.addEventListener('resize', resizeChart);
  279. });
  280. Vue.onUnmounted(() => {
  281. window.removeEventListener('resize', resizeChart);
  282. });
  283. return {
  284. domStyle,
  285. onSetting,
  286. onRefresh,
  287. };
  288. },
  289. render() {
  290. const HeaderContainer = Vue.resolveComponent('header-container');
  291. return Vue.h('div', { class: 'statistics-container', style: this.domStyle }, [
  292. Vue.h('div', { class: 'header' }, [
  293. Vue.h(HeaderContainer, { title: "项目产业分布", onSetting: this.onSetting, onRefresh: this.onRefresh })
  294. ]),
  295. Vue.h('div', { class: 'body' }, [
  296. Vue.h('div', { id: 'statistics-chart-industry', class: 'chart-container' })
  297. ])
  298. ]);
  299. }
  300. };