<!--
@ 作者: 鲁智强
@ 时间: 2023-08-15 11:34:38
@ 备注: 
-->
<template>
	<el-dialog :model-value="true" :title="title" @close="handleClose">
	{{props.rowInfo}}
		<el-form ref="ruleFormRef" :model="formData" label-width="120px" class="demo-ruleForm" style="width:100%">
		<el-form-item>
			<el-button @click="getInfo"></el-button>
		</el-form-item>
			<el-form-item label="行政组织">
				<el-table v-loading="isshow" :data="tablea">
					<el-table-column prop="id" label="指标名称" width="1000">
						<template #default="scope">
							<el-table :data="scope.row.child">
								<el-table-column prop="name" label="指标名称"/>
								<el-table-column prop="" label="说明">
									<el-input v-model="scope.row"/>
								</el-table-column>
								<el-table-column prop="referencescore" label="指标权重">
									<el-input v-model="scope.row.referencescore"/>
								</el-table-column>
								<el-table-column prop="" label="状态">
									<el-select v-model="scope.row">
										<el-option label="使用"/>
										<el-option label="禁用"/>
										<el-option label="观察"/>
									</el-select>
								</el-table-column>
							</el-table>
						</template>
					</el-table-column>				
			</el-table>
			</el-form-item>
			<el-form-item label="年度">
				<el-date-picker v-model="formData.year" type="year"/>
			</el-form-item>
	  <el-form-item>
        <el-button type="primary" @click="submitForm()">确定</el-button>
    </el-form-item>
	</el-form>	
	</el-dialog>
  </template>
  <script lang="ts" setup>
  import { reactive } from "vue";
  import {tarlist,addPostCont,addtarget,getgroupuser,addposttargetcont,search_orgpost,organdpost} from '@/api/opk/api'
  import {editPostCont} from '@/api/opk/pulic/api'
  import { ge_add } from '@/api/opk/news/api'
  import { create_scheme,ge_copy } from '@/api/opk/zxy/news/api'
  import "quill/dist/quill.snow.css"; 
  interface FormInfo {
	id: string;
	age: string;
	name: string;
	sex: string;
	ccc: string;
	ade: string;
	sort: number;
	title: string;
	type: number;
  }
const isshow = ref(false)
const props= defineProps( {
	  title: {
		type: String,
		default: "",
	  },
	  edPostBox: {
		type: Boolean,
		default: false,
	  },
	  rowInfo: {
		type: Object as () => FormInfo,
		default() {
		  return {};
		},
	  },
	  arrayNum: {
		type: Number,
		default: 0,
	  },
	});
const orgTreeProps ={
   label: 'name',
}
const orgTreeProp = {
	label:'title',
	children:'children'
}
const getInfo = ()
const emit = defineEmits(["update:edPostBox","editRow","addRow"])
const formData = reactive({
	deaprtname:"",
	year:"",
	asd:[] as string[],
	key:"",
})
const tablea = ref<any>([])
function ge_adds(){
	const yui = props.rowInfo.id.toString()
	ge_copy({id:yui})
	    .then((data) => {
        	tablea.value = data.data;
        }).finally(()=>{
			isshow.value = false
		})
	}
ge_adds()
  // 关闭弹窗
 const handleClose = ()=> {
    emit("update:edPostBox", false);
  }
 const submitForm=()=> {
    handleClose()
	const add = formData.deaprtname.toString()
	const edd = tablea._value
	const ess = formData.year.getFullYear()
	if (props.addrowInfo.name) {
      // 修改
      const id = props.addrowInfo; // 假设你有一个唯一的ID来识别要修改的项
      emit("editRow", formData);
    } else {
      // 新增
      create_scheme({orgid:add,year:ess,child:edd})
        .then((response:any) => {
          // 处理新增成功的情况
          if (response.code === 200) {
            ElMessage.success("新增成功");
            emit("addRow", formData);
          } else {
            // 处理新增失败的情况
            ElMessage.error("新增成功");
          }
        })
    }
  }
function lzq (){
	Object.assign(formData,props.rowInfo);
}
lzq()
  </script>
  
  <style scoped>
  .avatar-uploader .avatar {
	display: block;
	width: 178px;
	height: 178px;
  }
  </style>
  
  <style lang="scss">
  .avatar-uploader .el-upload {
	position: relative;
	overflow: hidden;
	cursor: pointer;
	border: 1px dashed var(--el-border-color);
	border-radius: 6px;
	transition: var(--el-transition-duration-fast);
  }
  
  .avatar-uploader .el-upload:hover {
	border-color: var(--el-color-primary);
  }
  
  .el-icon.avatar-uploader-icon {
	width: 178px;
	height: 178px;
	font-size: 28px;
	color: #8c939d;
	text-align: center;
  }
  .el-dialog{
	  width:1200px;
  }
  </style>
  