Ben Lin
2024-06-20 de7e6c408b6209158b08991d729c4bcc72055eec
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
<template>
  <div>
    <BasicTable @register="registerTable">
      <template #action="{ record }">
        <TableAction
          :actions="[
            {
              icon: 'clarity:info-standard-line',
              tooltip: '查看单据详情',
              onClick: handleEdit.bind(null, record),
            },
            {
              ifShow:
                !isNullOrEmpty(record.ERP_BILL_CODE) && is_active && record.STATUS != 3
                  ? true
                  : false,
              icon: 'Posted|svg',
              color: 'success',
              tooltip: 'WMS过账',
              onClick: handlePost.bind(null, record),
            },
            {
              ifShow: isNullOrEmpty(record.ERP_BILL_CODE) ? false : true,
              icon: 'restoration|svg',
              tooltip: '状态回退',
              onClick: handleStatus.bind(null, record),
            },
          ]"
        />
      </template>
      <!-- <template #toolbar>
        <a-button type="primary" @click="handleCreate"> 新增到货单 </a-button>
      </template>
      <template #action="{ record }">
        <TableAction
          :actions="[
            {
              icon: 'clarity:note-edit-line',
              onClick: handleEdit.bind(null, record),
            },
            {
              icon: 'ant-design:delete-outlined',
              color: 'error',
              popConfirm: {
                title: '是否确认删除?',
                placement: 'left',
                confirm: handleDelete.bind(null, record),
              },
            },
          ]"
        />
      </template> -->
    </BasicTable>
    <!-- <FinishedwarehouseDrawer @register="registerDrawer" @success="handleSuccess" /> -->
    <ReqModal @register="register" @success="handleSuccess" />
  </div>
</template>
<script lang="ts">
  import { defineComponent } from 'vue';
 
  import { BasicTable, useTable, TableAction } from '/@/components/Table';
 
  //import { useDrawer } from '/@/components/Drawer';
 
  import { columns, searchFormSchema } from './finishedwarehouse.data';
  import {
    //DeleteEnterWarehouse,
    getFinishedwarehouseListByPage,
    getStatusRestored,
  } from '/@/api/tigerapi/wms/finishedwarehouse';
  import { isNullOrEmpty } from '/@/utils/is';
  import ReqModal from './ReqModal.vue';
  import { useUserStore } from '/@/store/modules/user';
  import { useGo } from '/@/hooks/web/usePage';
  import { useI18n } from '/@/hooks/web/useI18n';
  import { useModal } from '/@/components/Modal';
  import { useMessage } from '/@/hooks/web/useMessage';
 
  const { createMessage } = useMessage();
 
  export default defineComponent({
    name: 'WHManagement',
    components: { BasicTable, TableAction, ReqModal },
    setup() {
      const go = useGo();
      const { t: bt } = useI18n();
      const [register, { openModal: openModal }] = useModal();
      //const [registerDrawer, { openDrawer }] = useDrawer();
      const [registerTable, { reload }] = useTable({
        title: '完工入库单',
        api: getFinishedwarehouseListByPage,
        columns,
        formConfig: {
          labelWidth: 120,
          schemas: searchFormSchema,
        },
        useSearchForm: true,
        showTableSetting: true,
        bordered: true,
        canResize: true,
        showIndexColumn: false,
        actionColumn: {
          width: 120,
          title: '操作',
          dataIndex: 'action',
          slots: { customRender: 'action' },
          fixed: 'right',
        },
      });
 
      const id = '22bed366178f46299dffdf87ea2136a6';
      const roles = useUserStore().getUserInfo.roles;
      const is_active = roles.some((item) => item.MENU_CODE === id);
 
      // function handleCreate() {
      //   openDrawer(true, {
      //     isUpdate: false,
      //   });
      // }
 
      function handleEdit(record: Recordable) {
        go('/finishedwarehouseDetail/' + record.BILLCODE);
      }
 
      // function handleDelete(record: Recordable) {
      //   console.log(record);
      //   //删除工厂
      //   const apiAction = DeleteEnterWarehouse(record);
      //   apiAction.then((action) => {
      //     if (action.IsSuccessed) {
      //       reload();
      //     }
      //   });
      // }
      //
      //完工入库单T100过账,wms同步过账
      async function handlePost(record: Recordable) {
        //var res = await SaveProd(record)
        //createMessage.info(bt('已手工过账,wms同步过账'));
        openModal(true, {
          data: record,
          info: '',
        });
      }
      // 状态复原
      async function handleStatus(record: Recordable) {
        const apiAction = getStatusRestored(record.BILLCODE);
        apiAction.then((res) => {
          console.log('res', res);
          if (res.IsSuccessed) {
            createMessage.success('状态复原成功');
          } else {
            createMessage.error('状态复原失败');
          }
        });
      }
      function handleSuccess() {
        reload();
      }
 
      return {
        registerTable,
        handlePost,
        handleStatus,
        isNullOrEmpty,
        is_active,
        handleEdit,
        register,
        // handleDelete,
        handleSuccess,
      };
    },
  });
</script>