<template>
  <div style="box-sizing: border-box; padding: 20px" class="aaacccvvv">
    <zj-form-container
      ref="formRef"
      :formData="formData"
      :formRules="formRules"
      :formAttributes="{ 'label-position': 'top' }"
    >
      <zj-form-module title="考核含时间设置" :formData="formData" :formItems="formItems" :column="1"> </zj-form-module>
    </zj-form-container>
    <div>
      <el-button size="mini" type="primary" @click="submit">提交</el-button>
      <el-button size="mini" type="success" @click="reset">重置</el-button>
    </div>
  </div>
</template>

<script>
import { letterManagerAddConfig, letterManagerConfigDeatil } from '@/api/assessmentIncludesTime.js'
import editTable from '@/components/template/editTable.js'
import { required } from '@/components/template/rules_verify.js'
export default {
  mixins: [editTable],
  data() {
    return {
      formData: {
        coreNum: '',
        dayNum: '',
        isDay: '',
        leConfigId: ''
      },
      formRules: {},
      INSURE_STEAD_UNIT: []
    }
  },
  computed: {
    formItems() {
      return [
        {
          name: 'el-input',
          md: 24,
          attributes: {},
          formItemAttributes: { label: '网点申诉时间', prop: 'dayNum' },
          slots: {
            prepend: (h, { props, onInput }) => {
              return <div>网点处理考核函申诉截止时间</div>
            },
            append: (h, { props, onInput }) => {
              return <div>天，即自考核函发送时间开始计算，达到截止时间则表示网点接收考核函，状态变更为【已执行】</div>
            }
          }
        },
        {
          name: 'el-radio',
          options: [
            { label: '限制处理天数', value: 'YES' },
            { label: '不限制处理天数', value: 'NO' }
          ],
          md: 24,
          attributes: {
            placeholder: '请输入'
          },
          formItemAttributes: {
            label: '中心处理时间',
            prop: 'isDay'
          }
        },
        {
          isShow: this.formData.isDay === 'YES',
          name: 'el-input',
          md: 24,
          attributes: {},
          formItemAttributes: { label: '', prop: 'coreNum', rules: [...required] },
          slots: {
            prepend: (h, { props, onInput }) => {
              return <div>中心处理考核函审批截止时间</div>
            },
            append: (h, { props, onInput }) => {
              return (
                <div>
                  天，即自网点发起申诉时间开始计算，达到截止时间则表示中心审批通过网点申诉，状态变更为【已撤销】
                </div>
              )
            }
          }
        }
      ]
    }
  },
  created() {
    // 获取详情
    letterManagerConfigDeatil().then(res => {
      this.formData = { ...res.data }
    })
  },
  methods: {
    submit() {
      this.$refs['formRef'].validate(valid => {
        if (valid) {
          letterManagerAddConfig({
            ...this.formData
          }).then(res => {
            this.$message({
              type: 'success',
              message: `保存成功!`
            })
          })
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    reset() {
      Object.assign(this.$data, this.$options.data())
    }
  }
}
</script>

<style lang="scss">
.aaacccvvv {
  .el-input__inner {
    width: 140px;
    max-width: 140px !important;
    min-width: 140px !important;
  }
  .el-input-group__append {
    width: 100% !important;
  }
}
</style>
