|
@@ -148,7 +148,7 @@
|
|
|
import {onActivated, ref,watch} from "vue";
|
|
|
import {useRouter, useRoute} from 'vue-router'
|
|
|
import costApi from '~api/project/cost.js';
|
|
|
-import {getArrValue,getObjValue,formValidate} from "js-fast-way"
|
|
|
+import {getArrValue,getObjValue,formValidate,objHasKey} from "js-fast-way"
|
|
|
import { getdepartmentList} from "~api/other";
|
|
|
//初始变量
|
|
|
const router = useRouter()
|
|
@@ -342,6 +342,7 @@ watch(() => [
|
|
|
], ([val,table]) => {
|
|
|
if(val==='construction'){
|
|
|
constructUnitData.value=table
|
|
|
+ formBaseModel.value.constructUnit=table
|
|
|
}
|
|
|
}, {deep: true})
|
|
|
const tabTab = ref([
|
|
@@ -353,10 +354,10 @@ const savetabdata=ref([])//当前数据
|
|
|
const tabChange = ({key}) => {
|
|
|
tabKey.value = key
|
|
|
if(key=='supervision'){
|
|
|
- tableData.value=supervisorUnitData.value.length>0?supervisorUnitData.value:originTableData.value
|
|
|
+ tableData.value=supervisorUnitData.value.length>0?supervisorUnitData.value:[{}]
|
|
|
formBaseModel.value.supervisorUnit=tableData.value
|
|
|
}else if(key=='construction'){
|
|
|
- tableData.value=constructUnitData.value.length>0?constructUnitData.value:originTableData.value
|
|
|
+ tableData.value=constructUnitData.value.length>0?constructUnitData.value:[{}]
|
|
|
formBaseModel.value.constructUnit=tableData.value
|
|
|
console.log( formBaseModel.value.constructUnit,' formBaseModel.value.constructUnit');
|
|
|
}else if(key=='bulid'){
|
|
@@ -392,7 +393,7 @@ const tableColumn = [
|
|
|
]
|
|
|
|
|
|
|
|
|
-const originTableData=ref([ {}])
|
|
|
+const originTableData=ref([{}])
|
|
|
const addRow=()=>{
|
|
|
tableData.value.push({})
|
|
|
}
|
|
@@ -404,13 +405,32 @@ const delRow=(index)=>{
|
|
|
const goBackClick = () => {
|
|
|
router.back()
|
|
|
}
|
|
|
+const isEmptyObj=(obj)=> {
|
|
|
+ let arr = Object.keys(obj);
|
|
|
+ return(arr.length == 0)
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
//保存submitForm
|
|
|
const submitLoaing=ref(false)
|
|
|
const submitForm=async()=>{
|
|
|
- console.log(formBaseModel.value,'formBaseModel.value');
|
|
|
- if(tabKey.value='construction'){
|
|
|
- formBaseModel.value.constructUnit=tableData.value
|
|
|
- }
|
|
|
+
|
|
|
+ //取消空对象提交
|
|
|
+ if(formBaseModel.value.supervisorUnit.length>0||formBaseModel.value.constructUnit.length>0||formBaseModel.value.buildUnit.length>0){
|
|
|
+ let suisnullObj= isEmptyObj(formBaseModel.value.supervisorUnit[0])
|
|
|
+ let buisnullObj= isEmptyObj(formBaseModel.value.buildUnit[0])
|
|
|
+ let coisnullObj= isEmptyObj(formBaseModel.value.constructUnit[0])
|
|
|
+ if(suisnullObj===true){
|
|
|
+ formBaseModel.value.supervisorUnit=[]
|
|
|
+ }if(buisnullObj){
|
|
|
+ formBaseModel.value.buildUnit=[]
|
|
|
+ }if(coisnullObj){
|
|
|
+ formBaseModel.value.constructUnit=[]
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
const res = await formValidate(formBaseRef.value)
|
|
|
if(res){
|
|
|
submitLoaing.value=true
|