<!--
@ 作者: 鲁智强
@ 时间: 2023-08-15 11:34:38
@ 备注: 岗位指标点击考核指标点击修改
-->
<template>
	<el-dialog :model-value="true" title="修改指标细则" @close="handleClose">
	<el-form ref="ruleFormRef" :data="zjr" class="demo-ruleForm">
		<el-form-item  label-width="100px" label="考核内容">
			<el-input v-model="zjr.title"/> 	
		</el-form-item>
		<el-form-item  label-width="100px" label="操作属性">
			<el-select v-model="zjr.punishmode">
				<el-option label="分数" :value="1" />
				<el-option label="现金" :value="2" />
				<el-option label="分数和现金" :value="3" />
			</el-select> 	
		</el-form-item>
		<el-form-item  label-width="100px" label="考核标准">
			<el-input v-model="zjr.referencescore"/> 	
		</el-form-item>
		<el-form-item  label-width="100px" label="计量单位">
			<el-input v-model="zjr.unit"/> 	
		</el-form-item>
		<el-form-item  label-width="100px" label="现金标准">
			<el-input v-model="zjr.cashstandard"/> 	
		</el-form-item>
		<el-form-item  label-width="100px" label="操作类型">
			<el-select v-model="zjr.class">
				<el-option label="扣除" :value="1" />
				<el-option label="增加" :value="2" />
				<el-option label="现场确认扣除/增加" :value="3" />
			</el-select> 	
		</el-form-item>
		<el-form-item  label-width="100px" label="检查方式">
			<el-select v-model="zjr.inspectint" multiple>
				<el-option label="现场检查" :value="1" />
				<el-option label="资料审查" :value="2" />
				<el-option label="事件触发" :value="3" />
			</el-select> 	
		</el-form-item>
		<el-form-item  label-width="100px" label="检查周期">
			<el-select v-model="zjr.cycleattr">
				<el-option label="月" :value="1" />
				<el-option label="季度" :value="2" />
				<el-option label="年" :value="3" />
			</el-select> 	
		</el-form-item>
		<el-form-item label="辅助计数：" label-width="100px">
			<el-input-number v-model="num" :min="1" />
		</el-form-item>
		<el-form-item  label-width="100px" label="检查依据">
			<el-input v-model="zjr.evidence" placeholder="请输入检查依据"/> 	
		</el-form-item>
		<el-form-item  label-width="100px" label="备注说明">
			<el-input v-model="zjr.explain"  placeholder="请输入备注说明" /> 	
		</el-form-item>
		<el-form-item label-width="100px" label="岗位/提报人">
			<span>关联岗位</span>
				<el-tree-select ref="orgTreeRef" v-model="formData.value1" show-checkbox clearable node-key="id" class="orgTree" :data="rty" :props="orgTreeProps" :render-after-expand="false"/>
			<span>提报人</span>
				<el-tree-select ref="orgTreeRef" v-model="formData.xf" show-checkbox multiple clearable node-key="id" class="orgTree" :data="ert" :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 { getdetailscont,getnew_target,edit_post,get_organdpost } from '@/api/opk/opk/api'

	import {getgroupuser} from '@/api/opk/api'

const isshow = ref(false)
const num = (1)
const props= defineProps( {
	  title: {
		type: String,
		default: "",
	  },
	  xyPostBox: {
		type: Boolean,
		default: false,
	  },
	  rowInfo: {
		type: Object,
		default() {
		  return {};
		},
	  },
	  arrayNum: {
		type: Number,
		default: 0,
	  },
	});
const orgTreeProps ={
   label: 'name',
   children:'child',
}
const orgTreeProp = {
	label:'name',
	children:'children'
}
const emit = defineEmits(["update:xyPostBox","editRow","addRow"])
const formData = reactive({
	id:"",
	orgidlist:"",
	title:"",
	censortype:"",
	value1:"",
	xf:"",
})
const zjr = ref<any>([])
function getoned(){
	const add = props.rowInfo.id.toString()
	getdetailscont({id:add})
		.then(data=>{
			zjr.value = data.data
		})
}
getoned()
const rty = ref([])
function getoneds(){
	get_organdpost({id:"309",all:0,levelL:0})
		.then(data=>{
			rty.value = data.data.list
		})
}
getoneds()
const ert = ref([])
function getgroup(){
	getgroupuser({id:309,level:4})
		.then(data=>{
			ert.value = data.data
		})
}
getgroup()
const sfl = ref([])
const lqa = ref([])
function parent(){
	const ess = props.rowInfo.parentid.toString()
	getnew_target({id:ess})
		.then(data=>{
			sfl.value = data.data.organdpostlist
			lqa.value = data.data.organdpostlist[0].child
		}).finally(()=>{
			isshow.value = false
		})
}
parent()

// 关闭弹窗
 const handleClose = ()=> {
    emit("update:xyPostBox", false);
  }
const handleDel = (val:any) => {
  		ElMessageBox.confirm("你确定删除这条信息吗?", "提示", {
    		confirmButtonText: "确认",
    		cancelButtonText: "取消",
    		type: "warning",
  		})
			console.log(val.id)	
};
 const submitForm=()=> {
    handleClose()
	const add = zjr._value.title
	const edd = zjr._value.punishmode
	const aee = zjr._value.referencescore
	const err = zjr._value.unit
	const lzq = zjr._value.inspectint.toString(',').split(',')
	const sqy = [{id:formData.value1,operator:formData.xf}]
	edit_post({id:zjr._value.id,title:add,punishtype:edd,standard:aee,unit:err,cashstandard:zjr._value.cashstandard,types:zjr._value.class,inspemethod:lzq,cycle:zjr._value.cycleattr,frequency:num,evidence:zjr._value.evidence,remarks:zjr._value.explain,relevantpostsman:sqy})
		.then(()=>{
			ElMessage.success("成功")
		})
  }  

  onMounted(()=>{
	Object.assign(formData,props.rowInfo);
  })
  </script>
  
  <style scoped> 
  </style>
  