liu
3 天以前 f11bd0d8d9c1190340a445a67df9e43cdbde0a3e
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
<script lang="ts" setup>
import { computed, ref } from 'vue';
 
import { useVbenModal } from '@vben/common-ui';
 
import { Table } from 'ant-design-vue';
 
import { getProcessListByParam } from '#/api/mes/pro/processdesign/processparam';
 
const emit = defineEmits(['success']);
 
const paramId = ref<number>();
const paramName = ref<string>('');
const loading = ref(false);
const processList = ref<{ id: number; code?: string; name?: string; attention?: string }[]>([]);
 
const getTitle = computed(() => `关联工序 - ${paramName.value || ''}`);
 
async function loadData() {
  if (!paramId.value) {
    return;
  }
  loading.value = true;
  try {
    processList.value = await getProcessListByParam(paramId.value);
  } finally {
    loading.value = false;
  }
}
 
const [Modal, modalApi] = useVbenModal({
  async onConfirm() {
    await modalApi.close();
  },
  async onOpenChange(isOpen: boolean) {
    if (!isOpen) {
      paramId.value = undefined;
      processList.value = [];
      return;
    }
    const data = modalApi.getData<{ paramId: number; paramName?: string }>();
    paramId.value = data.paramId;
    paramName.value = data.paramName || '';
    await loadData();
  },
});
 
const columns = [
  { title: '工序编码', dataIndex: 'code', key: 'code' },
  { title: '工序名称', dataIndex: 'name', key: 'name' },
  { title: '工艺要求', dataIndex: 'attention', key: 'attention' },
];
</script>
 
<template>
  <Modal :title="getTitle" class="w-2/5">
    <Table
      :columns="columns"
      :data-source="processList"
      :loading="loading"
      :pagination="false"
      row-key="id"
      size="small"
    >
      <template #emptyText>
        {{ loading ? '加载中…' : '该参数暂未被任何工序绑定' }}
      </template>
    </Table>
  </Modal>
</template>