ui-ddy-pc 0.0.1-beta
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/.env.development +4 -0
- package/.env.prod +1 -0
- package/.env.stage +3 -0
- package/.vscode/extensions.json +3 -0
- package/README.md +7 -0
- package/build/configure/package.json +11 -0
- package/index.html +13 -0
- package/index.js +4 -0
- package/package.json +33 -0
- package/src/App.vue +20 -0
- package/src/assets/table/empty-data.png +0 -0
- package/src/assets/table/magnifier.svg +7 -0
- package/src/assets/vue.svg +1 -0
- package/src/components/tableTest.vue +101 -0
- package/src/components/topSearch/search.vue +302 -0
- package/src/components/topSearch/searchItem.vue +80 -0
- package/src/components/topSign/topSign.vue +170 -0
- package/src/components/topTable/topTable.vue +854 -0
- package/src/docs/.vitepress/cache/deps/@theme_index.js +258 -0
- package/src/docs/.vitepress/cache/deps/@theme_index.js.map +7 -0
- package/src/docs/.vitepress/cache/deps/_metadata.json +40 -0
- package/src/docs/.vitepress/cache/deps/chunk-KGHB62SH.js +11434 -0
- package/src/docs/.vitepress/cache/deps/chunk-KGHB62SH.js.map +7 -0
- package/src/docs/.vitepress/cache/deps/chunk-TBELKJNH.js +9088 -0
- package/src/docs/.vitepress/cache/deps/chunk-TBELKJNH.js.map +7 -0
- package/src/docs/.vitepress/cache/deps/package.json +3 -0
- package/src/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +2588 -0
- package/src/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +7 -0
- package/src/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +567 -0
- package/src/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +7 -0
- package/src/docs/.vitepress/cache/deps/vue.js +323 -0
- package/src/docs/.vitepress/cache/deps/vue.js.map +7 -0
- package/src/docs/.vitepress/config.js +28 -0
- package/src/docs/api-examples.md +49 -0
- package/src/docs/combinedTable.md +158 -0
- package/src/docs/index.md +25 -0
- package/src/docs/markdown-examples.md +98 -0
- package/src/docs/unitTests/searchTest.vue +109 -0
- package/src/main.js +16 -0
- package/src/packages/index.js +3 -0
- package/src/router/index.js +24 -0
- package/src/store/index.js +35 -0
- package/src/style.css +73 -0
- package/src/utils/common.js +254 -0
- package/src/utils/currency.js +256 -0
- package/src/utils/errorCode.js +6 -0
- package/src/utils/request.js +220 -0
- package/src/utils/top.js +233 -0
- package/ui-ddy-pc/package.json +11 -0
- package/ui-ddy-pc/style.css +1 -0
- package/ui-ddy-pc/ui-ddy-pc.js +26436 -0
- package/ui-ddy-pc/ui-ddy-pc.umd.cjs +83 -0
- package/vite.config.js +54 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<search :searchConfig="searchConfig" @search="handleSearch"></search>
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
<script setup>
|
|
7
|
+
import search from '../../components/topSearch/search.vue';
|
|
8
|
+
|
|
9
|
+
import { reactive } from 'vue';
|
|
10
|
+
const searchConfig = reactive({
|
|
11
|
+
data: {},
|
|
12
|
+
// 默认选中的搜索项的值 重置也保留此值
|
|
13
|
+
defaultData: { scope: 1 },
|
|
14
|
+
config: [
|
|
15
|
+
{ label: '发料单号', field: 'code' },
|
|
16
|
+
{ label: '材料名称', field: 'clName' },
|
|
17
|
+
{
|
|
18
|
+
label: '发料单来源', field: 'dataSourceList', type: 'select',
|
|
19
|
+
options: [
|
|
20
|
+
{ value: "0", label: "磅房" },
|
|
21
|
+
{ value: "1", label: "移动端" },
|
|
22
|
+
{ value: "4", label: "拌合站" },
|
|
23
|
+
{ value: "5", label: "盘点" }
|
|
24
|
+
],
|
|
25
|
+
multiple: true
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
label: '是否关联', field: 'connStatus', type: 'select',
|
|
29
|
+
options: [
|
|
30
|
+
{ value: "", label: "全部" },
|
|
31
|
+
{ value: "0", label: "未关联" },
|
|
32
|
+
{ value: "1", label: "已关联" }
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
{ label: '材料编号', field: 'clCode' },
|
|
36
|
+
{ label: '仓库名称', field: 'warehouseName' },
|
|
37
|
+
{ label: '磅房名称', field: 'poundRoomName' },
|
|
38
|
+
{ label: '收料单位', field: 'gysName' },
|
|
39
|
+
{ label: '合同名称', field: 'contractInfoName' },
|
|
40
|
+
{
|
|
41
|
+
label: '发料时间', field: 'time', type: 'daterange', startField: "createTimeBegin", endField: "createTimeEnd",
|
|
42
|
+
format: 'YYYY-MM-DD HH:mm:ss', valueFormat: 'YYYY-MM-DD HH:mm:ss'
|
|
43
|
+
},
|
|
44
|
+
]
|
|
45
|
+
})
|
|
46
|
+
const handleSearch = (isReset) => {
|
|
47
|
+
console.log('查了', searchConfig.data);
|
|
48
|
+
}
|
|
49
|
+
</script>
|
|
50
|
+
<style lang="scss" scoped>
|
|
51
|
+
:deep(.search-container) {
|
|
52
|
+
|
|
53
|
+
position: relative;
|
|
54
|
+
min-height: 32px;
|
|
55
|
+
|
|
56
|
+
.search-row {
|
|
57
|
+
position: relative;
|
|
58
|
+
|
|
59
|
+
.item-label {
|
|
60
|
+
white-space: nowrap;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.buttons {
|
|
64
|
+
align-items: center;
|
|
65
|
+
margin-bottom: 18px;
|
|
66
|
+
display: inline-flex;
|
|
67
|
+
vertical-align: middle;
|
|
68
|
+
|
|
69
|
+
.btn {
|
|
70
|
+
display: flex;
|
|
71
|
+
align-items: center;
|
|
72
|
+
padding: 0px 20px;
|
|
73
|
+
cursor: pointer;
|
|
74
|
+
user-select: none;
|
|
75
|
+
|
|
76
|
+
.icon {
|
|
77
|
+
margin-top: 3px;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.text {
|
|
81
|
+
color: #303133;
|
|
82
|
+
font-size: 14px;
|
|
83
|
+
padding-left: 10px;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.row-item {
|
|
89
|
+
.el-col:nth-child(4n) {
|
|
90
|
+
.el-form-item {
|
|
91
|
+
margin-right: 0 !important;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
position: absolute;
|
|
96
|
+
right: 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.el-form-item {
|
|
100
|
+
margin-right: 10px !important;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.individual {
|
|
104
|
+
display: flex;
|
|
105
|
+
flex-direction: row-reverse;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
</style>
|
package/src/main.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createApp } from 'vue'
|
|
2
|
+
import './style.css'
|
|
3
|
+
import App from './App.vue'
|
|
4
|
+
import router from './router/index'
|
|
5
|
+
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
|
|
6
|
+
import { createPinia } from 'pinia'
|
|
7
|
+
import ElementPlus from 'element-plus'
|
|
8
|
+
import locale from 'element-plus/es/locale/lang/zh-cn'
|
|
9
|
+
|
|
10
|
+
const pinia = createPinia()
|
|
11
|
+
const app = createApp(App)
|
|
12
|
+
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
|
13
|
+
app.component(key, component)
|
|
14
|
+
}
|
|
15
|
+
app.use(ElementPlus, {locale})
|
|
16
|
+
app.use(router).use(pinia).mount('#app')
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createRouter, createWebHashHistory } from "vue-router";
|
|
2
|
+
|
|
3
|
+
const routes = [
|
|
4
|
+
{
|
|
5
|
+
path: "/",
|
|
6
|
+
name: "index",
|
|
7
|
+
component: () => import("@/components/tableTest.vue"),
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
path: "/searchTest",
|
|
11
|
+
name: "searchTest",
|
|
12
|
+
component: () => import("@/components/searchTest.vue"),
|
|
13
|
+
},
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
const router = createRouter({
|
|
17
|
+
history: createWebHashHistory(),
|
|
18
|
+
routes: routes,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
router.beforeEach((to, from, next) => {
|
|
22
|
+
next();
|
|
23
|
+
});
|
|
24
|
+
export default router;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { defineStore } from "pinia";
|
|
2
|
+
|
|
3
|
+
export const userStore = defineStore("store", {
|
|
4
|
+
state: () => {
|
|
5
|
+
return {
|
|
6
|
+
name: "cmps",
|
|
7
|
+
token: "",
|
|
8
|
+
subjectId: "",
|
|
9
|
+
subjectName: "",
|
|
10
|
+
origin: "",
|
|
11
|
+
users: {},
|
|
12
|
+
projectId: "",
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
actions: {
|
|
16
|
+
setToken(token) {
|
|
17
|
+
this.token = token;
|
|
18
|
+
},
|
|
19
|
+
setOrign(origin) {
|
|
20
|
+
this.origin = origin || "";
|
|
21
|
+
},
|
|
22
|
+
setUsers(users) {
|
|
23
|
+
this.users = users;
|
|
24
|
+
},
|
|
25
|
+
setSubjectId(subjectId) {
|
|
26
|
+
this.subjectId = subjectId;
|
|
27
|
+
},
|
|
28
|
+
setSubjectName(subjectName) {
|
|
29
|
+
this.subjectName = subjectName;
|
|
30
|
+
},
|
|
31
|
+
setProjectId(projectId) {
|
|
32
|
+
this.projectId = projectId;
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
});
|
package/src/style.css
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
3
|
+
line-height: 1.5;
|
|
4
|
+
font-weight: 400;
|
|
5
|
+
|
|
6
|
+
color-scheme: light dark;
|
|
7
|
+
color: rgba(255, 255, 255, 0.87);
|
|
8
|
+
background-color: #242424;
|
|
9
|
+
|
|
10
|
+
font-synthesis: none;
|
|
11
|
+
text-rendering: optimizeLegibility;
|
|
12
|
+
-webkit-font-smoothing: antialiased;
|
|
13
|
+
-moz-osx-font-smoothing: grayscale;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
a {
|
|
17
|
+
font-weight: 500;
|
|
18
|
+
color: #646cff;
|
|
19
|
+
text-decoration: inherit;
|
|
20
|
+
}
|
|
21
|
+
a:hover {
|
|
22
|
+
color: #535bf2;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
body {
|
|
26
|
+
margin: 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
h1 {
|
|
30
|
+
font-size: 3.2em;
|
|
31
|
+
line-height: 1.1;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
button {
|
|
35
|
+
border-radius: 8px;
|
|
36
|
+
border: 1px solid transparent;
|
|
37
|
+
padding: 0.6em 1.2em;
|
|
38
|
+
font-size: 1em;
|
|
39
|
+
font-weight: 500;
|
|
40
|
+
font-family: inherit;
|
|
41
|
+
background-color: #1a1a1a;
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
transition: border-color 0.25s;
|
|
44
|
+
}
|
|
45
|
+
button:hover {
|
|
46
|
+
border-color: #646cff;
|
|
47
|
+
}
|
|
48
|
+
button:focus,
|
|
49
|
+
button:focus-visible {
|
|
50
|
+
outline: 4px auto -webkit-focus-ring-color;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.card {
|
|
54
|
+
padding: 2em;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
#app {
|
|
58
|
+
width: 100%;
|
|
59
|
+
height: 100%;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@media (prefers-color-scheme: light) {
|
|
63
|
+
:root {
|
|
64
|
+
color: #213547;
|
|
65
|
+
background-color: #ffffff;
|
|
66
|
+
}
|
|
67
|
+
a:hover {
|
|
68
|
+
color: #747bff;
|
|
69
|
+
}
|
|
70
|
+
button {
|
|
71
|
+
background-color: #f9f9f9;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
import { userStore } from "@/store/index.js";
|
|
4
|
+
import currency from "@/utils/currency.js";
|
|
5
|
+
import qs from "qs";
|
|
6
|
+
|
|
7
|
+
const urlParams = qs.parse(window.location.href.split("?")[1]);
|
|
8
|
+
const env = import.meta.env;
|
|
9
|
+
const store = userStore();
|
|
10
|
+
function TableHead(label, prop, width = "") {
|
|
11
|
+
return {
|
|
12
|
+
label,
|
|
13
|
+
prop,
|
|
14
|
+
width,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function FormItem(label, field, span = 12) {
|
|
19
|
+
return {
|
|
20
|
+
label,
|
|
21
|
+
field,
|
|
22
|
+
span,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function SearchItem(label, field) {
|
|
27
|
+
return {
|
|
28
|
+
label,
|
|
29
|
+
field,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function formatDate(cellValue, pattern = "YYYY-MM-DD HH:mm:ss") {
|
|
34
|
+
if (!cellValue) return "";
|
|
35
|
+
return dayjs(cellValue).format(pattern);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// 配置项找到指定field对应items的下标
|
|
39
|
+
function getItemsIndex(items, field) {
|
|
40
|
+
return items.findIndex((item) => item.field == field);
|
|
41
|
+
}
|
|
42
|
+
function resolveFile(res, fileName) {
|
|
43
|
+
const aLink = document.createElement("a");
|
|
44
|
+
aLink.style.display = "none";
|
|
45
|
+
const blob = new Blob([res.data], { type: "" });
|
|
46
|
+
aLink.href = URL.createObjectURL(blob);
|
|
47
|
+
aLink.setAttribute("download", fileName); // 设置下载文件名称
|
|
48
|
+
document.body.appendChild(aLink);
|
|
49
|
+
aLink.click();
|
|
50
|
+
URL.revokeObjectURL(aLink.href); //清除引用
|
|
51
|
+
document.body.removeChild(aLink);
|
|
52
|
+
}
|
|
53
|
+
async function exportBlob(
|
|
54
|
+
callback,
|
|
55
|
+
params,
|
|
56
|
+
fileName,
|
|
57
|
+
loading,
|
|
58
|
+
isPost = false,
|
|
59
|
+
afterSuc = null
|
|
60
|
+
) {
|
|
61
|
+
const baseUrl = store.origin
|
|
62
|
+
? store.origin + "/" + env.VITE_BASE_API
|
|
63
|
+
: env.VITE_BASE_API;
|
|
64
|
+
let str = "";
|
|
65
|
+
if (!isPost) {
|
|
66
|
+
for (let key in params) {
|
|
67
|
+
if (params[key] || params[key] == 0) {
|
|
68
|
+
str += "&" + key + "=" + params[key];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
loading.value = true;
|
|
73
|
+
axios({
|
|
74
|
+
method: isPost ? "post" : "get",
|
|
75
|
+
url: isPost
|
|
76
|
+
? baseUrl + `${callback}`
|
|
77
|
+
: baseUrl + `${callback}?${str.slice(1)}`,
|
|
78
|
+
...(isPost ? { data: params } : {}),
|
|
79
|
+
responseType: "blob",
|
|
80
|
+
headers: { Authorization: "Bearer " + store.token },
|
|
81
|
+
})
|
|
82
|
+
.then((res) => {
|
|
83
|
+
if (!res.data) {
|
|
84
|
+
this.$message.error("下载失败,解析数据为空!");
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
resolveFile(res, fileName);
|
|
88
|
+
afterSuc ? afterSuc() : "";
|
|
89
|
+
})
|
|
90
|
+
.finally(() => {
|
|
91
|
+
loading.value = false;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function fixDigits(val, digits) {
|
|
95
|
+
return currency(val, { precision: digits }).value;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// 限制输入框小数
|
|
99
|
+
function limitDecimal(val, digits) {
|
|
100
|
+
// 去除多个0
|
|
101
|
+
let tmp = val.replace(/^0+(\d+(\.\d+)?)$/, "$1");
|
|
102
|
+
// 配置保留几位小数
|
|
103
|
+
const regExp = new RegExp(
|
|
104
|
+
"^\\D*(\\d{0,9}(?:\\.\\d{0," + digits + "})?).*$",
|
|
105
|
+
"g"
|
|
106
|
+
);
|
|
107
|
+
return tmp.replace(regExp, "$1");
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function judgePermi(val) {
|
|
111
|
+
// 测试环境取不到 默认true
|
|
112
|
+
if (env.VITE_NODE_ENV !== "env") {
|
|
113
|
+
console.log(
|
|
114
|
+
window.$wujie?.props.hasPermission(val),
|
|
115
|
+
"window.$wujie?.props.hasPermission(val)"
|
|
116
|
+
);
|
|
117
|
+
return window.$wujie?.props.hasPermission(val);
|
|
118
|
+
} else {
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function isCreatBy(userId) {
|
|
124
|
+
if (env.VITE_NODE_ENV !== "env") {
|
|
125
|
+
if (!userId) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
// 兼容代办链接中获取userId
|
|
129
|
+
return store.users?.userId
|
|
130
|
+
? store.users?.userId == userId
|
|
131
|
+
: urlParams?.userId == userId;
|
|
132
|
+
} else {
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function handleIndex(data, pageNum, pageSize) {
|
|
138
|
+
const num = (pageNum - 1) * pageSize;
|
|
139
|
+
return data.$index + num + 1;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// 判断内容是否超长显示了省略号
|
|
143
|
+
function judgeOverflow(el, disabled) {
|
|
144
|
+
let element = el.target;
|
|
145
|
+
let style = window.getComputedStyle(element);
|
|
146
|
+
let availableWidth =
|
|
147
|
+
element.clientWidth -
|
|
148
|
+
parseFloat(style.paddingLeft) -
|
|
149
|
+
parseFloat(style.paddingRight);
|
|
150
|
+
|
|
151
|
+
const range = document.createRange();
|
|
152
|
+
// 设置 range 的起点
|
|
153
|
+
range.setStart(element, 0);
|
|
154
|
+
// 设置 range 的终点,因为起终点都在同一个节点上,所以设置终点偏移量以选中节点的内容
|
|
155
|
+
range.setEnd(element, element.childNodes.length);
|
|
156
|
+
// 获取节点的内容的宽度
|
|
157
|
+
const rangeWidth = range.getBoundingClientRect().width;
|
|
158
|
+
|
|
159
|
+
if (rangeWidth > availableWidth) {
|
|
160
|
+
disabled.value = false;
|
|
161
|
+
} else {
|
|
162
|
+
disabled.value = true;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// 处理报表中文编码
|
|
167
|
+
function cjkEncode(text) {
|
|
168
|
+
if (text == null) {
|
|
169
|
+
return "";
|
|
170
|
+
}
|
|
171
|
+
var newText = "";
|
|
172
|
+
for (var i = 0; i < text.length; i++) {
|
|
173
|
+
var code = text.charCodeAt(i);
|
|
174
|
+
if (
|
|
175
|
+
code >= 128 ||
|
|
176
|
+
code == 91 ||
|
|
177
|
+
code == 35 ||
|
|
178
|
+
code == 43 ||
|
|
179
|
+
code == 45 ||
|
|
180
|
+
code == 93
|
|
181
|
+
) {
|
|
182
|
+
newText += "[" + code.toString(16) + "]";
|
|
183
|
+
} else {
|
|
184
|
+
newText += text.charAt(i);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return newText;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// 查找指定节点
|
|
191
|
+
function getTreeNode(data, key, value) {
|
|
192
|
+
let result = null;
|
|
193
|
+
data.forEach((item) => {
|
|
194
|
+
if (result) {
|
|
195
|
+
return; // 如果已找到结果,则终止当前循环
|
|
196
|
+
}
|
|
197
|
+
if (item[key] === value) {
|
|
198
|
+
result = item;
|
|
199
|
+
return; // 终止当前循环
|
|
200
|
+
} else if (item.children && item.children.length > 0) {
|
|
201
|
+
result = getTreeNode(item.children, key, value);
|
|
202
|
+
if (result) {
|
|
203
|
+
return; // 终止当前循环
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
return result;
|
|
208
|
+
}
|
|
209
|
+
// 查找指定节点及其所有父级
|
|
210
|
+
function handleAncestors(data, nodeKey, value) {
|
|
211
|
+
const ancestorNodes = [];
|
|
212
|
+
const findAncestors = (currentNode, nodeKey, value) => {
|
|
213
|
+
if (currentNode[nodeKey] === value) {
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
if (currentNode.children) {
|
|
217
|
+
for (let child of currentNode.children) {
|
|
218
|
+
if (findAncestors(child, nodeKey, value)) {
|
|
219
|
+
ancestorNodes.push(currentNode);
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return false;
|
|
225
|
+
};
|
|
226
|
+
for (let node of data) {
|
|
227
|
+
findAncestors(node, nodeKey, value);
|
|
228
|
+
}
|
|
229
|
+
return ancestorNodes;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const limitPercentage = (val) => {
|
|
233
|
+
// 去除除数字及小数点外的中英文特殊符号 去除多个0
|
|
234
|
+
return val.replace(/[^\d.]+/g, "").replace(/^0+(\d+(\.\d+)?)$/, "$1");
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
export {
|
|
238
|
+
TableHead,
|
|
239
|
+
FormItem,
|
|
240
|
+
SearchItem,
|
|
241
|
+
getItemsIndex,
|
|
242
|
+
exportBlob,
|
|
243
|
+
formatDate,
|
|
244
|
+
fixDigits,
|
|
245
|
+
limitDecimal,
|
|
246
|
+
judgePermi,
|
|
247
|
+
isCreatBy,
|
|
248
|
+
handleIndex,
|
|
249
|
+
judgeOverflow,
|
|
250
|
+
cjkEncode,
|
|
251
|
+
getTreeNode,
|
|
252
|
+
handleAncestors,
|
|
253
|
+
limitPercentage,
|
|
254
|
+
};
|