This commit is contained in:
28723
2024-07-08 10:05:22 +08:00
parent 796d2fcf63
commit 64cfd47d50
18 changed files with 500 additions and 191 deletions

View File

@@ -121,14 +121,8 @@
provide('addChildForm', addChildForm);
const getFormClass = computed(() => {
if (props.formLayout === 'flexVertical') {
return formConfig.formLayout.flexVertical;
}
if (props.formLayout === 'flex') {
return formConfig.formLayout.flex;
}
if (props.formLayout === 'flexv2') {
return formConfig.formLayout.flexv2;
if (props.formLayout) {
return formConfig.formLayout[props.formLayout as keyof typeof formConfig.formLayout];
}
return formConfig.formLayout.vertical;
});

View File

@@ -14,6 +14,7 @@ export const treeProps = {
type: [String, Object, Function] as PropType<string | Function | AxiosRequestConfig>,
default: undefined,
},
treeData: PropTypes.array.def([]),
params: PropTypes.object.def(() => ({})),
dynamicParams: PropTypes.oneOfType([
PropTypes.string,

View File

@@ -10,10 +10,10 @@
</div>
</div>
<div style="min-height: 300px">
<div style="min-height: 300px; overflow-y: scroll">
<ns-tree v-if="treeData?.length" v-bind="getBindValue" v-model:selectedKeys="selectedKeys">
<template #[item]="data" v-for="(item, index) in Object.keys($slots)" :key="index">
<slot :name="item" v-bind="data || {}"></slot>
<slot :name="item" v-bind="{ ...data, formModel } || {}"></slot>
</template>
</ns-tree>
<!-- <a-empty v-if="!treeData?.length" /> -->
@@ -21,7 +21,7 @@
</a-spin>
</template>
<script lang="ts" setup>
import { computed, nextTick, reactive, ref, unref, useAttrs } from 'vue';
import { computed, nextTick, reactive, ref, unref, useAttrs, watch } from 'vue';
import { TreeDataItem } from 'ant-design-vue/es/tree/Tree';
import { useApi } from '/nerv-lib/use/use-api';
import { AxiosRequestConfig } from 'axios';
@@ -33,16 +33,28 @@
defineOptions({
name: 'NsTreeApi',
});
const emit = defineEmits(['update:treeData']);
// const model = defineModel('treeData');
const formElRef = ref();
const props = defineProps(treeProps);
const treeData = ref<TreeDataItem[]>([]);
const treeData = ref(props.treeData);
const selectedKeys = ref(props.selectedKeys || []);
const { httpRequest } = useApi();
const requestConfig: AxiosRequestConfig = { method: 'get' };
const route = useRoute();
const attrs = useAttrs();
const formModel = reactive({});
watch(
() => props.treeData,
(val) => {
treeData.value = val;
},
{
deep: true,
},
);
const treeState = reactive({
loading: false,
});
@@ -56,6 +68,7 @@
return props.isSticky ? 'sticky' : 'static';
});
const formFinish = debounce((data: object) => {
selectedKeys.value = [];
getData(data);
}, 200);
const getBindValue = computed(() => ({
@@ -83,6 +96,8 @@
})
.then((res) => {
treeData.value = transform(get(res, resultField));
emit('update:treeData', treeData.value);
// model.value = treeData.value;
})
.finally(() => {
setLoading(false);

View File

@@ -11,6 +11,17 @@ export const formConfig = {
gutter: [0, 0],
justify: 'space-around',
},
formVertical: {
layout: 'horizontal',
class: 'ns-vertical-form',
wrapperCol: { span: 24 },
labelCol: { span: 0 },
span: 24,
sm: null, //≥576px <=768
lg: null, //>= 768
gutter: [0, 0],
justify: 'space-around',
},
flex: {
// layout: 'horizontal',
class: 'ns-flex-form ns-flex-form-horizontal',

View File

@@ -19,33 +19,51 @@
<h1 class="lg_card_title">{{ configStore.projectName }}</h1>
<p v-show="!errorShow" style="height: 8px"></p>
<p v-show="errorShow" class="lg_card_error">{{ errorMsg }}</p>
<!-- <p class="lg_card_tip">用户名/手机号</p> -->
<a-input class="loginInfo" placeholder="用户名" v-model:value="userName">
<template #prefix>
<ns-icon class="loginIcon" name="userName" size="19" style="margin-right: 20px" />
</template>
</a-input>
<!-- <p class="lg_card_tip">密码</p> -->
<a-input-password class="loginInfo" placeholder="密码" v-model:value="password">
<template #prefix>
<ns-icon class="loginIcon" name="passWord" size="19" style="margin-right: 20px" />
</template>
</a-input-password>
<!-- 验证码 -->
<a-form name="basic" :model="formState" @finish="submit">
<a-form-item name="userName" :rules="[{ required: true, message: '请输入用户名' }]">
<!-- <p class="lg_card_tip">用户名/手机号</p> -->
<a-input class="loginInfo" placeholder="用户名" v-model:value="userName">
<template #prefix>
<ns-icon class="loginIcon" name="userName" size="19" style="margin-right: 20px" />
</template>
</a-input>
</a-form-item>
<a-input v-model:value="code" placeholder="验证码" class="loginInfo">
<template #prefix>
<ns-icon class="loginIcon" name="verifyIcon" size="19" style="margin-right: 20px" />
</template>
<template #addonAfter>
<ns-verify @get-code="onGetCode" />
</template>
</a-input>
<!-- 记住密码 -->
<a-checkbox v-model:checked="isRemember" class="loginInfo">记住密码</a-checkbox>
<a-button @click="submit" :loading="loading" type="primary" class="loginInfo"
>登录</a-button
>
<a-form-item name="password" :rules="[{ required: true, message: '请输入密码' }]">
<!-- <p class="lg_card_tip">密码</p> -->
<a-input-password class="loginInfo" placeholder="密码" v-model:value="password">
<template #prefix>
<ns-icon class="loginIcon" name="passWord" size="19" style="margin-right: 20px" />
</template>
</a-input-password>
</a-form-item>
<a-form-item name="code" :rules="[{ validator }]">
<!-- 验证码 -->
<a-input v-model:value="code" placeholder="验证码" class="loginInfo">
<template #prefix>
<ns-icon
class="loginIcon"
name="verifyIcon"
size="19"
style="margin-right: 20px" />
</template>
<template #addonAfter>
<ns-verify @get-code="onGetCode" />
</template>
</a-input>
</a-form-item>
<!-- <a-form-item name="remember"> -->
<!-- 记住密码 -->
<a-checkbox v-model:checked="isRemember" class="loginInfo">记住密码</a-checkbox>
<!-- </a-form-item> -->
<a-form-item>
<a-button html-type="submit" :loading="loading" type="primary" class="loginInfo">
登录
</a-button>
</a-form-item>
</a-form>
</div>
</a-layout-content>
<!-- <a-layout-footer>Copyright 2021 xu科技 All Rights Reserved</a-layout-footer> -->
@@ -54,7 +72,7 @@
</template>
<script lang="ts">
import { defineComponent, onMounted, ref } from 'vue';
import { defineComponent, onMounted, reactive, ref } from 'vue';
import { useRouter } from 'vue-router';
import { appConfigStore } from '/nerv-lib/saas/store/modules/app-config';
import { authorizationService } from '/nerv-base/store/modules/authorization-service';
@@ -81,11 +99,12 @@
// title.value = appConfig.title ? appConfig.title : '账号登录';
const loading = ref<boolean>(false);
const configStore = appConfigStore();
console.log(configStore);
const formState = reactive({ userName, password, code });
const { getThemeConfig: themeConfig, projectName } = storeToRefs(configStore);
const useAuthorization = authorizationService();
const rememberFunc = (data) => {
console.log(isRemember.value);
if (!isRemember.value) return;
@@ -97,24 +116,28 @@
const { accountNo, password: pwd } = JSON.parse(data);
userName.value = accountNo;
password.value = pwd;
formState.userName = userName.value;
formState.password = password.value;
}
});
const submit = (): void => {
if (password.value === '') {
errorMsg.value = '请输入密码';
errorShow.value = true;
return;
}
if (userName.value === '') {
errorMsg.value = '请输入账号';
errorShow.value = true;
return;
}
// if (!code.value) {
// errorMsg.value = '请输入验证码';
const submit = (value): void => {
console.log(value);
// if (password.value === '') {
// errorMsg.value = '请输入密码';
// errorShow.value = true;
// return;
// }
// if (userName.value === '') {
// errorMsg.value = '请输入账号';
// errorShow.value = true;
// return;
// }
// if (!code.value) {
// // errorMsg.value = '请输入验证码';
// // errorShow.value = true;
// return;
// }
// if (code.value.toLocaleLowerCase() !== verifyCode.value.toLocaleLowerCase()) {
// errorMsg.value = '请输入正确的验证码';
// errorShow.value = true;
@@ -208,7 +231,15 @@
const onGetCode = (res) => {
verifyCode.value = res;
};
const validator = async (rule, value) => {
if (!value) return Promise.reject('请输入验证码');
if (value?.toLocaleLowerCase() !== verifyCode.value.toLocaleLowerCase())
return Promise.reject('请输入正确的验证码');
};
return {
validator,
formState,
projectName,
onGetCode,
code,
@@ -323,7 +354,7 @@
.loginInfo {
height: 48px;
width: 100%;
margin-bottom: 24px;
// margin-bottom: 24px;
font-size: 16px !important;
:deep(.ant-input) {
@@ -340,10 +371,12 @@
}
}
.loginInfo:last-child {
margin-bottom: 16px;
// margin-bottom: 16px;
}
.loginInfo:nth-child(5n + 2) {
margin-bottom: 0px;
.loginInfo:nth-child(4) {
width: fit-content;
// margin-bottom: 0px;
// height: 20px !important;
}
}