chooseEvaluateItem.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 v-for="(item,index) in childItems" :key="item.id" @click="chooseItem(item,index)" class="checkbox-item">
  13. <view class="item-name">{{item.name}}</view>
  14. <view>
  15. <radio :checked="item.checked" :value="item.id" />
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. <view style="flex-grow: 1;" v-if="items.length==0">
  21. <u-empty text="暂无考评指标" mode="list"></u-empty>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. import {findAllItem} from '@/api/assess'
  27. export default{
  28. data(){
  29. return{
  30. items: [],
  31. activeIndex:0,
  32. childItems:[],
  33. checkedItem: null // 已选指标
  34. }
  35. },
  36. onLoad(opts) {
  37. this.checkedItem = opts.item&&JSON.parse(opts.item)||null
  38. findAllItem().then(res=>{
  39. console.log(res,'0')
  40. if(res.status == 200){
  41. this.items = res.data
  42. this.onTab(0)
  43. }
  44. })
  45. },
  46. methods:{
  47. onTab(index){
  48. this.activeIndex = index
  49. this.childItems = this.items[index].assessTargetList
  50. this.childItems.map(item=>{
  51. item.checked = (this.checkedItem && item.id == this.checkedItem.id) ? true :false
  52. })
  53. },
  54. chooseItem(item,index){
  55. console.log(item,index)
  56. this.checkedItem = item
  57. uni.$emit('selKpItem',item)
  58. uni.navigateBack()
  59. }
  60. }
  61. }
  62. </script>
  63. <style lang="scss">
  64. page{
  65. height: 100%;
  66. background: #F8F8F8;
  67. }
  68. .kp-details{
  69. height: 100%;
  70. display: flex;
  71. flex-direction: column;
  72. .kp-tabsBox{
  73. flex-grow: 1;
  74. display: flex;
  75. .kp-tabs{
  76. width: 30%;
  77. text-align: center;
  78. margin: 15upx;
  79. overflow: auto;
  80. > view{
  81. padding: 15upx;
  82. background: #fff;
  83. border-radius: 6upx;
  84. box-shadow: 1px 2px 3px #eee;
  85. border: 1px solid #eee;
  86. margin-bottom: 15upx;
  87. > view{
  88. &:last-child{
  89. color: #666;
  90. }
  91. }
  92. }
  93. > view.active{
  94. background: #00aaff;
  95. color: #fff;
  96. > view{
  97. &:last-child{
  98. color: #fff;
  99. }
  100. }
  101. }
  102. }
  103. .kp-items{
  104. width: 70%;
  105. margin: 15upx 15upx 15upx 6upx;
  106. overflow: auto;
  107. .checkbox-item{
  108. width:100%;
  109. padding: 15upx;
  110. border-radius: 6upx;
  111. border: 1px solid #eee;
  112. box-shadow: 1px 2px 3px #eee;
  113. background: #fff;
  114. display: flex;
  115. justify-content: space-between;
  116. margin-bottom: 15upx;
  117. }
  118. }
  119. }
  120. .kp-ok{
  121. text-align: center;
  122. padding: 26upx;
  123. background: #55aaff;
  124. color: #fff;
  125. font-size: 18px;
  126. }
  127. }
  128. </style>