postEdit.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. <template>
  2. <ion-page class="list-page">
  3. <ion-header class="header-theme2">
  4. <ion-toolbar>
  5. <ion-buttons slot="start">
  6. <ion-icon :icon="arrowBackOutline" @click="back"></ion-icon>
  7. </ion-buttons>
  8. <ion-title>
  9. 岗位信息收集
  10. </ion-title>
  11. </ion-toolbar>
  12. </ion-header>
  13. <ion-content>
  14. <form autocomplete="off">
  15. <div class="bw-vue-form">
  16. <ion-list>
  17. <div class="form-title">基本信息</div>
  18. <div class="form-input">
  19. <ion-label>岗位名称<span class="danger">*</span></ion-label>
  20. <div>
  21. <ion-input placeholder="请选择岗位" label-placement="stacked" style="float: left;width:78%;"
  22. v-model="dataModel.professionName" class="custom">
  23. </ion-input>
  24. <ion-item style="width:22%;float: right;padding:0px;margin: 0px;">
  25. <post-selection :ProfessionID="dataModel.professionID" @SetProfessionID="onSetProfessionID"></post-selection>
  26. </ion-item>
  27. </div>
  28. <!-- <ion-note v-show="isCommit&&v$.dataModel.professionID.$error" class="danger" >请选择岗位</ion-note>-->
  29. </div>
  30. <div style="width: 100%;overflow: hidden;"></div>
  31. <div class="form-input">
  32. <ion-label>招聘数量(人)<span class="danger">*</span></ion-label>
  33. <ion-input type="number" placeholder="请输入招聘数量" label-placement="stacked" :clear-input="true"
  34. v-model="dataModel.recruitCount" class="custom">
  35. </ion-input>
  36. <!-- <ion-note slot="error">请输入招聘数量</ion-note>-->
  37. </div>
  38. <div class="form-input">
  39. <ion-label>招聘日期<span class="danger">*</span></ion-label>
  40. <div>
  41. <ion-datetime-button datetime="startTime" style="float:left;"></ion-datetime-button>
  42. <span style="float:left;padding-top: 5px;">至</span>
  43. <ion-datetime-button datetime="endTime" style="float:left;"></ion-datetime-button>
  44. <ion-modal :keep-contents-mounted="true">
  45. <ion-datetime placeholder="招聘日期" id="startTime"
  46. v-model="dataModel.startTime" :prefer-wheel="true"
  47. dataformatas="YYYY-MM-DD" presentation="date" cancel-text="取消" done-text="确定"
  48. :show-default-buttons="true" style="text-align: left;width: 100%;">
  49. </ion-datetime>
  50. </ion-modal>
  51. <ion-modal :keep-contents-mounted="true">
  52. <ion-datetime placeholder="招聘日期" id="endTime"
  53. v-model="dataModel.endTime" :prefer-wheel="true"
  54. dataformatas="YYYY-MM-DD" presentation="date" cancel-text="取消" done-text="确定"
  55. :show-default-buttons="true" style="text-align: left;width: 100%;">
  56. </ion-datetime>
  57. </ion-modal>
  58. <!-- <ion-note slot="error">招聘开始日期与结束日期不能为空</ion-note>-->
  59. </div>
  60. </div>
  61. <div style="overflow: hidden;width:100%;"></div>
  62. <div class="form-input">
  63. <ion-label>招聘地点<span class="danger">*</span></ion-label>
  64. <ion-textarea placeholder="请输入招聘地点" :rows="3" label-placement="stacked" :clear-input="true"
  65. v-model="dataModel.jobPlace" class="custom" style="border-bottom: 1px solid #fff2e8;">
  66. </ion-textarea>
  67. <!-- <ion-note slot="error">请输入招聘地点</ion-note>-->
  68. </div>
  69. <div class="form-title">
  70. 其他信息
  71. <div style="float: right;">
  72. <ion-label style="color: red;font-size: 14px;" @click="isShow=!isShow">{{isShow?"收起":"展开"}}</ion-label>
  73. </div>
  74. </div>
  75. <div v-show="isShow" >
  76. <div class="form-select">
  77. <ion-label>工作性质</ion-label>
  78. <ion-select interface="action-sheet" placeholder="请选择工作性质" cancel-text="取消" name="workNatureID"
  79. id="workNatureID" v-model="dataModel.workNatureID" style="width: 100%;text-align: left;" @ionChange="onIsTrailChange">
  80. <ion-select-option v-for="(record,key) in workNatureList" :key="key"
  81. v-model:value="record.value">
  82. {{ record.name }}
  83. </ion-select-option>
  84. </ion-select>
  85. </div>
  86. <div class="form-input">
  87. <ion-label>岗位月薪(元)</ion-label>
  88. <div>
  89. <ion-input type="number" placeholder="请输入金额" label-placement="stacked" style="float:left;width:40%;"
  90. v-model="dataModel.minSalary" class="custom">
  91. </ion-input>
  92. <ion-label style="float:left;width:5%;padding-top: 8px;">至</ion-label>
  93. <ion-input placeholder="请输入金额" label-placement="stacked" style="float:left;width:40%;"
  94. v-model="dataModel.maxSalary" class="custom">
  95. </ion-input>
  96. </div>
  97. </div>
  98. <div style="overflow: hidden;width:100%;"></div>
  99. <div class="form-select">
  100. <ion-label>是否有试用期</ion-label>
  101. <ion-select interface="action-sheet" placeholder="请选择是否有试用期" cancel-text="取消"
  102. id="isTrail" v-model="dataModel.isTrail" style="width: 100%;text-align: left;" @ionChange="onIsTrailChange">
  103. <ion-select-option v-for="(record,key) in isTrailList" :key="key"
  104. v-model:value="record.value">
  105. {{ record.name }}
  106. </ion-select-option>
  107. </ion-select>
  108. </div>
  109. <div class="form-input">
  110. <ion-label>试用期(月)</ion-label>
  111. <ion-input :disabled="!dataModel.isTrail" type="number" placeholder="请输入试用期月数" label-placement="stacked"
  112. v-model="dataModel.trailMonths" class="custom">
  113. </ion-input>
  114. </div>
  115. <div class="form-input">
  116. <ion-label>试用期月薪(元)</ion-label>
  117. <div>
  118. <ion-input placeholder="请输入金额" label-placement="stacked" style="float:left;width:40%;"
  119. v-model="dataModel.trailMinSalary" class="custom">
  120. </ion-input>
  121. <ion-label style="float:left;width:5%;padding-top: 8px;">至</ion-label>
  122. <ion-input placeholder="请输入金额" label-placement="stacked" style="float:left;width:40%;"
  123. v-model="dataModel.trailMaxSalary" class="custom">
  124. </ion-input>
  125. </div>
  126. </div>
  127. <div style="overflow: hidden;width:100%;"></div>
  128. <div class="form-select">
  129. <ion-label>工作年限要求</ion-label>
  130. <ion-select interface="action-sheet" placeholder="请选择工作年限" cancel-text="取消"
  131. id="workYear" v-model="dataModel.workYear" style="width: 100%;text-align: left;">
  132. <ion-select-option v-for="(record,key) in workYearList" :key="key"
  133. v-model:value="record.value">
  134. {{ record.name }}
  135. </ion-select-option>
  136. </ion-select>
  137. </div>
  138. <div class="form-select">
  139. <ion-label>学历要求</ion-label>
  140. <ion-select interface="action-sheet" placeholder="请选择学历" cancel-text="取消"
  141. id="cultureRank" v-model="dataModel.cultureRank" style="width: 100%;text-align: left;">
  142. <ion-select-option v-for="(record,key) in cultureRankList" :key="key"
  143. v-model:value="record.value">
  144. {{ record.name }}
  145. </ion-select-option>
  146. </ion-select>
  147. </div>
  148. <div class="form-input">
  149. <ion-label>其他要求</ion-label>
  150. <ion-textarea placeholder="请输入其他要求" :rows="3" label-placement="stacked"
  151. v-model="dataModel.postDesc" class="custom" style="border-bottom: 1px solid #fff2e8;">
  152. </ion-textarea>
  153. </div>
  154. <div class="form-input">
  155. <ion-label>福利待遇</ion-label>
  156. <ion-textarea placeholder="请输入福利待遇" :rows="3" label-placement="stacked"
  157. v-model="dataModel.welfare" class="custom" style="border-bottom: 1px solid #fff2e8;">
  158. </ion-textarea>
  159. </div>
  160. <div class="form-input">
  161. <ion-label>岗位联系人</ion-label>
  162. <ion-input placeholder="请输入岗位联系人" label-placement="stacked"
  163. v-model="dataModel.contactName" class="custom">
  164. </ion-input>
  165. </div>
  166. <div class="form-input">
  167. <ion-label>岗位联系电话</ion-label>
  168. <ion-input placeholder="请输入岗位联系电话" label-placement="stacked"
  169. v-model="dataModel.contactMobile" class="custom">
  170. </ion-input>
  171. </div>
  172. <div class="form-input">
  173. <ion-label>岗位联系人邮箱</ion-label>
  174. <ion-input placeholder="请输入岗位联系人邮箱" label-placement="stacked"
  175. v-model="dataModel.contactEmail" class="custom">
  176. </ion-input>
  177. </div>
  178. <div class="form-select">
  179. <ion-label>岗位标签</ion-label>
  180. <ion-select interface="action-sheet" placeholder="请选择岗位标签" cancel-text="取消"
  181. id="tagID" v-model="dataModel.tagID" style="width: 100%;text-align: left;">
  182. <ion-select-option v-for="(record,key) in postTagList" :key="key"
  183. v-model:value="record.value">
  184. {{ record.name }}
  185. </ion-select-option>
  186. </ion-select>
  187. </div>
  188. </div>
  189. </ion-list>
  190. </div>
  191. </form>
  192. </ion-content>
  193. <ion-footer>
  194. <ion-toolbar>
  195. <ion-button style="width: 100%;" @click="onSave">提交</ion-button>
  196. </ion-toolbar>
  197. </ion-footer>
  198. </ion-page>
  199. </template>
  200. <script lang="ts">
  201. import {computed, defineComponent, reactive, ref, toRefs, watch} from "vue";
  202. import {chevronDownOutline, chevronUpOutline, arrowBackOutline} from 'ionicons/icons';
  203. import {useRoute, useRouter} from "vue-router";
  204. import {alertController, onIonViewDidEnter} from "@ionic/vue";
  205. import {useVuelidate} from "@vuelidate/core";
  206. import {getPostByID,savePost} from "@/api/post";
  207. import {required} from "@vuelidate/validators";
  208. import {getSysDictionaryList} from "@/api/system/dictionary";
  209. import dayjs from "dayjs";
  210. import postSelection from "@/components/postSelection.vue";
  211. interface StepParams{
  212. loginUserID: string,
  213. }
  214. export default defineComponent({
  215. name: 'PostEdit',
  216. components:{postSelection},
  217. setup() {
  218. const router = useRouter();
  219. const route = useRoute();
  220. const isShow = ref<any>(false);
  221. const isEdit = ref<any>(false);
  222. const isCommit = ref<any>(false);
  223. const formState = reactive({
  224. dataModel: {
  225. companyID:null,
  226. professionName:null,
  227. professionID:null,
  228. postName:null,
  229. recruitCount:null,
  230. startTime:dayjs().format("YYYY-MM-DD"),
  231. endTime:dayjs().format("YYYY-MM-DD"),
  232. jobPlace:null,
  233. minSalary:null,
  234. maxSalary:null,
  235. isTrail:null,
  236. trailMonths:0,
  237. trailMinSalary:null,
  238. trailMaxSalary:null,
  239. workYear:null,
  240. cultureRank:null,
  241. welfare:null,
  242. postDesc:null,
  243. workNatureID:null,
  244. contactName:null,
  245. contactMobile:null,
  246. contactEmail:null,
  247. tagID:null,
  248. bonus:null,
  249. loginUserID:''
  250. }});
  251. const rules = computed(() => {
  252. return {
  253. dataModel: {
  254. professionName: {required},
  255. recruitCount: {required},
  256. startTime: {required},
  257. endTime: {required},
  258. jobPlace:{required}
  259. }
  260. }
  261. });
  262. const v$ = useVuelidate(rules, formState);
  263. const isTrailList = ref([
  264. {value: true, name: '是'},
  265. {value: false, name: '否'},
  266. ]);
  267. const workYearList = ref([]);
  268. const cultureRankList = ref([]);
  269. const workNatureList = ref([]);
  270. const postTagList = ref([]);
  271. const curStepData = ref<StepParams>({
  272. loginUserID:""
  273. });
  274. const presentAlert = async (message: string) => {
  275. const alert = await alertController.create({
  276. header: '错误!',
  277. message: message,
  278. buttons: [
  279. '确定'
  280. ],
  281. });
  282. await alert.present();
  283. }
  284. const onSetProfessionID = (data: any)=>{
  285. formState.dataModel.professionID = data.value;
  286. formState.dataModel.professionName = data.text;
  287. }
  288. const ifInputAllValid = ()=>{
  289. let errorMessage = "";
  290. let hasMinSalary = false;
  291. let hasTrailMinSalary = false;
  292. let curMinSalary = 0;
  293. let curTrailMinSalary = 0;
  294. if(dayjs(formState.dataModel.startTime).isAfter(dayjs(formState.dataModel.endTime))){
  295. errorMessage +="招聘结束日期不能早于开始日期!";
  296. isCommit.value = false;
  297. }
  298. if (formState.dataModel.minSalary!=null) {
  299. hasMinSalary = true;
  300. curMinSalary = formState.dataModel.minSalary;
  301. if(formState.dataModel.minSalary<0){
  302. errorMessage +="岗位最低月薪不能小于0!";
  303. isCommit.value = false;
  304. }
  305. }
  306. if (formState.dataModel.trailMinSalary!=null) {
  307. hasTrailMinSalary = true;
  308. curTrailMinSalary = formState.dataModel.trailMinSalary;
  309. if(formState.dataModel.trailMinSalary<0){
  310. errorMessage +="试用期最低月薪不能小于0!";
  311. isCommit.value = false;
  312. }
  313. }
  314. if (formState.dataModel.maxSalary!=null) {
  315. if(formState.dataModel.maxSalary<0){
  316. errorMessage +="岗位最高月薪不能小于0!";
  317. isCommit.value = false;
  318. }
  319. if(hasMinSalary){
  320. if(formState.dataModel.maxSalary < curMinSalary){
  321. errorMessage +="岗位最高月薪不能小于岗位最低月薪!";
  322. isCommit.value = false;
  323. }
  324. }
  325. }
  326. if (formState.dataModel.trailMaxSalary!=null) {
  327. if(formState.dataModel.trailMaxSalary<0){
  328. errorMessage +="试用期最高月薪不能小于0!";
  329. isCommit.value = false;
  330. }
  331. if(hasTrailMinSalary){
  332. if(formState.dataModel.trailMaxSalary < curTrailMinSalary){
  333. errorMessage +="试用期最高月薪不能小于岗位最低月薪!";
  334. isCommit.value = false;
  335. }
  336. }
  337. }
  338. if (formState.dataModel.trailMonths!=null) {
  339. if(formState.dataModel.isTrail&&formState.dataModel.trailMonths<0){
  340. errorMessage +="试用月数不能小于0!";
  341. isCommit.value = false;
  342. }
  343. }
  344. const mobileReg = /^1[3|4|5|6|7|8|9]\d{9}$/;
  345. const landlineReg = /[0-9-()()]{7,18}/;
  346. if(formState.dataModel.contactMobile != null){
  347. if(!mobileReg.test(formState.dataModel.contactMobile)&&!landlineReg.test(formState.dataModel.contactMobile)){
  348. errorMessage += "输入的联系电话有误!";
  349. isCommit.value = false;
  350. }
  351. }
  352. const emailReg = /^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/;
  353. if(formState.dataModel.contactEmail!=""&&formState.dataModel.contactEmail!=null){
  354. if(!emailReg.test(formState.dataModel.contactEmail)){
  355. errorMessage += "输入的邮箱有误!";
  356. isCommit.value = false;
  357. }
  358. }
  359. if(!isCommit.value){presentAlert(errorMessage);}
  360. }
  361. const onSave = async function (){
  362. isCommit.value = true;
  363. ifInputAllValid();
  364. const isFormCorrect = await v$.value.$validate();
  365. console.log("当前岗位信息",formState.dataModel);
  366. if (!isFormCorrect) {
  367. await presentAlert('请输入完整信息!');
  368. return null;
  369. }
  370. formState.dataModel.loginUserID = curStepData.value.loginUserID;
  371. savePost(formState.dataModel).then(result=>{
  372. if(result){
  373. router.push({path: "./postList", query: {reload:1,id:formState.dataModel.companyID,status: 3}});
  374. }
  375. })
  376. }
  377. const back = () => {
  378. router.push({path: "./postList", query: {reload:1,id:formState.dataModel.companyID,status: 2}});
  379. }
  380. const getWorkYearList = async function(){
  381. const data :any = await getSysDictionaryList("WorkYearType");
  382. workYearList.value = data;
  383. console.log(workYearList.value);
  384. }
  385. const getCultureRankList = async function(){
  386. const data:any = await getSysDictionaryList("CultureLevel");
  387. cultureRankList.value = data;
  388. console.log(cultureRankList.value);
  389. }
  390. const getWorkNationList = async function(){
  391. const data:any = await getSysDictionaryList("WorkNature");
  392. workNatureList.value = data;
  393. }
  394. const getPostTagList = async function(){
  395. const data:any = await getSysDictionaryList("PostTag");
  396. postTagList.value = data;
  397. }
  398. const loadData = async (postID: any,companyID:any,loginUserID:any) => {
  399. isCommit.value =false;
  400. curStepData.value.loginUserID = loginUserID;
  401. await getWorkYearList();
  402. await getCultureRankList();
  403. await getWorkNationList();
  404. await getPostTagList();
  405. const reqData = await getPostByID(postID);
  406. formState.dataModel = reqData;
  407. formState.dataModel.companyID = companyID;
  408. formState.dataModel.welfare = formState.dataModel.bonus;
  409. console.log("初始化岗位信息",formState.dataModel);
  410. };
  411. const reload = (postID: any,companyID:any,loginUserID:any) => {
  412. formState.dataModel.recruitCount = null;
  413. loadData(postID,companyID,loginUserID);
  414. }
  415. onIonViewDidEnter(() => {
  416. if (route.query.reload)
  417. reload(route.query.id,route.query.companyID,route.query.loginUserID);
  418. });
  419. return {
  420. ...toRefs(formState),
  421. chevronDownOutline,
  422. chevronUpOutline,
  423. arrowBackOutline,
  424. route,
  425. router,
  426. isShow,
  427. isEdit,
  428. isTrailList,
  429. workYearList,
  430. cultureRankList,
  431. workNatureList,
  432. postTagList,
  433. v$,
  434. onSetProfessionID,
  435. onSave,
  436. back,
  437. }
  438. }
  439. });
  440. </script>
  441. <style lang="less">
  442. .custom{
  443. --placeholder-color: gray;
  444. --placeholder-opacity: 0.5;
  445. }
  446. .title-item{
  447. margin-left: 15px;
  448. color:#1c3d70 !important;
  449. font-size: 14px !important;
  450. font-weight: bold;
  451. }
  452. ion-item {
  453. --border-width: 0;
  454. --border-style: none;
  455. ion-label, input, ion-select, ion-datetime {
  456. font-size: 14px !important;
  457. }
  458. }
  459. .stepFlex {
  460. margin: 0;
  461. display: flex;
  462. width: 100%;
  463. .stepFlex-item {
  464. position: relative;
  465. flex: 1;
  466. text-align: center;
  467. margin-top: -10px;
  468. .stepFlex-item-label {
  469. padding-top: 60px;
  470. font-size: 14px;
  471. .stepFlex-item-label-title {
  472. margin-top: 30px;
  473. }
  474. .stepFlex-item-label-desc {
  475. margin-top: 5px;
  476. color: #b9b9bd;
  477. }
  478. }
  479. }
  480. .greenCircle {
  481. top: calc(50% - 15px);
  482. left: calc(50% - 4px);
  483. position: absolute;
  484. z-index: 2;
  485. width: 10px;
  486. height: 10px;
  487. border-radius: 50%;
  488. background-color: #31A2FE;
  489. }
  490. .now {
  491. top: calc(50% - 18px);
  492. left: calc(50% - 8px);
  493. position: absolute;
  494. z-index: 3;
  495. width: 16px;
  496. height: 16px;
  497. border-radius: 50%;
  498. background-color: #31A2FE;
  499. border: 4px solid #c5e8f9;
  500. }
  501. .grayCircle {
  502. top: calc(50% - 15px);
  503. left: calc(50% - 4px);
  504. position: absolute;
  505. z-index: 2;
  506. width: 10px;
  507. height: 10px;
  508. border-radius: 50%;
  509. background-color: #ccc;
  510. }
  511. .greenLine {
  512. width: 100%;
  513. top: calc(50% - 11px);
  514. left: calc(50% - 2px);
  515. height: 2px;
  516. background-color: #31A2FE;
  517. position: absolute;
  518. }
  519. .grayLine {
  520. height: 0;
  521. border: 1px dashed #ccc;
  522. width: 100%;
  523. top: calc(50% - 11px);
  524. left: calc(50% - 2px);
  525. position: absolute;
  526. }
  527. }
  528. </style>