ChecklistItem.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <ul v-if="data">
  3. <li v-for="(item, itemIdx) in data" :key="item.itemCode">
  4. <checklist-item :data="item.children" @change="change" />
  5. <ul class="point-container">
  6. <li v-for="(point, pointIdx) in item.pointList" :key="point.pointCode" class="checklist-point">
  7. <uni-row>
  8. <uni-col :span="2">
  9. <text> {{ pointIdx + 1 }}</text>
  10. </uni-col>
  11. <uni-col :span="18">
  12. <text > {{ point.pointContent }} </text>
  13. <view class="uni-rate-container">
  14. <text>评价</text>
  15. <uni-rate v-model="point.score" @change="changePoint(point)" />
  16. </view>
  17. </uni-col>
  18. </uni-row>
  19. </li>
  20. </ul>
  21. </li>
  22. </ul>
  23. </template>
  24. <script>
  25. import ChecklistItem from '@/components/ChecklistItem.vue'
  26. export default {
  27. name: 'ChecklistItem',
  28. props: {
  29. value:{
  30. type:[String,Number]
  31. },
  32. data: {
  33. type: Array,
  34. default:()=>[]
  35. }
  36. },
  37. data(){
  38. return{
  39. items:[]
  40. }
  41. },
  42. components:{
  43. ChecklistItem
  44. },
  45. methods: {
  46. changePoint(item){
  47. var items=JSON.parse(JSON.stringify(this.items))
  48. var inItems=false;
  49. if(items.length>0){
  50. inItems=items.filter((_item)=>_item.pointId===item.pointId).length>0
  51. }
  52. if(!inItems){
  53. items.push({
  54. ...item
  55. })
  56. }else{
  57. for(let i=0;i<items.length;i++){
  58. if(items[i].pointId===item.pointId){items[i].score=item.score}
  59. }
  60. }
  61. this.items=items
  62. this.$emit("change",items);
  63. },
  64. change(items){
  65. this.$emit("change",items);
  66. }
  67. }
  68. }
  69. </script>
  70. <style lang="scss" scoped>
  71. ul {
  72. list-style-type: none;
  73. .uni-col-3{
  74. min-height: 1px;
  75. }
  76. }
  77. .checklist-item {
  78. color: #F7F7F7;
  79. padding: 20upx 0;
  80. line-height: 1;
  81. }
  82. .checklist-point {
  83. padding-top: 20upx;
  84. line-height: 1;
  85. }
  86. .uni-rate-container{
  87. display: flex;
  88. justify-content: flex-start;
  89. align-items: center;
  90. padding-top: 16upx;
  91. }
  92. </style>