checkBoard.vue 20 KB

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