Elizabeth's proactive approach involves introducing urinal toilet attachment , an ingenious concept that optimizes space and functionality.

time.vue 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. <template>
  2. <div class="main-contain">
  3. <div class="position">
  4. <bread-crumb :crumbs="crumbs"></bread-crumb>
  5. </div>
  6. <div class="app-container">
  7. <el-tabs v-model="activeName" @tab-click="handleClick">
  8. <el-tab-pane label="按时间分组" name="first"></el-tab-pane>
  9. <el-tab-pane label="按项目分组" name="second"></el-tab-pane>
  10. </el-tabs>
  11. <div class="cell clearfix">
  12. <el-select v-model="lapseto" placeholder="请选择" style="width:120px;margin-right:20px" @change="changeLapseto">
  13. <el-option
  14. v-for="item in options"
  15. :key="item.value"
  16. :label="item.label"
  17. :value="item.value"
  18. ></el-option>
  19. </el-select>
  20. <el-select v-model="type" placeholder="请选择" @change="chooseType" style="margin-right:20px">
  21. <el-option
  22. v-for="item in options1"
  23. :key="item.value"
  24. :label="item.label"
  25. :value="item.value"
  26. ></el-option>
  27. </el-select>
  28. <div v-if="type == '自定义'">
  29. <label class="title">
  30. <span class="name">日期查询</span> :
  31. </label>
  32. <el-date-picker
  33. v-model="listQuery.start_time"
  34. prefix-icon="el-icon-date"
  35. @change="changeTime"
  36. :editable="false"
  37. style="width: 196px;"
  38. type="date"
  39. placeholder="选择日期时间"
  40. align="right"
  41. format="yyyy-MM-dd"
  42. value-format="yyyy-MM-dd"
  43. ></el-date-picker>
  44. <span class>-</span>
  45. <el-date-picker
  46. v-model="listQuery.end_time"
  47. prefix-icon="el-icon-date"
  48. @change="changeEndTime"
  49. :editable="false"
  50. style="width: 196px;"
  51. type="date"
  52. placeholder="选择日期时间"
  53. align="right"
  54. format="yyyy-MM-dd"
  55. value-format="yyyy-MM-dd"
  56. ></el-date-picker>
  57. </div>
  58. </div>
  59. <div class="cell clearfix">
  60. <div class="time newLi" v-if="type == '按季度对比统计'">
  61. <ul class>
  62. <li
  63. :class="item.state == quarterType ? 'active' : ''"
  64. @click="chooseQuarter(item.state)"
  65. v-for="item in quarter"
  66. :key="item.value"
  67. >{{ item.label }}</li>
  68. </ul>
  69. </div>
  70. <div class="time newLi" v-if="type == '按月份对比统计'">
  71. <ul class>
  72. <li
  73. :class="item.state == monthType ? 'active' : ''"
  74. @click="chooseMonth(item.state)"
  75. v-for="item in month"
  76. :key="item.value"
  77. >{{ item.label }}</li>
  78. </ul>
  79. </div>
  80. </div>
  81. <div class="cell clearfix">
  82. <p class="chartTitle">统计图</p>
  83. </div>
  84. <div>
  85. <line-chart :options="chart"></line-chart>
  86. </div>
  87. <div class="cell clearfix">
  88. <p class="point"></p>
  89. <p class="pointTitle">指标正常范围值</p>
  90. </div>
  91. <div class="cell clearfix newDisplay">
  92. <span v-for="(item,index) in normData" :key="index" class="index">{{item.item_name}}({{item.min_range}}-{{item.large_range}})</span>
  93. </div>
  94. </div>
  95. </div>
  96. </template>
  97. <script>
  98. const moment = require('moment')
  99. import echarts from "echarts";
  100. import { GetOICData } from "@/api/qcd";
  101. import LineChart from "../../qcd/components/LineChart";
  102. import { uParseTime } from "@/utils/tools";
  103. import BreadCrumb from "@/xt_pages/components/bread-crumb";
  104. import {getNormData,getFirstQuarter}from "@/api/common/common"
  105. export default {
  106. components: {
  107. LineChart,
  108. BreadCrumb
  109. },
  110. data() {
  111. return {
  112. activeName: "first",
  113. modesData: {
  114. xAxis: [],
  115. series: []
  116. },
  117. crumbs: [
  118. { path: false, name: "科室质控" },
  119. { path: false, name: "科室质控达标统计" },
  120. { path: false, name: "按时间分组" }
  121. ],
  122. normData:[],
  123. listQuery: {
  124. start_time: "",
  125. end_time: "",
  126. page: 1,
  127. limit: 10
  128. },
  129. lapseto:0,
  130. options: [
  131. {
  132. value: 0,
  133. label: "全部"
  134. },
  135. {
  136. value: 1,
  137. label: "留治"
  138. },
  139. {
  140. value: 2,
  141. label: "转出"
  142. },
  143. ],
  144. value: "请选项",
  145. options1: [
  146. {
  147. value: "按季度对比统计",
  148. label: "按季度对比统计"
  149. },
  150. {
  151. value: "按月份对比统计",
  152. label: "按月份对比统计"
  153. },
  154. {
  155. value: "自定义",
  156. label: "自定义"
  157. }
  158. ],
  159. type: "按季度对比统计",
  160. quarter: [
  161. { value: 0, label: "第一季度", state: 0 },
  162. { value: 1, label: "第二季度", state: 1 },
  163. { value: 2, label: "第三季度", state: 2 },
  164. { value: 3, label: "第四季度", state: 3 }
  165. ],
  166. quarterType: 0,
  167. month: [
  168. { value: 0, label: "一月", state: 0 },
  169. { value: 1, label: "二月", state: 1 },
  170. { value: 2, label: "三月", state: 2 },
  171. { value: 3, label: "四月", state: 3 },
  172. { value: 4, label: "五月", state: 4 },
  173. { value: 5, label: "六月", state: 5 },
  174. { value: 6, label: "七月", state: 6 },
  175. { value: 7, label: "八月", state: 7 },
  176. { value: 8, label: "九月", state: 8 },
  177. { value: 9, label: "十月", state: 9 },
  178. { value: 10, label: "十一月", state: 10 },
  179. { value: 11, label: "十二月", state: 11 }
  180. ],
  181. monthType: 0,
  182. chart: {
  183. title: {
  184. text: "ECharts 入门示例"
  185. },
  186. tooltip: {},
  187. legend: {
  188. data: ["次数"],
  189. left: 0
  190. },
  191. xAxis: {
  192. data: ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
  193. },
  194. yAxis: {
  195. axisLabel: {
  196. formatter: "{value}%"
  197. },
  198. show: false
  199. },
  200. series: [
  201. {
  202. name: "次数",
  203. type: "bar",
  204. data: [
  205. "78.57",
  206. "50",
  207. "80",
  208. "93.33",
  209. "92.86",
  210. "100",
  211. "12",
  212. "77",
  213. "37"
  214. ],
  215. barWidth: 30,
  216. label: {
  217. normal: {
  218. show: true,
  219. position: "top",
  220. formatter: "{c}%"
  221. }
  222. },
  223. //配置样式
  224. itemStyle: {
  225. //通常情况下:
  226. //每个柱子的颜色即为colorList数组里的每一项,如果柱子数目多于colorList的长度,则柱子颜色循环使用该数组
  227. normal: {
  228. color: function(params) {
  229. //我这边就两个柱子,大体就两个柱子颜色渐变,所以数组只有两个值,多个颜色就多个值
  230. var colorList = [
  231. ["#A9E0F3", "#9FBDFC"],
  232. ["#A9E0F3", "#9FBDFC"],
  233. ["#A9E0F3", "#9FBDFC"],
  234. ["#FFD7C0", "#FF9994"],
  235. ["#FFD7C0", "#FF9994"],
  236. ["#FFD7C0", "#FF9994"],
  237. ["#D7C3FD", "#B3A8F7"],
  238. ["#D7C3FD", "#B3A8F7"],
  239. ["#D7C3FD", "#B3A8F7"]
  240. ];
  241. var index = params.dataIndex;
  242. if (params.dataIndex >= colorList.length) {
  243. index = params.dataIndex % colorList.length;
  244. }
  245. return new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  246. { offset: 0, color: colorList[index][0] },
  247. // { offset: 0.5, color: colorList[index][1] },
  248. { offset: 1, color: colorList[index][1] }
  249. ]);
  250. },
  251. barBorderRadius: [5, 5, 0, 0] //柱状角成椭圆形
  252. },
  253. //鼠标悬停时:
  254. emphasis: {
  255. shadowBlur: 10,
  256. shadowOffsetX: 0,
  257. shadowColor: "rgba(0, 0, 0, 0.5)"
  258. }
  259. }
  260. }
  261. ],
  262. }
  263. };
  264. },
  265. methods: {
  266. handleClick() {
  267. if (this.activeName == "second") {
  268. this.$router.push({ path: "/qcd/officesControlAnalysis/project" });
  269. }
  270. },
  271. changeTime() {},
  272. changeLapseto(val){
  273. console.log("val",val)
  274. this.lapseto = val
  275. const firstQuarterStart = moment().startOf('year').format('YYYY-MM-DD')
  276. const firstQuarterEnd = moment().month(2).endOf('month').format("YYYY-MM-DD")
  277. this.getFirstQuarter(val,firstQuarterStart,firstQuarterEnd)
  278. },
  279. changeEndTime(val) {
  280. var time =
  281. this.getTimestamp(val) - this.getTimestamp(this.listQuery.start_time);
  282. if (time < 0) {
  283. this.$message.error("结束时间不能小于开始时间");
  284. this.listQuery.end_time = "";
  285. } else {
  286. }
  287. },
  288. selectLapseTo(state) {
  289. this.stateType = state;
  290. this.listQuery.state = state;
  291. },
  292. chooseType(val) {
  293. console.log(val);
  294. this.type = val;
  295. },
  296. chooseQuarter(quarter) {
  297. this.quarterType = quarter;
  298. //第一季度
  299. if(quarter === 0){
  300. //本月的开始时间
  301. const firstQuarterStart = moment().startOf('year').format('YYYY-MM-DD')
  302. const firstQuarterEnd = moment().month(2).endOf('month').format("YYYY-MM-DD")
  303. this.getFirstQuarter(this.lapseto,firstQuarterStart,firstQuarterEnd)
  304. }
  305. //第二季度
  306. if(quarter === 1){
  307. const febQuarterStart = moment().month(3).startOf('month').format("YYYY-MM-DD")
  308. const fedQuarterEnd = moment().month(5).endOf('month').format("YYYY-MM-DD")
  309. this.getFirstQuarter(this.lapseto,febQuarterStart,fedQuarterEnd)
  310. }
  311. //第三季度
  312. if(quarter === 2){
  313. const threeQuarterStart = moment().month(6).startOf('month').format("YYYY-MM-DD")
  314. const threeQuarterEnd = moment().month(8).endOf('month').format("YYYY-MM-DD")
  315. this.getFirstQuarter(this.lapseto,threeQuarterStart,threeQuarterEnd)
  316. }
  317. //第四季度
  318. if(quarter === 3){
  319. const fourQuarterStart = moment().month(8).startOf('month').format("YYYY-MM-DD")
  320. const fourQuarterEnd = moment().month(11).endOf('month').format("YYYY-MM-DD")
  321. this.getFirstQuarter(this.lapseto,fourQuarterStart,fourQuarterEnd)
  322. }
  323. },
  324. chooseMonth(month) {
  325. this.monthType = month;
  326. //1月
  327. if(month == 0){
  328. const fourQuarterStart = moment().month(0).startOf('month').format("YYYY-MM-DD")
  329. console.log("fourQuarterStart",fourQuarterStart)
  330. const fourQuarterEnd = moment().month(0).endOf('month').format("YYYY-MM-DD")
  331. this.getFirstQuarter(this.lapseto,fourQuarterStart,fourQuarterEnd)
  332. }
  333. //2月
  334. if(month == 1){
  335. const fourQuarterStart = moment().month(1).startOf('month').format("YYYY-MM-DD")
  336. console.log("fourQuarterStart",fourQuarterStart)
  337. const fourQuarterEnd = moment().month(1).endOf('month').format("YYYY-MM-DD")
  338. this.getFirstQuarter(this.lapseto,fourQuarterStart,fourQuarterEnd)
  339. }
  340. //
  341. //3月
  342. if(month == 2){
  343. const fourQuarterStart = moment().month(2).startOf('month').format("YYYY-MM-DD")
  344. console.log("fourQuarterStart",fourQuarterStart)
  345. const fourQuarterEnd = moment().month(2).endOf('month').format("YYYY-MM-DD")
  346. this.getFirstQuarter(this.lapseto,fourQuarterStart,fourQuarterEnd)
  347. }
  348. //4月
  349. if(month == 3){
  350. const fourQuarterStart = moment().month(3).startOf('month').format("YYYY-MM-DD")
  351. console.log("fourQuarterStart",fourQuarterStart)
  352. const fourQuarterEnd = moment().month(3).endOf('month').format("YYYY-MM-DD")
  353. this.getFirstQuarter(this.lapseto,fourQuarterStart,fourQuarterEnd)
  354. }
  355. //5月
  356. if(month == 4){
  357. const fourQuarterStart = moment().month(4).startOf('month').format("YYYY-MM-DD")
  358. console.log("fourQuarterStart",fourQuarterStart)
  359. const fourQuarterEnd = moment().month(4).endOf('month').format("YYYY-MM-DD")
  360. this.getFirstQuarter(this.lapseto,fourQuarterStart,fourQuarterEnd)
  361. }
  362. //6月
  363. if(month == 5){
  364. const fourQuarterStart = moment().month(5).startOf('month').format("YYYY-MM-DD")
  365. console.log("fourQuarterStart",fourQuarterStart)
  366. const fourQuarterEnd = moment().month(5).endOf('month').format("YYYY-MM-DD")
  367. this.getFirstQuarter(this.lapseto,fourQuarterStart,fourQuarterEnd)
  368. }
  369. //7月
  370. if(month == 6){
  371. const fourQuarterStart = moment().month(6).startOf('month').format("YYYY-MM-DD")
  372. console.log("fourQuarterStart",fourQuarterStart)
  373. const fourQuarterEnd = moment().month(6).endOf('month').format("YYYY-MM-DD")
  374. this.getFirstQuarter(this.lapseto,fourQuarterStart,fourQuarterEnd)
  375. }
  376. //8月
  377. if(month == 7){
  378. const fourQuarterStart = moment().month(7).startOf('month').format("YYYY-MM-DD")
  379. console.log("fourQuarterStart",fourQuarterStart)
  380. const fourQuarterEnd = moment().month(7).endOf('month').format("YYYY-MM-DD")
  381. this.getFirstQuarter(this.lapseto,fourQuarterStart,fourQuarterEnd)
  382. }
  383. //9月
  384. if(month == 8){
  385. const fourQuarterStart = moment().month(8).startOf('month').format("YYYY-MM-DD")
  386. console.log("fourQuarterStart",fourQuarterStart)
  387. const fourQuarterEnd = moment().month(8).endOf('month').format("YYYY-MM-DD")
  388. this.getFirstQuarter(this.lapseto,fourQuarterStart,fourQuarterEnd)
  389. }
  390. //10月
  391. if(month == 9){
  392. const fourQuarterStart = moment().month(9).startOf('month').format("YYYY-MM-DD")
  393. console.log("fourQuarterStart",fourQuarterStart)
  394. const fourQuarterEnd = moment().month(9).endOf('month').format("YYYY-MM-DD")
  395. this.getFirstQuarter(this.lapseto,fourQuarterStart,fourQuarterEnd)
  396. }
  397. //11月
  398. if(month == 10){
  399. const fourQuarterStart = moment().month(10).startOf('month').format("YYYY-MM-DD")
  400. console.log("fourQuarterStart",fourQuarterStart)
  401. const fourQuarterEnd = moment().month(10).endOf('month').format("YYYY-MM-DD")
  402. this.getFirstQuarter(this.lapseto,fourQuarterStart,fourQuarterEnd)
  403. }
  404. //12月
  405. if(month == 11){
  406. const fourQuarterStart = moment().month(11).startOf('month').format("YYYY-MM-DD")
  407. console.log("fourQuarterStart",fourQuarterStart)
  408. const fourQuarterEnd = moment().month(11).endOf('month').format("YYYY-MM-DD")
  409. this.getFirstQuarter(this.lapseto,fourQuarterStart,fourQuarterEnd)
  410. }
  411. },
  412. getNormData(){
  413. getNormData().then(response=>{
  414. if(response.data.state === 1){
  415. var normdata = response.data.data.normdata
  416. console.log("normdata",normdata)
  417. this.normData = normdata
  418. }
  419. })
  420. },
  421. //第一季度
  422. getFirstQuarter(val,startime,endtime){
  423. this.modesData.series = []
  424. this.modesData.xAxis = []
  425. getFirstQuarter(val,startime,endtime).then(response=>{
  426. if(response.data.state === 1){
  427. var count = response.data.data.count
  428. console.log("count",count)
  429. var arr=[]
  430. for(let i=0;i<count.length;i++){
  431. for(let j=0;j<this.normData.length;j++){
  432. if(count[i].item_id == this.normData[j].inspection_minor){
  433. arr.push(count[i])
  434. }
  435. }
  436. }
  437. console.log("arr",arr)
  438. var arrtwo = this.arrayDate(count,this.normData)
  439. for(let i=0;i<arrtwo.length;i++){
  440. this.$set(arrtwo[i], 'Count', 0)
  441. }
  442. for(let i=0;i<arrtwo.length;i++){
  443. this.$set(arrtwo[i], 'Total', 1)
  444. }
  445. arrtwo.map(item => {
  446. arr.push(item)
  447. })
  448. arr.sort(this.compare('sort'))
  449. for(const key in this.normData ){
  450. this.modesData.xAxis.push(this.normData[key].item_name);
  451. if(key in arr){
  452. this.modesData.series.push(((parseInt(arr[key].Count)/parseInt(arr[key].Total))*100).toFixed(1));
  453. } else {
  454. this.modesData.series.push(0);
  455. }
  456. }
  457. this.chart.series[0].data = this.modesData.series
  458. this.chart.xAxis.data = this.modesData.xAxis
  459. console.log(2222,this.modesData)
  460. }
  461. })
  462. },
  463. compare(property){
  464. return function(a,b){
  465. var value1 = a[property];
  466. var value2 = b[property];
  467. return value1 - value2;
  468. }
  469. },
  470. arrayDate(array1,array2){
  471. var array1 = array1;
  472. var array2 = this.normData;
  473. var result = [];
  474. for(var i = 0; i < array2.length; i++){
  475. var obj = array2[i];
  476. var num = obj.inspection_minor; //staff_id 就是要对比的key
  477. var isExist = false;
  478. for(var j = 0; j < array1.length; j++){
  479. var aj = array1[j];
  480. var n = aj.item_id;
  481. if(n == num){
  482. isExist = true;
  483. break;
  484. }
  485. }
  486. if(!isExist){
  487. result.push(obj);
  488. }
  489. }
  490. console.log("result",result)
  491. return result;
  492. },
  493. },
  494. created(){
  495. //本月的开始时间
  496. const firstQuarterStart = moment().startOf('year').format('YYYY-MM-DD')
  497. const firstQuarterEnd = moment().month(2).endOf('month').format("YYYY-MM-DD")
  498. //获取指标正常范围值
  499. this.getNormData()
  500. this.getFirstQuarter(this.lapseto,firstQuarterStart,firstQuarterEnd)
  501. }
  502. };
  503. </script>
  504. <style lang="scss" scoped>
  505. .newLi {
  506. li {
  507. background: #f5f5f6;
  508. }
  509. }
  510. .chartTitle {
  511. font-size: 16px;
  512. font-weight: bold;
  513. color: #000000;
  514. }
  515. .point {
  516. width: 13px;
  517. height: 13px;
  518. background: linear-gradient(
  519. 0deg,
  520. rgba(169, 224, 243, 1),
  521. rgba(159, 189, 252, 1)
  522. );
  523. border-radius: 7px;
  524. margin-right: 8px;
  525. }
  526. .pointTitle {
  527. font-size: 13px;
  528. }
  529. .index {
  530. color: #a09ba3;
  531. font-size: 13px;
  532. margin-right: 36px;
  533. margin-bottom: 20px;
  534. }
  535. .newDisplay {
  536. flex-wrap: wrap;
  537. }
  538. </style>