<!-- 编辑流程页面 -->
<script lang="ts" setup name="DetailProcess">
import { reactive, ref } from 'vue'
import type { FormInstance, FormRules } from 'element-plus'
import type { Ref } from 'vue'
import setting from '../../setting.vue'
import type { Iform } from './process'
import WorkFlow from '@/components/workFlow/workFlow.vue'
const emits = defineEmits(['close'])
const ruleFormRef = ref<FormInstance>()
const form: Ref<Iform> = ref({
  number: '11111', // 编号
  name: '111', // 名称
  business: 'sss', // 关联业务
  desc: '2', // 流程描述
  selectDecision: '同意 驳回 拒绝', // 选择的决策
  rejectTo: '2', // 可驳回至
  changeData: '2', // 驳回修改数据
  isMessage: 'shi', // 审批结果通知发起人
})
// 可选决策项
const decision = [
  {
    id: 'reject-refuse',
    title: '同意 驳回 拒绝',
  },
  {
    id: 'reject',
    title: '同意 驳回',
  },
  {
    id: 'refuse',
    title: '同意 拒绝',
  },
]
// 可驳回至
const reject = [
  {
    id: 'change',
    title: '单据修改',
  },
]
// 驳回修改数据
const rejectChangeData = [
  {
    id: 'all',
    title: '重新按流程走',
  },
  {
    id: 'part',
    title: '送至驳回节点',
  },
]
// 审批结果通知发起人
const messageData = [
  {
    id: 'yes',
    title: '是',
  },
  {
    id: 'no',
    title: '否',
  },
]
// 关闭
const close = () => {
  emits('close')
}
</script>

<template>
  <div class="edit-process">
    <h5 class="title">
      流程编辑
    </h5>
    <div class="edit">
      <div class="button-area">
        <el-button type="primary" @click="close">
          关闭
        </el-button>
      </div>
      <el-form ref="ruleFormRef" :model="form" label-width="150px">
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="流程编号">
              {{ form.number }}
            </el-form-item>
            <el-form-item label="可选决策项">
              <el-select v-model="form.selectDecision" disabled placeholder="请选择">
                <el-option
                  v-for="item in decision"
                  :key="item.id"
                  :label="item.title"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="流程描述">
              <el-input v-model="form.desc" disabled type="textarea" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="流程名称">
              {{ form.name }}
            </el-form-item>

            <el-form-item v-if="form.selectDecision !== 'refuse'" label="可驳回至">
              <el-select v-model="form.rejectTo" disabled placeholder="请选择">
                <el-option
                  v-for="item in reject"
                  :key="item.id"
                  :label="item.title"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="审批结果通知发起人">
              <el-select v-model="form.isMessage" disabled placeholder="请选择">
                <el-option
                  v-for="item in messageData"
                  :key="item.id"
                  :label="item.title"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="关联业务">
              {{ form.business }}
            </el-form-item>
            <el-form-item v-if="form.selectDecision !== 'refuse'" label="驳回修改数据">
              <el-select v-model="form.changeData" disabled placeholder="请选择">
                <el-option
                  v-for="item in rejectChangeData"
                  :key="item.id"
                  :label="item.title"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <h5 class="title">
      流程配置
    </h5>
    <setting :allow-edit-node="false" />
  </div>
</template>

<style lang="scss" scoped>
  .edit-process {
    width: 100%;

    .title {
      margin: 0 0 20px;
      font-weight: 600;
    }

    .edit {
      width: 100%;
      padding: 12px;
      background-color: #fff;
      border-radius: 7px;
      margin: 0 0 20px;

      .button-area {
        width: 100%;
        display: flex;
        justify-content: flex-end;
        margin-bottom: 20px;
      }
    }

    .set {
      width: 100%;
      background-color: #fff;
      border-radius: 7px;
      margin: 20px 0;
    }
  }
</style>
