@skyfox2000/webui 1.0.0 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyfox2000/webui",
3
- "version": "1.0.0",
3
+ "version": "1.0.4",
4
4
  "description": "后台前端通用组件定义",
5
5
  "type": "module",
6
6
  "keywords": [],
@@ -26,6 +26,7 @@
26
26
  },
27
27
  "scripts": {
28
28
  "build": "pnpm i && vue-tsc -b && vite build",
29
+ "build:dev": "pnpm link ../502428_WebBase/ && vue-tsc -b && vite build",
29
30
  "build:dts": "vue-tsc -b && vite-dts-declaration",
30
31
  "build:types": "vue-tsc --declaration --emitDeclarationOnly"
31
32
  },
@@ -33,7 +34,7 @@
33
34
  "peerDependencies": {
34
35
  "@skyfox2000/fapi": "^1.1.17",
35
36
  "@skyfox2000/microbase": "^1.0.15",
36
- "@skyfox2000/webbase": "^1.1.0",
37
+ "@skyfox2000/webbase": "^1.1.7",
37
38
  "ant-design-vue": "^4.2.6",
38
39
  "dayjs": "^1.11.13",
39
40
  "pinia": "^2.3.0",
@@ -1,8 +1,8 @@
1
1
  <script setup lang="ts">
2
- import { EditorControl, ProviderKeys, useFormItemFactory } from '@skyfox2000/webbase';
3
- import { FormItem } from 'ant-design-vue';
2
+ import { EditorControl, ProviderKeys, useFormItemFactory, ValidateRuleItem } from '@skyfox2000/webbase';
3
+ import { FormItem, message } from 'ant-design-vue';
4
4
  import { Helper } from '../../common';
5
- import { inject, ref, useAttrs } from 'vue';
5
+ import { computed, inject, ref, useAttrs } from 'vue';
6
6
  import { AnyData } from '@skyfox2000/fapi';
7
7
 
8
8
  const props = defineProps<{
@@ -39,6 +39,41 @@ setTimeout(() => {
39
39
  visible.value = true;
40
40
  }, 30);
41
41
 
42
+ /**
43
+ * 递归获取规则
44
+ * - async-validator的语法规范
45
+ */
46
+ const getRule = (rule: Array<string>, ruleObj: Record<string, any> | undefined): ValidateRuleItem | undefined => {
47
+ if (!ruleObj) {
48
+ return undefined;
49
+ }
50
+ const [key, ...rest] = rule;
51
+ if (rule.length === 1) {
52
+ return ruleObj[key];
53
+ }
54
+ return getRule(rest, ruleObj[key].fields as Record<string, any>);
55
+ };
56
+ /**
57
+ * 是否必填
58
+ * - 如果rule为空,则不显示必填标记
59
+ * - 如果rule不为空,则根据formRules中的required属性判断是否必填
60
+ */
61
+ const required = computed(() => {
62
+ if (!props.rule) {
63
+ // 如果rule为空,则不显示必填标记
64
+ return false;
65
+ }
66
+ // 如果rule包含.,则表示是对象属性
67
+ const rule = getRule(props.rule.split('.'), editorCtrl?.formRules?.value);
68
+ if (!rule) {
69
+ message.error(`"${props.label}" 的验证规则 \`${props.rule}\` 不存在`);
70
+ errInfo.value.errClass = 'text-[#ff4d4f]';
71
+ errInfo.value.msg = `规则 \`${props.rule}\` 不存在,请检查代码!`;
72
+ return true;
73
+ }
74
+ return rule.required ?? true;
75
+ });
76
+
42
77
  // 参考代码
43
78
  // this.$parent.$el.scrollIntoView({
44
79
  // //滚动到指定节点
@@ -50,7 +85,7 @@ setTimeout(() => {
50
85
  <div :class="['w-full relative mb-1', width]">
51
86
  <FormItem
52
87
  v-if="visible"
53
- :required="!!rule && editorCtrl?.formRules?.value?.[rule]?.required"
88
+ :required="required"
54
89
  class="!w-[95%] relative"
55
90
  v-bind="attrs"
56
91
  :class="[rule ? '' : 'mb-3']"
@@ -29,6 +29,10 @@ const props = defineProps<{
29
29
  * 表格控制对象
30
30
  */
31
31
  gridCtrl: GridControl<AnyData>;
32
+ /**
33
+ * 模糊查询字段
34
+ */
35
+ likeFields?: string[];
32
36
  }>();
33
37
 
34
38
  // const pageData = props.gridData.page;
@@ -83,6 +87,14 @@ onMounted(() => {
83
87
 
84
88
  const onSearch = () => {
85
89
  let search = { ...props.search };
90
+ if (props.likeFields) {
91
+ for (const field of props.likeFields) {
92
+ if (search[field]) {
93
+ search[field] = { $like: '%' + search[field] + '%' };
94
+ }
95
+ }
96
+ }
97
+
86
98
  props.gridCtrl.gridQuery = {
87
99
  ...props.gridCtrl.gridQuery,
88
100
  Query: {
@@ -18,7 +18,7 @@ const confirmExit = () => {
18
18
  };
19
19
  </script>
20
20
  <template>
21
- <ToolIcon icon="icon-logout" @click="open = true" clickable class="w-5 h-5" />
21
+ <ToolIcon icon="icon-logout" @click="open = true" clickable class="w-5 h-5" title="退出系统" />
22
22
  <Modal v-model:open="open" title="确定退出?" ok-text="确定" cancel-text="取消" :width="380" @ok="confirmExit">
23
23
  <Flex align="center" justify="flex-start" :style="{ padding: '0 32px', margin: '20px 0' }">
24
24
  <ToolIcon icon="icon-question-circle" color="orange" class="w-[60px] h-[60px]" />
@@ -1,9 +1,10 @@
1
1
  <script lang="ts" setup>
2
- import { LayoutHeader, Avatar, theme, Space } from 'ant-design-vue';
2
+ import { LayoutHeader, theme, Space } from 'ant-design-vue';
3
3
  import { useSettingInfo } from '@skyfox2000/webbase';
4
4
  import { ToolIcon } from '../../common';
5
5
  import Breadcrumb from '../breadcrumb/index.vue';
6
6
  import HeaderExits from './headerExits.vue';
7
+ import User from './user.vue';
7
8
 
8
9
  const { useToken } = theme;
9
10
  const { token } = useToken();
@@ -36,7 +37,7 @@ const onCollapseClick = () => {
36
37
  </div>
37
38
  <div>
38
39
  <Space size="middle" class="flex items-center">
39
- <Avatar class="avatar" :style="{ backgroundColor: '#f56a00', fontSize: '14px' }" :size="24"> U </Avatar>
40
+ <User class="w-7 h-7" />
40
41
  <HeaderExits />
41
42
  </Space>
42
43
  </div>
@@ -0,0 +1,10 @@
1
+ <script setup lang="ts">
2
+ import { Tooltip, AppIcon } from '../../common';
3
+ import { useUserInfo } from '@skyfox2000/webbase';
4
+ const userInfo = useUserInfo().userInfo;
5
+ </script>
6
+ <template>
7
+ <Tooltip :title="userInfo.Name">
8
+ <AppIcon icon="icon-account" />
9
+ </Tooltip>
10
+ </template>
@@ -1,13 +1,26 @@
1
1
  <script setup lang="ts">
2
2
  import { Tabs, TabPane, theme } from 'ant-design-vue';
3
3
  import { useAppInfo, usePageInfo } from '@skyfox2000/webbase';
4
-
4
+ // import { useRouter } from 'vue-router';
5
5
  import { ToolIcon, Tooltip } from '../../common';
6
+ // import { watch } from 'vue';
6
7
 
7
8
  const { useToken } = theme;
8
9
  const { token } = useToken();
9
10
 
10
11
  const pageInfoStore = usePageInfo();
12
+ // const router = useRouter();
13
+
14
+ // 通过路由设置当前激活页签
15
+ // 避免通过浏览器后退按钮,导致页签不更新
16
+ // watch(
17
+ // () => router.currentRoute.value.path,
18
+ // (newVal) => {
19
+ // if (newVal !== pageInfoStore.TabActive) {
20
+ // pageInfoStore.setTabActive(newVal);
21
+ // }
22
+ // },
23
+ // );
11
24
 
12
25
  const onTabClicked = (tabKey: any) => {
13
26
  useAppInfo().push(tabKey as string);