<!--
  @description: 财务参数设置
  @Modifier: haofengxian
  @routerPath: /feeParameterSetting/tenderFeeSetting
  @date: 2020-6-30-17:04
-->
<template>
  <div>
    <!--标题-->
    <div class="title title_border p0-16">
      <i class="el-icon-s-home" />财务参数设置
    </div>
    <section class="p16">
      <el-form ref="ruleForm" :model="formData" :rules="rules" :inline-message="true">
        <table class="from_table">
          <tr>
            <td>
              <el-form-item label="服务费开票税率（%）" prop="serviceRate" />
            </td>
            <td>
              <el-input v-model="formData.serviceRate" type="number" />
            </td>
            <td>
              <el-form-item label="标书费开票税率（%）" prop="documentRate" />
            </td>
            <td>
              <el-input v-model="formData.documentRate" type="number" />
            </td>
          </tr>
          <tr>
            <td>
              <el-form-item label="评审费税率（%）" prop="reviewRate" />
            </td>
            <td>
              <el-input v-model="formData.reviewRate" type="number" />
            </td>
            <td>
              <el-form-item label="邮寄费超额限度（元）" prop="emailBeyondLimit" />
            </td>
            <td>
              <el-input v-model="formData.emailBeyondLimit" type="number" />
            </td>
          </tr>
        </table>
      </el-form>
    </section>
    <!-- 保存按钮 -->
    <div class="but_footer">
      <div class="but_footer-h">
        <div class="but_footer-but">
          <el-button :loading="confirmLoading" type="primary" @click="saveSettings('01')">
            生效
          </el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
/* 接口*/
import { queryFeeSetInfo, saveOrUpdateFeeSetInfo } from '@api/fee/tenderFeeSet'
/* 常用公共方法*/
import { checkMoney } from '@/assets/js/validate'
export default {
  name: 'TenderFeeSetting',
  data() {
    return {
      confirmLoading: false, // 暂存Loding
      formData: {
        documentRate: '', // 标书费开票税率（%）
        emailBeyondLimit: '', // 邮寄费超额限度（元）
        feeSetId: '', // 参数设置Id
        reviewRate: '', // 评审费税率（%）
        serviceRate: '' // 服务费开票税率（%）
      },
      rules: {
        serviceRate: [{ required: true, validator: checkMoney, trigger: 'blur' }], // 服务费
        documentRate: [{ required: true, validator: checkMoney, trigger: 'blur' }], // 标书费
        reviewRate: [{ required: true, validator: checkMoney, trigger: 'blur' }], // 评审费
        emailBeyondLimit: [{ required: true, validator: checkMoney, trigger: 'blur' }] // 邮寄费
      }
    }
  },
  mounted() {
    this.getFeeSetInfo()
  },
  methods: {
    // 获取财务参数设置数据
    getFeeSetInfo() {
      queryFeeSetInfo().then(res => {
        this.formData = res.data
      }).catch(() => {
      })
    },
    // 保存设置
    saveSettings() {
      this.$confirm('修改后将对未开票记录生效。确认修改？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        this.confirmLoading = true
        saveOrUpdateFeeSetInfo(this.formData).then(res => {
          this.$message({
            type: 'success',
            message: '操作成功'
          })
          this.confirmLoading = false
        }).catch(() => {
        })
      })
    }
  }
}
</script>

<style scoped>

</style>
