myCard.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <template>
  2. <view class="card_container">
  3. <view class="card_box">
  4. <!-- 标题区域 - 独立出来,宽度100% -->
  5. <view class="header_box" v-if="title">
  6. <view class="title_left">
  7. <view class="round" v-if="index">{{ index }}</view>
  8. <view class="orderId" :style="{ marginLeft: index ? '16rpx' : '' }">{{
  9. title
  10. }}</view>
  11. </view>
  12. <!-- 状态 - 固定在右上角 -->
  13. <view class="status-tag" v-if="status">{{ status }}</view>
  14. </view>
  15. <view class="item_box rx-bc" v-for="(_item, i) in columns" :key="i">
  16. <template v-for="val in _item">
  17. <view
  18. class="perce50"
  19. :class="[val.className, { 'full-width': val.isFullWidth }]"
  20. :style="val.style"
  21. :key="val.prop"
  22. v-if="!val.isNone"
  23. >
  24. <!-- 操作行 -->
  25. <view class="item_one rx-sc" v-if="val.type == 'action'">
  26. <view class="lable">{{ val.label }}</view>
  27. <view class="text" style="flex-wrap: wrap">
  28. <template v-for="(btn, bI) in btnList">
  29. <u-button
  30. :plain="true"
  31. :hairline="true"
  32. size="mini"
  33. :type="btn.btnType"
  34. v-if="judge(btn)"
  35. :text="btn.name"
  36. @click="action(btn)"
  37. :key="bI"
  38. ></u-button>
  39. </template>
  40. </view>
  41. </view>
  42. <!-- 普通信息行 -->
  43. <view class="item_one rx-sc kk" v-else>
  44. <view class="lable">{{ val.label }}</view>
  45. <view class="text" :class="val.valueClass" v-if="val.formatter">{{
  46. val.formatter(item) || ""
  47. }}</view>
  48. <view class="text" :class="val.valueClass" v-else-if="val.slot">
  49. <slot :name="val.slot"></slot>
  50. </view>
  51. <view class="text" :class="val.valueClass" v-else>{{
  52. item[val.prop] || ""
  53. }}</view>
  54. </view>
  55. </view>
  56. </template>
  57. </view>
  58. <!-- 查看详情 -->
  59. <view class="footer-link" v-if="showDetail" @click="goDetail">
  60. <text>查看详情</text>
  61. <u-icon name="arrow-right" size="24" color="#999999"></u-icon>
  62. </view>
  63. </view>
  64. </view>
  65. </template>
  66. <script>
  67. export default {
  68. props: {
  69. btnList: {
  70. type: Array,
  71. default: () => [],
  72. },
  73. item: {
  74. type: Object,
  75. default: () => ({}),
  76. },
  77. columns: {
  78. type: Array,
  79. default: () => [],
  80. },
  81. title: {
  82. type: String,
  83. default: "",
  84. },
  85. status: {
  86. type: String,
  87. default: "",
  88. },
  89. index: "",
  90. showDetail: {
  91. type: Boolean,
  92. default: true,
  93. },
  94. },
  95. computed: {
  96. judge() {
  97. return (item) => {
  98. if (item.judge) {
  99. let is = true;
  100. item.judge.forEach(({ key, value, authorities, fn }) => {
  101. if (authorities) {
  102. is = this.$isAuthorities(authorities);
  103. }
  104. if (value && !value.includes(this.item[key])) {
  105. is = false;
  106. }
  107. if (fn) {
  108. is = fn(this.item);
  109. }
  110. });
  111. return is;
  112. } else {
  113. return true;
  114. }
  115. };
  116. },
  117. },
  118. data() {
  119. return {};
  120. },
  121. methods: {
  122. action(item) {
  123. if (item.type == 1) {
  124. uni.navigateTo({
  125. url: item.pageUrl + "?id=" + this.item.id + (item.query || ""),
  126. });
  127. } else {
  128. this.$emit(item.apiName);
  129. }
  130. },
  131. goDetail() {
  132. this.$emit("goDetail", this.item);
  133. },
  134. },
  135. };
  136. </script>
  137. <style lang="scss" scoped>
  138. .card_container {
  139. padding: 20rpx 24rpx;
  140. background: #f5f5f5;
  141. }
  142. .card_box {
  143. background: #ffffff;
  144. border-radius: 16rpx;
  145. padding: 28rpx;
  146. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
  147. position: relative;
  148. .rx-bc {
  149. display: flex;
  150. align-items: flex-start;
  151. flex-flow: row wrap;
  152. > view {
  153. margin-top: 28rpx;
  154. &:first-child,
  155. &:nth-child(2) {
  156. margin-top: 0;
  157. }
  158. }
  159. }
  160. .rx-sc {
  161. display: flex;
  162. align-items: flex-start;
  163. }
  164. // 头部样式
  165. .header_box {
  166. display: flex;
  167. justify-content: space-between;
  168. align-items: center;
  169. width: 100%;
  170. position: relative;
  171. background: linear-gradient(135deg, #e8f5e9 0%, #f1f8e9 100%);
  172. padding: 20rpx 24rpx;
  173. border-radius: 12rpx 12rpx 0 0;
  174. margin: -28rpx -28rpx 28rpx -28rpx;
  175. width: calc(100% + 56rpx);
  176. box-sizing: border-box;
  177. .round {
  178. width: 44rpx;
  179. height: 44rpx;
  180. line-height: 44rpx;
  181. border-radius: 50%;
  182. background: $theme-color;
  183. color: #fff;
  184. text-align: center;
  185. font-size: 24rpx;
  186. font-weight: 600;
  187. flex-shrink: 0;
  188. }
  189. .orderId {
  190. color: #333333;
  191. font-size: 32rpx;
  192. font-weight: 600;
  193. white-space: nowrap;
  194. overflow: hidden;
  195. text-overflow: ellipsis;
  196. }
  197. .title_left {
  198. display: flex;
  199. align-items: center;
  200. flex: 1;
  201. padding-right: 140rpx;
  202. overflow: hidden;
  203. }
  204. // 状态标签
  205. .status-tag {
  206. background: #e3f2fd;
  207. color: #2196f3;
  208. font-size: 24rpx;
  209. padding: 8rpx 20rpx;
  210. border-radius: 24rpx;
  211. font-weight: 500;
  212. position: absolute;
  213. top: 50%;
  214. transform: translateY(-50%);
  215. right: 24rpx;
  216. z-index: 1;
  217. }
  218. }
  219. .item_box {
  220. .text {
  221. display: flex;
  222. flex: 1;
  223. uni-button:after {
  224. border: none;
  225. }
  226. uni-button {
  227. width: 100rpx;
  228. margin-left: 10rpx;
  229. margin-right: 0;
  230. color: #fff !important;
  231. border: none;
  232. background: #157a2c;
  233. margin-top: 3px;
  234. }
  235. }
  236. .kk .text {
  237. overflow: hidden;
  238. text-overflow: ellipsis;
  239. white-space: nowrap;
  240. display: block;
  241. }
  242. .item_one {
  243. width: 100%;
  244. font-size: 28rpx;
  245. line-height: 44rpx;
  246. display: flex;
  247. align-items: flex-start;
  248. .lable {
  249. color: #666666;
  250. flex-shrink: 0;
  251. margin-right: 12rpx;
  252. font-size: 28rpx;
  253. }
  254. .text {
  255. color: #000;
  256. font-size: 28rpx;
  257. flex: 1;
  258. white-space: nowrap;
  259. overflow: hidden;
  260. text-overflow: ellipsis;
  261. min-width: 0;
  262. // 高亮值样式
  263. &.highlight {
  264. color: #4caf50;
  265. }
  266. }
  267. }
  268. .gylx {
  269. color: $theme-color;
  270. }
  271. .perce50 {
  272. width: 50%;
  273. box-sizing: border-box;
  274. padding-right: 20rpx;
  275. &:nth-child(2n) {
  276. padding-right: 0;
  277. padding-left: 20rpx;
  278. }
  279. }
  280. .perce100 {
  281. width: 100%;
  282. }
  283. .full-width {
  284. width: 100% !important;
  285. padding-left: 0 !important;
  286. padding-right: 0 !important;
  287. }
  288. }
  289. // 底部查看详情
  290. .footer-link {
  291. display: flex;
  292. justify-content: center;
  293. align-items: center;
  294. margin-top: 28rpx;
  295. padding-top: 24rpx;
  296. border-top: 1rpx solid #f0f0f0;
  297. color: #666666;
  298. font-size: 28rpx;
  299. cursor: pointer;
  300. &:active {
  301. opacity: 0.7;
  302. }
  303. }
  304. }
  305. /deep/.u-input {
  306. padding: 0 !important;
  307. height: 44rpx !important;
  308. font-size: 26rpx !important;
  309. }
  310. /deep/.u-input__content__field-wrapper__field {
  311. font-size: 26rpx !important;
  312. }
  313. /deep/.uni-date-editor--x .uni-date__icon-clear {
  314. border: none !important;
  315. }
  316. /deep/.uni-date__x-input,
  317. /deep/.uni-date-x {
  318. padding: 0 !important;
  319. height: 44rpx !important;
  320. font-size: 26rpx !important;
  321. }
  322. /deep/.input-value {
  323. font-size: 26rpx !important;
  324. height: 44rpx !important;
  325. uni-text {
  326. font-size: 26rpx !important;
  327. }
  328. }
  329. /deep/.u-textarea {
  330. padding: 2px !important;
  331. }
  332. /deep/.u-textarea__field {
  333. font-size: 26rpx !important;
  334. }
  335. </style>