<!--
@ 作者: 鲁智强
@ 时间: 2023-08-15 11:34:38
@ 备注: 
-->
<template>
	<el-dialog :model-value="true" title="编辑指标" @close="handleClose">
		<el-form ref="ruleFormRef" :model="formData" label-width="120px" class="demo-ruleForm">
			<el-form-item label="说明">
				<el-input v-model="formData.content" type="textarea" />
			</el-form-item>
			<el-form-item label="状态">
				<el-select v-model="formData.state">
					<el-option label="使用" :value="1"/>
					<el-option label="禁止" :value="3"/>
				</el-select>
			</el-form-item>
			<el-form-item label="执行人">
				<el-tree-select ref="orgTreeRef" v-model="formData.uio" show-checkbox multiple node-key="id" :data="lcx" :props="orgTreeProps" :render-after-expand="false"/>
			</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 {get_runman,get_org,edit_scheme } from '@/api/opk/zxy/news/api'
const isshow = ref(false)
const props= defineProps( {
	  title: {
		type: String,
		default: "",
	  },
	  hyrPostBox: {
		type: Boolean,
		default: false,
	  },
	  rowInfo: {
		type: Object,
		default() {
		  return {};
		},
	  },
	  arrayNum: {
		type: Number,
		default: 0,
	  },
	});
const orgTreeProps ={
   label: 'name',
   children:'child'
}
const orgTreeProp = {
	label:'title',
	children:'children'
}

const emit = defineEmits(["update:hyrPostBox","editRow","addRow"])
const formData = reactive({
	iop:"",
	uio:"",
	yui:""
})
const tablea = ref<any>([])
function ge_adds(){
	const yui = props.rowInfo.targetid
	get_runman({id:yui,level:1,orgid:props.rowInfo.orgid,posid:"",type:1})
	    .then((data) => {
        	tablea.value = data.data;
        }).finally(()=>{
			isshow.value = false
		})
	}
ge_adds()
const lcx = ref<any>([])
function get_orgs(){
	get_org({id:"309",all:1})
	    .then((data) => {
        	lcx.value = data.data;
        }).finally(()=>{
			isshow.value = false
		})
	}
get_orgs()
  // 关闭弹窗
 const handleClose = ()=> {
    emit("update:hyrPostBox", false);
  }
  const submitForm=()=> {
    handleClose()
	const add = formData.uio.toString(',').split(',')
	edit_scheme({Operator:add,content:formData.content,orgid:props.rowInfo.orgid,planversionkey:props.rowInfo.plantversion,state:formData.state,targetid:props.rowInfo.targetid})
		.then(
			ElMessage.success("成功")
		)
  }  
  onMounted(()=>{
	Object.assign(formData,props.rowInfo);
})
 </script>
  