myCard.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <template>
  2. <view class="card_box">
  3. <view class="item_box rx-bc" v-for="(_item,i) in columns" :key="i">
  4. <template v-for="(val) in _item">
  5. <view class="perce50" :class="val.className" :style="val.style" :key="val.prop" v-if="!val.isNone">
  6. <view class="item_box rx-sc" v-if="val.type=='title'">
  7. <view class="round" v-if='index'>{{index}}</view>
  8. <view class="orderId" :style="{marginLeft: index?'16rpx':''}" v-if="val.slot">
  9. <slot :name="val.slot"> </slot>
  10. </view>
  11. <view class="orderId" :style="{marginLeft: index?'16rpx':''}" v-else>
  12. {{item[val.prop]||''}}
  13. </view>
  14. </view>
  15. <view class="item_one rx-sc" v-else-if="val.type=='action'">
  16. <view class="lable">{{val.label}}</view>
  17. <view class="text" style="flex-wrap: wrap;">
  18. <template v-for="(btn,bI) in btnList">
  19. <u-button :plain="true" :hairline="true" size='mini' :type="btn.btnType"
  20. v-if="judge(btn)" :text="btn.name" @click="action(btn)" :key="bI"></u-button>
  21. </template>
  22. </view>
  23. </view>
  24. <view class="item_one rx-sc kk" v-else>
  25. <view class="lable">{{val.label}}</view>
  26. <view class="text" v-if="val.formatter">{{val.formatter(item)||''}}</view>
  27. <view class="text" v-else-if="val.slot">
  28. <slot :name="val.slot"> </slot>
  29. </view>
  30. <view class="text" v-else>{{item[val.prop]||''}}</view>
  31. </view>
  32. </view>
  33. </template>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. export default {
  39. props: {
  40. btnList: {
  41. type: Array,
  42. default: () => []
  43. },
  44. item: {
  45. type: Object,
  46. default: () => ({})
  47. },
  48. columns: {
  49. type: Array,
  50. default: () => []
  51. },
  52. index: '',
  53. },
  54. computed: {
  55. judge() {
  56. return (item) => {
  57. if (item.judge) {
  58. let is = true
  59. item.judge.forEach(({
  60. key,
  61. value,
  62. authorities,
  63. fn
  64. }) => {
  65. if (authorities) {
  66. is = this.$isAuthorities(authorities)
  67. }
  68. if (value && !value.includes(this.item[key])) {
  69. is = false
  70. }
  71. if (fn) {
  72. is = fn(this.item)
  73. }
  74. })
  75. return is
  76. } else {
  77. return true
  78. }
  79. }
  80. }
  81. },
  82. data() {
  83. return {
  84. }
  85. },
  86. methods: {
  87. action(item) {
  88. if (item.type == 1) {
  89. uni.navigateTo({
  90. url: item.pageUrl + '?id=' + this.item.id + (item.query || '')
  91. })
  92. } else {
  93. this.$emit(item.apiName)
  94. }
  95. },
  96. }
  97. }
  98. </script>
  99. <style lang="scss" scoped>
  100. .card_box {
  101. width: 750rpx;
  102. padding: 16rpx 32rpx;
  103. box-sizing: border-box;
  104. border-bottom: 2rpx solid #E1E1E1;
  105. .rx-bc {
  106. align-items: start;
  107. flex-flow: row wrap;
  108. >view {
  109. margin-top: 8rpx;
  110. }
  111. }
  112. .rx-sc {
  113. align-items: start;
  114. }
  115. .item_box {
  116. // margin-top: 10rpx;
  117. .text {
  118. display: flex;
  119. // padding-right: 6rpx;
  120. flex: 1;
  121. uni-button:after {
  122. border: none;
  123. }
  124. ;
  125. uni-button {
  126. width: 100rpx;
  127. // height: 50rpx;
  128. margin-left: 10rpx;
  129. margin-right: 0;
  130. color: #fff !important;
  131. border: none;
  132. background: #157a2c;
  133. margin-top: 3px;
  134. // border: none;
  135. // /deep/uni-text {
  136. // font-size: 26rpx !important;
  137. // }
  138. }
  139. }
  140. .kk .text {
  141. overflow: hidden;
  142. text-overflow: ellipsis;
  143. display: -webkit-box;
  144. -webkit-box-orient: vertical;
  145. -webkit-line-clamp: 2;
  146. word-break: break-word;
  147. }
  148. .round {
  149. width: 40rpx;
  150. height: 40rpx;
  151. line-height: 40rpx;
  152. border-radius: 50%;
  153. background: $theme-color;
  154. color: #fff;
  155. text-align: center;
  156. font-size: 20rpx;
  157. }
  158. .orderId {
  159. color: #000;
  160. font-family: PingFang HK;
  161. font-size: 28rpx;
  162. font-style: normal;
  163. font-weight: 600;
  164. }
  165. .item_one {
  166. width: 100%;
  167. font-size: 26rpx;
  168. font-style: normal;
  169. font-weight: 400;
  170. line-height: 38rpx;
  171. word-wrap: break-word;
  172. }
  173. .gylx {
  174. color: $theme-color;
  175. }
  176. .perce50 {
  177. min-width: 50%;
  178. }
  179. .perce100 {
  180. width: 100% !important;
  181. }
  182. }
  183. }
  184. /deep/.u-input {
  185. padding: 0 !important;
  186. height: 44rpx !important;
  187. font-size: 26rpx !important;
  188. }
  189. /deep/.u-input__content__field-wrapper__field {
  190. font-size: 26rpx !important;
  191. }
  192. /deep/.uni-date-editor--x .uni-date__icon-clear {
  193. border: none !important;
  194. }
  195. /deep/.uni-date__x-input,
  196. /deep/.uni-date-x {
  197. padding: 0 !important;
  198. height: 44rpx !important;
  199. font-size: 26rpx !important;
  200. }
  201. /deep/.input-value {
  202. font-size: 26rpx !important;
  203. height: 44rpx !important;
  204. uni-text {
  205. font-size: 26rpx !important;
  206. }
  207. }
  208. /deep/.u-textarea {
  209. padding: 2px !important;
  210. }
  211. /deep/.u-textarea__field {
  212. font-size: 26rpx !important;
  213. }
  214. </style>