<template>
  <div id="passwdDia">
    <el-row>
      <el-col :span="24">
        <el-form :model="form" :rules="rules" ref="form" label-width="100px" class="demo-ruleForm">
          <el-form-item label="旧密码" prop="oldpasswd">
            <el-input v-model="form.oldpasswd" placeholder="请输入旧密码" show-password></el-input>
          </el-form-item>
          <el-form-item label="新密码" prop="newpasswd">
            <el-input v-model="form.newpasswd" placeholder="请输入新密码" show-password></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="submitForm('form')">保存</el-button>
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { mapState, createNamespacedHelpers } from 'vuex';
const { mapActions: login } = createNamespacedHelpers('login');
export default {
  name: 'passwdDia',
  props: {
    form: null,
  },
  components: {},
  data: function() {
    return {
      rules: {
        oldpasswd: [{ required: true, message: '请输入旧密码', trigger: 'blur' }],
        newpasswd: [{ required: true, message: '请输入新密码', trigger: 'blur' }],
      },
    };
  },
  created() {},
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate(async valid => {
        if (valid) {
          this.$emit('submitForm', { data: this.form });
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
  },
  computed: {
    ...mapState(['user']),
    pageTitle() {
      return `${this.$route.meta.title}`;
    },
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
};
</script>

<style lang="less" scoped></style>
