Newer
Older
ProductionSysFront / src / views / factoryManager / components / changePassword.vue
<!-- 小程序用户管理新增、编辑、详情 -->
<template>
  <el-dialog :visible.sync="dialogFormVisible" :close-on-click-modal="false" append-to-body title="重置密码">
    <el-form ref="dataForm" :rules="rules" :model="form" label-well-code="right" label-width="120px">
      <el-form-item label="密码" prop="password">
        <el-input v-model="form.password"/>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="saveData">提交</el-button>
      <el-button @click="cancel">取消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { changePass } from '@/api/factoryManager/miniUserManage'
import { RSAencrypt } from '@/utils/security'
export default {
  name: 'AddUserDialog',
  data() {
    return {
      dialogFormVisible: false, // 对话框是否显示
      form: {
        id: '',
        password: '' // 密码
      }, // 表单
      rules: {
        password: [{ required: true, message: '密码不能为空', trigger: ['blur', 'change'] }]
      } // 前端校验规则
    }
  },
  methods: {
    // 初始化对话框
    initDialog: function(dialogFormVisible, row = null) {
      this.dialogFormVisible = dialogFormVisible // 对话框显隐
      this.form.id = row.id
    },
    // 重置表单
    resetForm() {
      this.form = {
        password: '', // 密码
        id: '' // 主键
      }
    },
    // 点击提交
    saveData: function() {
      const param = {
        id: this.form.id,
        password: RSAencrypt(this.form.password) // 密码
      }
      changePass(param).then(res => {
        this.$message.success('重置成功')
        this.dialogFormVisible = false
        this.resetForm()
      }).catch(() => {
        this.$message.error('重置失败')
      })
    },
    // 点击取消
    cancel: function() {
      this.dialogFormVisible = false
      this.resetForm()
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .el-select{
    width: 100%;
  }
  .el-date-editor{
    width: 100%;
  }
</style>