postEdit.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  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. @click="onOpenPost" v-model="dataModel.professionName" class="custom" readonly >
  23. </ion-input>
  24. <ion-item style="width:22%;float: right;padding:0px;margin: 0px;">
  25. <post-selection-like ref="refPostSelectionLike" @resultInfo="onResultInfo"></post-selection-like>
  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" @ionBlur="recruitCountBlur">
  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>
  179. </ion-list>
  180. </div>
  181. </form>
  182. </ion-content>
  183. <ion-footer>
  184. <ion-toolbar>
  185. <ion-button style="width: 100%;" @click="onSave">提交</ion-button>
  186. </ion-toolbar>
  187. </ion-footer>
  188. </ion-page>
  189. </template>
  190. <script lang="ts">
  191. import {computed, defineComponent, reactive, ref, toRefs, watch} from "vue";
  192. import {chevronDownOutline, chevronUpOutline, arrowBackOutline} from 'ionicons/icons';
  193. import {useRoute, useRouter} from "vue-router";
  194. import {alertController, onIonViewDidEnter} from "@ionic/vue";
  195. import {useVuelidate} from "@vuelidate/core";
  196. import {getPostByID,savePost} from "@/api/post";
  197. import {required} from "@vuelidate/validators";
  198. import {getSysDictionaryList} from "@/api/system/dictionary";
  199. import dayjs from "dayjs";
  200. import PostSelectionLike from "@/components/postSelectionLike.vue";
  201. import {getCompanyById} from "@/api/company";
  202. interface StepParams{
  203. loginUserID: string,
  204. }
  205. export default defineComponent({
  206. name: 'PostEdit',
  207. components:{PostSelectionLike},
  208. setup() {
  209. const refPostSelectionLike = ref();
  210. const router = useRouter();
  211. const route = useRoute();
  212. const isShow = ref<any>(false);
  213. const isEdit = ref<any>(false);
  214. const isCommit = ref<any>(false);
  215. const formState = reactive({
  216. dataModel: {
  217. companyID:null,
  218. professionName:null,
  219. professionID:null,
  220. postName:null,
  221. recruitCount:null,
  222. startTime:dayjs().format("YYYY-MM-DD"),
  223. endTime:dayjs().format("YYYY-MM-DD"),
  224. jobPlace:null,
  225. minSalary:null,
  226. maxSalary:null,
  227. isTrail:null,
  228. trailMonths:0,
  229. trailMinSalary:null,
  230. trailMaxSalary:null,
  231. workYear:null,
  232. cultureRank:null,
  233. welfare:null,
  234. postDesc:null,
  235. workNatureID:null,
  236. contactName:null,
  237. contactMobile:null,
  238. contactEmail:null,
  239. bonus:null,
  240. loginUserID:''
  241. }});
  242. const rules = computed(() => {
  243. return {
  244. dataModel: {
  245. professionName: {required},
  246. recruitCount: {required},
  247. startTime: {required},
  248. endTime: {required},
  249. jobPlace:{required}
  250. }
  251. }
  252. });
  253. const v$ = useVuelidate(rules, formState);
  254. const isTrailList = ref([
  255. {value: true, name: '是'},
  256. {value: false, name: '否'},
  257. ]);
  258. const workYearList = ref([]);
  259. const cultureRankList = ref([]);
  260. const workNatureList = ref([]);
  261. const curStepData = ref<StepParams>({
  262. loginUserID:""
  263. });
  264. const presentAlert = async (message: string) => {
  265. const alert = await alertController.create({
  266. header: '错误!',
  267. message: message,
  268. buttons: [
  269. '确定'
  270. ],
  271. });
  272. await alert.present();
  273. }
  274. const onSetProfessionID = (data: any)=>{
  275. formState.dataModel.professionID = data.value;
  276. formState.dataModel.professionName = data.text;
  277. }
  278. function isStringInteger(value: string) {
  279. const n = parseInt(value, 10);
  280. return n.toString() === value && Number.isInteger(n);
  281. }
  282. function recruitCountBlur() {
  283. if (formState.dataModel.recruitCount != null) {
  284. if(!isStringInteger(formState.dataModel.recruitCount)||formState.dataModel.recruitCount<1){
  285. presentAlert("招聘数量必须为一个正整数!");
  286. }
  287. }
  288. }
  289. const ifInputAllValid = ()=>{
  290. let errorMessage = "";
  291. let hasMinSalary = false;
  292. let hasTrailMinSalary = false;
  293. let curMinSalary = 0.0;
  294. let curTrailMinSalary = 0.0;
  295. if(dayjs(formState.dataModel.startTime).isAfter(dayjs(formState.dataModel.endTime))){
  296. errorMessage +="招聘结束日期不能早于开始日期!";
  297. isCommit.value = false;
  298. }
  299. if (formState.dataModel.minSalary!=null) {
  300. hasMinSalary = true;
  301. curMinSalary = parseFloat(formState.dataModel.minSalary);
  302. if(formState.dataModel.minSalary<0){
  303. errorMessage +="岗位最低月薪不能小于0!";
  304. isCommit.value = false;
  305. }
  306. }
  307. if (formState.dataModel.trailMinSalary!=null) {
  308. hasTrailMinSalary = true;
  309. curTrailMinSalary = parseFloat(formState.dataModel.trailMinSalary);
  310. if(formState.dataModel.trailMinSalary<0){
  311. errorMessage +="试用期最低月薪不能小于0!";
  312. isCommit.value = false;
  313. }
  314. }
  315. if (formState.dataModel.maxSalary!=null) {
  316. if(formState.dataModel.maxSalary<0){
  317. errorMessage +="岗位最高月薪不能小于0!";
  318. isCommit.value = false;
  319. }
  320. if(hasMinSalary){
  321. if(parseFloat(formState.dataModel.maxSalary) < curMinSalary){
  322. errorMessage +="岗位最高月薪不能小于岗位最低月薪!";
  323. isCommit.value = false;
  324. }
  325. }
  326. }
  327. if (formState.dataModel.trailMaxSalary!=null) {
  328. if(formState.dataModel.trailMaxSalary<0){
  329. errorMessage +="试用期最高月薪不能小于0!";
  330. isCommit.value = false;
  331. }
  332. if(hasTrailMinSalary){
  333. if(parseFloat(formState.dataModel.trailMaxSalary) < curTrailMinSalary){
  334. errorMessage +="试用期最高月薪不能小于试用期最低月薪!";
  335. isCommit.value = false;
  336. }
  337. }
  338. }
  339. if (formState.dataModel.trailMonths!=null) {
  340. if(formState.dataModel.isTrail&&formState.dataModel.trailMonths<0){
  341. errorMessage +="试用月数不能小于0!";
  342. isCommit.value = false;
  343. }
  344. }
  345. const mobileReg = /^1[3|4|5|6|7|8|9]\d{9}$/;
  346. const landlineReg = /[0-9-()()]{7,18}/;
  347. if(formState.dataModel.contactMobile != null){
  348. if(!mobileReg.test(formState.dataModel.contactMobile)&&!landlineReg.test(formState.dataModel.contactMobile)){
  349. errorMessage += "输入的联系电话有误!";
  350. isCommit.value = false;
  351. }
  352. }
  353. const emailReg = /^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/;
  354. if(formState.dataModel.contactEmail!=""&&formState.dataModel.contactEmail!=null){
  355. if(!emailReg.test(formState.dataModel.contactEmail)){
  356. errorMessage += "输入的邮箱有误!";
  357. isCommit.value = false;
  358. }
  359. }
  360. if(!isCommit.value){presentAlert(errorMessage);}
  361. }
  362. const onSave = async function (){
  363. isCommit.value = true;
  364. const isFormCorrect = await v$.value.$validate();
  365. console.log("当前岗位信息",formState.dataModel);
  366. if (!isFormCorrect) {
  367. await presentAlert('请输入完整信息!');
  368. return null;
  369. }
  370. ifInputAllValid();
  371. formState.dataModel.loginUserID = curStepData.value.loginUserID;
  372. savePost(formState.dataModel).then(result=>{
  373. if(result){
  374. router.push({path: "./postList", query: {reload:1,id:formState.dataModel.companyID,status: 3}});
  375. }
  376. })
  377. }
  378. const onResultInfo = (data: any)=>{
  379. formState.dataModel.professionID = data.value;
  380. formState.dataModel.professionName = data.text;
  381. }
  382. const onOpenPost = () => {
  383. refPostSelectionLike.value.onOpen();
  384. }
  385. const back = () => {
  386. router.push({path: "./postList", query: {reload:1,id:formState.dataModel.companyID,status: 2}});
  387. }
  388. const getWorkYearList = async function(){
  389. const data :any = await getSysDictionaryList("WorkYearType");
  390. workYearList.value = data;
  391. console.log(workYearList.value);
  392. }
  393. const getCultureRankList = async function(){
  394. const data:any = await getSysDictionaryList("CultureLevel");
  395. cultureRankList.value = data;
  396. console.log(cultureRankList.value);
  397. }
  398. const getWorkNationList = async function(){
  399. const data:any = await getSysDictionaryList("WorkNature");
  400. workNatureList.value = data;
  401. }
  402. const loadData = async (postID: any,companyID:any,loginUserID:any) => {
  403. isCommit.value =false;
  404. curStepData.value.loginUserID = loginUserID;
  405. await getWorkYearList();
  406. await getCultureRankList();
  407. await getWorkNationList();
  408. const reqData = await getPostByID(postID);
  409. formState.dataModel = reqData;
  410. formState.dataModel.companyID = companyID;
  411. if(postID==null){
  412. const curPostCompany :any = await getCompanyById(companyID,loginUserID);
  413. formState.dataModel.welfare = curPostCompany.bonus;
  414. }
  415. console.log("初始化岗位信息",formState.dataModel);
  416. };
  417. const reload = (postID: any,companyID:any,loginUserID:any) => {
  418. formState.dataModel.recruitCount = null;
  419. loadData(postID,companyID,loginUserID);
  420. }
  421. onIonViewDidEnter(() => {
  422. if (route.query.reload)
  423. reload(route.query.id,route.query.companyID,route.query.loginUserID);
  424. });
  425. return {
  426. ...toRefs(formState),
  427. chevronDownOutline,
  428. chevronUpOutline,
  429. arrowBackOutline,
  430. route,
  431. router,
  432. isShow,
  433. isEdit,
  434. isTrailList,
  435. workYearList,
  436. cultureRankList,
  437. workNatureList,
  438. v$,
  439. refPostSelectionLike,
  440. onOpenPost,
  441. onResultInfo,
  442. recruitCountBlur,
  443. onSetProfessionID,
  444. onSave,
  445. back,
  446. }
  447. }
  448. });
  449. </script>
  450. <style lang="less">
  451. .custom{
  452. --placeholder-color: gray;
  453. --placeholder-opacity: 0.5;
  454. }
  455. .title-item{
  456. margin-left: 15px;
  457. color:#1c3d70 !important;
  458. font-size: 14px !important;
  459. font-weight: bold;
  460. }
  461. ion-item {
  462. --border-width: 0;
  463. --border-style: none;
  464. ion-label, input, ion-select, ion-datetime {
  465. font-size: 14px !important;
  466. }
  467. }
  468. .stepFlex {
  469. margin: 0;
  470. display: flex;
  471. width: 100%;
  472. .stepFlex-item {
  473. position: relative;
  474. flex: 1;
  475. text-align: center;
  476. margin-top: -10px;
  477. .stepFlex-item-label {
  478. padding-top: 60px;
  479. font-size: 14px;
  480. .stepFlex-item-label-title {
  481. margin-top: 30px;
  482. }
  483. .stepFlex-item-label-desc {
  484. margin-top: 5px;
  485. color: #b9b9bd;
  486. }
  487. }
  488. }
  489. .greenCircle {
  490. top: calc(50% - 15px);
  491. left: calc(50% - 4px);
  492. position: absolute;
  493. z-index: 2;
  494. width: 10px;
  495. height: 10px;
  496. border-radius: 50%;
  497. background-color: #31A2FE;
  498. }
  499. .now {
  500. top: calc(50% - 18px);
  501. left: calc(50% - 8px);
  502. position: absolute;
  503. z-index: 3;
  504. width: 16px;
  505. height: 16px;
  506. border-radius: 50%;
  507. background-color: #31A2FE;
  508. border: 4px solid #c5e8f9;
  509. }
  510. .grayCircle {
  511. top: calc(50% - 15px);
  512. left: calc(50% - 4px);
  513. position: absolute;
  514. z-index: 2;
  515. width: 10px;
  516. height: 10px;
  517. border-radius: 50%;
  518. background-color: #ccc;
  519. }
  520. .greenLine {
  521. width: 100%;
  522. top: calc(50% - 11px);
  523. left: calc(50% - 2px);
  524. height: 2px;
  525. background-color: #31A2FE;
  526. position: absolute;
  527. }
  528. .grayLine {
  529. height: 0;
  530. border: 1px dashed #ccc;
  531. width: 100%;
  532. top: calc(50% - 11px);
  533. left: calc(50% - 2px);
  534. position: absolute;
  535. }
  536. }
  537. </style>