Ben Lin
2025-03-18 f3122a551bf69f6aed1467a6acc24805e6b469eb
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
<template>
  <PageWrapper :title="bt('销售出库单的资料', [BILLCODE])" :content="bt('这是销售出库单详情页面。')" contentBackground @back="goBack">
    <template #footer>
      <a-tabs default-active-key="detail" v-model:activeKey="currentKey" @tabClick="tabClkcallback">
        <a-tab-pane key="detail" :tab="bt('单据详情')" />
        <a-tab-pane key="detailsn" :tab="bt('条码详情')" />
      </a-tabs>
    </template>
    <div>
      <div v-if="currentKey == 'detail'">
        <BasicTable @register="detailTable">
          <template #toolbar>
            <a-button preIcon="OutR|svg" ghost color="success" @click="aoaToExceldtl"> 导出 </a-button>
          </template>
          <template #action="{ record }">
            <TableAction :actions="[
              {
                icon: 'clarity:info-standard-line',
                tooltip: bt('查看单据详情'),
                onClick: JumpSnDetail.bind(null, record),
              },
            ]" />
          </template>
        </BasicTable>
      </div>
      <div v-if="currentKey == 'detailsn'">
        <BasicTable @register="detailsnTable">
          <template #toolbar>
            <a-button preIcon="OutR|svg" ghost color="success" @click="aoaToExcelsn"> 导出 </a-button>
          </template>
        </BasicTable>
      </div>
    </div>
    <Loading :loading="compState.loading" :tip="compState.tip" />
  </PageWrapper>
</template>
 
<script lang="ts" setup>
import { aoaToSheetXlsx } from '/@/components/Excel';
import { ref, reactive } from 'vue';
import { useRoute } from 'vue-router';
import { PageWrapper } from '/@/components/Page';
import { useTabs } from '/@/hooks/web/useTabs';
import { Tabs } from 'ant-design-vue';
import { Loading } from '/@/components/Loading';
import { useMessage } from '/@/hooks/web/useMessage';
import { useGo } from '/@/hooks/web/usePage';
//详情列表
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import {
  getSaleoutorderDetailListByPage,
  getSaleoutorderDetailSNListByPage,
} from '/@/api/tigerapi/wms/saleoutorder';
import { columns_D, columns_S, searchFormSchema_D, searchFormSchema_S } from './saleoutorder.data';
import { useI18n } from '/@/hooks/web/useI18n';
 
const { t: bt } = useI18n();
//ATabs: Tabs, ATabPane: Tabs.TabPane
const compState = reactive({
  absolute: false,
  loading: false,
  tip: '加载中...',
});
const { createMessage } = useMessage();
const ATabs = ref(Tabs);
const ATabPane = ref(Tabs.TabPane);
const route = useRoute();
var ITEM_CODE = ref('');
const go = useGo();
//获取JobId
const BILLCODE = ref(route.params?.BillCode);
const [detailTable, { getForm: DataDtl, getPaginationRef: DataPDtl }] = useTable({
  title: bt('单据详情列表'),
  api: getSaleoutorderDetailListByPage,
  columns: columns_D,
  useSearchForm: true,
  showTableSetting: true,
  bordered: true,
  canResize: true,
  showIndexColumn: false,
  formConfig: {
    labelWidth: 120,
    schemas: searchFormSchema_D,
  },
  actionColumn: {
    width: 80,
    title: bt('操作'),
    dataIndex: 'action',
    slots: { customRender: 'action' },
    fixed: 'right', //undefined,
  },
  searchInfo: { BILLCODE },
});
const [detailsnTable, { getForm: DataSn, getPaginationRef: DataPSn }] = useTable({
  title: bt('条码详情列表'),
  api: getSaleoutorderDetailSNListByPage,
  columns: columns_S,
  formConfig: {
    labelWidth: 120,
    schemas: searchFormSchema_S,
    model: { ITEM_CODE: ITEM_CODE },
  },
  useSearchForm: true,
  searchInfo: { BILLCODE },
  showTableSetting: false,
  bordered: true,
  canResize: true,
  showIndexColumn: false,
});
 
let arrdtl: any[] = [];
let arrsn: any[] = [];
function aoaToExceldtl() {
  const totals = DataPDtl().total
  if (totals < 30000) {
    arrdtl = [];
    compState.loading = true;
    const col = DataDtl().getFieldsValue()
    col.BILLCODE = BILLCODE.value
    getSaleoutorderDetailListByPage(col).then((data) => {
      data.items.forEach(element => {
        let start = ''
        switch (element.LINESTATUS) {
          case 0:
            start = bt('新增');
            break;
          case 1:
            start = bt('作业中');
            break;
          case 2:
            start = bt('完成');
            break;
          default:
            break;
        }
        arrdtl.push({
          '序号': element.BILLLINE,
          '物料名称': element.ITEM_NAME,
          '物料编码': element.ITEM_CODE,
          '操作时间': element.CREATE_TIME,
          '状态': start,
          '仓库名称': element.WAREHOUSECODE,
          '需求数量': element.PRQTY,
          '已发数量': element.QTY,
          '欠发数量': element.OWE_QTY,
        });
      });
      const arrHeader = columns_D.slice(3).map((column) => column.title);
      const arrData = arrdtl.map((item) => {
        return Object.keys(item).map((key) => item[key]);
      });
      // 保证data顺序与header一致
 
      if (arrdtl.length < 30000) {
        aoaToSheetXlsx({
          data: arrData,
          header: arrHeader,
          filename: '销售出库单明细.xlsx',
        });
      } else {
        createMessage.error(bt('导出数据不能超过三万条,如需要更多的请联系管理员'));
      }
    })
  }else{
    createMessage.error(bt('导出数据不能超过三万条,如需要更多的请联系管理员'));
  }
  compState.loading=false;
}
 
function aoaToExcelsn() {
  const totals = DataPSn().total
  if (totals < 30000) {
    arrsn = [];
    compState.loading = true;
    const col = DataSn().getFieldsValue()
    col.BILLCODE = BILLCODE.value
    getSaleoutorderDetailSNListByPage(col).then((data) => {
      data.items.forEach(element => {
        let start = ''
        switch (element.STATUS) {
          case 0:
            start = bt('不存在');
            break;
          case 10:
            start = bt('送货中');
            break;
          case 20:
            start = bt('待检验');
            break;
          case 30:
            start = bt('待入库');
            break;
          case 40:
            start = bt('在库中');
            break;
          case 50:
            start = bt('已下架');
            break;
          case 60:
            start = bt('已发料');
            break;
          case 70:
            start = bt('已上料');
            break;
          case 80:
            start = bt('已耗尽');
            break;
          case 90:
            start = bt('已退料');
            break;
          case 100:
            start = bt('已发货');
            break;
          default:
            break;
        }
        arrsn.push({
          '条码': element.SN,
          '修改时间':element.UPDATE_TIME,
          '状态': start,
          '物料编码': element.ITEM_CODE,
          '库存数量': element.QTY,
          '发料数量': element.ALLOC_QTY,
        });
      });
      const arrHeader = columns_S.map((column) => column.title);
      const arrData = arrsn.map((item) => {
        return Object.keys(item).map((key) => item[key]);
      });
      // 保证data顺序与header一致
 
      if (arrdtl.length < 30000) {
        aoaToSheetXlsx({
          data: arrData,
          header: arrHeader,
          filename: '销售出库条码明细.xlsx',
        });
      } else {
        createMessage.error(bt('导出数据不能超过三万条,如需要更多的请联系管理员'));
      }
      compState.loading=false;
    })
  }
}
 
// 此处可以得到用户ID
//const BILLCODE = ref(route.params?.BILLCODE.split(',')[1]);
var currentKey = ref('detail');
const { setTitle } = useTabs();
// TODO
// 本页代码仅作演示,实际应当通过userId从接口获得用户的相关资料
 
// 设置Tab的标题(不会影响页面标题)
setTitle(bt('详情:单据') + BILLCODE.value);
 
// 页面左侧点击返回链接时的操作
function goBack() {
  // 本例的效果时点击返回始终跳转到账号列表页,实际应用时可返回上一页
  go('/saleoutorder');
}
const tabClkcallback = (val: string) => {
  if (val == 'detail') {
    ITEM_CODE.value = '';
  }
};
function JumpSnDetail(record: Recordable) {
  currentKey.value = 'detailsn';
  ITEM_CODE.value = record.ITEM_CODE;
}
</script>