myCard.vue 4.5 KB

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