checkBoard.vue 21 KB

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