apply.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. <template>
  2. <div class="maintenance-apply-container">
  3. <div class="page-header">
  4. <div class="header-left">维保申请</div>
  5. <div class="header-right" @click="handleBack">返回</div>
  6. </div>
  7. <div class="content-wrapper">
  8. <div class="custom-steps-container">
  9. <div class="step-list">
  10. <div class="step-item active">
  11. <div class="step-icon">
  12. <el-icon><Check /></el-icon>
  13. </div>
  14. <div class="step-title">提交维保申请</div>
  15. </div>
  16. <div class="step-line active-line"></div>
  17. <div class="step-item">
  18. <div class="step-icon normal">
  19. <span>2</span>
  20. </div>
  21. <div class="step-title normal-text">审核通过开始服务</div>
  22. </div>
  23. </div>
  24. </div>
  25. <div class="form-container">
  26. <el-form :model="form" :rules="rules" ref="formRef" label-width="120px" class="apply-form" hide-required-asterisk>
  27. <el-form-item label="申请人名称:" prop="applicantName">
  28. <el-input v-model="form.applicantName" placeholder="请输入申请人名称" clearable />
  29. </el-form-item>
  30. <!-- The mockup shows a validation error explicitly for phone -->
  31. <el-form-item label="手机号码:" prop="phone" class="phone-item">
  32. <el-input v-model="form.phone" placeholder="请输入申请人手机号码" clearable />
  33. </el-form-item>
  34. <el-form-item label="验证码:" prop="verifyCode">
  35. <div class="verify-code-wrapper">
  36. <el-input v-model="form.verifyCode" placeholder="短信验证码" class="code-input" clearable />
  37. <div class="send-btn" @click="handleSendCode">发送验证码</div>
  38. </div>
  39. </el-form-item>
  40. <el-form-item label="">
  41. <div class="drag-verify-bar" @click="handleVerify">
  42. <div class="verify-btn" :class="{ verified: isVerified }">
  43. <div class="inner-dot" v-if="!isVerified"></div>
  44. <el-icon v-else color="#0fb881"><Check /></el-icon>
  45. </div>
  46. <div class="verify-text">{{ isVerified ? '验证通过' : '点击验证' }}</div>
  47. </div>
  48. </el-form-item>
  49. <el-form-item label="服务时间:" prop="serviceTime">
  50. <el-select v-model="form.serviceTime" placeholder="请选择服务时间" class="w-full" filterable>
  51. <el-option v-for="dict in service_time_type" :key="dict.value" :label="dict.label" :value="dict.value" />
  52. </el-select>
  53. </el-form-item>
  54. <el-form-item label="月度维保次数:" prop="monthlyTimes">
  55. <el-input v-model="form.monthlyTimes" placeholder="请输入月度维保次数" clearable />
  56. </el-form-item>
  57. <el-form-item label="维保类型:" prop="maintainType">
  58. <el-select v-model="form.maintainType" placeholder="请选择" class="w-full" filterable>
  59. <el-option v-for="dict in maintenance_type" :key="dict.value" :label="dict.label" :value="dict.value" />
  60. </el-select>
  61. </el-form-item>
  62. <el-form-item label="服务内容:" prop="serviceContent">
  63. <div class="service-content-wrapper">
  64. <div class="service-tags">
  65. <div class="tag-item" :class="{ active: form.serviceContent.includes('express') }" @click="toggleServiceContent('express')">
  66. 急速快递
  67. </div>
  68. <div class="tag-item" :class="{ active: form.serviceContent.includes('repair') }" @click="toggleServiceContent('repair')">
  69. 售后维修
  70. </div>
  71. <div class="tag-item" :class="{ active: form.serviceContent.includes('warranty') }" @click="toggleServiceContent('warranty')">
  72. 产品质保
  73. </div>
  74. </div>
  75. <el-input v-model="form.otherService" type="textarea" :rows="4" placeholder="请输入其他服务" class="other-service-input" />
  76. </div>
  77. </el-form-item>
  78. <el-form-item>
  79. <el-button type="primary" class="next-btn" @click="handleNext">下一步</el-button>
  80. </el-form-item>
  81. </el-form>
  82. </div>
  83. </div>
  84. </div>
  85. </template>
  86. <script setup lang="ts">
  87. import { ref, reactive, onMounted } from 'vue';
  88. import { useRouter } from 'vue-router';
  89. import { Check } from '@element-plus/icons-vue';
  90. import { ElMessage } from 'element-plus';
  91. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  92. const { service_time_type, maintenance_type } = toRefs<any>(proxy?.useDict('service_time_type', 'maintenance_type'));
  93. const router = useRouter();
  94. const formRef = ref();
  95. const isVerified = ref(false);
  96. const form = reactive({
  97. applicantName: '',
  98. phone: '',
  99. verifyCode: '',
  100. serviceTime: '',
  101. monthlyTimes: '',
  102. maintainType: '',
  103. serviceContent: [] as string[],
  104. otherService: ''
  105. });
  106. // To perfectly match the mockup which shows a persistent validation error on phone
  107. const validatePhone = (rule: any, value: string, callback: any) => {
  108. if (!value) {
  109. callback(new Error('请输入手机号码'));
  110. } else if (!/^1[3-9]\d{9}$/.test(value)) {
  111. callback(new Error('手机号码格式不正确'));
  112. } else {
  113. callback();
  114. }
  115. };
  116. const rules = {
  117. applicantName: [{ required: true, message: '请输入申请人名称', trigger: 'blur' }],
  118. phone: [{ required: true, validator: validatePhone, trigger: 'blur' }],
  119. verifyCode: [{ required: true, message: '请输入短信验证码', trigger: 'blur' }],
  120. serviceTime: [{ required: true, message: '请选择服务时间', trigger: 'change' }],
  121. monthlyTimes: [{ required: true, message: '请输入月度维保次数', trigger: 'blur' }],
  122. maintainType: [{ required: true, message: '请选择维保类型', trigger: 'change' }]
  123. };
  124. const handleBack = () => {
  125. router.back();
  126. };
  127. const handleSendCode = () => {
  128. if (!form.phone) {
  129. ElMessage.warning('请先输入手机号码');
  130. return;
  131. }
  132. ElMessage.success('验证码已发送');
  133. };
  134. const handleVerify = () => {
  135. isVerified.value = true;
  136. };
  137. const toggleServiceContent = (type: string) => {
  138. const index = form.serviceContent.indexOf(type);
  139. if (index > -1) {
  140. form.serviceContent.splice(index, 1);
  141. } else {
  142. form.serviceContent.push(type);
  143. }
  144. };
  145. const handleNext = async () => {
  146. if (!formRef.value) return;
  147. await formRef.value.validate((valid: boolean) => {
  148. if (valid) {
  149. if (!isVerified.value) {
  150. ElMessage.warning('请先点击验证');
  151. return;
  152. }
  153. ElMessage.success('提交成功');
  154. // router.push('...');
  155. }
  156. });
  157. };
  158. onMounted(() => {
  159. // To trigger the phone error message immediately as shown in the mockup
  160. setTimeout(() => {
  161. if (formRef.value) {
  162. formRef.value.validateField('phone').catch(() => {});
  163. }
  164. }, 500);
  165. });
  166. </script>
  167. <style scoped lang="scss">
  168. .maintenance-apply-container {
  169. background-color: #fff;
  170. flex: 1;
  171. border-radius: 4px;
  172. padding: 20px;
  173. }
  174. .page-header {
  175. display: flex;
  176. justify-content: space-between;
  177. align-items: center;
  178. padding: 0 40px;
  179. height: 60px;
  180. border-bottom: 1px solid #f0f0f0;
  181. .header-left {
  182. font-size: 16px;
  183. color: #333;
  184. font-weight: 500;
  185. }
  186. .header-right {
  187. font-size: 14px;
  188. color: #666;
  189. cursor: pointer;
  190. &:hover {
  191. color: #333;
  192. }
  193. }
  194. }
  195. .content-wrapper {
  196. max-width: 800px;
  197. margin: 0 auto;
  198. padding: 40px 20px;
  199. }
  200. /* Steps Styling */
  201. .custom-steps-container {
  202. margin-bottom: 60px;
  203. display: flex;
  204. justify-content: center;
  205. .step-list {
  206. display: flex;
  207. align-items: flex-start;
  208. width: 600px;
  209. justify-content: space-between;
  210. }
  211. .step-item {
  212. display: flex;
  213. flex-direction: column;
  214. align-items: center;
  215. position: relative;
  216. z-index: 2;
  217. background: #fff;
  218. padding: 0 10px;
  219. width: 140px;
  220. .step-icon {
  221. width: 40px;
  222. height: 40px;
  223. border-radius: 50%;
  224. display: flex;
  225. justify-content: center;
  226. align-items: center;
  227. font-size: 20px;
  228. border: 1px solid #e60012;
  229. color: #e60012;
  230. background-color: #fff;
  231. margin-bottom: 10px;
  232. &.normal {
  233. border-color: #d9d9d9;
  234. color: #b3b3b3;
  235. font-size: 18px;
  236. font-weight: bold;
  237. }
  238. }
  239. .step-title {
  240. font-size: 14px;
  241. color: #e60012;
  242. font-weight: 500;
  243. white-space: nowrap;
  244. &.normal-text {
  245. color: #999;
  246. }
  247. }
  248. }
  249. .step-line {
  250. flex: 1;
  251. height: 2px;
  252. background-color: #e60012;
  253. margin: 0 -20px;
  254. margin-top: 19px;
  255. z-index: 1;
  256. &.active-line {
  257. background-color: #e60012;
  258. }
  259. }
  260. }
  261. /* Form Styling */
  262. .form-container {
  263. display: flex;
  264. justify-content: center;
  265. .apply-form {
  266. width: 500px;
  267. }
  268. :deep(.el-form-item__label) {
  269. font-size: 14px;
  270. color: #333;
  271. font-weight: normal;
  272. }
  273. .full-width {
  274. width: 200px;
  275. }
  276. }
  277. .verify-code-wrapper {
  278. display: flex;
  279. align-items: center;
  280. width: 100%;
  281. border: 1px solid #dcdfe6;
  282. border-radius: 4px;
  283. overflow: hidden;
  284. transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
  285. &:focus-within {
  286. border-color: #409eff;
  287. }
  288. .code-input {
  289. flex: 1;
  290. :deep(.el-input__wrapper) {
  291. border-radius: 0;
  292. box-shadow: none !important;
  293. background-color: transparent;
  294. }
  295. }
  296. .send-btn {
  297. padding: 0 15px;
  298. color: #666;
  299. font-size: 13px;
  300. cursor: pointer;
  301. border-left: 1px solid #dcdfe6;
  302. background: #fafafa;
  303. height: 32px;
  304. line-height: 32px;
  305. &:hover {
  306. color: #409eff;
  307. }
  308. }
  309. }
  310. .drag-verify-bar {
  311. width: 100%;
  312. height: 34px;
  313. background-color: #f0f5ff;
  314. border: 1px solid #c6d8f5;
  315. border-radius: 4px;
  316. display: flex;
  317. align-items: center;
  318. cursor: pointer;
  319. position: relative;
  320. .verify-btn {
  321. width: 32px;
  322. height: 32px;
  323. background-color: #fff;
  324. border-radius: 50%;
  325. border: 1px solid #c6d8f5;
  326. display: flex;
  327. justify-content: center;
  328. align-items: center;
  329. margin-left: -1px;
  330. box-shadow: 0 0 5px rgba(0, 0, 0, 0.05);
  331. position: absolute;
  332. left: 10px;
  333. .inner-dot {
  334. width: 10px;
  335. height: 10px;
  336. background-color: #a4c2f4;
  337. border-radius: 50%;
  338. }
  339. &.verified {
  340. left: auto;
  341. right: -1px;
  342. border-color: #0fb881;
  343. }
  344. }
  345. .verify-text {
  346. flex: 1;
  347. text-align: center;
  348. font-size: 13px;
  349. color: #666;
  350. user-select: none;
  351. }
  352. &.success {
  353. background-color: #e5f7f1;
  354. border-color: #0fb881;
  355. .verify-text {
  356. color: #0fb881;
  357. }
  358. }
  359. }
  360. .service-content-wrapper {
  361. width: 100%;
  362. .service-tags {
  363. display: flex;
  364. flex-wrap: wrap;
  365. gap: 10px;
  366. margin-bottom: 12px;
  367. .tag-item {
  368. padding: 6px 16px;
  369. border: 1px solid #dcdfe6;
  370. border-radius: 4px;
  371. font-size: 13px;
  372. color: #666;
  373. cursor: pointer;
  374. transition: all 0.3s;
  375. &.active {
  376. border-color: var(--el-color-primary);
  377. color: var(--el-color-primary);
  378. // background-color: #ecf5ff;
  379. }
  380. &:hover {
  381. border-color: #c0c4cc;
  382. }
  383. }
  384. }
  385. .other-service-input {
  386. width: 100%;
  387. }
  388. }
  389. .next-btn {
  390. // background-color: #0fb881;
  391. // border-color: #0fb881;
  392. // color: #fff;
  393. // padding: 8px 25px;
  394. // border-radius: 2px;
  395. // font-weight: normal;
  396. // &:hover,
  397. // &:focus {
  398. // background-color: #12cc90;
  399. // border-color: #12cc90;
  400. // color: #fff;
  401. // }
  402. }
  403. /* Override error styles to match exactly the mockup */
  404. :deep(.phone-item.is-error) {
  405. .el-input__wrapper {
  406. box-shadow: 0 0 0 1px #f56c6c inset !important;
  407. }
  408. .el-form-item__error {
  409. color: #e60012; /* matching the red error text color in the mockup */
  410. }
  411. }
  412. </style>