<template>
    <el-dialog :title="titleMap[mode]" v-model="visible" :width="500" destroy-on-close @closed="$emit('closed')" :close-on-click-modal="false" :close-on-press-escape="false">
        <el-form ref="dialogForm" :model="formData" :rules="rules" label-width="100px" label-position="top">
            <el-row :gutter="15">
                <el-col :span="12" v-for="item in priceData">
                    <el-form-item :label="item.paper_size+colorData[item.color]+duplexData[item.duplex]" prop="number">
                        <el-input v-model="formData.number" clearable placeholder="请输入">
                            <template #append>元</template>
                        </el-input>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
        <el-alert type="error" :closable="false">可针对打印机设置额外收费。如：设置A4黑白单面打印额外增收0.1元，则打印A4黑白单面单价额外加收0.1元</el-alert>
		<template #footer>
			<el-button @click="visible=false" >取 消</el-button>
			<el-button type="primary" :loading="isSaveing" @click="submit()">设置</el-button>
		</template>
    </el-dialog>
</template>

<script>
export default {
    data(){
        return {
            loading: false,
            mode:"add",
            titleMap:{
                add:"更新地址",
                edit:"更新地址"
            },
            visible: false,
            isSaveing: false,
            formData:{},
            colorData:['','彩色','黑白'],
            duplexData:['','单面','双面'],
            priceData:[]
        }
    },
    methods: {
        open(mode = 'add'){
            this.mode = mode;
            this.visible = true;
            return this
        },
        //表单注入数据
        setData(data){
            this.formData.id = data.id;
            this.priceData = data.price;
            this.titleMap.edit = "打印机【"+data.name + "】额外收费"
        },
    }
}
</script>