<template>
  <el-row>
    <el-row class="movie-list">
      <el-col :md="18" style="padding-right: 5px; padding-left: 5px; padding-bottom: 5px">
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>邮件通知配置</span>
          </div>
          <div class="text item">
            <el-table
              :data="notifyConfigList"
              border
              style="width: 100%"
            >
              <el-table-column
                prop="id"
                label="ID"
              />
              <el-table-column
                prop="smtp"
                label="SMTP"
              />
              <el-table-column
                prop="username"
                label="帐号"
              />
              <el-table-column
                prop="password"
                label="密码"
              />
              <el-table-column
                prop="personal"
                label="发送人"
              />
              <el-table-column
                prop="defaultSender"
                label="是否默认"
              />
              <el-table-column
                fixed="right"
                label="操作"
              >
                <template slot-scope="scope">
                  <el-button
                    size="mini"
                    @click="onApprove(scope.row)"
                  >同意</el-button>
                  <el-button
                    size="mini"
                    type="danger"
                    @click="onDecline(scope.row)"
                  >拒绝</el-button>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </el-card>
      </el-col>
    </el-row>

    <el-dialog
      append-to-body
      :visible.sync="updateDialog"
      width="30%"
      center
    >
      <el-row style="padding-right: 5px; padding-left: 5px; padding-bottom: 5px; text-align: center">
        <el-form ref="form" :model="updateMobileForm" label-width="100px">
          <el-form-item label="密码">
            <el-input
              v-model="updateMobileForm.credential"
              type="password"
              placeholder="请输入密码"
              style="padding-right: 1px"
              clearable
            />
          </el-form-item>
          <el-form-item>
            <el-button
              type="primary"
              @click.native="updateUserEmail"
            >更新</el-button>
            <el-button
              type="primary"
              @click.native="updateDialog = false"
            >取消</el-button>
          </el-form-item>
        </el-form>
      </el-row>
    </el-dialog>
  </el-row>
</template>

<script>
import { userMixin } from 'assets/js/mixin'
import {
  getNotifyConfig
} from '@/api/admin'

export default {
  name: 'AdminNotifyConfig',
  mixins: [userMixin],
  data() {
    return {
      notifyConfigList: [],
      updateDialog: false,
      updateMobileForm: {
        principal: null,
        verifyCode: null,
        credential: null,
        captchaCode: null,
        channel: 1,
        plat: 2
      }
    }
  },
  created() {
    document.title = '站点配置'
    this.getData()
  },
  mounted() {
  },
  methods: {
    getData() {
      getNotifyConfig().then(resp => {
        if (resp.code === 0) {
          this.notifyConfigList = resp.data
        } else {
          this.$message.error(resp.msg)
        }
      })
    },
    // ****************************************************************************************************************
    onUpdate() {
      this.updateDialog = false
    },
    updateUserEmail() {
      this.$message.info(this.updateMobileForm)
      this.updateDialog = false
    },
    onApprove(row) {
      this.$message.info('同意充值 ' + row.chargeId)
    },
    onDecline(row) {
      this.$message.info('拒绝充值' + row.chargeId)
    }
  }
}
</script>

<style>
</style>
