Browse Source

岗位信息页面调整-编辑调整

liudijing 11 months ago
parent
commit
15c2f46843
1 changed files with 46 additions and 18 deletions
  1. 46 18
      vue/src/views/companyService/post/edit.vue

+ 46 - 18
vue/src/views/companyService/post/edit.vue

@@ -31,7 +31,7 @@
       </a-col>
       <a-col :span="22" style="text-align: right;">
         <Space>
-          <a-button @click="addPost">
+          <a-button @click="addPost" v-if="!isEdit">
             <template #icon>
               <plus-circle-outlined/>
             </template>
@@ -129,7 +129,7 @@
           </a-col>
           <a-col flex="400px">
             <a-form-item
-              label="是否试用期"
+              label="是否试用期"
               :label-col="{ span: 9 }"
               name="isTrail"
               :rules="[{ required: false, message: '请选择是否试用期!' }]"
@@ -145,7 +145,7 @@
           </a-col>
           <a-col flex="400px" :offset="1">
             <a-form-item
-              label="试用期时长(月)"
+              label="试用期(月)"
               :label-col="{ span: 9 }"
               name="trailtime"
               :rules="[{ required: false, message: '请选择试用期时长!' }]"
@@ -158,7 +158,7 @@
         <a-row>
           <a-col flex="300px" style="margin-left: 3px;">
             <a-form-item
-              label="试用期(元)"
+              label="试用期月薪(元)"
               name="trailMaxSalary"
               :label-col="{span:9}"
               :rules="[{ required: false, message: '请输入金额!' }]"
@@ -178,7 +178,7 @@
           </a-col>
           <a-col flex="400px">
             <a-form-item
-              label="工作年限"
+              label="工作年限要求"
               :label-col="{ span: 9 }"
               name="workYear"
               :rules="[{ required: false, message: '请选择工作年限!' }]"
@@ -223,7 +223,7 @@
             </a-form-item>
           </a-col>
         </a-row>
-        <a-row>
+        <a-row v-if="!isEdit">
           <a-col style="text-align: right;" span="23">
             <a-button type="danger" @click="delPostItem(index)">删除</a-button>
           </a-col>
@@ -242,8 +242,9 @@
 import {defineComponent, reactive, ref} from 'vue';
 import {useRouter} from 'vue-router';
 // import {save, getPostByID,savePostList} from '@/api/companyService/post'
-import {savePostList} from '@/api/companyService/post'
+import {savePostList, getPostByID} from '@/api/companyService/post'
 import type {SelectProps} from 'ant-design-vue';
+import {message} from 'ant-design-vue';
 import {useTabsViewStore} from '@/store/modules/tabsView';
 import BUploadFile from '@/components/file/uploadFile.vue';
 import {get} from '@/api/common';
@@ -277,17 +278,17 @@ export default defineComponent(
     name: 'PostEdit',
     components: {BUploadFile},
     setup() {
-      const postCompany=reactive<companyModel>({companyId:null});//关联企业信息
+      const postCompany = reactive<companyModel>({companyId: null});//关联企业信息
       const router = useRouter();
       const fullpath = router.currentRoute.value.fullPath;
       const tabsViewStore = useTabsViewStore();
+      const isEdit = ref(false);
 
       const cultureLevelList = ref<SelectProps['options']>();
       const WorkYearTypelList = ref<SelectProps['options']>();
       const companyList = ref<SelectProps['options']>();
       const postStatusList = [{name: '启用', value: 1}, {name: '停用', value: 0}];
       const trialStatusList = [{name: '是', value: true}, {name: '否', value: false}];
-
       const postDataList = ref<postModel[]>([]);
       const addPost = () => {
         (postDataList.value as any[]).push({
@@ -338,6 +339,12 @@ export default defineComponent(
           item.companyID = postCompany.companyId + "";
           item.recordStatus = 1;
         })
+        //判断重复-根据岗位名称、工作年限、学历要求、岗位薪资、试用期薪资
+        const isRepetition = hasDuplicates(postDataList.value, compareFunction);
+        if (isRepetition) {
+          message.warning('岗位信息存在重复!');
+          return;
+        }
         savePostList(postDataList.value).then((result) => {
           if (result) {
             tabsViewStore.closeCurrentTab(fullpath);
@@ -346,15 +353,34 @@ export default defineComponent(
         });
       }
 
-      // const loadData = (id: any) => {
-      //   getPostByID(id).then(result => {
-      //     formState.dataModel = result;
-      //   })
-      // };
+      const hasDuplicates = (arr, compareFn) => {
+        for (let i = 0; i < arr.length; i++) {
+          for (let j = i + 1; j < arr.length; j++) {
+            if (compareFn(arr[i], arr[j])) {
+              return true;
+            }
+          }
+        }
+        return false;
+      }
+
+      const compareFunction = (obj1, obj2) => obj1.postName === obj2.postName && obj1.workYear === obj2.workYear
+        && obj1.maxSalary === obj2.maxSalary && obj1.minSalary === obj2.minSalary
+        && obj1.trailMaxSalary === obj2.trailMaxSalary && obj1.trailMinSalary === obj2.trailMinSalary
+        && obj1.cultureRank === obj2.cultureRank;
+
+      const loadData = (id: any) => {
+        getPostByID(id).then(result => {
+          // formState.dataModel = result;
+          console.log(result);
+          postCompany.companyId = (result as postModel).companyID;
+          (postDataList.value as any[]).push(result);
+        })
+      };
 
       return {
         // ...toRefs(formState),
-        // loadData,
+        loadData,
         onClose,
         onFinish,
         companyList,
@@ -365,12 +391,14 @@ export default defineComponent(
         addPost,
         WorkYearTypelList,
         delPostItem,
-        postCompany
+        postCompany,
+        isEdit
       }
     },
     created() {
-      // const id = history.state.params?.id;
-      // this.loadData(id);
+      const id = history.state.params?.id;
+      if (id) this.isEdit = true;
+      this.loadData(id);
     }
   })
 </script>