<template>
    <hc-new-dialog v-model="isShow" is-table widths="666px" title="修改项目支付项" @save="modalSave">
        <el-scrollbar class="hc-dialog-scrollbar">
            <el-form ref="formRef" class="p-2" label-position="left" label-width="auto" :model="formModel" :rules="formRules">
                <el-form-item label="支付项编号：">
                    <el-input v-model="formModel.key1" />
                </el-form-item>
                <el-form-item label="支付项名称：">
                    <el-input v-model="formModel.key2" />
                </el-form-item>
                <el-form-item label="支付项类型：">
                    <el-select v-model="formModel.key3" block>
                        <el-option label="xx项" :value="1" />
                    </el-select>
                </el-form-item>
                <el-form-item class="nowrap" label="合同计算公式：">
                    <el-input v-model="formModel.key4" class="flex-1" disabled />
                    <el-link type="primary" class="ml-2 line-height-normal" @click="formulaClick">添加公式</el-link>
                    <el-link type="danger" class="ml-2 line-height-normal">删除公式</el-link>
                </el-form-item>
                <el-form-item class="nowrap" label="变更计算公式：">
                    <el-input v-model="formModel.key5" disabled class="flex-1" />
                    <el-link type="primary" class="ml-2 line-height-normal">添加公式</el-link>
                    <el-link type="danger" class="ml-2 line-height-normal">删除公式</el-link>
                </el-form-item>
                <el-form-item class="nowrap" label="本期计算公式：">
                    <el-input v-model="formModel.key6" disabled class="flex-1" />
                    <el-link type="primary" class="ml-2 line-height-normal">添加公式</el-link>
                    <el-link type="danger" class="ml-2 line-height-normal">删除公式</el-link>
                </el-form-item>
                <el-form-item label="是否为扣款项：">
                    <el-select v-model="formModel.key7" block>
                        <el-option label="xx项" :value="1" />
                    </el-select>
                </el-form-item>
                <el-form-item label="是否加粗：">
                    <el-select v-model="formModel.key8" block>
                        <el-option label="xx项" :value="1" />
                    </el-select>
                </el-form-item>
                <el-form-item label="是否手动输入：">
                    <el-select v-model="formModel.key9" block>
                        <el-option label="xx项" :value="1" />
                    </el-select>
                </el-form-item>
                <el-form-item label="是否显示百分比：">
                    <el-select v-model="formModel.key10" block>
                        <el-option label="xx项" :value="1" />
                    </el-select>
                </el-form-item>
                <el-form-item label="支付项适用类型：">
                    <el-select v-model="formModel.key11" block>
                        <el-option label="xx项" :value="1" />
                    </el-select>
                </el-form-item>
                <el-form-item label="排序号：">
                    <el-input v-model="formModel.key12" />
                </el-form-item>
                <el-form-item label="备注：">
                    <el-input v-model="formModel.key13" :autosize="{ minRows: 4, maxRows: 8 }" type="textarea" />
                </el-form-item>
            </el-form>
        </el-scrollbar>
    </hc-new-dialog>
    <HcFormula v-model="isFormulaShow" />
</template>

<script setup>
import { ref, watch } from 'vue'
import HcFormula from './formula.vue'

const props = defineProps({
    ids: {
        type: [String, Number],
        default: '',
    },
})

//事件
const emit = defineEmits(['finish', 'close'])

//双向绑定
// eslint-disable-next-line no-undef
const isShow = defineModel('modelValue', {
    default: false,
})

//监听
watch(() => [
    props.ids,
], ([ids]) => {
    console.log('ids', ids)
}, { immediate: true })

//监听
watch(isShow, (val) => {
    if (val) {
        console.log('处理数据')
    }
})

//弹窗表单
const formRef = ref(null)
const formModel = ref({ })
const formRules = ref({})

const modalSave = () => {
    emit('finish')
}

//公式
const isFormulaShow = ref(false)
const formulaClick = () => {
    isFormulaShow.value = true
}
</script>
