From 01b6b200bedf57900a88bbd982cf25889e13dc49 Mon Sep 17 00:00:00 2001
From: shj <1790240199@qq.com>
Date: 星期三, 10 八月 2022 14:17:09 +0800
Subject: [PATCH] 对接

---
 src/views/goalManagement/targetDecompositionYear/component/Dailog.vue |  100 +++++++++++++++++++++++++++++++++++---------------
 1 files changed, 70 insertions(+), 30 deletions(-)

diff --git a/src/views/goalManagement/targetDecompositionYear/component/Dailog.vue b/src/views/goalManagement/targetDecompositionYear/component/Dailog.vue
index f49da8a..1dd0819 100644
--- a/src/views/goalManagement/targetDecompositionYear/component/Dailog.vue
+++ b/src/views/goalManagement/targetDecompositionYear/component/Dailog.vue
@@ -33,15 +33,15 @@
 		</el-form>
 		<el-tabs v-model="activeName" class="demo-tabs">
 			<el-tab-pane label="目标指标分解" name="1">
-				<el-button type="primary" size="default" @click="daiAdd" :disabled="disabled">新增</el-button>
+				<el-button type="primary" size="default" @click="daiAdd('新增')" :disabled="disabled">新增</el-button>
 			</el-tab-pane>
 		</el-tabs>
-		<el-table :data="form.targetDivideDetailList" style="width: 100%">
+		<el-table :data="formUp.targetDivideDetailList" style="width: 100%">
 			<el-table-column align="center" property="dutyDepartmentId" label="责任部门" width="180" />
 			<el-table-column align="center" property="value" label="考核指标" width="180" />
 			<el-table-column align="center" property="makerDepartmentId" label="制定人部门" />
 			<el-table-column align="center" property="makeDate" label="制定日期" />
-			<el-table-column align="center" property="commitPersonId" label="上报人" />
+			<el-table-column align="center" property="commitPersonName" label="上报人" />
 			<el-table-column align="center" property="操作">
 				<template #default="scope">
 					<el-button link type="primary" @click="daiAdd('查看', scope.row)">查看</el-button>
@@ -62,16 +62,25 @@
 </template>
 <script lang="ts">
 import { defineComponent, ref, reactive } from 'vue';
+import {timeDate} from '/@/assets/index.ts'
 import { Search, FullScreen } from '@element-plus/icons-vue';
 import DailogAdd from './DailogAdd.vue';
 import { ElMessageBox, ElMessage, ElButton, ElInput, TabsPaneContext } from 'element-plus';
 import DailogSearch from '../../../../components/DailogSearch/DailogSearch.vue';
 import { goalManagementApi } from '/@/api/goalManagement';
+import { emit } from 'process';
+import {deepClone} from '/@/utils/other'
 export default defineComponent({
-	components: { DailogAdd, DailogSearch },
-	setup() {
+	components: { DailogAdd, DailogSearch},
+	setup(props,{emit}) {
 		const dialogVisible = ref<boolean>(false);
-		const form = ref({});
+		const form = ref({
+			qName: '',
+			indexNum: '',
+			year: '',
+			value: '',
+			targetDivideDetailList:[]
+		});
 		const targetType = ref();
 		const disabled = ref(false);
 		const titles = ref();
@@ -86,36 +95,49 @@
 					.then((res) => {
 						if (res.data.code == 200) {
 							form.value = res.data.data;
+							formUp.targetDivideDetailList=form.value.targetDivideDetailList
 						} else {
 							ElMessage.error(res.data.msg);
 						}
 					});
 			}
 		};
-		const onNumber = (e: object) => {
-			form.value = e;
+		const onNumber = (val: object) => {
+			form.value = val;
 		};
 		// 导航
 		const activeName = ref('1');
 		// 表格
 		const tableData = ref([]);
 		// 新增弹窗
+		const index=ref<any>()
 		const Show = ref();
-		const daiAdd = (title:string,data: any) => {
-			console.log(data)
-			Show.value.openDailog(title,data);
+		const daiAdd = (title: string, data: any) => {
+			index.value = formUp.targetDivideDetailList.indexOf(data);
+			Show.value.openDailog(title, data);
 		};
 		const formUp = reactive({
 			targetId: '', //关联的目标指标/外键
 			delTargetDivideDetails: '', //要删除的目标指标分解ID,多个用逗号隔开
 			targetDivideDetailList: [], //目标指标分解列表
 		});
-		const add = (e: any) => {
-			formUp.targetDivideDetailList.push(e);
+
+
+
+
+		const add = (val: any) => {
+			const item = deepClone(val)
+            if(index.value==-1){
+				formUp.targetDivideDetailList.push(item);
+			}else{
+				formUp.targetDivideDetailList[index.value] = item;
+			}
+			
 			// let obj=JSON.parse(JSON.stringify(form.value))
 		};
 		// 新增
 		const submitForm = () => {
+			formUp.delTargetDivideDetails=arr.value.toString()
 			formUp.targetId = form.value.id;
 			goalManagementApi()
 				.gettargetDivideDetail(formUp)
@@ -125,29 +147,30 @@
 							message: res.data.msg,
 							type: 'success',
 						});
-						dialogVisible.value=false
+						dialogVisible.value = false;
+						emit("addList")
 					} else {
 						ElMessage.error(res.data.msg);
 					}
 				});
+				form.value = {
+				qName: '',
+				indexNum: '',
+				year: '',
+				value: '',
+				targetDivideDetailList:[]
+			};
+			tableData.value = [];
+			formUp.targetId = '';
+			formUp.delTargetDivideDetails = '';
+			formUp.targetDivideDetailList = [];
 		};
+		const arr=ref([])
 		// 删除
 		const Delete = (data: any) => {
-			formUp.targetId= data.targetId
-			formUp.delTargetDivideDetails = data.id;
-			// formUp.targetDivideDetailList=data
-			goalManagementApi()
-				.gettargetDivideDetail(formUp)
-				.then((res) => {
-					if (res.data.code == 200) {
-						ElMessage({
-							message: res.data.msg,
-							type: 'success',
-						});
-					} else {
-						ElMessage.error(res.data.msg);
-					}
-				});
+			formUp.targetDivideDetailList.splice(form.value.targetDivideDetailList.indexOf(data), 1);
+			formUp.targetId = data.targetId;
+			arr.value.push(data.id)
 		};
 		// 安全目标指标弹窗
 		const Shows = ref();
@@ -157,8 +180,17 @@
 		// 关闭
 		const resetForm = () => {
 			dialogVisible.value = false;
-			form.value = {};
+			form.value = {
+				qName: '',
+				indexNum: '',
+				year: '',
+				value: '',
+				targetDivideDetailList:[]
+			};
 			tableData.value = [];
+			formUp.targetId = '';
+			formUp.delTargetDivideDetails = '';
+			formUp.targetDivideDetailList = [];
 		};
 		//全屏
 		const full = ref(false);
@@ -169,7 +201,15 @@
 				full.value = false;
 			}
 		};
+		// 时间格式处理
+		// const timeDate = (data: any) => {
+		// 	let result = new Date(data).getTime();
+		// 	return result;
+		// };
 		return {
+			index,
+			timeDate,
+			arr,
 			form,
 			dialogVisible,
 			openDailog,

--
Gitblit v1.9.2