Blame view

src/components/store/AdminLoginProperty.vue 2.07 KB
b25b036d   wuxw   v1.9 优化日期
1
  <template>
f804bf62   wuxw   报表功能测试完成
2
    <el-dialog :title="$t('propertyCompanyManage.passwordConfirm')" :visible.sync="visible" width="30%">
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
      <el-form>
        <el-form-item :label="$t('propertyCompanyManage.password')" required>
          <el-input v-model="password" type="password" :placeholder="$t('propertyCompanyManage.enterCurrentPassword')" />
        </el-form-item>
      </el-form>
      <div slot="footer">
        <el-button @click="visible = false">{{ $t('common.cancel') }}</el-button>
        <el-button type="primary" @click="handleLogin">{{ $t('propertyCompanyManage.login') }}</el-button>
      </div>
    </el-dialog>
  </template>
  
  <script>
  import { adminLoginProperty } from '@/api/store/propertyCompanyManageApi'
  import {  _loadStaffPrivileges } from '@/api/user/loginApi';
  import { _loadCommunityInfo } from '@/api/community/communityApi';
  
  export default {
    name: 'AdminLoginProperty',
  
    data() {
      return {
        password: '',
        visible: false,
        propertyInfo: {}
      }
    },
    methods: {
      open(row) {
        this.visible = true
        this.propertyInfo = row.staffInfo  
      },
      async handleLogin() {
        if (!this.password) {
          this.$message.warning(this.$t('propertyCompanyManage.passwordRequired'))
          return
        }
  
        try {
          const loginInfo = {
            username: this.propertyInfo.staffName,
            userId: this.propertyInfo.staffId,
            curPasswd: this.password,
            curUserName: this.$getUser().name
          }
  
         const {data} = await adminLoginProperty(loginInfo)
         this.visible = false
  
         this.handleSelect(data[0])
  
          this.$emit('success')
        } catch (error) {
          this.$message.error(error.message)
        }
      },
      async handleSelect(_userData) {
        localStorage.clear();
        localStorage.setItem('token', _userData.token);
        let _user = {
          userId: _userData.userId,
          name: _userData.name,
          tel: _userData.tel
        }
        localStorage.setItem('user', JSON.stringify(_user));
        await _loadStaffPrivileges();
        await _loadCommunityInfo();
        window.location.href = '/';
      },
    }
  }
  </script>