monitoringtask.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. <!-- 监督任务管理 -->
  2. <template>
  3. <div class="suptaskbox">
  4. <div class="suptaskbox_serach">
  5. <el-select
  6. v-model="uservalue"
  7. multiple
  8. filterable
  9. placeholder="请选择任务监督人"
  10. size="mini"
  11. collapse-tags
  12. >
  13. <el-option
  14. v-for="item in useroptions"
  15. :key="item.user_id"
  16. :label="item.real_name"
  17. :value="item.user_id"
  18. >
  19. </el-option>
  20. </el-select>
  21. <el-date-picker
  22. v-model="monvalue"
  23. type="monthrange"
  24. range-separator="至"
  25. start-placeholder="开始月份"
  26. end-placeholder="结束月份"
  27. size="mini"
  28. :editable="false"
  29. >
  30. </el-date-picker>
  31. <el-button type="info" size="mini" @click="searchchilk">搜索</el-button>
  32. <el-button type="warning" size="mini" @click="download"
  33. :disabled="disabled"
  34. >{{disabled?'下载中...':'下载统计结果'}}</el-button
  35. >
  36. </div>
  37. <el-card class="box-card">
  38. <div
  39. :style="{ height: '100%', width: '100%' }"
  40. id="mychartpie"
  41. ref="mychartpie"
  42. ></div>
  43. </el-card>
  44. </div>
  45. </template>
  46. <script>
  47. //这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  48. import * as echarts from "echarts";
  49. export default {
  50. //import引入的组件需要注入到对象中才能使用
  51. components: {},
  52. data() {
  53. //这里存放数据
  54. return {
  55. monvalue: "", //月份
  56. useroptions: [], //监测人员名单
  57. uservalue: [],
  58. disabled:false
  59. };
  60. },
  61. //监听属性 类似于data概念
  62. computed: {},
  63. //监控data中的数据变化
  64. watch: {},
  65. //方法集合
  66. methods: {
  67. //监督人员列表
  68. getuserlist() {
  69. this.$axios({
  70. method: "POST",
  71. url: "/api/api_gateway?method=control_center.task.task_user_list",
  72. data: this.qs.stringify({
  73. user_type: "supervisor",
  74. }),
  75. }).then((res) => {
  76. // console.log(res.data.data);
  77. this.useroptions = res.data.data;
  78. });
  79. },
  80. //任务列表 data_report.report.task_report
  81. gettasklist(start_time, end_time) {
  82. // console.log(JSON.stringify(this.uservalue));
  83. var operator_user_id_list = "";
  84. if (this.uservalue.length != 0) {
  85. operator_user_id_list = JSON.stringify(this.uservalue);
  86. }
  87. this.$axios({
  88. method: "POST",
  89. url: "/api/api_gateway?method=data_report.report.supervisor_report",
  90. data: this.qs.stringify({
  91. operator_user_id_list, // 非必填 任务处理人id数组 ['1', '2']
  92. start_time, //月份
  93. end_time, //结束
  94. }),
  95. }).then((res) => {
  96. console.log(res.data.data);
  97. // this.useroptions = res.data.data;
  98. var tasklist = res.data.data;
  99. var userlist = []; //任务人列表
  100. var offtask = []; //已完成
  101. for (var i = 0; i < tasklist.length; i++) {
  102. userlist.push(tasklist[i].real_name);
  103. offtask.push(tasklist[i].count);
  104. }
  105. this.init(userlist, offtask);
  106. });
  107. },
  108. init(userlist, offtask) {
  109. let categoryData = userlist;
  110. let chartdata = offtask;
  111. let backgroundColor = "rgba(255,255,255,1)";
  112. let itemcolor = {
  113. type: "linear",
  114. colorStops: [
  115. {
  116. offset: 0,
  117. color: "rgba(6, 120, 157,1)",
  118. },
  119. {
  120. offset: 0.5,
  121. color: "rgba(6, 120, 157,0.2)",
  122. },
  123. {
  124. offset: 1,
  125. color: "rgba(6, 120, 157,1)",
  126. },
  127. ],
  128. };
  129. var option = {
  130. textStyle: {
  131. color: "#c0c3cd",
  132. fontSize: 14,
  133. },
  134. toolbox: {
  135. show: false,
  136. feature: {
  137. saveAsImage: {
  138. backgroundColor: "#031245",
  139. },
  140. restore: {},
  141. },
  142. iconStyle: {
  143. borderColor: "#c0c3cd",
  144. },
  145. },
  146. legend: {
  147. top: 10,
  148. itemWidth: 8,
  149. itemHeight: 8,
  150. icon: "circle",
  151. left: "center",
  152. padding: 0,
  153. textStyle: {
  154. color: "#c0c3cd",
  155. fontSize: 14,
  156. padding: [2, 0, 0, 0],
  157. },
  158. },
  159. color: ["#00D7E9", "rgba(0, 215, 233, 0.9)"],
  160. grid: {
  161. containLabel: true,
  162. left: 40,
  163. right: 20,
  164. bottom: 40,
  165. top: 40,
  166. },
  167. xAxis: {
  168. axisLine: {
  169. lineStyle: {
  170. color: "#999",
  171. },
  172. show: true,
  173. },
  174. axisLabel: {
  175. color: "#333",
  176. fontSize: 14,
  177. interval: 0,
  178. },
  179. data: categoryData,
  180. type: "category",
  181. },
  182. yAxis: {
  183. nameTextStyle: {
  184. color: "#c0c3cd",
  185. padding: [0, 0, -10, 0],
  186. fontSize: 14,
  187. },
  188. axisLabel: {
  189. color: "#000",
  190. fontSize: 14,
  191. },
  192. axisTick: {
  193. lineStyle: {
  194. color: "#668092",
  195. width: 1,
  196. },
  197. show: true,
  198. },
  199. splitLine: {
  200. show: true,
  201. lineStyle: {
  202. color: "#335971",
  203. // "type": "dashed"
  204. },
  205. },
  206. axisLine: {
  207. lineStyle: {
  208. color: "#333",
  209. width: 1,
  210. // "type": "dashed"
  211. },
  212. show: true,
  213. },
  214. name: "",
  215. },
  216. series: [
  217. {
  218. data: chartdata,
  219. type: "bar",
  220. barMaxWidth: "auto",
  221. barWidth: 20,
  222. itemStyle: {
  223. color: {
  224. x: 0,
  225. y: 1,
  226. x2: 0,
  227. y2: 0,
  228. type: "linear",
  229. colorStops: [
  230. {
  231. offset: 0,
  232. color: "#00D7E9",
  233. },
  234. {
  235. offset: 1,
  236. color: "rgba(0, 167, 233,0.3)",
  237. },
  238. ],
  239. },
  240. },
  241. label: {
  242. show: true,
  243. position: "top",
  244. distance: 10,
  245. color: "#00D7E9",
  246. },
  247. },
  248. {
  249. data: [1, 1, 1, 1, 1, 1],
  250. type: "pictorialBar",
  251. barMaxWidth: "20",
  252. symbol: "diamond",
  253. symbolOffset: [0, "50%"],
  254. symbolSize: [20, 10],
  255. },
  256. {
  257. data: chartdata,
  258. type: "pictorialBar",
  259. barMaxWidth: "20",
  260. symbolPosition: "end",
  261. symbol: "diamond",
  262. symbolOffset: [0, "-50%"],
  263. symbolSize: [20, 12],
  264. zlevel: 2,
  265. },
  266. ],
  267. tooltip: {
  268. show: true,
  269. formatter: "{b}:{c0}",
  270. },
  271. };
  272. echarts.init(document.getElementById("mychartpie")).setOption(option);
  273. },
  274. searchchilk() {
  275. // console.log(this.monvalue, this.uservalue);
  276. var start_time = this.timetag(0);
  277. var end_time = this.timetag(1);
  278. this.gettasklist(start_time, end_time);
  279. },
  280. timetag(i) {
  281. var time = "";
  282. if (this.monvalue.length != 0) {
  283. time =
  284. this.monvalue[i].getFullYear() +
  285. "-" +
  286. (this.monvalue[i].getMonth() + 1 < 10
  287. ? "0" + (this.monvalue[i].getMonth() + 1)
  288. : this.monvalue[i].getMonth() + 1);
  289. }
  290. return time;
  291. },
  292. download(start_time, end_time) {
  293. // var operator_user_id_list = "";
  294. // if (this.uservalue.length != 0) {
  295. // operator_user_id_list = JSON.stringify(this.uservalue);
  296. // }
  297. this.disabled = true
  298. this.$axios({
  299. method: "POST",
  300. url: "/api/api_gateway?method=data_report.report.supervisor_export",
  301. // data: this.qs.stringify({
  302. // operator_user_id_list, // 非必填 任务处理人id数组 ['1', '2']
  303. // start_time, //月份
  304. // end_time, //结束
  305. // }),
  306. responseType: "blob",
  307. }).then((res) => {
  308. console.log(res.data.data);
  309. this.downloadFile(res, "监督任务统计.xls");
  310. });
  311. },
  312. downloadFile(res, name) {
  313. let link = document.createElement("a");
  314. link.href = window.URL.createObjectURL(new Blob([res.data]));
  315. link.target = "_blank";
  316. //文件名和格式
  317. link.download = name;
  318. document.body.appendChild(link);
  319. link.click();
  320. document.body.removeChild(link);
  321. this.disabled = false
  322. },
  323. },
  324. beforeCreate() {}, //生命周期 - 创建之前
  325. //生命周期 - 创建完成(可以访问当前this实例)
  326. created() {},
  327. beforeMount() {}, //生命周期 - 挂载之前
  328. //生命周期 - 挂载完成(可以访问DOM元素)
  329. mounted() {
  330. this.getuserlist();
  331. this.gettasklist();
  332. },
  333. beforeUpdate() {}, //生命周期 - 更新之前
  334. updated() {}, //生命周期 - 更新之后
  335. beforeDestroy() {}, //生命周期 - 销毁之前
  336. destroyed() {}, //生命周期 - 销毁完成
  337. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  338. };
  339. </script>
  340. <style lang="less" scoped>
  341. .suptaskbox {
  342. width: 100%;
  343. height: 100%;
  344. .suptaskbox_serach {
  345. /deep/.el-select,
  346. /deep/.el-date-editor {
  347. width: 240px;
  348. }
  349. /deep/.el-button--info {
  350. background-color: #409eff;
  351. border-color: #409eff;
  352. margin-left: 10px;
  353. }
  354. }
  355. .box-card {
  356. /deep/.el-card__body {
  357. width: 100%;
  358. height: 100%;
  359. padding: 0;
  360. }
  361. margin-top: 15px;
  362. width: 98%;
  363. height: 90%;
  364. // #mychartpie {
  365. // width: 100%;
  366. // height: 100%;
  367. // div {
  368. // width: 100% !important;
  369. // height: 100% !important;
  370. // /deep/canvas {
  371. // width: 100% !important;
  372. // height: 100% !important;
  373. // }
  374. // }
  375. // }
  376. // #mychartpie>div{
  377. // width: 100% !important;
  378. // height: 100% !important;
  379. // }
  380. }
  381. }
  382. /deep/.el-date-editor{
  383. cursor: pointer;
  384. .el-range-input{
  385. cursor: pointer;
  386. }
  387. }
  388. </style>