index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. <template>
  2. <div>
  3. <div class="jbd-title-cont"> 检测人员任务统计 </div>
  4. <div class="contain">
  5. <div class="date">
  6. 统计时间:
  7. <el-date-picker v-model="monthValues" type="monthrange" align="right" unlink-panels range-separator="至"
  8. start-placeholder="开始月份" end-placeholder="结束月份" :picker-options="pickerOptions"
  9. @change="changeDate">
  10. </el-date-picker>
  11. </div>
  12. <div class="chart">
  13. <div id="echart-line" :style="{ width: '100%', height: '100%', paddingRight: '10px' }"></div>
  14. </div>
  15. </div>
  16. <el-dialog :visible.sync="dialogTableVisible">
  17. <div class="dialogbox">
  18. <div class="jbd-title-cont"> {{ setParams.seriesName }}-{{ setParams.name }} </div>
  19. <div class="ibps">
  20. <ibps-crud key="istree" ref="crud" :data="formDataFiiter" :toolbars="listConfig.toolbars"
  21. :search-form="listConfig.searchForm" :pk-key="pkKey" :columns="listConfig.columns"
  22. :loading="loading" @action-event="handleAction" :pagination="pagination"
  23. @pagination-change="handlePaginationChange">
  24. <template slot="jianceyuan"  slot-scope="scope">
  25. <ibps-user-selector :value="scope.row.jian_ce_yuan_" type="user" :multiple="true"
  26. :disabled="true" readonly-text="text" @callback="data => formId = data.id" />
  27. </template>
  28. <template slot="fuheyuan"  slot-scope="scope">
  29. <ibps-user-selector :value="scope.row.fu_he_yuan_" type="user" :multiple="true"
  30. :disabled="true" readonly-text="text" @callback="data => formId = data.id" />
  31. </template>
  32. </ibps-crud>
  33. </div>
  34. </div>
  35. </el-dialog>
  36. </div>
  37. </template>
  38. <script>
  39. import * as echarts from 'echarts';
  40. import curdPost from '@/business/platform/form/utils/custom/joinCURD.js'
  41. import IbpsUserSelector from '@/business/platform/org/selector'
  42. import ActionUtils from '@/utils/action'
  43. export default {
  44. components: {
  45. 'ibps-user-selector': IbpsUserSelector
  46. },
  47. props: {},
  48. data() {
  49. return {
  50. pkKey: 'id', // 主键 如果主键不是pk需要传主键
  51. pickerOptions: {
  52. shortcuts: [{
  53. text: '本月',
  54. onClick(picker) {
  55. const start = new Date();
  56. start.setDate(1);
  57. picker.$emit('pick', [start, new Date()]);
  58. }
  59. }, {
  60. text: '今年至今',
  61. onClick(picker) {
  62. const end = new Date();
  63. const start = new Date(new Date().getFullYear(), 0);
  64. picker.$emit('pick', [start, end]);
  65. }
  66. }, {
  67. text: '最近六个月',
  68. onClick(picker) {
  69. const end = new Date();
  70. const start = new Date();
  71. start.setMonth(start.getMonth() - 6);
  72. start.setDate(1);
  73. picker.$emit('pick', [start, end]);
  74. }
  75. }]
  76. },
  77. monthValues: [],
  78. dialogTableVisible: false,
  79. getchart: null,
  80. option: {
  81. title: {
  82. text: ''
  83. },
  84. tooltip: {
  85. trigger: 'axis',
  86. axisPointer: {
  87. type: 'shadow'
  88. }
  89. },
  90. legend: {
  91. orient: 'vertical',
  92. right: '10',
  93. top: 'center'
  94. },
  95. grid: {
  96. left: '2%',
  97. right: '10%',
  98. bottom: '3%',
  99. containLabel: true
  100. },
  101. xAxis: {
  102. type: 'value',
  103. name: '任务数量(项)',
  104. boundaryGap: [0, 0]
  105. },
  106. yAxis: {
  107. type: 'category',
  108. name: '检测人员',
  109. data: []
  110. },
  111. series: [
  112. {
  113. name: '检测未完成数',
  114. type: 'bar',
  115. data: [],
  116. label: {
  117. show: true,
  118. position: 'right',
  119. valueAnimation: true
  120. }
  121. },
  122. {
  123. name: '检测已完成数',
  124. type: 'bar',
  125. data: [],
  126. label: {
  127. show: true,
  128. position: 'right',
  129. valueAnimation: true
  130. }
  131. },
  132. {
  133. name: '复核未完成数',
  134. type: 'bar',
  135. data: [],
  136. label: {
  137. show: true,
  138. position: 'right',
  139. valueAnimation: true
  140. }
  141. },
  142. {
  143. name: '复核已完成数',
  144. type: 'bar',
  145. data: [],
  146. label: {
  147. show: true,
  148. position: 'right',
  149. valueAnimation: true
  150. }
  151. }
  152. ]
  153. },
  154. setParams: {},
  155. formData: [],
  156. formDataFiiter: [],
  157. listConfig: {
  158. // 工具栏
  159. toolbars: [
  160. { key: 'search' }
  161. ],
  162. // 查询条件
  163. searchForm: {
  164. forms: [
  165. { prop: 'yang_pin_bian_hao', label: '样品编号' },
  166. { prop: 'yang_pin_ming_che', label: '样品名称' },
  167. { prop: 'jian_ce_shi_jian_', label: '检测时间' },
  168. { prop: 'shi_yan_shi_ming', label: '实验室名' },
  169. ]
  170. },
  171. // 表格字段配置
  172. columns: [
  173. { prop: 'yang_pin_bian_hao', label: '样品编号' },
  174. { prop: 'yang_pin_ming_che', label: '样品名称' },
  175. { prop: 'jian_ce_shi_jian_', label: '检测时间' },
  176. { prop: 'shi_yan_shi_ming', label: '实验室名' },
  177. { prop: 'fu_jian_', label: '附件' },
  178. { prop: 'jian_ce_yuan_', label: '检测员', slotName: "jianceyuan" },
  179. { prop: 'fu_he_yuan_', label: '复核员', slotName: "fuheyuan" },
  180. { prop: 'jie_guo_pan_ding_', label: '结果判定' },
  181. { prop: 'jian_ce_zhuang_ta', label: '检测状态' }
  182. ]
  183. },
  184. startDate: '1949-10-1',
  185. endDate: '',
  186. chartData: [],
  187. pagination: { limit: 20, page: 1 },
  188. loading: false
  189. };
  190. },
  191. computed: {},
  192. methods: {
  193. initChart() {
  194. this.getchart = echarts.init(document.getElementById('echart-line'));
  195. document.getElementById('echart-line').setAttribute('_echarts_instance_', '');
  196. this.getchart.setOption(this.option, true);
  197. //随着屏幕大小调节图表
  198. window.addEventListener("resize", () => {
  199. this.getchart.resize();
  200. });
  201. this.getchart.on('click', (params) => {
  202. this.pagination = { limit: 20, page: 1 }
  203. this.dialogTableVisible = true
  204. this.setParams["dataIndex"] = params.dataIndex
  205. this.setParams["name"] = params.name
  206. switch (params.seriesName) {
  207. case "检测未完成数":
  208. this.setParams["seriesName"] = "未完成检测项目情况"
  209. break;
  210. case "检测已完成数":
  211. this.setParams["seriesName"] = "已完成检测项目情况"
  212. break;
  213. case "复核未完成数":
  214. this.setParams["seriesName"] = "未完成复核项目情况"
  215. break;
  216. case "复核已完成数":
  217. this.setParams["seriesName"] = "已完成复核项目情况"
  218. break;
  219. default:
  220. break;
  221. }
  222. this.formLoading()
  223. });
  224. },
  225. /**
  226. * 处理按钮事件
  227. */
  228. handleAction(command, position, selection, data) {
  229. switch (command) {
  230. case 'search':// 查询
  231. console.log("搜索")
  232. const params = this.$refs['crud'] ? this.$refs['crud'].getSearcFormData() : {}
  233. console.log("params:", params)
  234. this.formLoading()
  235. break
  236. default:
  237. break
  238. }
  239. },
  240. /**
  241. * 处理分页事件
  242. */
  243. handlePaginationChange(page) {
  244. this.pagination = page
  245. this.paginationFunc(this.formData)
  246. },
  247. // 图表数据加载
  248. chartLoading() {
  249. // 获取所有检测人员任务统计
  250. const sql = `select *from (select ie.ID_ as jcId,ie.NAME_ as jcName,count(tj.jian_ce_zhuang_ta != '已完成' or null) as jianCeWeiWanCheng,count(tj.jian_ce_zhuang_ta = '已完成' or null) as jianCeYiWanCheng from
  251. t_jchzb tj,ibps_party_employee ie
  252. where tj.jian_ce_yuan_ = ie.ID_ and tj.update_time_ between '${this.startDate}' and '${this.endDate}' group by jian_ce_yuan_
  253. ) jc LEFT JOIN
  254. (
  255. select ie.ID_ as fhId,ie.NAME_ as fhName,count(tj.jian_ce_zhuang_ta != '已完成' or null) as fuHeWeiWanCheng,count(tj.jian_ce_zhuang_ta = '已完成' or null) as fuHeYiWanCheng from
  256. t_jchzb tj,ibps_party_employee ie
  257. where tj.fu_he_yuan_ = ie.ID_ and tj.update_time_ between '${this.startDate}' and '${this.endDate}' group by fu_he_yuan_
  258. ) fh on jc.jcName = fh.fhName
  259. UNION (
  260. select *from (select ie.ID_ as jcId, ie.NAME_ as jcName,count(tj.jian_ce_zhuang_ta != '已完成' or null) as jianCeWeiWanCheng,count(tj.jian_ce_zhuang_ta = '已完成' or null) as jianCeYiWanCheng from
  261. t_jchzb tj,ibps_party_employee ie
  262. where tj.jian_ce_yuan_ = ie.ID_ and tj.update_time_ between '${this.startDate}' and '${this.endDate}' group by jian_ce_yuan_
  263. ) jc RIGHT JOIN
  264. (
  265. select ie.ID_ as fhId,ie.NAME_ as fhName,count(tj.jian_ce_zhuang_ta != '已完成' or null) as fuHeWeiWanCheng,count(tj.jian_ce_zhuang_ta = '已完成' or null) as fuHeYiWanCheng from
  266. t_jchzb tj,ibps_party_employee ie
  267. where tj.fu_he_yuan_ = ie.ID_ and tj.update_time_ between '${this.startDate}' and '${this.endDate}' group by fu_he_yuan_
  268. ) fh on jc.jcName = fh.fhName
  269. )`
  270. this.option.yAxis.data = []
  271. this.option.series[0].data = []
  272. this.option.series[1].data = []
  273. this.option.series[2].data = []
  274. this.option.series[3].data = []
  275. this.chartData = []
  276. curdPost('sql', sql).then(res => {
  277. const data = res.variables.data
  278. for (let i of data) {
  279. this.option.yAxis.data.push(i.jcName ? i.jcName : i.fhName)
  280. // 检测未完成数
  281. this.option.series[0].data.push(i.jianCeWeiWanCheng ? i.jianCeWeiWanCheng : 0)
  282. // 检测已完成数
  283. this.option.series[1].data.push(i.jianCeYiWanCheng ? i.jianCeYiWanCheng : 0)
  284. // 复核未完成数
  285. this.option.series[2].data.push(i.fuHeWeiWanCheng ? i.fuHeWeiWanCheng : 0)
  286. // 复核已完成数
  287. this.option.series[3].data.push(i.fuHeYiWanCheng ? i.fuHeYiWanCheng : 0)
  288. this.chartData.push(i)
  289. }
  290. this.initChart()
  291. }).catch(error => {
  292. console.log(error)
  293. })
  294. },
  295. formLoading() {
  296. this.loading = true
  297. let wheresql = this.chartData[this.setParams.dataIndex].jcId ? `jian_ce_yuan_='${this.chartData[this.setParams.dataIndex].jcId}'` : `fu_he_yuan_='${this.chartData[this.setParams.dataIndex].fhId}'`
  298. let formsql = `select jian_ce_zhuang_ta,fu_jian_,yang_pin_bian_hao,yang_pin_ming_che,shi_yan_shi_ming,
  299. bao_gao_jian_ce_r,jie_guo_pan_ding_,jian_ce_yuan_,fu_he_yuan_,jian_ce_shi_jian_ FROM t_jchzb
  300. where update_time_ BETWEEN '${this.startDate}' AND '${this.endDate}' and ${wheresql} and `
  301. let sql = ''
  302. const params = this.$refs['crud'] ? this.$refs['crud'].getSearcFormData() : {}
  303. // console.log("params:", params)
  304. switch (this.setParams.seriesName) {
  305. case "未完成检测项目情况":
  306. sql = formsql + `jian_ce_zhuang_ta != '已完成'`
  307. break;
  308. case "已完成检测项目情况":
  309. sql = formsql + `jian_ce_zhuang_ta = '已完成' `
  310. break;
  311. case "未完成复核项目情况":
  312. sql = formsql + `jian_ce_zhuang_ta != '已完成' `
  313. break;
  314. case "已完成复核项目情况":
  315. sql = formsql + `jian_ce_zhuang_ta = '已完成' `
  316. break;
  317. default:
  318. break;
  319. }
  320. sql = sql + `${params.jian_ce_shi_jian_ ? ` and jian_ce_shi_jian_ like '%${params.jian_ce_shi_jian_}%'` : ``}`
  321. sql = sql + `${params.shi_yan_shi_ming ? ` and shi_yan_shi_ming like '%${params.shi_yan_shi_ming}%'` : ``}`
  322. sql = sql + `${params.yang_pin_bian_hao ? ` and yang_pin_bian_hao like '%${params.yang_pin_bian_hao}%'` : ``}`
  323. sql = sql + `${params.yang_pin_ming_che ? ` and yang_pin_ming_che like '%${params.yang_pin_ming_che}%'` : ``}`
  324. curdPost('sql', sql).then(res => {
  325. this.loading = false
  326. const data = res.variables.data
  327. this.formData = res.variables.data
  328. document.getElementsByClassName("el-pagination__rightwrapper")[0].style.display = "none";
  329. this.paginationFunc(res.variables.data)
  330. }).catch(error => {
  331. console.log(error)
  332. this.loading = false
  333. })
  334. },
  335. /**
  336. * 数据分页
  337. * par:[]
  338. * pagination: { limit: 20, page: 1 },
  339. */
  340. paginationFunc(par) {
  341. this.formDataFiiter = []
  342. for (var i = (this.pagination.limit * this.pagination.page - this.pagination.limit); i < (this.pagination.limit * this.pagination.page); i++) {
  343. if (i < this.formData.length) {
  344. this.formDataFiiter.push(this.formData[i])
  345. }
  346. }
  347. },
  348. changeDate(value) {
  349. let year = value[1].getFullYear()
  350. let month = value[1].getMonth() + 1
  351. // 这里传入的是整数时间,返回的是下个月的第一天,因为月份是0-11
  352. let nextMonthFirthDay = new Date(year, month, 1) // 下个月的第一天
  353. let oneDay = 1000 * 60 * 60 * 24 // 一天的时间毫秒数
  354. let endDay = new Date(nextMonthFirthDay - oneDay)
  355. let day = endDay.getDate() // 本月最后一天
  356. this.endDate = value[1].getFullYear() + '-' + (value[1].getMonth() + 1) + '-' + day
  357. this.startDate = value[0].getFullYear() + '-' + (value[0].getMonth() + 1) + '-' + value[0].getDate()
  358. this.chartLoading()
  359. }
  360. },
  361. created() {
  362. const initendDate = new Date();
  363. this.endDate = initendDate.getFullYear() + '-' + (initendDate.getMonth() + 1) + '-' + initendDate.getDate()
  364. this.chartLoading()
  365. },
  366. mounted() {
  367. this.initChart()
  368. }
  369. };
  370. </script>
  371. <style lang="less" scoped>
  372. .contain {
  373. width: 100%;
  374. height: 800px;
  375. border-left: 1px solid #dfdcdc;
  376. }
  377. .date {
  378. text-align: right;
  379. padding-right: 20px;
  380. }
  381. .chart {
  382. width: 95%;
  383. height: 900px;
  384. }
  385. .jbd-title-cont {
  386. text-align: center;
  387. font-weight: bold;
  388. background-color: rgb(249, 255, 255);
  389. width: 100%;
  390. font-size: 18px;
  391. }
  392. .dialogbox {
  393. display: flex;
  394. flex-direction: column;
  395. }
  396. .ibps {
  397. top: 55px;
  398. border: 1px solid rgb(241, 238, 238);
  399. }
  400. /deep/ .el-dialog {
  401. height: 700px;
  402. width: 80%;
  403. }
  404. /deep/ .el-dialog__header {
  405. border: 0;
  406. }
  407. /deep/ .el-pagination__rightwrapper1 {
  408. display: none;
  409. }
  410. /deep/ .ibps-container-crud__header {
  411. margin-top: 55px;
  412. }
  413. /deep/ .el-dialog__headerbtn {
  414. z-index: 9999;
  415. }
  416. </style>