<template>
    <div id="financeClaimsForm">
        <el-row>
            <el-col :span="24" class="form">
                <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="120px" class="demo-ruleForm">
                    <el-col :span="24">
                        <el-form-item label="产品名称" prop="name">
                            <el-input v-model="ruleForm.name" placeholder="请输入产品名称"></el-input>
                        </el-form-item>
                    </el-col>

                    <el-col :span="12">
                        <el-form-item label="利率范围" prop="mongey_min_rate">
                            <el-input class="mongeyrate" v-model="ruleForm.mongey_min_rate" placeholder="利率范围（小）"></el-input>%~
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item prop="mongey_max_rate" class="formItem">
                            <el-input class="mongeyrate" v-model="ruleForm.mongey_max_rate" placeholder="利率范围（大）"></el-input>%
                        </el-form-item>
                    </el-col>

                    <el-col :span="12">
                        <el-form-item label="贷款期限(个月)" prop="claims_min_term">
                            <el-input class="mongeyrate" v-model="ruleForm.claims_min_term" placeholder="贷款期限（小）"></el-input>个月~
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item prop="claims_max_term" class="formItem">
                            <el-input class="mongeyrate" v-model="ruleForm.claims_max_term" placeholder="贷款期限（大）"></el-input>个月
                        </el-form-item>
                    </el-col>

                    <el-col :span="12">
                        <el-form-item label="贷款额度(万元)" prop="claims_min_money">
                            <el-input class="mongeyrate" v-model="ruleForm.claims_min_money" placeholder="贷款额度（小）"></el-input>~
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item prop="claims_max_money" class="formItem">
                            <el-input class="mongeyrate" v-model="ruleForm.claims_max_money" placeholder="贷款额度（大）"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="所属金融机构" prop="ensure_id">
                            <el-select v-model="ruleForm.uid" placeholder="请选择金融机构">
                                <el-option v-for="(item, index) in insList" :key="index" :label="item.name" :value="item.id"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="担保方式" prop="ensure_id">
                            <el-select v-model="ruleForm.ensure_id" placeholder="请选择担保方式">
                                <el-option v-for="(item, index) in dbList" :key="index" :label="item.name" :value="item.code"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="还款方式" prop="repayment_id">
                            <el-select v-model="ruleForm.repayment_id" placeholder="请选择还款方式">
                                <el-option v-for="(item, index) in hkList" :key="index" :label="item.name" :value="item.code"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="产品类型" prop="repayment_id">
                            <el-select v-model="ruleForm.cplx_id" placeholder="请选择产品类型">
                                <el-option v-for="(item, index) in lxList" :key="index" :label="item.name" :value="item.code"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="产品属性" prop="cattribute">
                            <el-select v-model="ruleForm.cattribute" multiple placeholder="请选择产品属性">
                                <el-option v-for="(item, index)  in sxList" :key="index" :label="item.name" :value="item.code"> </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="简介名称">
                            <el-input v-model="ruleForm.news[0].news_name" placeholder="请输入简介名称"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="简介内容">
                            <el-input type="textarea" v-model="ruleForm.news[0].news_info" placeholder="请输入简介内容"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="视频附件(请上传MP4格式文件)" prop="enclosure">
                            <uploadFile
                                    :limit="1"
                                    :data="ruleForm.video"
                                    :isBtn="true"
                                    :url="`/files/financial/custom/upload`"
                                    @uploadSuccess="uploadFileSuccess"
                                    @remove="removeFile"
                            ></uploadFile>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                    <el-form-item label="视频图片附件" prop="enclosure">
                    <uploadFileImage
                    :limit="1"
                    :data="ruleForm.videoimg"
                    :isBtn="true"
                    :url="`/files/financial/custom/upload`"
                    @uploadSuccess="uploadFileSuccessvideoimg"
                    @remove="removeFilevideoimg"
                    ></uploadFileImage>
                    </el-form-item>
                    </el-col>
                    <el-col :span="24" class="btn">
                        <el-button size="small" @click="resetForm('ruleForm')">取消</el-button>
                        <el-button type="primary" size="small" @click="submitForm('ruleForm')">提交</el-button>
                    </el-col>
                </el-form>
            </el-col>
        </el-row>
    </div>
    <!--:disabled="isAble"-->
</template>

<script>
  import uploadFile from '@/layout/custom/uploadFile.vue';
  import uploadFileImage from '@/layout/custom/uploadImage.vue';
  export default {
    name: 'financeClaimsForm',
    props: {
      ruleForm: null,
      hkList: null,
      dbList: null,
      lxList: null,
      sxList:null,
      insList:null,
    },
    components: {
      uploadFile,
      uploadFileImage,
    },
    data: () => ({
      rules: {
        mongey_min_rate: [
          { required: true, message: '请输入利率', trigger: 'blur' },
          { pattern: /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/, message: '请输入大于0的数字' },
        ],
        cattribute: [
          { required: true, message: '选择产品属性', trigger: 'blur' },
        ],
        mongey_max_rate: [
          { required: true, message: '请输入利率', trigger: 'blur' },
          { pattern: /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/, message: '请输入大于0的数字' },
        ],
        claims_min_term: [
          { required: true, message: '请输入贷款期限', trigger: 'blur' },
          { pattern: /^\+?[1-9]\d*$/, message: '请输入大于0的正整数' },
        ],
        claims_max_term: [
          { required: true, message: '请输入贷款期限', trigger: 'blur' },
          { pattern: /^\+?[1-9]\d*$/, message: '请输入大于0的正整数' },
        ],
        claims_min_money: [
          { required: true, message: '贷款额度', trigger: 'blur' },
          { pattern: /^\+?[1-9]\d*$/, message: '请输入大于0的正整数' },
        ],
        claims_max_money: [
          { required: true, message: '贷款额度', trigger: 'blur' },
          { pattern: /^\+?[1-9]\d*$/, message: '请输入大于0的正整数' },
        ],
        ensure_id: [{ required: true, message: '请选择担保方式', trigger: 'blur' }],
        repayment_id: [
          { required: true, message: '请输入贷款期限', trigger: 'blur' },
          { pattern: /^\+?[1-9]\d*$/, message: '请选择还款方式' },
        ],
        claimsmoney: [
          { required: true, message: '请输入贷款额度', trigger: 'blur' },
          { pattern: /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/, message: '请输入大于0的数字' },
        ],
      },

    }),
    created() {},
    computed: {},
    methods: {
      submitForm() {
        this.$emit('submitForm', { data: this.ruleForm });
      },
      resetForm() {
        this.$emit('resetForm');
      },
      uploadFileSuccess({ data }) {
        this.$set(this.ruleForm, 'video', data.uri);
      },
      removeFile(file) {
        this.$set(this.ruleForm, 'video', '');
      },
      uploadFileSuccessvideoimg({ data }) {
        this.$set(this.ruleForm, 'videoimg', data.uri);
      },
      removeFilevideoimg(file) {
        this.$set(this.ruleForm, 'videoimg', '');
      },
    },
  };
</script>

<style lang="less" scoped>
    .form {
        padding: 0 200px 0 0;
    }
    .mongeyrate {
        width: 93%;
    }
    /deep/.formItem .el-form-item__content {
        margin-left: 0 !important;
    }
    .btn {
        text-align: center;
        padding: 30px 0;
    }
    /deep/.el-textarea__inner {
        height: 150px;
    }
</style>
