<template>
    <div class="fullheight">
        <el-form
            v-form
            data-vv-scope="BizWindFactoryForm"
            class="wind-field-form"
        >
            <el-row>
                <el-col :span="12">
                    <ht-form-item label="风场名称">
                        <ht-input
                            v-model="BizWindFactory.wfName"
                            validate="required"
                        />
                    </ht-form-item>
                </el-col>
                <el-col :span="12">
                    <ht-form-item label="风场容量">
                        <ht-input
                            type="number"
                            :min="0"
                            v-model="BizWindFactory.capacity"
                            validate="required"
                        >
                        </ht-input>
                        <span> MW</span>
                    </ht-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <ht-form-item label="机组数量">
                        <ht-input
                            type="number"
                            :min="0"
                            v-model="BizWindFactory.setsNo"
                            validate="required"
                        />
                    </ht-form-item>
                </el-col>
                <el-col :span="12">
                    <ht-form-item label="环线数量">
                        <ht-input
                            type="number"
                            :min="0"
                            v-model="BizWindFactory.lineNo"
                            validate="required"
                        />
                    </ht-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <ht-form-item label="经度">
                        <ht-input
                            type="number"
                            v-model="BizWindFactory.longitude"
                            :max="180"
                            :min="-180"
                            :precision="6"
                            placeholder="请输入经度"
                        />
                    </ht-form-item>
                </el-col>
                <el-col :span="12">
                    <ht-form-item label="纬度">
                        <ht-input
                            type="number"
                            v-model="BizWindFactory.latitude"
                            :max="90"
                            :min="-90"
                            :precision="6"
                            placeholder="请输入纬度"
                        />
                    </ht-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <ht-form-item label="风场建设时间">
                        <el-date-picker
                            format="yyyy-MM-dd"
                            v-model="BizWindFactory.buildDate"
                            type="date"
                            placeholder="风场建设时间"
                        >
                        </el-date-picker>
                    </ht-form-item>
                </el-col>
                <el-col :span="12">
                    <ht-form-item label="并网时间">
                        <el-date-picker
                            format="yyyy-MM-dd"
                            v-model="BizWindFactory.gridDate"
                            type="date"
                            placeholder="并网时间"
                        >
                        </el-date-picker>
                    </ht-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <ht-form-item label="详细地址">
                        <ht-input
                            type="textarea"
                            v-model="BizWindFactory.address"
                        />
                    </ht-form-item>
                </el-col>
                <el-col :span="12">
                    <ht-form-item label="地址英文名称">
                        <ht-input
                            type="textarea"
                            v-model="BizWindFactory.addressEn"
                        />
                    </ht-form-item>
                </el-col>
            </el-row>
        </el-form>
        <div style="text-align: center">
            <!-- <el-button
                type="primary"
                :style="saveBtnStyle"
                @click="paramSubmit"
                icon="el-icon-document-checked"
                >保存风场信息</el-button
            > -->
            <ht-submit-button
                url="${cssc}/biz/base/windFactory/v1/"
                :model="BizWindFactory"
                :request-method="saveMethod"
                scope-name="BizWindFactoryForm"
                icon="el-icon-document-checked"
                >保存风场信息</ht-submit-button
            >
        </div>
    </div>
</template>
<script>
export default {
    data() {
        return {
            BizWindFactory: {},
            saveMethod: 'POST',
        }
    },
    mounted() {
        this.$validator = this.$root.$validator
    },
    created() {
        this.loadData()
    },
    methods: {
        loadData() {
            this.$http.post('${cssc}/biz/base/windFactory/v1/list', {}).then(
                (resp) => {
                    let response = resp.data
                    if (response.length) {
                        this.BizWindFactory = response[0]
                        this.saveMethod = 'PUT'
                    } else {
                        this.saveMethod = 'POST'
                    }
                },
                (error) => {
                    reject(error)
                }
            )
        },
    },
}
</script>

<style lang="scss" scoped>
.wind-field-form {
    width: 90%;
    margin: 10px auto 60px;
    .inputs {
        width: 90%;
        /deep/ .el-input-number {
            width: 100%;
        }
    }
    .el-input-number {
        width: 90%;
    }
    .el-date-editor {
        width: 90%;
    }
}
</style>
