checkBoard.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. <template>
  2. <div :class="$style.content">
  3. <dv-full-screen-container>
  4. <!-- 头部内容 -->
  5. <div :class="$style.header">
  6. <dv-decoration-8 :class="$style.left" />
  7. <dv-decoration-5 :class="$style.center" />
  8. <dv-decoration-8 :class="$style.right" :reverse="true" />
  9. <div :class="$style.title">{{ titleName }}</div>
  10. <div :class="$style.time">
  11. <span>月份:</span>
  12. <el-date-picker
  13. v-model="month"
  14. type="month"
  15. value-format="yyyy-MM"
  16. format="yyyy-MM"
  17. placeholder="日期选择"
  18. style="width: 120px"
  19. :readonly="false"
  20. :editable="true"
  21. :clearable="false"
  22. @change="updateAll"
  23. />
  24. </div>
  25. <div :class="$style.back" @click.prevent="goBack()">
  26. <dv-border-box-8>返回</dv-border-box-8>
  27. </div>
  28. </div>
  29. <dv-border-box-1>
  30. <!-- topBar -->
  31. <top-bar v-if="topBarData.length" :info="topBarData" />
  32. <!-- middleCard -->
  33. <middle-card v-if="middleCardData.flag" :info="middleCardData" />
  34. <!-- bottomCard -->
  35. <bottom-card v-if="bottomCardData.flag" :info="bottomCardData" />
  36. </dv-border-box-1>
  37. </dv-full-screen-container>
  38. </div>
  39. </template>
  40. <script>
  41. import screenfull from 'screenfull'
  42. import curdPost from '@/business/platform/form/utils/custom/joinCURD.js'
  43. export default {
  44. name: 'checkBoard',
  45. components: {
  46. topBar: () => import('./component/topBar'),
  47. middleCard: () => import('./component/middleCard'),
  48. bottomCard: () => import('./component/bottomCard')
  49. },
  50. data() {
  51. const d = new Date()
  52. return {
  53. titleName: '检测综合信息查询',
  54. year: d.toJSON().slice(0, 4),
  55. month: d.toJSON().slice(0, 7),
  56. today: d.toJSON().slice(0, 10),
  57. label: ['委托', '受理', '任务发放', '报告'],
  58. topBarData: [],
  59. middleCardData: {
  60. tableData: {
  61. header: [
  62. '检测项目',
  63. '检测类型',
  64. '计划完成时间',
  65. '当前状态',
  66. '人员'
  67. ],
  68. data: [],
  69. rowNum: 7,
  70. columnWidth: ['300','100','150','150','100']
  71. },
  72. acceptData:[],
  73. taskData: [],
  74. flag: false
  75. },
  76. bottomCardData: {
  77. flag: false
  78. },
  79. timer: null
  80. }
  81. },
  82. // beforeRouteEnter(to, from, next){
  83. // Promise.all([ ]).done(([ res ]) => {
  84. // console.log(res)
  85. // }).then(err => {
  86. // window.observer.trigger('error', err)
  87. // next()
  88. // })
  89. // },
  90. created() {
  91. if (screenfull.isEnabled && !screenfull.isFullscreen) {
  92. this.allView()
  93. }
  94. this.updateAll()
  95. if (this.timer){
  96. clearInterval(this.timer)
  97. }
  98. this.timer = setInterval(() => {
  99. this.updateAll()
  100. },600000)
  101. },
  102. beforeDestroy() {
  103. if (screenfull.isFullscreen) {
  104. screenfull.toggle()
  105. }
  106. clearInterval(this.timer)
  107. },
  108. methods: {
  109. allView() {
  110. // 默认显示全屏
  111. screenfull.request()
  112. },
  113. goBack() {
  114. this.$router.back(-1)
  115. },
  116. updateAll(e) {
  117. this.getTopBarData()
  118. this.getMiddleData()
  119. this.getBottomData()
  120. },
  121. // 获取topBar数据
  122. /**
  123. * 委托——t_mjwtsqb
  124. * 检测——t_jchzb
  125. * 任务——t_rwfpb
  126. * 报告——t_mjjcbg
  127. */
  128. getTopBarData() {
  129. let quarter = this.getDateRange('quarter')
  130. let week = this.getDateRange('week')
  131. // 获取委托数及受理数
  132. const sql = `select wt.month as month, wt.accepted as accepted, wt2.today as today, wt2.week as week, wt2.quarter as quarter, jc.total as jcTotal, jc.finished as jcFinish, rw.task as task, rw.finished as rwFinish, bg.report as report, bg.process as process,bg.approval as approval
  133. from
  134. (select count(id_) as month, count(zhuang_tai_ = '委托结束' or null) as accepted from t_mjwtsqb where create_time_ LIKE '${this.month}%') wt,
  135. (select count(create_time_ like '${this.today}' or null) as today, count(create_time_ between '${week.start}' and '${week.end}' or null) as week, count(create_time_ between '${quarter.start}' and '${quarter.end}' or null) as quarter from t_mjwtsqb) wt2,
  136. (select count(id_) as total, count(jian_ce_zhuang_ta = '已完成' or null) as finished from t_jchzb where create_time_ LIKE '${this.month}%') jc,
  137. (select count(id_) as task, count(zhuang_tai_ = '任务已完成' or null) as finished from t_rwfpb where create_time_ LIKE '${this.month}%') rw,
  138. (select count(id_) as report, count(zhuang_tai_ = '报告待审核' or null) as process, count(zhuang_tai_ = '报告待审批' or null) as approval from t_mjjcbg where create_time_ LIKE '${this.month}%') bg`
  139. // console.log(sql)
  140. curdPost('sql', sql).then(res => {
  141. const data = res.variables.data
  142. console.log(data)
  143. if ( data && data.length ) {
  144. const { month, accepted, approval, jcFinish, jcTotal, process, report, rwFinish, task, today, week, quarter } = data[0]
  145. this.middleCardData.taskData = [month, jcTotal, task, report]
  146. let result = [
  147. {
  148. title: '委托',
  149. children: [
  150. {
  151. label: '本季度',
  152. value: quarter
  153. },
  154. {
  155. label: '月度',
  156. value: month
  157. },
  158. {
  159. label: '本周',
  160. value: week
  161. },
  162. {
  163. label: '本日',
  164. value: today
  165. },
  166. {
  167. label: '受理',
  168. value: accepted
  169. }
  170. ]
  171. },
  172. {
  173. title: '任务分配',
  174. children: [
  175. {
  176. label: '总数',
  177. value: task
  178. },
  179. {
  180. label: '已完成',
  181. value: rwFinish
  182. },
  183. {
  184. label: '未完成',
  185. value: task - rwFinish
  186. }
  187. ]
  188. },
  189. {
  190. title: '检测',
  191. children: [
  192. {
  193. label: '总数',
  194. value: jcTotal
  195. },
  196. {
  197. label: '已完成',
  198. value: jcFinish
  199. },
  200. {
  201. label: '未完成',
  202. value: jcTotal - jcFinish
  203. }
  204. ]
  205. },
  206. {
  207. title: '报告',
  208. children: [
  209. {
  210. label: '总数',
  211. value: report
  212. },
  213. {
  214. label: '已完成',
  215. value: report - approval - process
  216. },
  217. {
  218. label: '待审批',
  219. value: approval
  220. },
  221. {
  222. label: '待审核',
  223. value: process
  224. }
  225. ]
  226. }
  227. ]
  228. this.topBarData = result
  229. }
  230. }).catch(error => {
  231. console.log(error)
  232. })
  233. },
  234. // 获取中间图表数据
  235. getMiddleData() {
  236. // 获取检测数据
  237. // const sql1 = `select tm.jian_ce_xiang_mu_, tm.jian_ce_lei_bie_, IFNULL(rw.qi_wang_wan_cheng, '') as qi_wang_wan_cheng, rw.zhuang_tai_, ipe.NAME_ from t_rwfpb rw, ibps_party_employee ipe, t_mjjcnlfw tm where rw.jian_ce_yuan_ = ipe.ID_ and rw.jian_ce_xiang_mu_ = tm.id_ and rw.create_time_ like '${this.month}%'`
  238. const sql1 = `select tm.jian_ce_xiang_mu_, tm.jian_ce_lei_bie_, IFNULL(rwz.wan_cheng_shi_jia, '') as qi_wang_wan_cheng, rw.zhuang_tai_, ipe.NAME_ from t_rwfpb rw, ibps_party_employee ipe, t_mjjcnlfw tm, t_mjrwfpzb rwz where rwz.jian_ce_yuan_ = ipe.ID_ and rwz.ren_wu_bian_hao_ = tm.id_ and rw.id_ = rwz.wai_jian_ and rw.create_time_ like '${this.month}%'`
  239. // 获取检测受理类型数据
  240. const sql2 = `select count(tm.jian_ce_lei_bie_ = '理化' or null) as lh, count(tm.jian_ce_lei_bie_ = '微生物' or null) as wsw, count(tm.jian_ce_lei_bie_ = '细胞活率' or null) as xbhl, count(tm.jian_ce_lei_bie_ = '残留检测' or null) as cljc, count(tm.jian_ce_lei_bie_ = '细胞鉴别' or null) as xbjb from t_jchzb tj, t_mjjcnlfw tm where tj.jian_ce_xiang_mu_ = tm.id_ and tj.create_time_ like '${this.month}%'`
  241. Promise.all([
  242. curdPost('sql', sql1),
  243. curdPost('sql', sql2)
  244. ]).then(([res1, res2]) => {
  245. const data1 = res1.variables.data
  246. const data2 = res2.variables.data
  247. // console.log(data1, data2)
  248. this.middleCardData.tableData.data = []
  249. data1.forEach(item => {
  250. this.middleCardData.tableData.data.push(Object.values(item))
  251. })
  252. this.middleCardData.acceptData = Object.values(data2[0])
  253. this.middleCardData.flag = true
  254. }).catch(error => {
  255. console.log(error)
  256. })
  257. },
  258. // 获取底部图表数据
  259. getBottomData() {
  260. // 获取检测委托受理情况数据
  261. const sql1 = `select tm.zhuang_tai_ as state, DATE_FORMAT(tm.create_time_, '%Y-%m-%d %H:%i:%s') as time from t_mjwtsqb tm where tm.create_time_ like '${this.year}%'`
  262. // 获取检测月度年度任务完成情况数据
  263. const sql2 = `select rw.zhuang_tai_ as state, DATE_FORMAT(rw.create_time_, '%Y-%m-%d %H:%i:%s') as time from t_rwfpb rw where rw.create_time_ like '${this.year}%'`
  264. // 获取已委托样品数量
  265. const sql3 = `select count(yp.id_) as unReceive from t_mjypb yp, t_mjwtsqb wt where yp.wai_jian_ = wt.id_ and yp.create_time_ like '${this.month}%'`
  266. // 获取样品 收样/留样/不合格数量
  267. const sql4 = `select count(id_) as receive, count(shi_fou_liu_yang_ = '是' or null) as keep, count(yan_shou_zhuang_t = '残缺' or null) as incomplete from t_mjypdjb where create_time_ like '${this.month}%'`
  268. Promise.all([
  269. curdPost('sql', sql1),
  270. curdPost('sql', sql2),
  271. curdPost('sql', sql3),
  272. curdPost('sql', sql4),
  273. ]).then(([ res1, res2, res3, res4]) => {
  274. this.bottomCardData.flag = false
  275. const data1 = res1.variables.data
  276. const data2 = res2.variables.data
  277. const data3 = res3.variables.data
  278. const data4 = res4.variables.data
  279. // console.log(data1, data2, data3, data4)
  280. let trust = new Array(12).fill(0)
  281. let accepted = new Array(12).fill(0)
  282. let task = new Array(12).fill(0)
  283. let complete = new Array(12).fill(0)
  284. data1.forEach(item => {
  285. const index = parseInt(item.time.slice(5,7)) - 1
  286. if (item.state === '委托结束') {
  287. accepted[index]++
  288. }
  289. trust[index]++
  290. })
  291. data2.forEach(item => {
  292. const index = parseInt(item.time.slice(5,7)) - 1
  293. if (item.state === '任务已完成') {
  294. complete[index]++
  295. }
  296. task[index]++
  297. })
  298. let taskCount = task.reduce((pre, cur) => pre + cur)
  299. let completeCount = complete.reduce((pre, cur) => pre + cur)
  300. let year = [
  301. {
  302. name: '未完成',
  303. value: taskCount - completeCount
  304. },
  305. {
  306. name: '已完成',
  307. value: completeCount
  308. }
  309. ]
  310. let sample = [data3[0].unReceive - data4[0].receive, data4[0].receive, data4[0].incomplete, data4[0].keep]
  311. this.bottomCardData.trust = trust
  312. this.bottomCardData.accepted = accepted
  313. this.bottomCardData.task = task
  314. this.bottomCardData.complete = complete
  315. this.bottomCardData.year = year
  316. this.bottomCardData.sample = sample
  317. this.bottomCardData.flag = true
  318. // console.log(this.bottomCardData)
  319. }).catch(error => {
  320. console.log(error)
  321. })
  322. },
  323. // 获取本周和本季度的开始和结束日期,以对象形式返回
  324. getDateRange(type) {
  325. let current = new Date()
  326. if (type !== 'week' && type !== 'quarter') {
  327. console.log('type is error')
  328. return
  329. }
  330. if (type === 'quarter') {
  331. let year = current.getFullYear()
  332. let month = current.getMonth()
  333. const dateList = [
  334. {
  335. start: `${year}-01-01`,
  336. end: `${year}-03-31`
  337. },
  338. {
  339. start: `${year}-04-01`,
  340. end: `${year}-06-31`
  341. },
  342. {
  343. start: `${year}-07-01`,
  344. end: `${year}-09-31`
  345. },
  346. {
  347. start: `${year}-10-01`,
  348. end: `${year}-12-31`
  349. }
  350. ]
  351. let quarter = dateList[parseInt(month / 3)]
  352. return quarter
  353. }
  354. if (type === 'week') {
  355. let week = {}
  356. let currentWeek = current.getDay() === 0 ? 7 : current.getDay()
  357. let temp = new Date(current - (currentWeek - 1) * 86400000)
  358. week.start = new Date(current - (currentWeek - 1) * 86400000).toJSON().slice(0, 10)
  359. week.end = new Date((temp / 1000 + 6 * 86400) * 1000).toJSON().slice(0, 10)
  360. return week
  361. }
  362. }
  363. }
  364. }
  365. </script>
  366. <style lang="scss" module>
  367. .content {
  368. width: 100%;
  369. height: 100%;
  370. background-color: #030409;
  371. position: absolute;
  372. color: #fff;
  373. z-index: 999;
  374. :global {
  375. #dv-full-screen-container {
  376. background-image: url('../datav/img/bg.png');
  377. background-size: 100% 100%;
  378. box-shadow: 0 0 3px blue;
  379. display: flex;
  380. flex-direction: column;
  381. }
  382. .main-content {
  383. flex: 1;
  384. display: flex;
  385. flex-direction: column;
  386. }
  387. .block-left-right-content {
  388. flex: 1;
  389. display: flex;
  390. margin-top: 0.8%;
  391. }
  392. .block-top-bottom-content {
  393. flex: 1;
  394. display: flex;
  395. flex-direction: column;
  396. box-sizing: border-box;
  397. padding-left: 0.8%;
  398. }
  399. .block-top-content {
  400. height: 55%;
  401. display: flex;
  402. flex-grow: 0;
  403. box-sizing: border-box;
  404. padding-bottom: 0.8%;
  405. }
  406. }
  407. .header {
  408. position: relative;
  409. width: 100%;
  410. height: 100px;
  411. display: flex;
  412. justify-content: space-between;
  413. flex-shrink: 0;
  414. .left, .right {
  415. width: 25%;
  416. height: 60px;
  417. }
  418. .center {
  419. width: 40%;
  420. height: 60px;
  421. margin-top: 30px;
  422. }
  423. .title {
  424. position: absolute;
  425. font-size: 30px;
  426. font-weight: bold;
  427. left: 50%;
  428. top: 15px;
  429. transform: translateX(-50%);
  430. }
  431. .time, .back {
  432. width: 8%;
  433. cursor: pointer;
  434. height: 2.825rem;
  435. line-height: 2.825rem;
  436. text-align: center;
  437. margin-top: 2.5%;
  438. flex: 1;
  439. position: absolute;
  440. color: #ffffff;
  441. }
  442. .time {
  443. display: flex;
  444. justify-content: flex-end;
  445. width: 20%;
  446. right: 75%;
  447. }
  448. .back {
  449. left: 75%;
  450. }
  451. }
  452. }
  453. </style>