headerContent.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <!-- 样品数据总览组件 -->
  3. <div class="baseBgColor">
  4. <div class="totalNumber">
  5. <div>委托样品总数</div>
  6. <div class="number">{{EntrustedTotal}}个</div>
  7. </div>
  8. <div class="notReceived">
  9. <div>待收样数量(已委托未收样)</div>
  10. <div class="number">{{NotReceiveNumber}}个</div>
  11. </div>
  12. <div class="received">
  13. <div>已收样数量</div>
  14. <div class="number">{{ReceiveNumber}}个</div>
  15. </div>
  16. <div class="staging">
  17. <div>待检样品数量</div>
  18. <div class="number">{{StagingNumber}}个</div>
  19. </div>
  20. <div class="unqualified">
  21. <div>不合格样品数量</div>
  22. <div class="number">{{UnqualifiedNumber}}个</div>
  23. </div>
  24. <div class="retention">
  25. <div>留样样品数量</div>
  26. <div class="number">{{RetentionNumber}}个</div>
  27. </div>
  28. <div class="retention">
  29. <div>样品完成检测数量</div>
  30. <div class="number">{{SuccessNumber}}个</div>
  31. </div>
  32. <!-- <button @click="getTime">时间</button> -->
  33. </div>
  34. </template>
  35. <script>
  36. import curdPost from '@/business/platform/form/utils/custom/joinCURD.js'
  37. export default {
  38. data(){
  39. return{
  40. timer:null,
  41. sendTime:'',
  42. EntrustedTotal:0,
  43. NotReceiveNumber:0,
  44. ReceiveNumber:0,
  45. StagingNumber:0,
  46. UnqualifiedNumber:0,
  47. RetentionNumber:0,
  48. SuccessNumber:0
  49. }
  50. },
  51. created(){
  52. //数据获取
  53. this.getEntrustedTotalData()
  54. this.getNotReceivedData()
  55. this.getReceivedData()
  56. this.getUnqualifiedData()
  57. this.getSuccessData()
  58. this.getStayData()
  59. this.getStagingNumberData()
  60. //拿到数据后先获取当前时间,把时间传给父组件
  61. this.getNowTime()
  62. // this.$emit('getUpdateTime',this.sendTime)
  63. // 页面进来先清除定时器
  64. clearInterval(this.timer)
  65. this.timer = null
  66. this.timer = setInterval(() =>{
  67. this.getEntrustedTotalData()
  68. this.getNotReceivedData()
  69. this.getSuccessData()
  70. this.getReceivedData()
  71. this.getUnqualifiedData()
  72. this.getStayData()
  73. // console.log('执行了定时器',this.sendTime)
  74. //数据回来之后调用触发this.$emit,触发父组件自定义方法获取时间
  75. this.getNowTime()
  76. // this.$emit('getUpdateTime',this.sendTime)
  77. }, 1000 * 60 *30);
  78. // 组件销毁清楚定时器
  79. this.$once('hook:beforeDestroy', () => {
  80. clearInterval(this.timer);
  81. })
  82. },
  83. methods:{
  84. //获取时间
  85. getNowTime(){
  86. const nowDate = new Date();
  87. const date = {
  88. year: nowDate.getFullYear(),
  89. month: nowDate.getMonth() + 1,
  90. day: nowDate.getDate(),
  91. hour: nowDate.getHours(),
  92. }
  93. this.sendTime = date.year + '年' + date.month + '月' + date.day + '日' +date.hour + '时'
  94. // console.log("获取时间函数执行了",this.sendTime)
  95. //获取时间的时候直接传给父组件
  96. this.$emit('getUpdateTime',this.sendTime)
  97. },
  98. //委托样品总数:样品表所有
  99. getEntrustedTotalData(){
  100. let sql1 = "select count(id_) as sum from t_mjypb"
  101. curdPost('sql',sql1).then(response => {
  102. let data = response.variables.data
  103. this.EntrustedTotal = data[0].sum
  104. })
  105. },
  106. //待收样数量:已委托,未收到
  107. getNotReceivedData(){
  108. let sql2= "select count(id_) as sum from t_mjypb WHERE wai_jian_ in(select id_ from t_mjwtsqb where zhuang_tai_ = '待样品接收')"
  109. curdPost('sql',sql2).then(response => {
  110. let data = response.variables.data
  111. this.NotReceiveNumber = data[0].sum
  112. })
  113. },
  114. //已经收样
  115. getReceivedData(){
  116. let sql3= "select count(id_) as sum from t_mjypdjb"
  117. curdPost('sql',sql3).then(response => {
  118. let data = response.variables.data
  119. this.ReceiveNumber = data[0].sum
  120. })
  121. },
  122. //待检样品数量
  123. getStagingNumberData(){
  124. // let sql6 = "select * from t_mjypdjb"
  125. let sql6= "select count(id_) as sum from t_mjypdjb where liu_zhuan_zhuang_ = '待检' "
  126. curdPost('sql',sql6).then(response => {
  127. let data = response.variables.data
  128. this.StagingNumber =data[0].sum
  129. // console.log("样品登记表数据777",this.StagingNumber)
  130. })
  131. },
  132. //不合格样品数量
  133. getUnqualifiedData(){
  134. let sql4= "select count(id_) as sum from t_mjypdjb where yan_shou_zhuang_t = '残缺'"
  135. curdPost('sql',sql4).then(response => {
  136. let data = response.variables.data
  137. this.UnqualifiedNumber =data[0].sum
  138. })
  139. },
  140. //留样样品数量
  141. getStayData(){
  142. let sql5= "select * from (select * from t_mjypdjb where liu_yang_ri_qi_ ='' ) a where a.shi_fou_liu_yang_ != '否'"
  143. curdPost('sql',sql5).then(response => {
  144. let data = response.variables.data
  145. this.RetentionNumber = data.length
  146. })
  147. },
  148. //样品完成检测数量
  149. getSuccessData(){
  150. let sql6= "select COUNT(t_mjypdjb.id_) as num from t_mjypdjb LEFT JOIN t_mjjcbg on t_mjypdjb.yang_pin_bian_hao = t_mjjcbg.yang_pin_bian_hao where t_mjjcbg.zhuang_tai_ = '报告待发放'"
  151. curdPost('sql',sql6).then(response => {
  152. let data = response.variables.data
  153. this.SuccessNumber = data[0].num
  154. })
  155. }
  156. },
  157. }
  158. </script>
  159. <style lang="scss" scoped>
  160. .baseBgColor{
  161. width: 100%;
  162. height: 80px;
  163. background-color: rgba(6, 30, 93, 0.5);
  164. display: flex;
  165. .totalNumber,
  166. .notReceived,
  167. .received,
  168. .staging,
  169. .unqualified,
  170. .retention
  171. {
  172. border-right: 1px solid #00db95;
  173. flex: 1;
  174. text-align: center;
  175. font-size: 16px;
  176. display: flex;
  177. flex-direction:cloumn;
  178. flex-wrap :wrap;
  179. align-content: space-around;
  180. margin: 10px 0px;
  181. position:relative;
  182. text-align:center;
  183. display:table-cell;
  184. vertical-align:middle;
  185. .number{
  186. display:inline-block;
  187. margin: 15px 0px 0px 0px;
  188. }
  189. }
  190. }
  191. </style>