zs
2025-05-12 7baa0d978e41f395891753b208d805bc02edee38
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
import { computed, defineComponent, onMounted, reactive, ref } from 'vue'
import type { Ref } from 'vue'
import BaseTable from '@/components/Table/Table'
import styles from './WmsInOutStockOrder.module.scss'
import { useWmsInOutStockOrder } from '../../../Controllers/WmsInOutStockOrder'
import Search from '@/components/Search/Search'
import { columns } from './Config'
import TdButton from '@/components/TdButton/TdButton'
import { vPermission } from '@/libs/Permission/Permission'
import { getWmsEnumData } from '@/widgets/WmsInOutStockOrder/Models/Service/WmsInOutStockOrderDrawer'
import dayjs from 'dayjs'
import {
  ElInput,
  ElSelect,
  ElOption,
  ElDatePicker,
  ElForm,
  ElFormItem,
  ElDialog,
  ElTable,
  ElTableColumn,
  ElButton,
  ElMessage,
} from 'element-plus'
import { injectModel } from '@/libs/Provider/Provider'
 
interface RenderTableType {
  url?: string
  dataSource: Ref<any[]>
  isDrag?: boolean
  isChecked?: boolean
  isHidePagination?: boolean
  params?: Record<string, any>
  autoHeight?: boolean
}
 
export default defineComponent({
  name: 'WmsInOutStockOrder',
  directives: {
    permission: vPermission,
  },
  setup(props, ctx) {
    const {
      dataSource,
      contextMenu,
      tableRef,
      selection,
      onRowClick,
      onCheck,
      openDetail,
    } = useWmsInOutStockOrder(props, ctx)
 
    // 叫料弹窗相关状态
    const callMaterialDialog = reactive({
      visible: false,
      title: '叫料',
      selectedItems: [] as any[],
    })
 
    // 打开叫料弹窗
    const openCallMaterialDialog = () => {
      if (selection.value.length === 0) {
        ElMessage.warning('请至少选择一条记录')
        return
      }
      callMaterialDialog.selectedItems = [...selection.value]
      console.log('选中的数据:', callMaterialDialog.selectedItems)
      callMaterialDialog.visible = true
    }
 
    // 确认叫料
    const confirmCallMaterial = () => {
      // 这里添加叫料逻辑
      console.log('叫料数据:', callMaterialDialog.selectedItems)
      ElMessage.success('叫料成功')
      callMaterialDialog.visible = false
    }
 
    /**
     * @returns 叫料弹窗
     */
    const RenderCallMaterialDialog = () => {
      return (
        <ElDialog
          v-model={callMaterialDialog.visible}
          title={callMaterialDialog.title}
          width="70%"
          v-slots={{
            footer: () => (
              <div class={styles.dialogFooter}>
                <ElButton onClick={() => (callMaterialDialog.visible = false)}>
                  取消
                </ElButton>
                <ElButton type="primary" onClick={confirmCallMaterial}>
                  确认叫料
                </ElButton>
              </div>
            ),
          }}
        >
          <ElTable data={callMaterialDialog.selectedItems} border>
            <ElTableColumn prop="orderNo" label="单据号" width="180" />
            <ElTableColumn prop="materialNo" label="物料编号" width="180" />
            <ElTableColumn prop="materialName" label="物料名称" />
            <ElTableColumn prop="materialModel" label="型号" />
            <ElTableColumn prop="placeNo" label="库位编号" />
            <ElTableColumn prop="quantity" label="数量" />
          </ElTable>
        </ElDialog>
      )
    }
 
    /**
     * @returns 表格
     */
    const RenderBaseTable = (props: RenderTableType) => {
      const {
        url,
        dataSource,
        isDrag,
        isChecked,
        isHidePagination,
        params,
        autoHeight,
      } = props
 
      return (
        <div
          class={{
            [styles.wmsInOutStockOrderList]: true,
          }}
        >
          <BaseTable
            ref={tableRef}
            url={url}
            v-model:dataSource={dataSource.value}
            columns={columns}
            contextMenu={contextMenu}
            params={params}
            isDrag={isDrag}
            isChecked={isChecked}
            autoHeight={autoHeight}
            onCheck={onCheck}
            onRowClick={onRowClick}
            isHidePagination={isHidePagination}
            pageSize={20}
            v-slots={{
              operateTime: ({ row }: any) => {
                return (
                  <div>
                    {row.operateTime != null
                      ? dayjs(row.operateTime).format('YYYY-MM-DD HH:mm:ss')
                      : '-'}
                  </div>
                )
              },
              creationTime: ({ row }: any) => {
                return (
                  <div>
                    {row.creationTime != null
                      ? dayjs(row.creationTime).format('YYYY-MM-DD HH:mm:ss')
                      : '-'}
                  </div>
                )
              },
              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.wmsInOutStockOrderContent}>
          {/* 叫料弹窗 */}
          <RenderCallMaterialDialog />
 
          {/* 操作按钮区域 */}
          <div class={styles.headerContent}>
            <div class={styles.header}>
              <ElButton
                v-permission="wmsInOutStockOrder-call"
                type="primary"
                onClick={openCallMaterialDialog}
              >
                叫料
              </ElButton>
            </div>
          </div>
 
          <RenderBaseTable
            dataSource={dataSource}
            isChecked={true}
            isDrag={true}
          />
        </div>
      )
    }
  },
})