supervisiontask.vue 10 KB

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