Ben Lin
2024-05-29 c89adfd5c5df23b6b102766092867adc2330ebb7
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
<template>
  <div>
    <BasicTable @register="registerTable">
      <template #toolbar>
        <a-button color="primary" @click="addWo" preIcon="add_02|svg"> 新增 </a-button>
        <a-button ghost color="success" @click="ExcelToDb" preIcon="excel-import|svg">
          导入
        </a-button>
      </template>
      <template #form-add="{ field }">
        <a-button
          v-if="field"
          class="mt-1 ml-1"
          size="small"
          @click="handleSelectItem"
          preIcon="search|svg"
        />
        <ItemModal @register="registerItemAdd" @success="handleItemSuccess" />
      </template>
      <template #action="{ record }">
        <TableAction
          :actions="[
            {
              icon: 'clarity:note-edit-line',
              tooltip: '修改',
              onClick: handleEdit.bind(null, record),
            },
            {
              icon: 'ant-design:delete-outlined',
              color: 'error',
              tooltip: '删除',
              popConfirm: {
                title: '是否确认删除?',
                placement: 'left',
                confirm: handleDelete.bind(null, record),
              },
            },
            {
              icon: 'config|svg',
              tooltip: '配置工艺',
              onClick: handleConfig.bind(null, record),
            },
            {
              icon: 'release|svg',
              tooltip: '下发',
              onClick: handleRelease.bind(null, record),
            },
            {
              icon: 'unrelease|svg',
              tooltip: '取消下发',
              onClick: handleUnRelease.bind(null, record),
            },
            {
              icon: 'suspend-blue|svg',
              tooltip: '暂停',
              onClick: handlePause.bind(null, record),
            },
          ]"
        />
      </template>
    </BasicTable>
    <Loading :loading="compState.loading" :tip="compState.tip" />
    <!-- <WmsItemDrawer @register="registerDrawer" @success="handleSuccess" /> -->
    <WoDrawer @register="registerDrawer" @success="handleSuccess" />
    <WoModal @register="registerWo" @success="handleSuccess" />
  </div>
</template>
<script lang="ts" setup>
  import { reactive, unref, h, onMounted } from 'vue';
  import { BasicTable, useTable, TableAction } from '/@/components/Table';
  import WoDrawer from './WoDrawer.vue';
  import WoModal from './WoModal.vue';
  import ItemModal from '/@/views/components/ItemModal.vue';
  import { useDrawer } from '/@/components/Drawer';
  import { columns, searchFormSchema } from './biz_mes_wo.data';
  import { DeleteMesWo } from '/@/api/tigerapi/mes/wo';
  import { Loading } from '/@/components/Loading';
  import { useMessage } from '/@/hooks/web/useMessage';
  import { useI18n } from '/@/hooks/web/useI18n';
  import { useModal } from '/@/components/Modal';
  import { getListByPage } from '/@/api/tigerapi/system';
 
  const { t } = useI18n();
  const { createMessage } = useMessage();
  const [registerDrawer, { openDrawer }] = useDrawer();
  const compState = reactive({
    absolute: false,
    loading: false,
    tip: '加载中...',
  });
  const [registerWo, { openModal: openWoModal }] = useModal();
  const [registerItemAdd, { openModal: openItemModal }] = useModal();
  const [registerTable, { getForm, reload }] = useTable({
    title: '工单信息',
    api: getListByPage,
    columns,
    formConfig: {
      labelWidth: 120,
      schemas: searchFormSchema,
    },
    actionColumn: {
      width: 220,
      title: '操作',
      dataIndex: 'action',
      slots: { customRender: 'action' },
      fixed: 'right', //undefined,
    },
    ellipsis: true,
    useSearchForm: true,
    showTableSetting: true,
    bordered: true,
    showIndexColumn: false,
  });
 
  onMounted(() => {});
 
  //新增
  function addWo() {
    openDrawer(true, {
      isUpdate: false,
    });
  }
  //编辑
  function handleEdit(record: any) {
    openDrawer(true, {
      isUpdate: true,
      record,
    });
  }
  function handleSuccess() {
    reload();
  }
  //导入
  function ExcelToDb() {
    openWoModal(true, {
      data: 'content',
      info: 'Info',
    });
  }
  //配置工艺
  function handleConfig(record: Recordable) {
    // const apiAction = SaveTool(record, unref(true), true);
    // apiAction.then((action) => {
    //   if (action.IsSuccessed) {
    //     createMessage.success(t('已报废'));
    //     reload();
    //   } else {
    //     createMessage.success(t('报废操作失败'));
    //   }
    // });
  }
  //下发
  function handleRelease(record: Recordable) {}
  //取消下发
  function handleUnRelease(record: Recordable) {}
  //暂停
  function handlePause(record: Recordable) {}
  //删除
  function handleDelete(record: Recordable) {
    const apiAction = DeleteMesWo(record.ID);
    apiAction.then((action) => {
      if (action.IsSuccessed) {
        createMessage.success(t('已删除'));
        reload();
      } else {
        createMessage.success(t('删除操作失败'));
      }
    });
  }
  //点击打开物料列表框
  function handleSelectItem() {
    openItemModal(true, {
      data: 'content',
      info: 'Info',
    });
  }
 
  function handleItemSuccess(d, u) {
    getForm().setFieldsValue({
      ITEM_CODE: d.values.values,
    });
  }
</script>