fix: 优化旧账号的重置密码逻辑
This commit is contained in:
		
							parent
							
								
									f48f8da512
								
							
						
					
					
						commit
						c2732a05a6
					
				| 
						 | 
					@ -50,3 +50,12 @@ export function checkUsername (username) {
 | 
				
			||||||
    params: { username }
 | 
					    params: { username }
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 重置子账号密码
 | 
				
			||||||
 | 
					export function resetPassword (subAccountId, newPassword) {
 | 
				
			||||||
 | 
					  return httpRequest({
 | 
				
			||||||
 | 
					    url: httpRequest.adornUrl(`/merchant-api/subaccount/${subAccountId}/reset-password`),
 | 
				
			||||||
 | 
					    method: 'put',
 | 
				
			||||||
 | 
					    data: httpRequest.adornData({ newPassword })
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,6 +35,12 @@
 | 
				
			||||||
            ></el-option>
 | 
					            ></el-option>
 | 
				
			||||||
          </el-select>
 | 
					          </el-select>
 | 
				
			||||||
        </el-form-item>
 | 
					        </el-form-item>
 | 
				
			||||||
 | 
					        <el-form-item>
 | 
				
			||||||
 | 
					          <el-button type="warning" @click="openResetPasswordDialog">重置密码</el-button>
 | 
				
			||||||
 | 
					        </el-form-item>
 | 
				
			||||||
 | 
					        <el-form-item label="状态">
 | 
				
			||||||
 | 
					          <el-switch v-model="form.enable" active-text="启用" inactive-text="禁用"></el-switch>
 | 
				
			||||||
 | 
					        </el-form-item>
 | 
				
			||||||
      </template>
 | 
					      </template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      <el-form-item label="姓名" prop="name">
 | 
					      <el-form-item label="姓名" prop="name">
 | 
				
			||||||
| 
						 | 
					@ -63,6 +69,23 @@
 | 
				
			||||||
        <el-button type="primary" @click="save">保存</el-button>
 | 
					        <el-button type="primary" @click="save">保存</el-button>
 | 
				
			||||||
      </el-form-item>
 | 
					      </el-form-item>
 | 
				
			||||||
    </el-form>
 | 
					    </el-form>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <el-dialog
 | 
				
			||||||
 | 
					      title="重置密码"
 | 
				
			||||||
 | 
					      :visible.sync="resetPasswordDialogVisible"
 | 
				
			||||||
 | 
					      width="30%"
 | 
				
			||||||
 | 
					      @close="newPassword = ''"
 | 
				
			||||||
 | 
					    >
 | 
				
			||||||
 | 
					      <el-form label-width="80px">
 | 
				
			||||||
 | 
					        <el-form-item label="新密码">
 | 
				
			||||||
 | 
					          <el-input v-model="newPassword" type="password" placeholder="请输入新密码"></el-input>
 | 
				
			||||||
 | 
					        </el-form-item>
 | 
				
			||||||
 | 
					      </el-form>
 | 
				
			||||||
 | 
					      <span slot="footer" class="dialog-footer">
 | 
				
			||||||
 | 
					        <el-button @click="resetPasswordDialogVisible = false">取 消</el-button>
 | 
				
			||||||
 | 
					        <el-button type="primary" @click="handleResetPassword">确 定</el-button>
 | 
				
			||||||
 | 
					      </span>
 | 
				
			||||||
 | 
					    </el-dialog>
 | 
				
			||||||
  </div>
 | 
					  </div>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -73,7 +96,8 @@ import {
 | 
				
			||||||
  getSubAccountList,
 | 
					  getSubAccountList,
 | 
				
			||||||
  getSubAccountDetail,
 | 
					  getSubAccountDetail,
 | 
				
			||||||
  updateSubAccount,
 | 
					  updateSubAccount,
 | 
				
			||||||
  checkUsername
 | 
					  checkUsername,
 | 
				
			||||||
 | 
					  resetPassword
 | 
				
			||||||
} from '@/api/modules/subaccount'
 | 
					} from '@/api/modules/subaccount'
 | 
				
			||||||
import routerConfig from '@/router/full-routers'
 | 
					import routerConfig from '@/router/full-routers'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -131,6 +155,8 @@ export default {
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return {
 | 
					    return {
 | 
				
			||||||
 | 
					      resetPasswordDialogVisible: false,
 | 
				
			||||||
 | 
					      newPassword: '',
 | 
				
			||||||
      form: {
 | 
					      form: {
 | 
				
			||||||
        operationType: 'create',
 | 
					        operationType: 'create',
 | 
				
			||||||
        username: '',
 | 
					        username: '',
 | 
				
			||||||
| 
						 | 
					@ -139,7 +165,8 @@ export default {
 | 
				
			||||||
        mobile: '',
 | 
					        mobile: '',
 | 
				
			||||||
        permissionCodes: [],
 | 
					        permissionCodes: [],
 | 
				
			||||||
        remark: '',
 | 
					        remark: '',
 | 
				
			||||||
        accountId: null
 | 
					        accountId: null,
 | 
				
			||||||
 | 
					        enable: true
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
      subAccountList: [],
 | 
					      subAccountList: [],
 | 
				
			||||||
      permissionList: [],
 | 
					      permissionList: [],
 | 
				
			||||||
| 
						 | 
					@ -210,13 +237,30 @@ export default {
 | 
				
			||||||
        this.permissionList = mapTreeForElTree(filteredTree);
 | 
					        this.permissionList = mapTreeForElTree(filteredTree);
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					    openResetPasswordDialog() {
 | 
				
			||||||
 | 
					      if (!this.form.accountId) {
 | 
				
			||||||
 | 
					        this.$message.error('请先选择要更新的账号');
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      this.resetPasswordDialogVisible = true;
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    handleResetPassword() {
 | 
				
			||||||
 | 
					      if (!this.newPassword) {
 | 
				
			||||||
 | 
					        this.$message.error('请输入新密码');
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      resetPassword(this.form.accountId, this.newPassword).then(() => {
 | 
				
			||||||
 | 
					        this.$message.success('密码重置成功');
 | 
				
			||||||
 | 
					        this.resetPasswordDialogVisible = false;
 | 
				
			||||||
 | 
					      });
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
    handleTreeCheck() {
 | 
					    handleTreeCheck() {
 | 
				
			||||||
      // getCheckedKeys(true) will return an array of keys of the currently checked leaf nodes.
 | 
					      // getCheckedKeys(true) will return an array of keys of the currently checked leaf nodes.
 | 
				
			||||||
      this.form.permissionCodes = this.$refs.permissionTree.getCheckedKeys(true);
 | 
					      this.form.permissionCodes = this.$refs.permissionTree.getCheckedKeys(true);
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    loadSubAccountList() {
 | 
					    loadSubAccountList() {
 | 
				
			||||||
      getSubAccountList().then(res => {
 | 
					      getSubAccountList().then(res => {
 | 
				
			||||||
        this.subAccountList = res.data.data || [];
 | 
					        this.subAccountList = res.data.data.data || [];
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    handleAccountChange(accountId) {
 | 
					    handleAccountChange(accountId) {
 | 
				
			||||||
| 
						 | 
					@ -227,6 +271,7 @@ export default {
 | 
				
			||||||
        this.form.mobile = accountDetails.mobile;
 | 
					        this.form.mobile = accountDetails.mobile;
 | 
				
			||||||
        this.form.remark = accountDetails.remark;
 | 
					        this.form.remark = accountDetails.remark;
 | 
				
			||||||
        this.form.permissionCodes = accountDetails.permissionCodes || [];
 | 
					        this.form.permissionCodes = accountDetails.permissionCodes || [];
 | 
				
			||||||
 | 
					        this.form.enable = accountDetails.enabled;
 | 
				
			||||||
        this.$nextTick(() => {
 | 
					        this.$nextTick(() => {
 | 
				
			||||||
          this.$refs.permissionTree.setCheckedKeys(this.form.permissionCodes);
 | 
					          this.$refs.permissionTree.setCheckedKeys(this.form.permissionCodes);
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
| 
						 | 
					@ -255,7 +300,7 @@ export default {
 | 
				
			||||||
              mobile: this.form.mobile,
 | 
					              mobile: this.form.mobile,
 | 
				
			||||||
              permissionCodes: this.form.permissionCodes,
 | 
					              permissionCodes: this.form.permissionCodes,
 | 
				
			||||||
              remark: this.form.remark,
 | 
					              remark: this.form.remark,
 | 
				
			||||||
              enabled: true // 根据示例,默认为 true
 | 
					              enabled: this.form.enable
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
            updateSubAccount(updateData).then(() => {
 | 
					            updateSubAccount(updateData).then(() => {
 | 
				
			||||||
              this.$message.success('更新成功');
 | 
					              this.$message.success('更新成功');
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue