index.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <template>
  2. <div class="app-container">
  3. <el-tabs v-model="activeName" >
  4. <el-tab-pane :label="num1" name="approval" @click="tabClick"></el-tab-pane>
  5. <el-tab-pane :label="num2" name="approved" @click="tabClick" ></el-tab-pane>
  6. </el-tabs>
  7. <component :is="currentPage" :oid="ocode"></component>
  8. </div>
  9. </template>
  10. <script>
  11. import { getCountStatus } from "@/api/qualityControl/qualityControl";
  12. import approval from '@/views/qualityControl/approval';
  13. import approved from '@/views/qualityControl/approved';
  14. import { _ } from "core-js";
  15. export default {
  16. mounted() {
  17. let code = this.$route.query.mid; // 质管企微跳转ID
  18. if(code!= undefined){
  19. this.ocode = code;
  20. this.activeName = 'approved';
  21. }
  22. },
  23. name: "tabs",
  24. data() {
  25. return {
  26. ocode: '',
  27. num1: '',
  28. num2: '',
  29. queryParams1: '0',
  30. queryParams2: '1',
  31. activeName: 'approval' // 默认激活第一个标签
  32. };
  33. },
  34. watch: {
  35. currentPage(newValue, oldValue) {
  36. if(oldValue != newValue){
  37. this.tabClick();
  38. if(newValue == 'approval'){
  39. this.$router.replace('/business/qualityControl/index');
  40. }
  41. }
  42. },
  43. },
  44. created() {
  45. this.tabClick();
  46. },
  47. methods: {
  48. tabClick(){
  49. getCountStatus(this.queryParams1).then(response => {
  50. this.num1 = "待处理 ("+response.data+")";
  51. });
  52. getCountStatus(this.queryParams2).then(response => {
  53. this.num2 = "已处理 ("+response.data+")";
  54. });
  55. }
  56. },
  57. components:{
  58. approval,
  59. approved
  60. },
  61. computed: {
  62. // 计算属性返回当前应该显示的组件
  63. currentPage() {
  64. return this.activeName;
  65. }
  66. }
  67. };
  68. </script>