index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <!--
  2. * @Author: liuzhenlin 461480418@qq.ocm
  3. * @Date: 2023-03-09 14:30:53
  4. * @LastEditors: liuzhenlin
  5. * @LastEditTime: 2023-03-13 10:05:18
  6. * @Description: file content
  7. * @FilePath: \oms\pages\project\components\list.vue
  8. -->
  9. <template>
  10. <view class="card-wrap">
  11. <!-- 表单头部 -->
  12. <view class="card-item" v-for="(item, index) in dataList" :key="index">
  13. <view class="card-header">
  14. <u-row>
  15. <u-col :span="7">
  16. <view class="no">{{ index + 1 }}</view>
  17. </u-col>
  18. <u-col :span="5">
  19. <view class="flex">
  20. <u-text customStyle="margin-right:20rpx" align="right" size="26rpx" color="#5B8DCD"></u-text>
  21. <view class="flex1" v-if="item.open" @click="changeOpen(index, false)">
  22. <u-text customStyle="margin-right:10rpx" size="26rpx" color="#5B8DCD" text="收起"></u-text>
  23. <u-icon name="arrow-up"></u-icon>
  24. </view>
  25. <view class="flex1" v-else @click="changeOpen(index, true)">
  26. <u-text customStyle="margin-right:10rpx" size="26rpx" color="#5B8DCD" text="展开"></u-text>
  27. <u-icon name="arrow-down"></u-icon>
  28. </view>
  29. </view>
  30. </u-col>
  31. </u-row>
  32. </view>
  33. <!-- 内容 -->
  34. <view class="content">
  35. <view class="desc-area" v-if="!item.open">
  36. <slot name="header" :dataItem="item"></slot>
  37. </view>
  38. <view class="form-area" v-else>
  39. <view class="form-item" v-for="(v, i) in columns" :key="i">
  40. <!-- label -->
  41. <view class="form-label flex_l">
  42. <view class="label-tag"></view>
  43. {{ v.label }}
  44. </view>
  45. <!-- input -->
  46. <u-textarea v-if="!v.customRender" autoHeight :disabled="v.disabled" v-model="item[v.prop]"></u-textarea>
  47. <slot name="content" :dataItem="item" :propsss="v.prop" v-else></slot>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. export default {
  56. props: {
  57. data: {
  58. type: Object | Array,
  59. required: true,
  60. default: () => [],
  61. },
  62. columns: {
  63. type: Object | Array,
  64. required: true,
  65. default: () => [],
  66. },
  67. },
  68. data() {
  69. return {
  70. dataList: [],
  71. }
  72. },
  73. mounted() {
  74. this.dataList = this.data.map((item) => ({ ...item, open: true }))
  75. },
  76. methods: {
  77. changeOpen(index, status) {
  78. this.dataList[index].open = status
  79. },
  80. getData() {
  81. let result = []
  82. this.dataList.map((item) => {
  83. const { open, ...items } = item
  84. result.push({ ...items })
  85. })
  86. },
  87. },
  88. components: {},
  89. }
  90. </script>
  91. <style lang="scss" scoped>
  92. .card-item {
  93. border-radius: 10px;
  94. border: 1px solid #bdbdbd;
  95. overflow: hidden;
  96. margin-bottom: 20rpx;
  97. .card-header {
  98. padding: 20rpx 30rpx;
  99. padding-bottom: 20rpx;
  100. background: -webkit-linear-gradient(top, #eeeff3, #fbfbfd);
  101. .no {
  102. width: 50rpx;
  103. height: 50rpx;
  104. background: #78b0ed;
  105. border-radius: 50%;
  106. text-align: center;
  107. line-height: 50rpx;
  108. color: #fff;
  109. }
  110. }
  111. .form-item {
  112. padding-bottom: 30rpx;
  113. .form-label {
  114. font-size: 30rpx;
  115. font-weight: bold;
  116. color: #323232;
  117. padding-bottom: 18rpx;
  118. .label-tag {
  119. width: 15rpx;
  120. height: 15rpx;
  121. background: #ff4d4f;
  122. border-radius: 50%;
  123. margin-right: 10rpx;
  124. }
  125. }
  126. }
  127. .content {
  128. padding: 20rpx 30rpx;
  129. }
  130. }
  131. </style>