12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <template>
- <el-dialog
- title="重置密码"
- :visible.sync="dialogVisible"
- width="33%"
- :before-close="handleClose"
- >
- <el-form :model="number" ref="number" :rules="rules" label-width="100px">
- <el-form-item label prop="password">
- <template slot="label" class="status"><span>密  码</span>:</template>
- <el-input
- placeholder="请输入"
- v-model.trim="number.password"
- minlength="6"
- maxlength="18"
- ></el-input>
- </el-form-item>
- </el-form>
- <span slot="footer" class="dialog-footer">
- <el-button size="small" @click="dialogVisible = false">取 消</el-button>
- <el-button
- size="small"
- style="margin-left: 60px"
- type="primary"
- @click="submit('number')"
- >确 定</el-button
- >
- </span>
- </el-dialog>
- </template>
- <script>
- import * as api from '@/api/api'
- export default {
- data() {
- const validatePass = (rule, value, callback) => {
- if (value.length < 6 || value.length > 18) {
- callback(new Error('密码不能小于6位,大于18位'))
- } else {
- callback()
- }
- }
- return {
- dialogVisible: false,
- number: {
- password: ''
- },
- id: '',
- rules: {
- password: [{ required: true, trigger: 'blur', validator: validatePass }]
- }
- }
- },
- methods: {
- handleClose() {
- this.number.password = ''
- this.dialogVisible = false
- this.$parent.search()
- },
- openClose(val) {
- this.dialogVisible = true
- this.id = val.id
- },
- /**
- * @method 确定提交
- * **/
- submit(formName) {
- this.$refs[formName].validate(valid => {
- if (valid) {
- let code = {
- id: this.id,
- password: this.number.password
- }
- api.PUT('/user/resetPassword', code).then(res => {
- if (res.code == 0) {
- this.handleClose()
- this.$message.success(res.data)
- }
- })
- }
- })
- }
- }
- }
- </script>
- <style lang="less" scoped>
- // .status {
- // padding: 0 12px 0 0;
- // }
- // .status::before {
- // content: '*';
- // color: #f56c6c;
- // margin-right: 4px;
- // }
- </style>
|