zs
2025-05-05 11bff3e93067768199bab9bfff37e8eae17d8d92
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
import { computed, defineComponent, onMounted, reactive, ref } from 'vue'
import type { Ref } from 'vue'
import BaseTable from '@/components/Table/Table'
import styles from './WmsArea.module.scss'
import { useWmsArea } from '../../../Controllers/WmsArea'
import IconButton from '@/components/IconButton/IconButton'
import WmsAreaDrawer from '../Dialog/WmsAreaDrawer/WmsAreaDrawer'
import Search from '@/components/Search/Search'
import { columns } from './Config'
import TdButton from '@/components/TdButton/TdButton'
import { vPermission } from '@/libs/Permission/Permission'
import { ElForm, ElFormItem, ElInput, ElOption, ElSelect } from 'element-plus'
import {
  getWmsEnumData,
  getStoreDataList,
} from '@/widgets/HIAWms/Models/Service/WmsMaterialDrawer'
 
interface RenderTableType {
  url?: string
  dataSource: Ref<any[]>
  isDrag?: boolean
  isChecked?: boolean
  isHidePagination?: boolean
  params?: Record<string, any>
  autoHeight?: boolean
}
 
export default defineComponent({
  name: 'WmsArea',
  directives: {
    permission: vPermission,
  },
  setup(props, ctx) {
    const {
      dataSource,
      contextMenu,
      dialogConfig,
      tableRef,
      current,
      search,
      sort,
      headers,
      onError,
      onSearch,
      onRowClick,
      onConfirmWmsArea,
      onCheck,
      onAddWmsArea,
      onExport,
      openDetail,
      onSuccess,
      onBeforeUpload,
    } = useWmsArea(props, ctx)
 
    // 新增的查询条件
    const queryForm = ref({
      areaNo: '',
      areaName: '',
      areaType: '',
      areaStatus: '',
      filter: '',
    })
 
    const queryParams = computed(() => ({
      ...queryForm.value,
      areaType: queryForm.value.areaType || '', // 处理下拉
      areaStatus: queryForm.value.areaStatus || '',
    }))
 
    // 动态枚举选项
    const enumOptions = reactive({
      areaType: [] as Array<{ label: string; value: any }>,
      areaStatus: [] as Array<{ label: string; value: any }>,
    })
 
    // 获取枚举数据
    const fetchEnumData = async () => {
      try {
        // 获取物料类型枚举
        const areaTypeData = await getWmsEnumData({
          EnumName: 'AreaTypeEnum',
        })
        enumOptions.areaType = areaTypeData.map((item) => ({
          label: item.description,
          value: item.value,
        }))
 
        // 获取采购类型枚举
        const areaStatusData = await getWmsEnumData({
          EnumName: 'AreaStatusEnum',
        })
        enumOptions.areaStatus = areaStatusData.map((item) => ({
          label: item.description,
          value: item.value,
        }))
      } catch (error) {
        console.error('获取枚举数据失败:', error)
      }
    }
 
    // 组件挂载时获取枚举数据
    onMounted(() => {
      fetchEnumData()
    })
 
    // 新增的查询方法
    const handleQuery = async () => {
      // tableRef.value.getTableList()
      tableRef.value.getList(queryParams.value)
    }
 
    // 重置查询条件
    const resetQuery = () => {
      queryForm.value = {
        areaNo: '',
        areaName: '',
        areaType: '',
        areaStatus: '',
        filter: '',
      }
    }
 
    /**
     * @returns 表格
     */
    const RenderBaseTable = (props: RenderTableType) => {
      const {
        url,
        dataSource,
        isDrag,
        isChecked,
        isHidePagination,
        params,
        autoHeight,
      } = props
 
      return (
        <div
          class={{
            [styles.wmsAreaList]: true,
          }}
        >
          <BaseTable
            ref={tableRef}
            url={url}
            sortUrlTpl="/api/v1/HIAWms/wmsArea/{id}/adjustsort/{sort}"
            v-model:dataSource={dataSource.value}
            columns={columns}
            contextMenu={contextMenu}
            params={params}
            isDrag={isDrag}
            isChecked={isChecked}
            autoHeight={autoHeight}
            onCheck={onCheck}
            onRowClick={onRowClick}
            isHidePagination={isHidePagination}
            pageSize={50}
            v-slots={{
              name: ({ row }: any) => {
                return row?.name ? (
                  <TdButton
                    onClick={() => openDetail(row)}
                    text={<span style="color:#5a84ff">详情</span>}
                    icon="scale"
                    tip={row?.name}
                    hover
                  >
                    {row?.name}
                  </TdButton>
                ) : (
                  '-'
                )
              },
            }}
          ></BaseTable>
        </div>
      )
    }
    return () => {
      return (
        <div class={styles.wmsAreaContent}>
          {/* 添加/编辑 */}
          <WmsAreaDrawer
            v-model={dialogConfig.visible}
            title={dialogConfig.title}
            row={current.value}
            sort={sort.value}
            onConfirm={onConfirmWmsArea}
          />
          {/* 新增的查询表单 */}
          <ElForm
            inline
            model={queryForm.value}
            class={styles.queryForm}
            label-width="80px"
          >
            <ElFormItem label="关键字">
              <ElInput
                v-model={queryForm.value.filter}
                placeholder="请输入关键字搜索"
                clearable
                class={styles.formItem}
              />
            </ElFormItem>
            <ElFormItem label="库区编码">
              <ElInput
                v-model={queryForm.value.areaNo}
                placeholder="请输入库区编码"
                clearable
                class={styles.formItem}
              />
            </ElFormItem>
            <ElFormItem label="库区名称">
              <ElInput
                v-model={queryForm.value.areaName}
                placeholder="请输入库区名称"
                clearable
                class={styles.formItem}
              />
            </ElFormItem>
            <ElFormItem label="库位类型">
              <ElSelect
                v-model={queryForm.value.areaType}
                placeholder="请选择托盘类型"
                clearable
                loading={enumOptions.areaType.length === 0}
                class={styles.formItem}
              >
                {enumOptions.areaType.map((option) => (
                  <ElOption
                    key={option.value}
                    label={option.label}
                    value={option.value}
                  />
                ))}
              </ElSelect>
            </ElFormItem>
            <ElFormItem label="库区状态">
              <ElSelect
                v-model={queryForm.value.areaStatus}
                placeholder="请选择托盘状态"
                clearable
                loading={enumOptions.areaStatus.length === 0}
                class={styles.formItem}
              >
                {enumOptions.areaStatus.map((option) => (
                  <ElOption
                    key={option.value}
                    label={option.label}
                    value={option.value}
                  />
                ))}
              </ElSelect>
            </ElFormItem>
            {/* <ElFormItem label="日期范围">
              <ElDatePicker
                v-model={queryForm.value.dateRange}
                type="daterange"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                value-format="YYYY-MM-DD"
              />
            </ElFormItem> */}
            <ElFormItem>
              <IconButton type="primary" icon="search" onClick={handleQuery}>
                查询
              </IconButton>
              <IconButton
                style="margin-left: 10px;"
                icon="refresh"
                onClick={resetQuery}
              >
                重置
              </IconButton>
            </ElFormItem>
          </ElForm>
 
          <div class={styles.headerContent}>
            <div class={styles.header}>
              <IconButton
                v-permission="wmsArea-add"
                icon="add-p"
                onClick={onAddWmsArea}
                type="primary"
              >
                添加
              </IconButton>
              <el-divider direction="vertical" />
              <el-upload
                v-permission="wmsArea-import"
                name="file"
                accept=".xlsx,.xls,.csv"
                show-file-list={false}
                onError={onError}
                onSuccess={onSuccess}
                before-upload={onBeforeUpload}
                headers={headers.value}
                action="/api/v1/HIAWms/wmsArea/import"
              >
                <IconButton icon="in">导入</IconButton>
              </el-upload>
 
              <IconButton
                v-permission="wmsArea-output"
                icon="out"
                onClick={onExport}
              >
                导出
              </IconButton>
            </div>
            {/* <Search
              placeholder="请输入关键字"
              v-model={search.value}
              onConfirm={onSearch}
              style={{ marginTop: '-1px' }}
            /> */}
          </div>
          <RenderBaseTable
            url="/api/v1/HIAWms/wmsArea"
            dataSource={dataSource}
            isChecked={true}
            isDrag={true}
          />
        </div>
      )
    }
  },
})