<template>
  <div class="app-content">
    <a-spin :spinning="loading" style="width: 100%;height: 100%;">
      <div class="card_ct">
        <a-form-model ref="form" :model="formData" :rules="rules">
          <a-divider orientation="left">设置</a-divider>
          <!-- <a-form-model-item label="文件上传路径" prop="filePath" class="text_line">
            <a-input v-model="formData.filePath" :maxLength="50" style="width:200px;" />
          </a-form-model-item>
          <a-form-model-item label="图片上传路径" prop="imgPath" class="text_line">
            <a-input v-model="formData.imgPath" :maxLength="50" style="width:200px;" />
          </a-form-model-item> -->
          <a-form-model-item label="短信发送接口地址" prop="SMSApiUrl" class="text_line">
            <a-input v-model="formData.SMSApiUrl" :maxLength="50" style="width:250px;" />
          </a-form-model-item>
          <a-form-model-item label="是否允许同时登录相同账户" prop="loginType" class="text_line">
            <a-radio-group v-model="formData.loginType">
              <a-radio value="1">
                是
              </a-radio>
              <a-radio value="2">
                否
              </a-radio>
            </a-radio-group>
          </a-form-model-item>
          <a-form-model-item label="申报项目类型" prop="projType" class="text_line">
            <a-radio-group v-model="formData.projType">
              <a-radio value="1" name="type">
                科研项目
              </a-radio>
              <a-radio value="2" name="type">
                重点学科项目
              </a-radio>
              <a-radio value="3" name="type">
                同时申报科研项目和重点学科项目
              </a-radio>
            </a-radio-group>
          </a-form-model-item>
          <a-divider dashed />
          <a-row>
            <a-col style="text-align: center;width:100%;">
              <a-button type="primary" style="width:100px;" @click="submit">保存</a-button>
            </a-col>
          </a-row>
        </a-form-model>
      </div>
    </a-spin>
  </div>
</template>

<script>
import { isEmptyParams, hideIdCard, hidePhone, checkEmail } from "@/views/utils/common"
export default {
  name: 'systemSet',
  components: {
  
  },
  data () {
    return {
      formData: {
        // filePath: null,
        // imgPath: null,
        SMSApiUrl: null,
        loginType: null,
        projType: null,
      },
      rules: {
        // filePath: [{ required: true, message: '请输入文件上传路径', trigger: 'blur' },],
        // imgPath: [{ required: true, message: '请输入图片上传路径', trigger: 'blur' },],
        SMSApiUrl: [{ required: true, message: '请输入短信发送接口地址', trigger: 'blur' },],
        loginType: [{ required: true, message: '请选择登录设置', trigger: 'change' }],
        projType: [{ required: true, message: '请选择申报项目类型', trigger: 'change' }],
      },
      loading: true
    }
  },
  created () {
    this.getSystemSet()
  },
  methods: {
    getSystemSet () {
      this.$api.systemSet.getSystemSet().then(({ data = {} }) => {
        if (data) {
          this.formData = data
        }
        this.loading = false
      }).catch(() => { this.loading = false })
    },
    submit () {
      this.$refs.form.validate(valid => {
        if (valid) {
          this.loading = true
          let pars = isEmptyParams(this.formData)
          let par = { ...pars }
          this.$api.systemSet.save(par).then(({ data = {} }) => {
            if (data) {
              this.$message.success('修改成功！')
            }
            this.loading = false
          }).catch(() => { this.loading = false })
        } else {
          return false;
        }
      })
    }
  }
}
</script>

<style lang="less" scoped>
.app-content {
  padding: 10px 0px;
}
.card_ct {
  height: 100%;
  border-radius: 4px;
  border: 1px solid #e6ebf5;
  overflow: auto;
  -webkit-transition: 0.3s;
  transition: 0.3s;
}
::v-deep .ant-divider .ant-divider-inner-text {
  color: #1890ff;
}
::v-deep .ant-form {
  padding: 0 6px;
  .ant-form-item {
    margin-bottom: 2px !important;
  }
  .text_line {
    .ant-form-item-label {
      width: 190px !important;
      line-height: 21px !important;
    }
    .ant-form-item-control-wrapper {
      padding-left: 4px;
      width: calc(100% - 190px) !important;
    }
  }
  .ant-row {
    .ant-col {
      display: inline-block;
    }
    .ant-form-item-label {
      width: 70px;
    }
    .ant-form-item-control-wrapper {
      width: calc(100% - 70px);
    }
    .ant-form-explain {
      margin-left: 5px;
      display: inline-block;
    }
  }
  .ant-radio-inner {
    border-color: #625f5f;
  }
  .ant-checkbox-inner {
    border-color: #625f5f;
  }
  span.ant-radio + * {
    padding: 0 2px;
  }
  .ant-checkbox + span {
    padding: 0 2px;
  }
}
</style>
