ApplyCard.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <template>
  2. <view class="apply-card">
  3. <view class="apply-body">
  4. <view class="apply-head">
  5. <view class="apply-icon" :style="{ color: row.color, background: iconBg }">
  6. {{ iconText }}
  7. </view>
  8. <view class="apply-main">
  9. <view class="apply-title-row">
  10. <text class="apply-title">{{ row.title || "申请" }}</text>
  11. <text class="status-tag" :class="'status-' + statusClass">{{ row.statusLabel || "—" }}</text>
  12. </view>
  13. <text class="apply-no">{{ subText }}</text>
  14. </view>
  15. </view>
  16. <!-- 管理端(申请记录):显示申请人 -->
  17. <view v-if="admin" class="apply-person">
  18. <text class="person-name">{{ row.applicantName || "—" }}</text>
  19. <text v-if="row.applicantJobNumber" class="person-meta">工号 {{ row.applicantJobNumber }}</text>
  20. <text v-if="row.organizationName" class="person-meta">{{ row.organizationName }}</text>
  21. </view>
  22. <!--
  23. 移动端没有详情页的业务(如「劳动合同申请」):直接在卡片上说清楚去哪看。
  24. 文案口径与 openEssApplication 的 toast 一致(都走 pcOnlyHintOf)。
  25. -->
  26. <view v-if="pcHint" class="pc-hint">
  27. <text class="pc-hint-mark">!</text>
  28. <text class="pc-hint-text">{{ pcHint }}</text>
  29. </view>
  30. <view v-if="row.maskedSummary" class="apply-summary">{{ row.maskedSummary }}</view>
  31. <view v-if="row.createdAt || row.currentNode" class="apply-foot">
  32. <text class="foot-time">{{ row.createdAt || "" }}</text>
  33. <text v-if="row.currentNode" class="foot-node">当前节点 · {{ row.currentNode }}</text>
  34. </view>
  35. </view>
  36. <!--
  37. 动作栏:
  38. 申请详情 = 主操作(实心渐变绿)→ 按业务类型跳对应详情页;
  39. 审批流程 = 次操作(描边绿)→ 公共流程详情页。
  40. 两个按钮的样式**固定不变**:同一个动作在任何卡片上都得长得一样,
  41. 不能因为「这张卡没有申请详情」就把审批流程改成实心(那样看起来是另一个操作)。
  42. 「移动端看不了」的业务(如劳动合同)没有详情页,直接不渲染「申请详情」按钮。
  43. -->
  44. <view class="apply-actions">
  45. <view v-if="canOpenDetail" class="apply-btn apply-btn--primary press" @click="$emit('detail')">
  46. 申请详情
  47. </view>
  48. <view class="apply-btn apply-btn--ghost press" @click="$emit('flow')">审批流程</view>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. /**
  54. * 申请卡片(「我的申请」pages/hr/apply/list 与「申请记录」pages/hr/apply/record 共用)
  55. *
  56. * 为什么抽成组件:两个页面只差一个 admin(是否显示申请人),卡片模板与样式完全一致,
  57. * 放两份必然漂移。样式只在本组件里写一次。
  58. *
  59. * 事件:
  60. * detail —— 申请详情(页面调用 openEssApplication,按 businessType 跳对应详情)
  61. * flow —— 审批流程(跳公共页 /pages/home/wt/components/detail?processInstanceId=)
  62. */
  63. import { businessMetaOf, pcOnlyHintOf } from "@/api/hr/essApplication";
  64. export default {
  65. name: "ApplyCard",
  66. props: {
  67. /** adaptEssApplication 的产物 */
  68. row: { type: Object, default: () => ({}) },
  69. /** 管理端(申请记录):卡片上额外显示申请人 */
  70. admin: { type: Boolean, default: false },
  71. },
  72. emits: ["detail", "flow"],
  73. computed: {
  74. iconText() {
  75. return this.row.icon || (businessMetaOf(this.row.businessType) || {}).icon || "申";
  76. },
  77. /** 图标底色:取业务主题色 + 8 位 hex 的 10% 透明度 */
  78. iconBg() {
  79. const color = String(this.row.color || "#157a2c");
  80. return /^#[0-9a-fA-F]{6}$/.test(color) ? `${color}1a` : "rgba(21, 122, 44, 0.1)";
  81. },
  82. statusClass() {
  83. return this.row.statusClass || "pending";
  84. },
  85. /** 副信息:优先单号,没有单号时退回时间 */
  86. subText() {
  87. return this.row.applicationNo || this.row.createdAt || "—";
  88. },
  89. /** 只有「移动端看不了」的业务类型才提示(supported 由 essApplication 判定) */
  90. pcHint() {
  91. return this.row.supported ? "" : pcOnlyHintOf(this.row);
  92. },
  93. /** 有详情页才给「申请详情」按钮:没有详情页时点了也只能弹提示 */
  94. canOpenDetail() {
  95. return Boolean(this.row.supported);
  96. },
  97. },
  98. };
  99. </script>
  100. <style scoped lang="scss">
  101. /* .status-tag / .press 来自 HR 公共样式;组件内部要用就得自己引一次
  102. (scoped 样式不会作用到子组件内部的元素,父页面引了这里也用不到) */
  103. @import "@/pages/hr/common-style.scss";
  104. .apply-card {
  105. margin-bottom: 24rpx;
  106. background: #fff;
  107. border: 1rpx solid #eef0f3;
  108. border-radius: 20rpx;
  109. box-shadow: 0 4rpx 16rpx rgba(31, 35, 41, 0.05);
  110. /* 让动作栏的浅底不溢出圆角 */
  111. overflow: hidden;
  112. }
  113. .apply-body {
  114. padding: 28rpx 28rpx 22rpx;
  115. }
  116. .apply-head {
  117. display: flex;
  118. align-items: flex-start;
  119. }
  120. .apply-icon {
  121. flex: none;
  122. width: 76rpx;
  123. height: 76rpx;
  124. border-radius: 20rpx;
  125. display: flex;
  126. align-items: center;
  127. justify-content: center;
  128. font-size: 32rpx;
  129. font-weight: 600;
  130. }
  131. .apply-main {
  132. flex: 1;
  133. min-width: 0;
  134. margin-left: 22rpx;
  135. padding-top: 2rpx;
  136. }
  137. .apply-title-row {
  138. display: flex;
  139. align-items: center;
  140. }
  141. .apply-title {
  142. flex: 1;
  143. min-width: 0;
  144. color: #1f2329;
  145. font-size: 30rpx;
  146. font-weight: 600;
  147. letter-spacing: 0.5rpx;
  148. overflow: hidden;
  149. white-space: nowrap;
  150. text-overflow: ellipsis;
  151. }
  152. .apply-title-row .status-tag {
  153. flex: none;
  154. margin-left: 16rpx;
  155. }
  156. .apply-no {
  157. display: block;
  158. margin-top: 10rpx;
  159. color: #a3a9b3;
  160. font-size: 22rpx;
  161. letter-spacing: 0.5rpx;
  162. }
  163. /* 管理端申请人 */
  164. .apply-person {
  165. margin-top: 22rpx;
  166. display: flex;
  167. align-items: center;
  168. flex-wrap: wrap;
  169. font-size: 23rpx;
  170. color: #4b5563;
  171. }
  172. .person-name {
  173. font-weight: 500;
  174. }
  175. .person-meta {
  176. margin-left: 18rpx;
  177. color: #8b939f;
  178. }
  179. /* 移动端看不了的业务:卡片内直接说明去处 */
  180. .pc-hint {
  181. margin-top: 22rpx;
  182. padding: 16rpx 20rpx;
  183. border-radius: 14rpx;
  184. background: #fff8e8;
  185. display: flex;
  186. align-items: center;
  187. }
  188. .pc-hint-mark {
  189. flex: none;
  190. width: 32rpx;
  191. height: 32rpx;
  192. margin-right: 12rpx;
  193. border-radius: 50%;
  194. background: #f0a020;
  195. color: #fff;
  196. font-size: 22rpx;
  197. font-weight: 700;
  198. text-align: center;
  199. line-height: 32rpx;
  200. }
  201. .pc-hint-text {
  202. flex: 1;
  203. min-width: 0;
  204. color: #a3690d;
  205. font-size: 23rpx;
  206. line-height: 1.5;
  207. }
  208. .apply-summary {
  209. margin-top: 22rpx;
  210. padding: 20rpx;
  211. border-radius: 14rpx;
  212. background: #f7f8fa;
  213. color: #555d68;
  214. font-size: 25rpx;
  215. line-height: 1.5;
  216. }
  217. .apply-foot {
  218. margin-top: 22rpx;
  219. padding-top: 20rpx;
  220. border-top: 1rpx dashed #eef0f3;
  221. display: flex;
  222. align-items: center;
  223. justify-content: space-between;
  224. color: #9aa1ab;
  225. font-size: 22rpx;
  226. }
  227. .foot-time {
  228. letter-spacing: 0.5rpx;
  229. }
  230. .foot-node {
  231. color: #157a2c;
  232. }
  233. /* 动作栏:浅底 + 上分隔线,按钮右对齐,主次分明 */
  234. .apply-actions {
  235. padding: 18rpx 28rpx 22rpx;
  236. display: flex;
  237. align-items: center;
  238. justify-content: flex-end;
  239. background: #fbfcfd;
  240. border-top: 1rpx solid #f2f4f7;
  241. }
  242. .apply-btn {
  243. min-width: 152rpx;
  244. height: 62rpx;
  245. padding: 0 30rpx;
  246. border-radius: 999rpx;
  247. display: flex;
  248. align-items: center;
  249. justify-content: center;
  250. font-size: 25rpx;
  251. font-weight: 500;
  252. box-sizing: border-box;
  253. }
  254. .apply-btn + .apply-btn {
  255. margin-left: 18rpx;
  256. }
  257. /* 主操作:实心渐变绿(与 HR 模块标题竖条同一组绿色) */
  258. .apply-btn--primary {
  259. color: #fff;
  260. background: linear-gradient(135deg, #1aa53c, #157a2c);
  261. box-shadow: 0 4rpx 12rpx rgba(21, 122, 44, 0.2);
  262. }
  263. /* 次操作:白底绿描边 */
  264. .apply-btn--ghost {
  265. color: #157a2c;
  266. background: #fff;
  267. border: 1rpx solid #cfe6d5;
  268. }
  269. </style>