w-ui-v1 1.1.34 → 1.1.36
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/index.ts +3 -1
- package/package.json +1 -1
- package/utils/apis/tree.ts +20 -0
- package/w-add/w-add.vue +6 -10
- package/w-tree/w-tree.vue +108 -0
package/index.ts
CHANGED
|
@@ -17,6 +17,7 @@ import WReportTable from './w-report-table/w-report-table.vue'
|
|
|
17
17
|
import WFormControlVue from './w-form-control/w-form-control.vue'
|
|
18
18
|
import WScanBindingSensor from './w-scan-binding-sensor/w-scan-binding-sensor.vue'
|
|
19
19
|
import WUpdateVersion from './w-update-version/w-update-version.vue'
|
|
20
|
+
import WTree from './w-tree/w-tree.vue'
|
|
20
21
|
import {menu} from './utils/apis/menu'
|
|
21
22
|
import request from './utils/http'
|
|
22
23
|
import nfc from './utils/nfc'
|
|
@@ -41,7 +42,8 @@ const coms: any[] = [
|
|
|
41
42
|
WReportTable,
|
|
42
43
|
WFormControlVue,
|
|
43
44
|
WScanBindingSensor,
|
|
44
|
-
WUpdateVersion
|
|
45
|
+
WUpdateVersion,
|
|
46
|
+
WTree
|
|
45
47
|
]
|
|
46
48
|
// 批量组件注册
|
|
47
49
|
function install(Vue: App) {
|
package/package.json
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import request from '../http.js'
|
|
2
|
+
// 树列表页面详细配置
|
|
3
|
+
export function treeConfigApi(sourceId: string) {
|
|
4
|
+
return request({
|
|
5
|
+
url: `/v3/ttmpl/config?sourceId=${sourceId}`,
|
|
6
|
+
})
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
//树数据
|
|
10
|
+
export function treeDataApi(sourceId: string) {
|
|
11
|
+
return request({
|
|
12
|
+
url: `/v3/ttmpl/root-data?sourceId=${sourceId}`,
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
//树节点数据
|
|
16
|
+
export function treeNodeDataApi(sourceId: string,mainCode?:string) {
|
|
17
|
+
return request({
|
|
18
|
+
url: `/v3/ltmpl/top-data?sourceId=${sourceId}&mainCode=${mainCode}`,
|
|
19
|
+
})
|
|
20
|
+
}
|
package/w-add/w-add.vue
CHANGED
|
@@ -87,17 +87,13 @@ const message = useMessage()
|
|
|
87
87
|
defineOptions({
|
|
88
88
|
name: 'w-add'
|
|
89
89
|
})
|
|
90
|
-
const props = defineProps({
|
|
91
|
-
sourceId: {
|
|
92
|
-
type: String,
|
|
93
|
-
default: ''
|
|
94
|
-
},
|
|
95
|
-
mainCode: {
|
|
96
|
-
type: String,
|
|
97
|
-
default: ''
|
|
98
|
-
},
|
|
99
90
|
|
|
100
|
-
|
|
91
|
+
interface Props {
|
|
92
|
+
sourceId:string
|
|
93
|
+
mainCode?:string
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const props = defineProps<Props>()
|
|
101
97
|
const mainCode=ref('')
|
|
102
98
|
const sourceId = ref('')
|
|
103
99
|
const pageConf = ref({ groups: [] })
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<wd-col-picker label="选择地址" v-model="value" :columns="columns" :column-change="columnChange" :display-format="displayFormat"
|
|
3
|
+
@confirm="handleConfirm"></wd-col-picker>
|
|
4
|
+
</template>
|
|
5
|
+
|
|
6
|
+
<script setup lang="ts">
|
|
7
|
+
import { ref, reactive, defineOptions, onMounted,defineProps } from 'vue'
|
|
8
|
+
import { treeConfigApi, treeDataApi,treeNodeDataApi } from '../utils/apis/tree'
|
|
9
|
+
import { pageConfig } from '../utils/apis/pageConfig'
|
|
10
|
+
defineOptions({
|
|
11
|
+
name: 'WTree',
|
|
12
|
+
})
|
|
13
|
+
const value = ref<string[]>([])
|
|
14
|
+
const sourceId = ref('')
|
|
15
|
+
const columns = ref<any[]>([])
|
|
16
|
+
const treeConfigs = reactive({
|
|
17
|
+
branchRatmplId: "",
|
|
18
|
+
branchTitle: "",
|
|
19
|
+
id: "",
|
|
20
|
+
rootGtmplId: '',
|
|
21
|
+
primaryColumnId: ""
|
|
22
|
+
})
|
|
23
|
+
// 定义 props 类型
|
|
24
|
+
interface Props {
|
|
25
|
+
sourceId: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const props=defineProps<Props>()
|
|
29
|
+
onMounted(() => {
|
|
30
|
+
sourceId.value=props.sourceId
|
|
31
|
+
treeConfig1()
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
//获取配置1
|
|
35
|
+
const treeConfig1 = async () => {
|
|
36
|
+
try {
|
|
37
|
+
const res = await treeConfigApi(sourceId.value)
|
|
38
|
+
treeConfigs.branchRatmplId = res.data.ttmplConfig.branchRatmplId
|
|
39
|
+
treeConfigs.branchTitle = res.data.ttmplConfig.branchTitle
|
|
40
|
+
treeConfigs.id = res.data.ttmplConfig.id
|
|
41
|
+
treeConfigs.rootGtmplId = res.data.ttmplConfig.rootGtmplId
|
|
42
|
+
treeConfig2(treeConfigs.branchRatmplId)
|
|
43
|
+
} catch (error) {
|
|
44
|
+
//TODO handle the exception
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//获取配置2
|
|
49
|
+
const treeConfig2 = async (sourceId : string) => {
|
|
50
|
+
try {
|
|
51
|
+
const res = await pageConfig(sourceId)
|
|
52
|
+
treeConfigs.primaryColumnId = res.data.ltmplConfig.primaryColumn.sourceId
|
|
53
|
+
getTreeData(treeConfigs.branchRatmplId)
|
|
54
|
+
} catch (error) {
|
|
55
|
+
//TODO handle the exception
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//获取数据
|
|
60
|
+
const getTreeData = async (sourceId : string) => {
|
|
61
|
+
try {
|
|
62
|
+
const res = await treeDataApi(sourceId)
|
|
63
|
+
|
|
64
|
+
columns.value = [res.data.entities.map((item : any) => {
|
|
65
|
+
return {
|
|
66
|
+
value: item.code,
|
|
67
|
+
label: item.fieldMap[treeConfigs.primaryColumnId]
|
|
68
|
+
}
|
|
69
|
+
})]
|
|
70
|
+
} catch (error) {
|
|
71
|
+
//TODO handle the exception
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const columnChange = async ({ selectedItem, resolve, finish }) => {
|
|
76
|
+
try {
|
|
77
|
+
const res = await treeNodeDataApi(treeConfigs.branchRatmplId, selectedItem.value)
|
|
78
|
+
if(res.data.entities&&res.data.entities.length){
|
|
79
|
+
resolve(
|
|
80
|
+
res.data.entities.map((item : any) => {
|
|
81
|
+
return {
|
|
82
|
+
value: item.code,
|
|
83
|
+
label: item.fieldMap[treeConfigs.primaryColumnId]
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
)
|
|
87
|
+
}else{
|
|
88
|
+
finish()
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
} catch (error) {
|
|
92
|
+
finish(false)
|
|
93
|
+
//TODO handle the exception
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function handleConfirm({ value }) {
|
|
99
|
+
console.log(value)
|
|
100
|
+
}
|
|
101
|
+
// 格式化方法
|
|
102
|
+
const displayFormat = (selectedItems: Record<string, any>[]) => {
|
|
103
|
+
return selectedItems[selectedItems.length - 2].label + '/' + selectedItems[selectedItems.length - 1].label
|
|
104
|
+
}
|
|
105
|
+
</script>
|
|
106
|
+
|
|
107
|
+
<style>
|
|
108
|
+
</style>
|