ChartIndex.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <template>
  2. <Timenation />
  3. <BarChart v-if="true" />
  4. <LineChart v-else />
  5. <!-- <div v-if="isShowAll === false" style="text-align: center">
  6. <el-button type="text" @click="currentDayChart">今日</el-button>
  7. <el-button type="text" @click="currentMonthChart">本月</el-button>
  8. <el-button type="text" @click="allDatasChart">累计</el-button>
  9. </div>
  10. <div v-else>
  11. <el-form inline ref="ruleFormRef" :model="form" style="width: 600px">
  12. <el-form-item style="margin-top: 20px">
  13. <el-select
  14. v-model="form.workspace"
  15. placeholder="请选择车间"
  16. style="width: 140px; text-align: left"
  17. >
  18. <el-option
  19. v-for="item in departmentList"
  20. :key="item.deptId"
  21. :value="item.deptName"
  22. :label="item.deptName"
  23. ></el-option>
  24. </el-select>
  25. </el-form-item>
  26. <el-button style="text-align: left; width: 100px" type="primary" @click="getDepartmentData"
  27. >生成柱状图</el-button
  28. >
  29. <el-button style="text-align: left; margin-left: 180px" type="text" @click="currentDayChart"
  30. >今日</el-button
  31. >
  32. <el-button style="text-align: left" type="text" @click="currentMonthChart">本月</el-button>
  33. <el-button style="text-align: left" type="text" @click="allDatasChart">累计</el-button>
  34. </el-form>
  35. </div> -->
  36. <!-- <div id="container" style="width: 600px; height: 470px; margin-left: 20px"></div> -->
  37. </template>
  38. <script setup lang="ts">
  39. import Timenation from './Timenation.vue';
  40. import BarChart from '../../charts/BarChart.vue';
  41. import LineChart from '../../charts/LineChart.vue';
  42. // import * as echarts from 'echarts';
  43. // import { ref, markRaw } from 'vue';
  44. // import { watch } from 'vue';
  45. // import { onMounted } from 'vue';
  46. // import { DepartMentModel, VisitsModel, getDeptList } from '@/api/datamanagement/dataplatform';
  47. // interface DataOption {
  48. // title: {},//标题
  49. // tooltip: {},//虚线
  50. // calculate: Boolean,
  51. // xAxis: {},
  52. // yAxis: {},
  53. // series: SerialModel[]
  54. // }
  55. // const visible = ref(false);
  56. // const userId = ref(1);
  57. // const isShowAll = ref(false);//控制标题是否居中
  58. // const chart = ref<any>("");
  59. // const departmentList = ref<DepartMentModel[]>([]);
  60. // const getDepartmentList = () => {
  61. // getDeptList().then((res) => {
  62. // departmentList.value = res;
  63. // });
  64. // };
  65. // watch(
  66. // () => props.dialogVisible,
  67. // (newvisible) => {
  68. // visible.value = newvisible
  69. // console.log('tablechart', visible.value)
  70. // },
  71. // { immediate: true },
  72. // )
  73. // watch(
  74. // () => props.userId,
  75. // (newuserId) => {
  76. // userId.value = newuserId
  77. // console.log('tablechart-data:', userId.value)
  78. // currentDayChart()
  79. // },
  80. // { immediate: true },
  81. // )
  82. // const form = ref({
  83. // workspace: '',
  84. // });
  85. // const props = defineProps<{
  86. // stuffNo?: number | string | undefined,
  87. // currentDayChart: (d: number) => Promise<VisitsModel[]>,
  88. // currentMonthChart: (d: number) => Promise<VisitsModel[]>,
  89. // allDatasChart: (d: number) => Promise<VisitsModel[]>,
  90. // getDepartmentData: () => Promise<unknown>,
  91. // }>();
  92. // function initChart(data: DataOption, title: [], series: []) {
  93. // data.xAxis = {};
  94. // const dataseries = ref<SerialModel[]>([]);
  95. // const type = ref('category');
  96. // const horidata = ref([]) //todo,获取横坐标
  97. // const nameLocation = ref('center');
  98. // const axisLabel = { interval: 0, rotate: 30 };
  99. // const nameTextStyle = {
  100. // color: 'red',
  101. // fontSize: 6,
  102. // };
  103. // horidata.value = title;
  104. // data.xAxis = { type: type.value, data: horidata.value, nameLocation: nameLocation.value, axisLabel: axisLabel, nameTextStyle: nameTextStyle }
  105. // const seriesdata = ref<SerialModel>({
  106. // data: [],//todo,获取数值,
  107. // type: 'bar'
  108. // })
  109. // seriesdata.value.data = series;
  110. // dataseries.value.push(seriesdata.value)
  111. // data.series = dataseries.value;
  112. // console.log('data.xAxis.data', data.xAxis);
  113. // console.log('data.yAxis.data', data.series)
  114. // console.log(data)
  115. // createChart(data);
  116. // }
  117. // // 查看今日数据
  118. // function currentDayChart() {
  119. // isShowAll.value = false;
  120. // console.log('table-chart-currentday');
  121. // const daytitle = ref();
  122. // const seriesdata = ref();
  123. // props.currentDayChart(userId.value).then(res => {
  124. // daytitle.value = getHorizontalTitle(res);
  125. // seriesdata.value = getVorizontalData(res);
  126. // console.log('查看今日数据', res);
  127. // console.log('查看今日数据', daytitle);
  128. // console.log('查看今日数据', seriesdata);
  129. // initChart(optionday.value, daytitle.value, seriesdata.value)
  130. // })
  131. // };
  132. // // 查看本月数据
  133. // function currentMonthChart() {
  134. // isShowAll.value = false;
  135. // console.log('currentmonth:', userId.value);
  136. // const monthtitle = ref();
  137. // const monthseriesdata = ref()
  138. // props.currentMonthChart(userId.value).then(res => {
  139. // console.log('table-chart-currentmonth:', res);
  140. // monthtitle.value = getHorizontalTitle(res);
  141. // monthseriesdata.value = getVorizontalData(res);
  142. // console.log('查看今日数据', res);
  143. // console.log('查看今日数据', monthtitle);
  144. // console.log('查看今日数据', monthseriesdata);
  145. // initChart(optionmonth.value, monthtitle.value, monthseriesdata.value)
  146. // })
  147. // };
  148. // // 查看累计数据
  149. // function allDatasChart() {
  150. // isShowAll.value = true;
  151. // console.log('alldata:', userId.value);
  152. // const alltitle = ref();
  153. // const allseriesdata = ref()
  154. // props.allDatasChart(userId.value).then(res => {
  155. // console.log(res);
  156. // alltitle.value = getHorizontalTitle(res);
  157. // allseriesdata.value = getVorizontalData(res);
  158. // console.log('查看今日数据', res);
  159. // console.log('查看今日数据', alltitle);
  160. // console.log('查看今日数据', allseriesdata);
  161. // initChart(optionall.value, alltitle.value, allseriesdata.value)
  162. // })
  163. // }
  164. // interface SerialModel {
  165. // data: [],
  166. // type: string,
  167. // }
  168. // // 创建图表
  169. // function createChart(option: DataOption) {
  170. // chart.value = markRaw(echarts.init(document.getElementById('container') as HTMLDivElement))
  171. // chart.value.setOption(option);
  172. // // 大小自适应
  173. // window.addEventListener('resize', () => {
  174. // chart.value.resize();
  175. // })
  176. // }
  177. // // 创建柱状图
  178. // function getDepartmentData() {
  179. // // todo,原型未定义
  180. // }
  181. // function getHorizontalTitle(data: VisitsModel[]) {
  182. // console.log('getHorizontalTitle:', data)
  183. // const title = ref<string[]>([]);
  184. // for (var i = 0; i < data.length; i++) {
  185. // title.value.push(data[i].workshopName)
  186. // console.log('getHorizontalTitle-data-i', data[i].workshopName)
  187. // }
  188. // console.log('title:', title);
  189. // return title;
  190. // }
  191. // function getVorizontalData(data: VisitsModel[]) {
  192. // console.log('getvorizontaldata:', data)
  193. // const seriesData = ref<number[]>([]);
  194. // for (var i = 0; i < data.length; i++) {
  195. // seriesData.value.push(data[i].visits)
  196. // console.log('getHorizontalTitle-data-i', data[i].visits)
  197. // }
  198. // console.log('seriesData:', seriesData);
  199. // return seriesData;
  200. // }
  201. // const optionday = ref();
  202. // optionday.value = {
  203. // title: {
  204. // text: '各车间地点访问次数柱状图(天)',
  205. // x: "center", //设置标题位置居中
  206. // textStyle: {//设置主标题的文字风格
  207. // fontSize: 10 //文字大小
  208. // },
  209. // },//标题
  210. // tooltip: {
  211. // trigger: 'axis'
  212. // },//虚线
  213. // calculate: true,//显示数据
  214. // xAxis: {
  215. // type: 'category',
  216. // data: [],//todo,获取横坐标
  217. // nameLocation: 'center',
  218. // axisLabel: { interval: 0, rotate: 30 },
  219. // nameTextStyle: {
  220. // color: 'red',
  221. // fontSize: 6,
  222. // }
  223. // },
  224. // yAxis: {
  225. // type: 'value',
  226. // name: '访问次数',
  227. // nameTextStyle: {
  228. // color: 'black',
  229. // fontSize: 8,
  230. // padding: 0,
  231. // }
  232. // },
  233. // series: [
  234. // {
  235. // data: [],//todo,获取数值,
  236. // type: 'bar'
  237. // }
  238. // ]
  239. // };
  240. // const optionmonth = ref();
  241. // optionmonth.value = {
  242. // title: {
  243. // text: '各车间地点访问次数柱状图(月)',
  244. // x: "center", //设置标题位置居中
  245. // textStyle: {//设置主标题的文字风格
  246. // fontSize: 10 //文字大小
  247. // },
  248. // },//标题
  249. // tooltip: {
  250. // trigger: 'axis'
  251. // },//虚线
  252. // calculate: true,//显示数据
  253. // xAxis: {
  254. // type: 'category',
  255. // data: [],//todo,获取横坐标
  256. // nameLocation: 'center',
  257. // axisLabel: { interval: 0, rotate: 30 },
  258. // nameTextStyle: {
  259. // color: 'red',
  260. // fontSize: 6,
  261. // }
  262. // },
  263. // yAxis: {
  264. // type: 'value',
  265. // name: '访问次数',
  266. // nameTextStyle: {
  267. // color: 'black',
  268. // fontSize: 8,
  269. // padding: 0,
  270. // }
  271. // },
  272. // series: [
  273. // {
  274. // data: [],//todo,获取数值,
  275. // type: 'bar'
  276. // }
  277. // ]
  278. // };
  279. // const optionall = ref();
  280. // optionall.value = {
  281. // title: {
  282. // text: '各车间地点访问次数柱状图(汇总)',
  283. // x: "center", //设置标题位置居中
  284. // textStyle: {//设置主标题的文字风格
  285. // fontSize: 10 //文字大小
  286. // },
  287. // },//标题
  288. // tooltip: {
  289. // trigger: 'axis'
  290. // },//虚线
  291. // calculate: true,//显示数据
  292. // xAxis: {
  293. // type: 'category',
  294. // data: [],//todo,获取横坐标
  295. // nameLocation: 'center',
  296. // axisLabel: { interval: 0, rotate: 30 },
  297. // nameTextStyle: {
  298. // color: 'red',
  299. // fontSize: 6,
  300. // }
  301. // },
  302. // yAxis: {
  303. // type: 'value',
  304. // name: '访问次数',
  305. // nameTextStyle: {
  306. // color: 'black',
  307. // fontSize: 8,
  308. // padding: 0,
  309. // }
  310. // },
  311. // series: [
  312. // {
  313. // data: [],//todo,获取数值,
  314. // type: 'bar'
  315. // }
  316. // ]
  317. // };
  318. // onMounted(() => {
  319. // isShowAll.value = false;
  320. // getDepartmentList();
  321. // })
  322. </script>
  323. <style scoped></style>