zs
2025-05-05 6ecd5b23904d2e862dd572ab7feb1a85824fc9ad
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
import { defineComponent, reactive, ref, computed } from 'vue'
import type { Ref } from 'vue'
import BaseTable from '@/components/Table/Table'
import styles from './WmsStore.module.scss'
import { useWmsStore } from '../../../Controllers/WmsStore'
import IconButton from '@/components/IconButton/IconButton'
import WmsStoreDrawer from '../Dialog/WmsStoreDrawer/WmsStoreDrawer'
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 } from 'element-plus'
import { getWmsEnumData } 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: 'WmsStore',
  directives: {
    permission: vPermission,
  },
  setup(props, ctx) {
    const {
      dataSource,
      contextMenu,
      dialogConfig,
      tableRef,
      current,
      search,
      sort,
      headers,
      onError,
      onSearch,
      onRowClick,
      onConfirmWmsStore,
      onCheck,
      onAddWmsStore,
      onExport,
      openDetail,
      onSuccess,
      onBeforeUpload,
    } = useWmsStore(props, ctx)
 
    // 新增的查询条件
    const queryForm = ref({
      storeCode: '',
      storeName: '',
      filter: '',
    })
 
    const queryParams = computed(() => ({
      ...queryForm.value,
    }))
 
    // 新增的查询方法
    const handleQuery = async () => {
      console.log('查询条件:', queryParams.value)
      // tableRef.value.getTableList()
      tableRef.value.getList(queryParams.value)
    }
 
    // 重置查询条件
    const resetQuery = () => {
      queryForm.value = {
        storeCode: '',
        storeName: '',
        filter: '',
      }
    }
 
    /**
     * @returns 表格
     */
    const RenderBaseTable = (props: RenderTableType) => {
      const {
        url,
        dataSource,
        isDrag,
        isChecked,
        isHidePagination,
        params,
        autoHeight,
      } = props
 
      return (
        <div
          class={{
            [styles.wmsStoreList]: true,
          }}
        >
          <BaseTable
            ref={tableRef}
            url={url}
            sortUrlTpl="/api/v1/HIAWms/wmsStore/{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.wmsStoreContent}>
          {/* 添加/编辑 */}
          <WmsStoreDrawer
            v-model={dialogConfig.visible}
            title={dialogConfig.title}
            row={current.value}
            sort={sort.value}
            onConfirm={onConfirmWmsStore}
          />
 
          {/* 新增的查询表单 */}
          <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.storeCode}
                placeholder="请输入仓库编码"
                clearable
                class={styles.formItem}
              />
            </ElFormItem>
            <ElFormItem label="仓库名称">
              <ElInput
                v-model={queryForm.value.storeName}
                placeholder="请输入仓库名称"
                clearable
                class={styles.formItem}
              />
            </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="wmsStore-add"
                icon="add-p"
                onClick={onAddWmsStore}
                type="primary"
              >
                添加
              </IconButton>
              <el-divider direction="vertical" />
              <el-upload
                v-permission="wmsStore-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/wmsStore/import"
              >
                <IconButton icon="in">导入</IconButton>
              </el-upload>
 
              <IconButton
                v-permission="wmsStore-output"
                icon="out"
                onClick={onExport}
              >
                导出
              </IconButton>
            </div>
            {/* <Search
              placeholder="请输入关键字"
              v-model={search.value}
              onConfirm={onSearch}
              style={{ marginTop: '-1px' }}
            /> */}
          </div>
          <RenderBaseTable
            url="/api/v1/HIAWms/wmsStore"
            dataSource={dataSource}
            isChecked={true}
            isDrag={true}
          />
        </div>
      )
    }
  },
})