Browse Source

新增合同验证

duy 2 years ago
parent
commit
9947c46532

+ 11 - 3
src/views/project/contract/components/base.vue

@@ -138,6 +138,10 @@ const props = defineProps({
         type:Array,
         default:()=>([])
     },
+    isres:{
+        type: Boolean,
+        default: false//验证是否可以保存
+    }
  
 })
 
@@ -145,6 +149,7 @@ const infoData = ref(props.datas)
 const isDisabled = ref(props.disabled)
 const saveLoaingVal=ref(props.saveLoaing)
 const formBaseModel = ref(props.datas)
+const isresdata = ref(props.isres)
 //获取合同类型
 const contractTypeval=ref(props.contractType)
 
@@ -154,14 +159,16 @@ const projectListval=ref(props.projectList)
 //深度监听
 watch(() => [
     props.datas,
-    formBaseModel
-], ([datas,val]) => {
+    formBaseModel,
+    props.isres
+], ([datas,val,isres]) => {
     console.log(val,'val');
     emit('update:datas', val)
     infoData.value = datas
     formBaseModel.value=datas
     betweenTime.value[0]=val.value['startTime']
     betweenTime.value[1]=val.value['endTime']
+    isresdata.value=isres
 }, {deep: true})
 
 //监听
@@ -218,7 +225,7 @@ const formInvoiceRules = {}
 const goBackClick = () => {
     router.back()
 }
-const emit= defineEmits(['saveClick',"update:datas"])
+const emit= defineEmits(['saveClick',"update:datas","changeIsres"])
 
 //提交保存
 const saveClick = async() => {
@@ -229,6 +236,7 @@ const saveClick = async() => {
         window.$message.warning('请选择合同起止日期')
     }
     const res = await formValidate(formBaseRef.value)
+    emit('changeIsres',res)
     if(res&&startTime&&endTime){
         emit('saveClick')
     }

+ 13 - 2
src/views/project/contract/components/file.vue

@@ -54,20 +54,27 @@ const props = defineProps({
     saveLoaing:{
         type: Boolean,
         default: false
+    },
+    isres:{
+        type: Boolean,
+        default: false//验证是否可以保存
     }
 })
 
 const infoData = ref(props.datas)
 const isDisabled = ref(props.disabled)
 const saveLoaingVal=ref(props.saveLoaing)
+const isresdata = ref(props.isres)
 
 //深度监听
 watch(() => [
     props.datas,
-    infoData
+    infoData,
+    props.isres
 ], ([datas,infoData]) => {
     infoData.value = datas
     emit('update:datas', infoData)
+    isresdata.value=isres
 }, {deep: true})
 
 //监听
@@ -106,7 +113,11 @@ const emit= defineEmits(['saveClick',"update:datas"])
 //提交保存
 const saveClick = () => {
     console.log(infoData.value,'infoData');
-    emit('saveClick')
+    if(isresdata.value){
+        emit('saveClick')
+    }else{
+        window.$message.warning('请输入合同基础信息必填项')
+    }
     
 
 }

+ 15 - 3
src/views/project/contract/components/milestone.vue

@@ -86,21 +86,28 @@ const props = defineProps({
     reminderUserList:{
         type:Array,
         default:()=>([])
+    },
+    isres:{
+        type: Boolean,
+        default: false//验证是否可以保存
     }
 })
 
 const infoData = ref(props.datas)
 const isDisabled = ref(props.disabled)
 const saveLoaingVal=ref(props.saveLoaing)
+const isresdata = ref(props.isres)
 
 //深度监听
 watch(() => [
     props.datas,
-    infoData
-], ([datas,infoData]) => {
+    infoData,
+    props.isres
+], ([datas,infoData,isres]) => {
    console.log(datas,'datas');
     infoData.value = datas
     emit('update:datas', infoData)
+    isresdata.value=isres
 
 }, {deep: true})
 
@@ -144,7 +151,12 @@ const delRow=(index)=>{
 //提交保存
 const saveClick = () => {
     console.log(infoData.value,'infoData');
-    emit('saveClick')
+    if(isresdata.value){
+        emit('saveClick')
+    }else{
+        window.$message.warning('请输入合同基础信息必填项')
+    }
+    
  
 
 }

+ 33 - 4
src/views/project/contract/form.vue

@@ -1,16 +1,26 @@
 <template>
     <HcTabsSimple :cur="tabsKey" :datas="tabsData" @tabClick="tabsClick">
         <template #tab-base>
-            <baseTabCard :datas="infoData" :disabled="dataType === 'view'" v-if="tabsKey === 'base'" @saveClick="saveClick" :saveLoaing="saveLoaing" :contractType="contractType" :projectList="projectList"/>
+            <baseTabCard 
+            :datas="infoData" 
+            :disabled="dataType === 'view'" 
+            v-if="tabsKey === 'base'" 
+            @saveClick="saveClick" 
+            :saveLoaing="saveLoaing" 
+            :contractType="contractType" 
+            :projectList="projectList"
+            :isres="isres"
+            @changeIsres="changeIsres"
+            />
         </template>
         <template #tab-file>
-            <fileTabCard :datas="infoDataFile" :disabled="dataType === 'view'" v-if="tabsKey === 'file'" @saveClick="saveClick"  :saveLoaing="saveLoaing"/>
+            <fileTabCard :datas="infoDataFile" :disabled="dataType === 'view'" v-if="tabsKey === 'file'" @saveClick="saveClick"  :saveLoaing="saveLoaing" :isres="isres"/>
         </template>
         <template #tab-milestone>
-            <milestoneTab :datas="milestoneData" :disabled="dataType === 'view'" v-if="tabsKey === 'milestone'" @saveClick="saveClick"  :saveLoaing="saveLoaing" :reminderUserList="reminderUserList"/>
+            <milestoneTab :datas="milestoneData" :disabled="dataType === 'view'" v-if="tabsKey === 'milestone'" @saveClick="saveClick"  :saveLoaing="saveLoaing" :reminderUserList="reminderUserList" :isres="isres"/>
         </template>
         <template #tab-record>
-            <recordTabCard :datas="recordData" v-if="tabsKey === 'record'"/>
+            <recordTabCard :datas="recordData" v-if="tabsKey === 'record'" :isres="isres"/>
         </template>
         
     </HcTabsSimple>
@@ -42,6 +52,7 @@ onActivated(() => {
     setTabsData()
     getContractType()
     getUserDict()
+    tabsKey.value='base'
     if(dataType.value!=='add'){
         getContractInfoById()
         getListByContractId()
@@ -119,11 +130,29 @@ const getListByContractId=async()=>{
 //合同开票记录
 const recordData=ref([])
 const saveLoaing=ref(false)
+const isEmptyObj=(obj)=> {
+    let arr = Object.keys(obj);
+    return(arr.length == 0)
+
+}
+const isres=ref(false)
+//改变是否可以保存的状态
+const changeIsres=(val)=>{
+    isres.value=val
+}    
 //保存
 const saveClick=(info,type)=>{
   console.log(infoData.value,'indo11111');
   console.log(infoDataFile.value,'infoDataFile');
   console.log(milestoneData.value,'milestoneData');
+  //限制空对象不提交
+  milestoneData.value.forEach((ele,index)=>{
+    let ele1=isEmptyObj(ele)
+    if(ele1){
+        milestoneData.value.splice(index)
+    }
+  })
+  console.log( milestoneData.value,' milestoneData.value111');
   let saveobj={...infoData.value}
   saveobj.contractAccessory=infoDataFile.value.pdfUrl
   saveobj.list=milestoneData.value

+ 1 - 0
src/views/project/contract/update.vue

@@ -60,6 +60,7 @@ onActivated(() => {
     dataId.value = useRoutes?.query?.id ?? ''
     console.log(useRoutes.query)
     getContractList()
+    getTableData()
     contractId.value=''
 })