<script setup>
import RPC from '@/utils/rpc';
const props = defineProps({
  type: {
    type: String,
    required: true,
  },
  row: [Object],
})

const emit = defineEmits(['closed', 'onSuccess'])

const dialogVisible = ref(false)

const isAdd = computed(() => props.type === 'add')

onMounted(() => {
  dialogVisible.value = true
})

const formRef = ref(null)
const formField = ref({
  color_component: []
})
const formRules = reactive({

})

const loading = ref(false)

function closed() {
  emit('closed')
}

const submitForm = () => {

}

const detailData = ref([])
if (!isAdd.value) {
  // formField.value = props.row
}


const add = () => {
  formField.value.color_component.push({ num: calcId(formField.value.color_component), color_paste_id: '', remark: '', ratio: 0.01 })
}

const handleDelete = row => {
  formField.value.color_component = formField.value.color_component.filter(item => item.num !== row.num)
}

</script>

<template>
  <el-dialog align-center :title="isAdd ? '新增' : '修改'" width="774px" v-model="dialogVisible" @closed="closed" :close-on-click-modal="false">
    <el-form ref="formRef" label-position="right" label-suffix=":" :model="formField" :rules="formRules" v-loading="loading">
      111
    </el-form>

    <template #footer>
      <div class="dialog-footer">
        <el-button @click="closed">
          取 消
        </el-button>
        <el-button type="primary" :loading="loading" @click="submitForm">
          确 定
        </el-button>
      </div>
    </template>
  </el-dialog>
</template>

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