<template>
  <el-form :model="form" ref="formRef" label-width="auto">
    <el-form-item label="是否关联成交率">
      <el-radio-group v-model="form.withSuccess">
        <el-radio :label="1"> 是 </el-radio>
        <el-radio :label="0"> 否 </el-radio>
      </el-radio-group>
    </el-form-item>
    <el-form-item label="关联规则" v-if="form.withSuccess">
      <div>
        <el-button @click="form.rules.push({})">新增规则</el-button>
        <div
          v-for="(item, index) in form.rules"
          :key="index"
          class="mt-10px flex justify-center items-center"
        >
          <span>成交率达</span>
          <el-input
            class="ml-10px"
            v-model="item.successRate"
            placeholder="成交率"
            style="width: 100px"
            type="number"
            :min="0"
          >
            <template #suffix>%</template>
          </el-input>
          <span>，可结算</span>
          <el-input
            class="ml-10px"
            v-model="item.comissionRate"
            placeholder="提成率"
            style="width: 100px"
            type="number"
            :min="0"
          >
            <template #suffix>%</template>
          </el-input>
          <span>提成</span>
        </div>
      </div>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit">保存</el-button>
      <el-button @click="getData">刷新</el-button>
    </el-form-item>
  </el-form>
</template>

<script setup name="BasicSettingClue">
const message = useMessage()

const form = ref({
  withSuccess: 1,
  rules: []
})

function getData() {
  form.value = {
    withSuccess: 1
  }
}

function onSubmit() {
  message.success('保存成功')
}
</script>

<style lang="scss" scoped></style>
