honorEdit.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <template>
  2. <ion-page>
  3. <ion-header class="header-theme2">
  4. <ion-toolbar>
  5. <ion-buttons slot="start">
  6. <ion-icon :icon="arrowBackOutline" @click="onCancel"
  7. style="padding-left:10px;width:24px;height:24px;"></ion-icon>
  8. </ion-buttons>
  9. <ion-title>个人荣誉收集</ion-title>
  10. </ion-toolbar>
  11. </ion-header>
  12. <ion-content>
  13. <div class="stepFlex">
  14. <div v-for="(record,key) in stepList" :key="key" class="stepFlex-item">
  15. <div
  16. :class="[(record.val < curStepData?.statusVal || curStepData?.statusVal==stepList.val) ? 'greenCircle' :record.val == curStepData?.statusVal ? 'now' : 'grayCircle']"></div>
  17. <div v-if="key !== stepList.length - 1"
  18. :class="[record.val < curStepData?.statusVal ? 'greenLine' : 'grayLine']"></div>
  19. <div class="stepFlex-item-label">
  20. <p class="stepFlex-item-label-title" @click="onPathRedirect(record.val)">{{ record.title }}</p>
  21. <p class="stepFlex-item-label-desc" @click="onPathRedirect(record.val)">{{ record.desc }}</p>
  22. </div>
  23. </div>
  24. </div>
  25. <form ref="editForm" @submit.prevent="onSave">
  26. <div class="bw-vue-form">
  27. <ion-list class="canvasWrapper">
  28. <div class="form-title">个人荣誉</div>
  29. <div class="form-input">
  30. <ion-label>荣誉名称<span class="danger">*</span></ion-label>
  31. <ion-input name="schoolName" id="schoolName" class="custom"
  32. placeholder="请输入荣誉名称" v-model="honorData.dataModel.honorName"></ion-input>
  33. </div>
  34. <div class="form-input">
  35. <ion-label>
  36. 获得时间<span class="danger">*</span>
  37. </ion-label>
  38. <div class="dateTimeBox">
  39. <ion-datetime-button datetime="completeTime"></ion-datetime-button>
  40. <ion-modal :keep-contents-mounted="true">
  41. <ion-datetime id="completeTime" placeholder="日期"
  42. v-model="honorData.dataModel.getTime" :prefer-wheel="true"
  43. dataformatas="YYYY-MM-DD" presentation="date" cancel-text="取消" done-text="确定"
  44. :show-default-buttons="true">
  45. </ion-datetime>
  46. </ion-modal>
  47. </div>
  48. </div>
  49. </ion-list>
  50. </div>
  51. </form>
  52. </ion-content>
  53. <ion-footer>
  54. <ion-toolbar>
  55. <ion-button style="width:100%;" @click="onSave">保 存</ion-button>
  56. </ion-toolbar>
  57. </ion-footer>
  58. <ion-loading
  59. :is-open="loading"
  60. message="加载中..."
  61. @didDismiss="setOpen(false)">
  62. </ion-loading>
  63. </ion-page>
  64. </template>
  65. <script setup lang="ts">
  66. import {arrowBackOutline} from "ionicons/icons";
  67. import {useRoute, useRouter} from "vue-router";
  68. import {computed, reactive, ref} from "vue";
  69. import {getHonorByID, saveHonor} from "@/api/honor/honor";
  70. import {alertController, onIonViewDidEnter} from "@ionic/vue";
  71. import {required} from "@vuelidate/validators";
  72. import {useVuelidate} from "@vuelidate/core";
  73. import dayjs from "dayjs";
  74. const router = useRouter();
  75. const route = useRoute();
  76. const honorData = reactive({
  77. dataModel: {
  78. honorID: "",
  79. jobUserID: "",
  80. honorName: '',
  81. getTime: dayjs().format("YYYY-MM-DD"),
  82. }
  83. });
  84. const curStepData = ref({
  85. name: "",
  86. statusVal: 2,
  87. loginUserID: ""
  88. });
  89. const stepList = ref([
  90. {title: '基础信息', desc: '个人基础信息', val: 1},
  91. {title: '教育经历', desc: '完善教育经历', val: 2},
  92. {title: '工作经验', desc: '完善工作经验', val: 3},
  93. {title: '求职意向', desc: '个人求职意向', val: 4},
  94. {title: '个人荣誉', desc: '完善个人荣誉', val: 5},
  95. ]);
  96. const loading = ref(false);
  97. const isEditJobUser = ref(0);
  98. const presentAlert = async (message: string) => {
  99. const alert = await alertController.create({
  100. header: '错误!',
  101. message: message,
  102. buttons: [
  103. '确定'
  104. ],
  105. });
  106. await alert.present();
  107. }
  108. const honorRules = computed(() => {
  109. return {
  110. dataModel: {
  111. honorName: {required},
  112. getTime: {required},
  113. }
  114. }
  115. });
  116. const honorValid = useVuelidate(honorRules, honorData);
  117. const loadData = async (honorID: any, jobUserID: any, status: any, userID: any) => {
  118. loading.value = true;
  119. curStepData.value.statusVal = status;
  120. curStepData.value.loginUserID = userID;
  121. await getHonorByID(honorID).then((result: any) => {
  122. honorData.dataModel.honorID = result.honorID;
  123. honorData.dataModel.honorName = result.honorName;
  124. honorData.dataModel.getTime = dayjs(result.getTime).format("YYYY-MM-DD");
  125. honorData.dataModel.jobUserID = jobUserID;
  126. }).finally(() => {
  127. loading.value = false;
  128. })
  129. };
  130. const reload = async (honorID: any, jobUserID: any, status: any, isEdit: any) => {
  131. await loadData(honorID, jobUserID, status, isEdit);
  132. }
  133. const onCancel = () => {
  134. router.push({
  135. path: './userEdit',
  136. query: {reload: 1, jobUserID: honorData.dataModel.jobUserID, status: 5, loginUserId: curStepData.value.loginUserID}
  137. });
  138. }
  139. const onPathRedirect = (statusValue: any) => {
  140. if (isEditJobUser.value == 1) {
  141. router.push({
  142. path: './userEdit',
  143. query: {
  144. reload: 1,
  145. jobUserID: honorData.dataModel.jobUserID,
  146. status: 5,
  147. loginUserId: curStepData.value.loginUserID
  148. }
  149. });
  150. }
  151. }
  152. const onSave = async function () {
  153. const isFormCorrect = await honorValid.value.$validate();
  154. if (!isFormCorrect) {
  155. await presentAlert("请填写完整的信息!");
  156. return null;
  157. }
  158. saveHonor(honorData.dataModel).then(result => {
  159. if (result) {
  160. honorData.dataModel.honorID = "";
  161. honorData.dataModel.honorName = "";
  162. honorData.dataModel.getTime = dayjs().format("YYYY-MM-DD");
  163. router.push({
  164. path: './userEdit',
  165. query: {
  166. reload: 1,
  167. jobUserID: honorData.dataModel.jobUserID,
  168. status: 5,
  169. loginUserId: curStepData.value.loginUserID
  170. }
  171. });
  172. }
  173. });
  174. }
  175. const setOpen = (isOpen: boolean) => {
  176. loading.value = isOpen;
  177. };
  178. onIonViewDidEnter(() => {
  179. if (route.query.reload)
  180. reload(route.query.honorID, route.query.jobUserID, route.query.status, route.query.loginUserID);
  181. });
  182. </script>
  183. <style lang="less">
  184. ion-input.custom {
  185. --placeholder-color: gray;
  186. --placeholder-opacity: 0.5;
  187. }
  188. .title-item {
  189. margin-left: 15px;
  190. color: #1c3d70 !important;
  191. font-size: 14px !important;
  192. font-weight: bold;
  193. }
  194. .stepFlex {
  195. margin: 0;
  196. display: flex;
  197. width: 100%;
  198. .stepFlex-item {
  199. position: relative;
  200. flex: 1;
  201. text-align: center;
  202. margin-top: -10px;
  203. .stepFlex-item-label {
  204. padding-top: 60px;
  205. font-size: 14px;
  206. .stepFlex-item-label-title {
  207. margin-top: 30px;
  208. }
  209. .stepFlex-item-label-desc {
  210. margin-top: 5px;
  211. color: #b9b9bd;
  212. }
  213. }
  214. }
  215. .greenCircle {
  216. top: calc(50% - 15px);
  217. left: calc(50% - 4px);
  218. position: absolute;
  219. z-index: 2;
  220. width: 10px;
  221. height: 10px;
  222. border-radius: 50%;
  223. background-color: #31A2FE;
  224. }
  225. .now {
  226. top: calc(50% - 18px);
  227. left: calc(50% - 8px);
  228. position: absolute;
  229. z-index: 3;
  230. width: 16px;
  231. height: 16px;
  232. border-radius: 50%;
  233. background-color: #31A2FE;
  234. border: 4px solid #c5e8f9;
  235. }
  236. .grayCircle {
  237. top: calc(50% - 15px);
  238. left: calc(50% - 4px);
  239. position: absolute;
  240. z-index: 2;
  241. width: 10px;
  242. height: 10px;
  243. border-radius: 50%;
  244. background-color: #ccc;
  245. }
  246. .greenLine {
  247. width: 100%;
  248. top: calc(50% - 11px);
  249. left: calc(50% - 2px);
  250. height: 2px;
  251. background-color: #31A2FE;
  252. position: absolute;
  253. }
  254. .grayLine {
  255. height: 0;
  256. border: 1px dashed #ccc;
  257. width: 100%;
  258. top: calc(50% - 11px);
  259. left: calc(50% - 2px);
  260. position: absolute;
  261. }
  262. }
  263. .dateTimeBox {
  264. width: 100%;
  265. display: flex;
  266. margin-top: 5px;
  267. justify-content: space-between;
  268. align-content: center;
  269. }
  270. </style>