|  | @@ -1,14 +1,134 @@
 | 
	
		
			
				|  |  |  <template>
 | 
	
		
			
				|  |  | -  <div class="system_config"></div>
 | 
	
		
			
				|  |  | +  <div class="system_config">
 | 
	
		
			
				|  |  | +    <div class="btn-box">
 | 
	
		
			
				|  |  | +      <el-button type="primary" @click="getInfo" :loading="refresh_loading">刷新</el-button>
 | 
	
		
			
				|  |  | +      <el-button type="primary" :loading="loading" @click="onSubmit">应用</el-button>
 | 
	
		
			
				|  |  | +    </div>
 | 
	
		
			
				|  |  | +    <el-form :model="configForm" ref="configForm" label-width="100px" class="config-form">
 | 
	
		
			
				|  |  | +      <el-form-item label="邮箱地址" prop="address">
 | 
	
		
			
				|  |  | +        <el-input
 | 
	
		
			
				|  |  | +          v-model="configForm.address"
 | 
	
		
			
				|  |  | +          autocomplete="off"
 | 
	
		
			
				|  |  | +          placeholder="请输入邮箱地址"
 | 
	
		
			
				|  |  | +          @blur="handleTrim('configForm', 'address')"
 | 
	
		
			
				|  |  | +          maxlength="100"
 | 
	
		
			
				|  |  | +        >
 | 
	
		
			
				|  |  | +        </el-input>
 | 
	
		
			
				|  |  | +      </el-form-item>
 | 
	
		
			
				|  |  | +      <el-form-item label="SMTP 服务器" prop="smtp">
 | 
	
		
			
				|  |  | +        <el-input
 | 
	
		
			
				|  |  | +          v-model="configForm.smtp"
 | 
	
		
			
				|  |  | +          autocomplete="off"
 | 
	
		
			
				|  |  | +          placeholder="请输入SMTP 服务器"
 | 
	
		
			
				|  |  | +          @blur="handleTrim('configForm', 'smtp')"
 | 
	
		
			
				|  |  | +          maxlength="200"
 | 
	
		
			
				|  |  | +        >
 | 
	
		
			
				|  |  | +        </el-input>
 | 
	
		
			
				|  |  | +      </el-form-item>
 | 
	
		
			
				|  |  | +      <el-form-item label="邮箱登录名" prop="user_name">
 | 
	
		
			
				|  |  | +        <el-input
 | 
	
		
			
				|  |  | +          v-model="configForm.user_name"
 | 
	
		
			
				|  |  | +          autocomplete="off"
 | 
	
		
			
				|  |  | +          placeholder="请输入邮箱登录名"
 | 
	
		
			
				|  |  | +          @blur="handleTrim('configForm', 'user_name')"
 | 
	
		
			
				|  |  | +          maxlength="100"
 | 
	
		
			
				|  |  | +        >
 | 
	
		
			
				|  |  | +        </el-input>
 | 
	
		
			
				|  |  | +      </el-form-item>
 | 
	
		
			
				|  |  | +      <el-form-item label="邮箱登录密码" prop="password">
 | 
	
		
			
				|  |  | +        <el-input
 | 
	
		
			
				|  |  | +          v-model="configForm.password"
 | 
	
		
			
				|  |  | +          :type="newPwdFlag ? 'text' : 'password'"
 | 
	
		
			
				|  |  | +          autocomplete="off"
 | 
	
		
			
				|  |  | +          placeholder="请输入密码"
 | 
	
		
			
				|  |  | +          @blur="handleTrim('configForm', 'password')"
 | 
	
		
			
				|  |  | +          maxlength="100"
 | 
	
		
			
				|  |  | +        >
 | 
	
		
			
				|  |  | +          <i slot="suffix" class="el-icon-view show-icon" @click="changeIcon('newPwdFlag')" v-if="newPwdFlag"></i>
 | 
	
		
			
				|  |  | +          <i slot="suffix" class="show-icon" @click="changeIcon('newPwdFlag')" v-else>
 | 
	
		
			
				|  |  | +            <svg-icon icon-class="eye-invisible"></svg-icon>
 | 
	
		
			
				|  |  | +          </i>
 | 
	
		
			
				|  |  | +        </el-input>
 | 
	
		
			
				|  |  | +      </el-form-item>
 | 
	
		
			
				|  |  | +    </el-form>
 | 
	
		
			
				|  |  | +  </div>
 | 
	
		
			
				|  |  |  </template>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  <script>
 | 
	
		
			
				|  |  | +import { getSysConfigMailbox, setSysConfigMailbox } from '@/api/user';
 | 
	
		
			
				|  |  |  export default {
 | 
	
		
			
				|  |  |    name: 'SystemConfig',
 | 
	
		
			
				|  |  |    data() {
 | 
	
		
			
				|  |  | -    return {};
 | 
	
		
			
				|  |  | +    const validateEmail = (rule, value, callback) => {
 | 
	
		
			
				|  |  | +      if (value === '') {
 | 
	
		
			
				|  |  | +        callback();
 | 
	
		
			
				|  |  | +      } else {
 | 
	
		
			
				|  |  | +        let reg = /^[a-zA-Z0-9_\.-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
 | 
	
		
			
				|  |  | +        let result = reg.test(value);
 | 
	
		
			
				|  |  | +        if (result) {
 | 
	
		
			
				|  |  | +          callback();
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +          callback(new Error('请输入正确的邮箱地址'));
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  | +    return {
 | 
	
		
			
				|  |  | +      configForm: {
 | 
	
		
			
				|  |  | +        address: '',
 | 
	
		
			
				|  |  | +        smtp: '',
 | 
	
		
			
				|  |  | +        user_name: '',
 | 
	
		
			
				|  |  | +        password: '',
 | 
	
		
			
				|  |  | +      },
 | 
	
		
			
				|  |  | +      rules: {
 | 
	
		
			
				|  |  | +        address: [{ validator: validateEmail, trigger: 'blur' }],
 | 
	
		
			
				|  |  | +      },
 | 
	
		
			
				|  |  | +      newPwdFlag: false, // 查看新密码
 | 
	
		
			
				|  |  | +      loading: false,
 | 
	
		
			
				|  |  | +      refresh_loading: false,
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  | +  },
 | 
	
		
			
				|  |  | +  methods: {
 | 
	
		
			
				|  |  | +    // 去掉前后空格
 | 
	
		
			
				|  |  | +    handleTrim(form, fild) {
 | 
	
		
			
				|  |  | +      this[form][fild] = this[form][fild].trim();
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    changeIcon(flag) {
 | 
	
		
			
				|  |  | +      this[flag] = !this[flag];
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    getInfo() {
 | 
	
		
			
				|  |  | +      this.refresh_loading = true;
 | 
	
		
			
				|  |  | +      getSysConfigMailbox()
 | 
	
		
			
				|  |  | +        .then((res) => {
 | 
	
		
			
				|  |  | +          this.refresh_loading = false;
 | 
	
		
			
				|  |  | +          if (res.status === 1) {
 | 
	
		
			
				|  |  | +            this.configForm.address = res.address;
 | 
	
		
			
				|  |  | +            this.configForm.smtp = res.smtp;
 | 
	
		
			
				|  |  | +            this.configForm.user_name = res.user_name;
 | 
	
		
			
				|  |  | +            this.configForm.password = res.password;
 | 
	
		
			
				|  |  | +          }
 | 
	
		
			
				|  |  | +        })
 | 
	
		
			
				|  |  | +        .catch(() => {
 | 
	
		
			
				|  |  | +          this.refresh_loading = false;
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    // 应用
 | 
	
		
			
				|  |  | +    onSubmit() {
 | 
	
		
			
				|  |  | +      this.loading = true;
 | 
	
		
			
				|  |  | +      setSysConfigMailbox(this.configForm)
 | 
	
		
			
				|  |  | +        .then((res) => {
 | 
	
		
			
				|  |  | +          this.loading = false;
 | 
	
		
			
				|  |  | +          if (res.status === 1) {
 | 
	
		
			
				|  |  | +            this.$message.success('操作成功!');
 | 
	
		
			
				|  |  | +          }
 | 
	
		
			
				|  |  | +        })
 | 
	
		
			
				|  |  | +        .catch(() => {
 | 
	
		
			
				|  |  | +          this.loading = false;
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +  },
 | 
	
		
			
				|  |  | +  created() {
 | 
	
		
			
				|  |  | +    this.getInfo();
 | 
	
		
			
				|  |  |    },
 | 
	
		
			
				|  |  | -  methods: {},
 | 
	
		
			
				|  |  |  };
 | 
	
		
			
				|  |  |  </script>
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -17,5 +137,23 @@ export default {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  .system_config {
 | 
	
		
			
				|  |  |    @include page-base;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  .btn-box {
 | 
	
		
			
				|  |  | +    width: 100%;
 | 
	
		
			
				|  |  | +    max-width: 1148px;
 | 
	
		
			
				|  |  | +    padding: 20px 0;
 | 
	
		
			
				|  |  | +    margin: 10px auto;
 | 
	
		
			
				|  |  | +    border-bottom: $border;
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  .config-form {
 | 
	
		
			
				|  |  | +    width: 100%;
 | 
	
		
			
				|  |  | +    max-width: 1148px;
 | 
	
		
			
				|  |  | +    margin: 10px auto;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    :deep .el-input--small {
 | 
	
		
			
				|  |  | +      width: 304px;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  </style>
 |