<template>
  <div class="dialog" v-if="dialogForm">
    <div class="head_box">
      <span class="title">人力情报信息搜索任务调度{{ title }}</span>
      <div>
        <el-button size="small" @click="close">关闭</el-button>
      </div>
    </div>
    <div class="cntinfo">
      <el-form :model="listQuery" :label-width="130" label-position="right">
        <div class="form-row">
          <el-form-item label="任务编号">
            <el-input v-model="listQuery.rwbh" placeholder="请输入任务编号" />
          </el-form-item>
          <el-form-item label="任务标题">
            <el-input v-model="listQuery.rwbt" placeholder="请输入任务标题" />
          </el-form-item>
          <el-form-item label="任务类型">
            <el-select v-model="listQuery.rwlx" placeholder="请选择任务类型">
              <el-option label="类型1" value="1" />
              <el-option label="类型2" value="2" />
            </el-select>
          </el-form-item>
          <el-form-item label="任务来源">
            <el-input v-model="listQuery.rwly" placeholder="请输入任务来源" />
          </el-form-item>
        </div>

        <div class="form-row">
          <el-form-item label="反馈截止时间">
            <el-date-picker v-model="listQuery.fkjzsj" type="datetime" placeholder="请选择反馈截止时间" />
          </el-form-item>
          <el-form-item label="严重程度">
            <el-select v-model="listQuery.yzcd" placeholder="请选择严重程度">
              <el-option label="一般" value="1" />
              <el-option label="严重" value="2" />
              <el-option label="特别严重" value="3" />
            </el-select>
          </el-form-item>
          <el-form-item label="任务类型细类">
            <el-select v-model="listQuery.rwlxxl" placeholder="请选择任务类型细类">
              <el-option label="细类1" value="1" />
              <el-option label="细类2" value="2" />
            </el-select>
          </el-form-item>
          <el-form-item label="状态">
            <el-select v-model="listQuery.cpcd" placeholder="请选择产品程度">
              <el-option label="一般" value="1" />
              <el-option label="重要" value="2" />
            </el-select>
          </el-form-item>
        </div>

        <div class="form-row">
          <el-form-item label="任务内容" class="full-width">
            <el-input type="textarea" v-model="listQuery.rwnr" :rows="4" placeholder="请输入任务内容" />
          </el-form-item>
        </div>

        <div class="form-row">
          <el-form-item label="备注" class="full-width">
            <el-input type="textarea" v-model="listQuery.bz" :rows="2" placeholder="请输入备注" />
          </el-form-item>
        </div>
      </el-form>
    </div>
  </div>
</template>

<script setup>
import MyTable from "@/components/aboutTable/MyTable.vue";
import { ref,reactive } from "vue";

const dialogForm = ref(false);
const title = ref("");
const listQuery = ref({
  xgry: []
});
const pageForm = reactive({
  tableData: [
    {
      xm: "张三",
      xb: "男",
      sfzh: "51018319969699999",
      hjd: "",
      hjdpcs: "",
      bq: "重点人员"
    }
  ],
  keyCount: 0,
  tableConfiger: {
    rowHieght: 61,
    showSelectType: "checkBox",
    loading: false
  },
  controlsWidth: 220,
  tableColumn: [
    { label: "姓名", prop: "xm" },
    { label: "性别", prop: "xb" },
    { label: "身份证号", prop: "sfzh" },
    { label: "户籍地", prop: "hjd" },
    { label: "户籍地派出所", prop: "hjdpcs" },
    { label: "标签", prop: "bq" }
  ]
});

// 初始化数据
const init = (type, row) => {
  dialogForm.value = true;
  title.value = type === "add" ? "新增" : "编辑";
  if (type === "edit" && row) {
    listQuery.value = { ...row };
  } else {
    listQuery.value = {
      xgry: []
    };
  }
};

const close = () => {
  dialogForm.value = false;
};

const handleAdd = () => {
  listQuery.value.xgry.push({
    xm: "",
    zjhm: "",
    lxdh: ""
  });
};

const handleDelete = (index) => {
  listQuery.value.xgry.splice(index, 1);
};

defineExpose({ init });
</script>

<style lang="scss" scoped>
.dialog {
  padding: 20px;

  .head_box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
  }
  .cntinfo {
    height: calc(100% - 70px);
    overflow: hidden;
    overflow-y: auto;
  }

  .form-row {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 20px;

    .el-form-item {
      flex: 1;
      min-width: 300px;
      margin-right: 20px;

      &.full-width {
        flex: 0 0 100%;
      }
    }
  }

  :deep(.el-divider__text) {
    font-size: 16px;
    font-weight: bold;
  }
}
</style>
