ny
22 小时以前 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
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
<script lang="ts" setup>
import type { ActionItem, BasicColumn } from '@jnpf/ui/vxeTable';
 
import { ref } from 'vue';
 
import { useMessage } from '@jnpf/hooks';
import { usePopup } from '@jnpf/ui/popup';
import { BasicVxeTable, TableAction, useVxeTable } from '@jnpf/ui/vxeTable';
 
import dayjs from 'dayjs';
import { Grid as VxeGrid } from 'vxe-table';
 
import { delOrder, getOrderEntryList, getOrderList, getOrderPlanList } from '#/api/extend/order';
import { useFlowState } from '#/hooks/flow/useFlowStatus';
import { $t } from '#/locales';
import FlowParser from '#/views/workFlow/components/FlowParser.vue';
 
defineOptions({ name: 'ExtendOrder' });
 
const flowId = ref<string>('585361795057715206');
const { createMessage } = useMessage();
const { getFlowStatusContent, getFlowStatusColor } = useFlowState();
const [registerFlowParser, { openPopup: openFlowParser }] = usePopup();
const columns: BasicColumn[] = [
  { title: '订单编码', dataIndex: 'orderCode', width: 150 },
  { title: '订单日期', dataIndex: 'orderDate', width: 150, format: 'date|YYYY-MM-DD HH:mm:ss' },
  { title: '客户名称', dataIndex: 'customerName', width: 200 },
  { title: '业务人员', dataIndex: 'salesmanName', width: 120 },
  { title: '付款金额', dataIndex: 'receivableMoney', width: 100 },
  { title: '制单人员', dataIndex: 'creatorUser', width: 120 },
  { title: '订单备注', dataIndex: 'description' },
  { title: '状态', dataIndex: 'currentState', width: 120, align: 'center', slots: { default: 'currentState' } },
];
const goodsColumns: BasicColumn[] = [
  { title: '序号', width: 50, align: 'center', type: 'seq' },
  { title: '商品名称', field: 'goodsName' },
  { title: '规格型号', field: 'specifications', width: 80 },
  { title: '单位', field: 'unit', width: 80 },
  { title: '数量', field: 'qty', width: 80 },
  { title: '单价', field: 'price', width: 80 },
  { title: '金额', field: 'amount', width: 80 },
  { title: '折扣%', field: 'discount', width: 80 },
  { title: '税率%', field: 'cess', width: 80 },
  { title: '实际单价', field: 'actualPrice', width: 80 },
  { title: '实际金额', field: 'actualAmount', width: 80 },
];
const planColumns: BasicColumn[] = [
  { title: '序号', width: 50, align: 'center', type: 'seq' },
  { title: '收款日期', field: 'receivableDate', width: 150, format: 'date|YYYY-MM-DD HH:mm:ss' },
  { title: '收款比率%', field: 'receivableRate', width: 100 },
  { title: '收款金额', field: 'receivableMoney', width: 100 },
  { title: '收款方式', field: 'receivableMode', width: 100 },
  { title: '收款摘要', field: 'abstract' },
];
const searchInfo = {
  flowId: flowId.value,
};
const [registerTable, { reload }] = useVxeTable({
  api: getOrderList,
  columns,
  searchInfo,
  useSearchForm: true,
  formConfig: {
    schemas: [
      {
        field: 'keyword',
        label: $t('common.keyword'),
        component: 'Input',
        componentProps: { placeholder: $t('common.enterKeyword'), submitOnPressEnter: true },
      },
      {
        field: 'pickerVal',
        label: '订单日期',
        component: 'DateRange',
        componentProps: {
          format: 'YYYY-MM-DD HH:mm:ss',
          showTime: { defaultValue: [dayjs('00:00:00', 'HH:mm:ss'), dayjs('23:59:59', 'HH:mm:ss')] },
          placeholder: ['开始时间', '结束时间'],
        },
      },
    ],
    fieldMapToTime: [['pickerVal', ['startTime', 'endTime']]],
  },
  actionColumn: {
    width: 150,
    title: '操作',
    dataIndex: 'action',
  },
  showExpandColumn: true,
  expandConfig: {
    lazy: true,
    loadMethod({ row }) {
      return new Promise((resolve) => {
        if (row.goodsList?.length || row.planList?.length) return;
        row.childTableLoading = true;
        getOrderEntryList(row.id)
          .then((res) => {
            row.childTableLoading = false;
            row.goodsList = res.data.list;
            resolve(row);
          })
          .catch(() => {
            row.childTableLoading = false;
          });
        getOrderPlanList(row.id).then((res) => {
          row.planList = res.data.list;
          resolve(row);
        });
      });
    },
  },
});
 
function getTableActions(record): ActionItem[] {
  return [
    {
      label: $t('common.editText'),
      disabled: ![0, 8, 9].includes(record.currentState),
      onClick: toDetail.bind(null, record, '-1'),
    },
    {
      label: $t('common.delText'),
      color: 'error',
      disabled: ![0, 9].includes(record.currentState),
      modelConfirm: {
        onOk: handleDelete.bind(null, record.id),
      },
    },
    {
      label: $t('common.detailText'),
      disabled: !record.currentState,
      onClick: toDetail.bind(null, record, 0),
    },
  ];
}
function handleDelete(id) {
  delOrder(id).then((res) => {
    createMessage.success(res.msg);
    reload();
  });
}
function toDetail(record, opType) {
  const data = {
    id: record.flowTaskId || record.id,
    flowId: flowId.value,
    opType,
  };
  openFlowParser(true, data);
}
function handleAdd() {
  const data = {
    id: '',
    flowId: flowId.value,
    opType: '-1',
  };
  openFlowParser(true, data);
}
function goodsFooterMethod({ columns, data }) {
  return [
    columns.map((column, columnIndex) => {
      if (columnIndex === 0) return '合计';
      if ([1, 2].includes(columnIndex)) return '';
      let sumVal = data.reduce((sum, d) => sum + Number.parseFloat(d[column.property as any]), 0);
      sumVal = Number.isNaN(sumVal) ? '' : sumVal;
      sumVal = sumVal && !Number.isInteger(sumVal) ? sumVal.toFixed(2) : sumVal;
      return sumVal;
    }),
  ];
}
function planFooterMethod({ columns, data }) {
  return [
    columns.map((column, columnIndex) => {
      if (columnIndex === 0) return '合计';
      if ([1, 4, 5].includes(columnIndex)) return '';
      let sumVal = data.reduce((sum, d) => sum + Number.parseFloat(d[column.property as any]), 0);
      sumVal = Number.isNaN(sumVal) ? '' : sumVal;
      sumVal = sumVal && !Number.isInteger(sumVal) ? sumVal.toFixed(2) : sumVal;
      return sumVal;
    }),
  ];
}
</script>
 
<template>
  <div class="jnpf-content-wrapper">
    <div class="jnpf-content-wrapper-center">
      <div class="jnpf-content-wrapper-content">
        <BasicVxeTable @register="registerTable">
          <template #tableTitle>
            <a-button type="primary" pre-icon="icon-ym icon-ym-btn-add" @click="handleAdd()">{{ $t('common.addText') }}</a-button>
          </template>
          <template #expandedRowRender="{ record }">
            <a-tabs size="small" v-loading="record.childTableLoading">
              <a-tab-pane key="1" tab="订单商品">
                <VxeGrid :data="record.goodsList" :columns="goodsColumns" show-footer :footer-method="goodsFooterMethod" />
              </a-tab-pane>
              <a-tab-pane key="2" tab="收款计划">
                <VxeGrid :data="record.planList" :columns="planColumns" show-footer :footer-method="planFooterMethod" />
              </a-tab-pane>
            </a-tabs>
          </template>
          <template #currentState="{ record }">
            <JnpfTextTag :content="getFlowStatusContent(record.currentState)" :color="getFlowStatusColor(record.currentState)" />
          </template>
          <template #action="{ record }">
            <TableAction :actions="getTableActions(record)" />
          </template>
        </BasicVxeTable>
      </div>
    </div>
    <FlowParser @register="registerFlowParser" @reload="reload" />
  </div>
</template>