<!--转派 -->
<template>
  <div>
    <el-dialog title="修改审核人" :model-value="zPshow" width="320px" :before-close="handleClose" :center="false">
      <div class="pq_content">
        <label>任务负责人</label>
        <el-select v-model="theUserId" placeholder="请选择" filterable remote :remote-method="userremoteMethod">
          <el-option v-for="item in data.userlist" :key="item.id" :label="item.nickname" :value="item.id" />
        </el-select>
      </div>
      <div class="pq_content" style="justify-content: right;margin-top: 15px;">
        <div class="l-button pqbt" @click="handleClose">取消</div>
        <div class="l-button" style="margin-right: 0;margin-left: 15px;" @click="makeSure">确认</div>
      </div>
    </el-dialog>
  </div>
</template>
<script setup name= "LDialog">
import { ElMessage } from 'element-plus'
import { getUsers } from '../../utils/lc'
import { defineProps, defineEmits, getCurrentInstance, reactive, ref, watch, useAttrs } from 'vue'
/* 数据层 */
const { proxy } = getCurrentInstance()
let data = reactive({
  userlist: [],
  userSet: { page: 1, size: 9999999, nickname: '' }
})
// 爷爷给孙子传值赋值
const props = defineProps(['zPshow', 'userId', 'ids'])
let theUserId = ref(JSON.parse(JSON.stringify(props.userId)))
const attrs = useAttrs()
/* 初始化 */
getUsers(data.userSet).then(res => {
  data.userlist = JSON.parse(JSON.stringify(res.data))
})
/* 方法 */
const emits = defineEmits(['update:zPshow'])
// 远程搜索人
function userremoteMethod (value) {
  proxy.$http.showLoading(false).get('project/data/user', { nickname: value, page: 1, size: 99999 }).then(res => {
    data.userlist = res.data.data
  })
}
// 确认
function makeSure () {
  if (props.ids) {
    proxy.$http.showLoading(false).get('project/task/ch_user', { ids: props.ids, type: 'leader_user', user_id: theUserId.value }).then(res => {
      // 刷新爷组件详情数据接口
      if (res.errno == 200) {
        attrs.deppgetPageInfo()
        ElMessage({ type: 'success', message: '操作成功' })
      } else {
        ElMessage({
          type: 'error',
          message: res.errmsg
        })
      }
    })
  }
  emits('update:zPshow', false)
}
//关闭的点击事件
function handleClose () {
  emits('update:zPshow', false)
}
</script>
<style  scoped lang="scss">
@import '@/assets/style/lc.scss';
</style>

