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