evaluateItem.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <view class="kp-details">
  3. <!-- 考评项 -->
  4. <view class="kp-tabsBox">
  5. <view class="kp-tabs">
  6. <view @click="onTab(index)" :class="activeIndex == index ? 'active':''" v-for="(item,index) in items" :key="item.id">
  7. <view>{{item.name}}</view>
  8. <view>({{item.assessTargetNum}}项)</view>
  9. </view>
  10. </view>
  11. <view class="kp-items">
  12. <view>
  13. <checkbox-group @change="checkboxChange" class="checkbox-group">
  14. <label v-for="item in childItems" :key="item.id" >
  15. <view class="checkbox-item">
  16. <view class="item-name">{{item.name}}</view>
  17. <view>
  18. <checkbox :value="item.id" :checked="item.checked" />
  19. </view>
  20. </view>
  21. </label>
  22. </checkbox-group>
  23. </view>
  24. </view>
  25. </view>
  26. <!-- 选择按钮 -->
  27. <view class="kp-ok">
  28. 确定选择
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import {findAllItem} from '@/api/assess'
  34. export default{
  35. data(){
  36. return{
  37. items: [],
  38. activeIndex:0,
  39. childItems:[],
  40. checkedList:[]
  41. }
  42. },
  43. onLoad() {
  44. findAllItem().then(res=>{
  45. if(res.status == 200){
  46. this.items = res.data
  47. this.onTab(0)
  48. }
  49. })
  50. },
  51. methods:{
  52. onTab(index){
  53. this.activeIndex = index
  54. this.childItems = this.items[index].assessTargetList
  55. },
  56. checkboxChange: function (e) {
  57. var items = this.items,
  58. values = e.detail.value;
  59. this.checkedList = values
  60. console.log(values,'checkboxChange')
  61. for (var i = 0, lenI = items.length; i < lenI; ++i) {
  62. const item = items[i]
  63. if(values.includes(item.value)){
  64. }else{
  65. this.$set(item,'checked',false)
  66. }
  67. }
  68. }
  69. }
  70. }
  71. </script>
  72. <style lang="scss">
  73. page{
  74. height: 100%;
  75. background: #F8F8F8;
  76. }
  77. .kp-details{
  78. height: 100%;
  79. display: flex;
  80. flex-direction: column;
  81. .kp-tabsBox{
  82. flex-grow: 1;
  83. display: flex;
  84. .kp-tabs{
  85. width: 30%;
  86. text-align: center;
  87. margin: 15upx;
  88. overflow: auto;
  89. > view{
  90. padding: 15upx;
  91. background: #fff;
  92. border-radius: 6upx;
  93. box-shadow: 1px 2px 3px #eee;
  94. margin-bottom: 15upx;
  95. > view{
  96. &:last-child{
  97. color: #666;
  98. }
  99. }
  100. }
  101. > view.active{
  102. background: #00aaff;
  103. color: #fff;
  104. > view{
  105. &:last-child{
  106. color: #fff;
  107. }
  108. }
  109. }
  110. }
  111. .kp-items{
  112. width: 70%;
  113. margin: 15upx 15upx 15upx 6upx;
  114. overflow: auto;
  115. > view{
  116. .checkbox-group{
  117. .checkbox-item{
  118. width:100%;
  119. padding: 15upx;
  120. border-radius: 6upx;
  121. box-shadow: 1px 2px 3px #eee;
  122. background: #fff;
  123. display: flex;
  124. justify-content: space-between;
  125. margin-bottom: 15upx;
  126. }
  127. }
  128. }
  129. }
  130. }
  131. .kp-ok{
  132. text-align: center;
  133. padding: 26upx;
  134. background: #55aaff;
  135. color: #fff;
  136. font-size: 18px;
  137. }
  138. }
  139. </style>