Browse Source

出差管理预算计划

duy 2 năm trước cách đây
mục cha
commit
c655647afb
1 tập tin đã thay đổi với 42 bổ sung10 xóa
  1. 42 10
      src/views/attendance/business-trip/info.vue

+ 42 - 10
src/views/attendance/business-trip/info.vue

@@ -157,10 +157,10 @@
         >
             <HcTable :column="tableBudgetColumn" :datas="tableBudgetData" :loading="tableBudgetLoading">
                 <template #action="{ row, index }">
-                    <el-button v-if="row.relevance" size="small" type="danger" @click="row.relevance = false">
+                    <el-button v-if="row.relevance" size="small" type="danger" @click="rowDisassociate(row)">
                         取消关联
                     </el-button>
-                    <el-button v-else size="small" type="primary" @click="row.relevance = true">
+                    <el-button v-else size="small" type="primary" @click="rowRelevance(row)">
                         关联
                     </el-button>
                 </template>
@@ -482,24 +482,19 @@ const getApprovesListData = async ()=>{
         timeLineData.value = []
     }
 }
-//返回
-const goBackClick = () => {
-  router.back()
-}
-
-//提交保存
-const doubleClick = () => {
 
-}
 
 //关联预算计划
 const budgetModal = ref(false)
 const budgetIds = ref([])
 const budgetIndex = ref([])
+const relatedIds = ref([])
 const budgetModalShow = (item, index) => {
     budgetModal.value = true
     budgetIndex.value = index
     // budgetIds.value = item.budgetPlanIds?.split(',') || []
+    const { budgetPlanIds } = formModel.value
+    relatedIds.value = budgetPlanIds?.split(',') || []
     budgetIds.value = formModel.value.projectId
     getBudgetTableData(formModel.value.projectId)
 }
@@ -532,6 +527,42 @@ const getBudgetTableData = async (projectId) => {
         tableBudgetData.value = []
     }
 }
+//判断是否关联
+const isRowRelevance = async (data) => {
+    const res = getArrValue(data)
+    const ids = relatedIds.value
+    res.forEach(item => {
+        item.isRelevance = ids.includes(item.id)
+    })
+    return res
+}
+
+//取消关联
+const rowDisassociate = (row) => {
+    const ids = relatedIds.value
+    const index = ids.indexOf(row.id)
+    if (index > -1) {
+        ids.splice(index, 1)
+    }
+    relatedIds.value = ids
+    row.isRelevance = false
+
+
+}
+
+//关联
+const rowRelevance = (row) => {
+    tableBudgetData.value.forEach((ele)=>{
+        ele.isRelevance = false
+        rowDisassociate(ele)
+    })
+    const ids = relatedIds.value
+    console.log(relatedIds.value, 'relatedIds.value')
+    ids.push(row.id)
+    relatedIds.value = ids
+    row.isRelevance = true
+}
+
 //行程
 const detailsObj1 = {
     trafficType: '', // 交通工具
@@ -553,6 +584,7 @@ const detailsObj = {
     projectId: '', // 所属项目
     submitStatus: null, // 审提交状态 1=暂存 2=提交审批
     journeyList: [detailsObj1],
+    budgetPlanIds:'', //预算计划ID
 }
 const fellowTravelerUserIds = ref([])
 //处理表单数据