刘光辉
7 小时以前 0dfe84494048ce27ba8449831782128412d3eb13
1
2
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<script lang="ts" setup>
import { onMounted, ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
 
import { useMessage } from '@jnpf/hooks';
import { BasicForm, useForm } from '@jnpf/ui/form';
import { AesEncryption, encryptByMd5 } from '@jnpf/utils';
 
import { preferences } from '@vben/preferences';
 
import { joinSaas } from '#/api/permission/userSetting';
 
defineOptions({ name: 'Join' });
 
const router = useRouter();
const route = useRoute();
const aesEncryption = new AesEncryption();
const { createMessage } = useMessage();
const btnLoading = ref<boolean>(false);
 
const [registerForm, { resetFields, validate, setFieldsValue }] = useForm({
  baseColProps: { span: 24 },
  layout: 'vertical',
  schemas: [
    {
      field: 'tenantId',
      label: '租户号',
      component: 'Input',
      componentProps: { placeholder: '打开链接时带入', disabled: true },
      rules: [{ required: true, trigger: 'blur', message: '必填' }],
    },
    {
      field: 'companyName',
      label: '企业名称',
      component: 'Input',
      componentProps: { placeholder: '打开链接时带入', disabled: true },
    },
    {
      field: 'appId',
      label: '应用编码',
      component: 'Input',
      componentProps: { placeholder: '打开链接时带入', disabled: true },
      rules: [{ required: true, trigger: 'blur', message: '必填' }],
    },
    {
      field: 'appName',
      label: '应用名称',
      component: 'Input',
      componentProps: { placeholder: '打开链接时带入', disabled: true },
    },
    {
      field: 'account',
      label: '您在该应用下的账号及密码',
      component: 'Input',
      componentProps: { placeholder: '请输入账号' },
      rules: [{ required: true, trigger: 'blur', message: '必填' }],
    },
    {
      field: 'password',
      label: '',
      component: 'InputPassword',
      componentProps: { placeholder: '请输入密码' },
      rules: [{ required: true, trigger: 'blur', message: '必填' }],
    },
  ],
});
 
async function handleSubmit() {
  const values = await validate();
  if (!values) return;
  btnLoading.value = true;
  const password = encryptByMd5(values.password);
  const encryptPassword = aesEncryption.encryptByAES(password);
  const query = { ...values, password: encryptPassword };
  joinSaas(query)
    .then((res) => {
      createMessage.success(res.msg).then(() => {
        router.push(preferences.app.defaultHomePath);
        btnLoading.value = false;
      });
    })
    .catch(() => {
      btnLoading.value = false;
    });
}
function init() {
  if (!route.query.encryption) return;
  const encryption = route.query.encryption as string;
  const configStr = aesEncryption.decryptByAES(encryption);
  if (!configStr) return;
  const config = JSON.parse(configStr);
  resetFields();
  setFieldsValue(config);
}
 
onMounted(() => {
  init();
});
</script>
 
<template>
  <div class="join-container">
    <div class="join-container-main">
      <div class="join-banner"></div>
      <div class="join-form">
        <div class="join-form-cap">加入企业</div>
        <BasicForm @register="registerForm" />
        <a-button type="primary" class="w-[150px]" @click="handleSubmit" :loading="btnLoading">确定</a-button>
      </div>
    </div>
  </div>
</template>
<style lang="scss" scoped>
.join-container {
  height: 100%;
  padding: 30px 0;
  overflow: auto;
  background: no-repeat top center;
  background-color: #ecedf7;
  background-image: url('@/assets/images/join/join-bg.png');
  background-size: contain;
 
  .join-container-main {
    width: 1310px;
    margin: 0 auto;
  }
 
  .join-banner {
    height: 251px;
    background-image: url('@/assets/images/join/join-head.png');
    background-size: contain;
  }
 
  .join-form {
    padding: 30px 100px;
    background: var(--component-background);
    border-radius: 0 0 8px 8px;
 
    .join-form-cap {
      position: relative;
      padding-left: 10px;
      margin-bottom: 20px;
      font-size: 24px;
      font-weight: 500;
      line-height: 32px;
 
      &::before {
        position: absolute;
        top: 5px;
        left: 0;
        display: block;
        width: 6px;
        height: 24px;
        overflow: hidden;
        content: '';
        background-color: var(--primary-color);
        border-radius: 4px 0 0 4px;
      }
    }
  }
}
 
.dark,
.dark[data-theme='custom'],
.dark[data-theme='default'] {
  .join-container {
    background-color: #333;
    background-image: none;
  }
}
</style>