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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
| <template>
| <ElDialog
| title="选择站点"
| :model-value="visible"
| width="1080px"
| align-center
| destroy-on-close
| @update:model-value="handleVisibleChange"
| >
| <div class="space-y-4">
| <div
| class="rounded border border-[var(--art-border-color)] bg-[var(--art-main-bg-color)] px-4 py-3 text-sm"
| >
| 已选组托单 {{ selectedRows.length }} 条
| </div>
|
| <ArtSearchBar
| v-model="searchForm"
| :items="searchItems"
| @search="handleSearch"
| @reset="handleReset"
| />
|
| <ArtTableHeader v-model:columns="columnChecks" :loading="loading" @refresh="refreshData" />
|
| <ArtTable
| :loading="loading"
| :data="data"
| :columns="columnsWithButton"
| :pagination="pagination"
| @pagination:size-change="handleSizeChange"
| @pagination:current-change="handleCurrentChange"
| />
| </div>
| </ElDialog>
| </template>
|
| <script setup>
| import { computed, h, ref, watch } from 'vue'
| import { ElButton } from 'element-plus'
| import { useTable } from '@/hooks/core/useTable'
| import { fetchDeviceSitePage } from '@/api/device-site'
| import {
| buildWaitPakinSiteSearchParams,
| createWaitPakinSiteSearchState,
| normalizeWaitPakinSiteRow
| } from '../waitPakinPage.helpers'
|
| const props = defineProps({
| visible: { type: Boolean, default: false },
| selectedRows: { type: Array, default: () => [] }
| })
|
| const emit = defineEmits(['update:visible', 'select'])
|
| const searchForm = ref(createWaitPakinSiteSearchState())
|
| const searchItems = computed(() => [
| {
| label: '站点名称',
| key: 'name',
| type: 'input',
| props: {
| clearable: true,
| placeholder: '请输入站点名称'
| }
| },
| {
| label: '站点',
| key: 'site',
| type: 'input',
| props: {
| clearable: true,
| placeholder: '请输入站点'
| }
| },
| {
| label: '设备位',
| key: 'deviceSite',
| type: 'input',
| props: {
| clearable: true,
| placeholder: '请输入设备位'
| }
| }
| ])
|
| const {
| columns,
| columnChecks,
| data,
| loading,
| pagination,
| getData,
| replaceSearchParams,
| resetSearchParams,
| handleSizeChange,
| handleCurrentChange,
| refreshData
| } = useTable({
| core: {
| apiFn: fetchDeviceSitePage,
| apiParams: {
| current: 1,
| pageSize: 20,
| type: 1
| },
| paginationKey: {
| current: 'current',
| size: 'pageSize'
| },
| columnsFactory: () => [
| { type: 'globalIndex', label: '序号', width: 72, align: 'center' },
| { prop: 'name', label: '站点名称', minWidth: 140, showOverflowTooltip: true },
| { prop: 'site', label: '站点', minWidth: 120, showOverflowTooltip: true },
| { prop: 'deviceSite', label: '设备位', minWidth: 120, showOverflowTooltip: true },
| { prop: 'wcsCode', label: 'WCS编码', minWidth: 140, showOverflowTooltip: true },
| { prop: 'label', label: '标签', minWidth: 120, showOverflowTooltip: true },
| { prop: 'updateTimeText', label: '更新时间', minWidth: 170, showOverflowTooltip: true },
| {
| prop: 'operation',
| label: '操作',
| width: 110,
| align: 'center',
| formatter: (row) => ({
| label: '选择',
| type: 'primary',
| plain: true,
| onClick: () => emit('select', row)
| })
| }
| ]
| },
| transform: {
| dataTransformer: (records) => {
| if (!Array.isArray(records)) {
| return []
| }
| return records.map((item) => normalizeWaitPakinSiteRow(item))
| }
| }
| })
|
| const columnsWithButton = computed(() =>
| columns.value.map((column) => {
| if (column.prop !== 'operation') {
| return column
| }
| return {
| ...column,
| formatter: (row) => {
| const action = column.formatter(row)
| return h(
| ElButton,
| {
| type: action.type,
| plain: action.plain,
| onClick: action.onClick
| },
| () => action.label
| )
| }
| }
| })
| )
|
| function handleSearch(params) {
| replaceSearchParams(buildWaitPakinSiteSearchParams(params))
| getData()
| }
|
| function handleReset() {
| Object.assign(searchForm.value, createWaitPakinSiteSearchState())
| resetSearchParams()
| }
|
| function handleVisibleChange(value) {
| emit('update:visible', value)
| }
|
| watch(
| () => props.visible,
| (visible) => {
| if (visible) {
| getData()
| }
| }
| )
| </script>
|
|