Ben Lin
2024-06-25 f73947395184fd635df3d74c1c4b2701d0c708c1
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
import { BasicColumn, FormSchema } from '/@/components/Table';
import { h } from 'vue';
import { Switch } from 'ant-design-vue';
import { SaveWh } from '/@/api/tigerapi/wms/warehouse';
import { useMessage } from '/@/hooks/web/useMessage';
 
import { useUserStore } from '/@/store/modules/user';
 
export const columns: BasicColumn[] = [
  {
    title: '仓库名称',
    resizable: true,
    sorter: true,
    dataIndex: 'WH_NAME',
    width: 200,
  },
  {
    title: '仓库值',
    resizable: true,
    sorter: true,
    dataIndex: 'WH_CODE',
    width: 180,
  },
  {
    title: '接料重扫',
    dataIndex: 'SCAN_AF_CUT',
    width: 120,
    customRender: ({ record }) => {
      if (!Reflect.has(record, 'pendingStatus1')) {
        record.pendingStatus1 = false;
      }
      const id = 'd70918d6fe474b96b6dabba5c8679c30';
      const roles = useUserStore().getUserInfo.roles;
      const is_active = roles.some((item) => item.MENU_CODE === id);
      return h(Switch, {
        checked: record.IS_ACTIVE === 'Y',
        checkedChildren: '已启用',
        unCheckedChildren: '已禁用',
 
        disabled: !is_active,
        loading: record.pendingStatus1,
        onChange(checked: boolean) {
          const oldStatus = record.IS_ACTIVE;
          record.pendingStatus1 = true;
          const newStatus = checked ? 'Y' : 'N';
          console.log(10, newStatus);
          const { createMessage } = useMessage();
          record.IS_ACTIVE = newStatus;
          SaveWh(record, true)
            .then(() => {
              createMessage.success(`是否启用已成功修改`);
            })
            .catch(() => {
              createMessage.error('修改失败');
              record.IS_ACTIVE = oldStatus;
            })
            .finally(() => {
              record.pendingStatus1 = false;
            });
        },
      });
    },
  },
  {
    title: '创建时间',
    resizable: true,
    sorter: true,
    dataIndex: 'CREATE_TIME',
    width: 180,
  },
  {
    title: '备注',
    resizable: true,
    sorter: true,
    dataIndex: 'REMARK',
  },
];
 
export const searchFormSchema: FormSchema[] = [
  {
    field: 'WH_NAME',
    label: '仓库称',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    field: 'WH_CODE',
    label: '仓库值',
    component: 'Input',
    colProps: { span: 8 },
  },
];
 
export const formSchema: FormSchema[] = [
  {
    field: 'WH_NAME',
    label: '仓库名称',
    required: true,
    component: 'Input',
  },
  {
    field: 'WH_CODE',
    label: '仓库值',
    required: true,
    component: 'Input',
  },
  {
    field: 'ID',
    label: '仓库ID',
    component: 'Input',
    show: false,
  },
];