smartvideomonitorstat.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. <template>
  2. <basic-container>
  3. <!--<avue-crud :option="option"
  4. :table-loading="loading"
  5. :data="data"
  6. :page="page"
  7. :permission="permissionList"
  8. :before-open="beforeOpen"
  9. v-model="form"
  10. ref="crud"
  11. @row-update="rowUpdate"
  12. @row-save="rowSave"
  13. @row-del="rowDel"
  14. @search-change="searchChange"
  15. @search-reset="searchReset"
  16. @selection-change="selectionChange"
  17. @current-change="currentChange"
  18. @size-change="sizeChange"
  19. @refresh-change="refreshChange"
  20. @on-load="onLoad">
  21. <template slot="menuLeft">
  22. <el-button type="danger"
  23. size="small"
  24. icon="el-icon-delete"
  25. plain
  26. v-if="permission.smartvideomonitorstat_delete"
  27. @click="handleDelete">删 除
  28. </el-button>
  29. </template>
  30. </avue-crud>-->
  31. <el-row>
  32. <el-col span="4" :push="6">选择日期</el-col>
  33. <el-col span="16" :push="4">
  34. <el-date-picker size="mini" v-model="dateSelect" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" align="left" @change="getPersonInOutStat" value-format="yyyy-MM-dd">
  35. </el-date-picker>
  36. </el-col>
  37. </el-row>
  38. <el-row :gutter="20" style="height: 600px;">
  39. <el-col span="24">
  40. <div ref="personStatChart" style="width:100%;height:500px"></div>
  41. </el-col>
  42. </el-row>
  43. </basic-container>
  44. </template>
  45. <script>
  46. import {getList, getDetail, add, update, remove, personInOutStat} from "@/api/smartapplication/smartvideomonitorstat";
  47. import {mapGetters} from "vuex";
  48. import {getRecordByTab} from "../../api/smartapplication/deviceheartbeat";
  49. export default {
  50. props:{
  51. serialNum: null,
  52. },
  53. data() {
  54. return {
  55. form: {},
  56. query: {},
  57. loading: true,
  58. page: {
  59. pageSize: 10,
  60. currentPage: 1,
  61. total: 0
  62. },
  63. dateSelect: "",
  64. selectionList: [],
  65. option: {
  66. menu: false,
  67. height:'auto',
  68. calcHeight: 30,
  69. tip: false,
  70. searchShow: true,
  71. searchMenuSpan: 6,
  72. border: true,
  73. index: true,
  74. viewBtn: true,
  75. selection: true,
  76. dialogClickModal: false,
  77. column: [
  78. {
  79. label: "设备序列号",
  80. prop: "serialNum",
  81. rules: [{
  82. required: true,
  83. message: "请输入设备序列号",
  84. trigger: "blur"
  85. }]
  86. },
  87. {
  88. label: "进入人数",
  89. prop: "enterCnt",
  90. rules: [{
  91. required: true,
  92. message: "请输入进入人数",
  93. trigger: "blur"
  94. }]
  95. },
  96. {
  97. label: "离开人数",
  98. prop: "leaveCnt",
  99. rules: [{
  100. required: true,
  101. message: "请输入离开人数",
  102. trigger: "blur"
  103. }]
  104. },
  105. // {
  106. // label: "总计人数",
  107. // prop: "totalCnt",
  108. // rules: [{
  109. // required: true,
  110. // message: "请输入总计人数",
  111. // trigger: "blur"
  112. // }]
  113. // },
  114. {
  115. label: "统计日期",
  116. prop: "statDate",
  117. rules: [{
  118. required: true,
  119. message: "请输入统计日期",
  120. trigger: "blur"
  121. }]
  122. },
  123. // {
  124. // label: "机构路径",
  125. // prop: "orgPosition",
  126. // rules: [{
  127. // required: true,
  128. // message: "请输入机构路径",
  129. // trigger: "blur"
  130. // }]
  131. // },
  132. ]
  133. },
  134. personStatOption: {
  135. tooltip: {
  136. trigger: 'axis'
  137. },
  138. legend: {
  139. data: ['进入数量', '离开数量']
  140. },
  141. toolbox: {
  142. show: true,
  143. feature: {
  144. dataView: {show: true, readOnly: false},
  145. magicType: {show: true, type: ['line', 'bar']},
  146. restore: {show: true},
  147. saveAsImage: {show: true}
  148. }
  149. },
  150. calculable: true,
  151. xAxis: [
  152. {
  153. type: 'category',
  154. data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
  155. }
  156. ],
  157. yAxis: [
  158. {
  159. type: 'value'
  160. }
  161. ],
  162. series: [
  163. {
  164. name: '进入数量',
  165. type: 'bar',
  166. data: [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3],
  167. markPoint: {
  168. data: [
  169. {type: 'max', name: '最大值'},
  170. {type: 'min', name: '最小值'}
  171. ]
  172. },
  173. markLine: {
  174. data: [
  175. {type: 'average', name: '平均值'}
  176. ]
  177. }
  178. },
  179. {
  180. name: '离开数量',
  181. type: 'bar',
  182. data: [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3],
  183. markPoint: {
  184. data: [
  185. {name: '年最高', value: 182.2, xAxis: 7, yAxis: 183},
  186. {name: '年最低', value: 2.3, xAxis: 11, yAxis: 3}
  187. ]
  188. },
  189. markLine: {
  190. data: [
  191. {type: 'average', name: '平均值'}
  192. ]
  193. }
  194. }
  195. ]
  196. },
  197. data: []
  198. };
  199. },
  200. computed: {
  201. ...mapGetters(["permission"]),
  202. permissionList() {
  203. return {
  204. addBtn: this.vaildData(this.permission.smartvideomonitorstat_add, false),
  205. viewBtn: this.vaildData(this.permission.smartvideomonitorstat_view, false),
  206. delBtn: this.vaildData(this.permission.smartvideomonitorstat_delete, false),
  207. editBtn: this.vaildData(this.permission.smartvideomonitorstat_edit, false)
  208. };
  209. },
  210. ids() {
  211. let ids = [];
  212. this.selectionList.forEach(ele => {
  213. ids.push(ele.id);
  214. });
  215. return ids.join(",");
  216. }
  217. },
  218. methods: {
  219. init(){
  220. this.page.currentPage =1;
  221. this.page.pageSize =10;
  222. this.onLoad(this.page)
  223. },
  224. rowSave(row, done, loading) {
  225. add(row).then(() => {
  226. this.onLoad(this.page);
  227. this.$message({
  228. type: "success",
  229. message: "操作成功!"
  230. });
  231. done();
  232. }, error => {
  233. loading();
  234. window.console.log(error);
  235. });
  236. },
  237. rowUpdate(row, index, done, loading) {
  238. update(row).then(() => {
  239. this.onLoad(this.page);
  240. this.$message({
  241. type: "success",
  242. message: "操作成功!"
  243. });
  244. done();
  245. }, error => {
  246. loading();
  247. console.log(error);
  248. });
  249. },
  250. rowDel(row) {
  251. this.$confirm("确定将选择数据删除?", {
  252. confirmButtonText: "确定",
  253. cancelButtonText: "取消",
  254. type: "warning"
  255. })
  256. .then(() => {
  257. return remove(row.id);
  258. })
  259. .then(() => {
  260. this.onLoad(this.page);
  261. this.$message({
  262. type: "success",
  263. message: "操作成功!"
  264. });
  265. });
  266. },
  267. handleDelete() {
  268. if (this.selectionList.length === 0) {
  269. this.$message.warning("请选择至少一条数据");
  270. return;
  271. }
  272. this.$confirm("确定将选择数据删除?", {
  273. confirmButtonText: "确定",
  274. cancelButtonText: "取消",
  275. type: "warning"
  276. })
  277. .then(() => {
  278. return remove(this.ids);
  279. })
  280. .then(() => {
  281. this.onLoad(this.page);
  282. this.$message({
  283. type: "success",
  284. message: "操作成功!"
  285. });
  286. this.$refs.crud.toggleSelection();
  287. });
  288. },
  289. beforeOpen(done, type) {
  290. if (["edit", "view"].includes(type)) {
  291. getDetail(this.form.id).then(res => {
  292. this.form = res.data.data;
  293. });
  294. }
  295. done();
  296. },
  297. searchReset() {
  298. this.query = {};
  299. this.onLoad(this.page);
  300. },
  301. searchChange(params, done) {
  302. this.query = params;
  303. this.page.currentPage = 1;
  304. this.onLoad(this.page, params);
  305. done();
  306. },
  307. selectionChange(list) {
  308. this.selectionList = list;
  309. },
  310. selectionClear() {
  311. this.selectionList = [];
  312. this.$refs.crud.toggleSelection();
  313. },
  314. currentChange(currentPage){
  315. this.page.currentPage = currentPage;
  316. },
  317. sizeChange(pageSize){
  318. this.page.pageSize = pageSize;
  319. },
  320. refreshChange() {
  321. this.onLoad(this.page, this.query);
  322. },
  323. getPersonInOutStat(){
  324. let params = {};
  325. params.serialNum = this.serialNum;
  326. params.beginDate = this.dateSelect[0];
  327. params.endDate = this.dateSelect[1];
  328. personInOutStat(params).then(res =>{
  329. const personStatChart = this.$echarts.init(this.$refs.personStatChart);
  330. this.personStatOption.xAxis[0].data = res.data.data.dateList;
  331. this.personStatOption.series[0].data = res.data.data.enterCtnList;
  332. this.personStatOption.series[1].data = res.data.data.leaveCtnList;
  333. const personStatOption = this.personStatOption;
  334. personStatChart.setOption(personStatOption)
  335. window.addEventListener("resize", function() {
  336. personStatChart.resize();
  337. });
  338. this.$on('hook:destroyed', () => {
  339. window.removeEventListener("resize", function() {
  340. personStatChart.resize();
  341. });
  342. })
  343. })
  344. },
  345. onLoad(page, params = {}) {
  346. params.serialNum = this.serialNum;
  347. personInOutStat(params).then(res =>{
  348. const personStatChart = this.$echarts.init(this.$refs.personStatChart);
  349. this.personStatOption.xAxis[0].data = res.data.data.dateList;
  350. this.personStatOption.series[0].data = res.data.data.enterCtnList;
  351. this.personStatOption.series[1].data = res.data.data.leaveCtnList;
  352. const personStatOption = this.personStatOption;
  353. personStatChart.setOption(personStatOption)
  354. window.addEventListener("resize", function() {
  355. personStatChart.resize();
  356. });
  357. this.$on('hook:destroyed', () => {
  358. window.removeEventListener("resize", function() {
  359. personStatChart.resize();
  360. });
  361. })
  362. })
  363. }
  364. }
  365. };
  366. </script>
  367. <style>
  368. </style>