<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"
|
/>
|
<NormalModal @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" />
|
<WoDrawer @register="registerDrawer" @success="handleSuccess" />
|
<WoModal @register="registerWo" @success="handleSuccess" :title="title" :mtitle="mtitle" />
|
<CustModal
|
@register="registerCust"
|
@success="handleSuccess"
|
:type="cType"
|
:detailSlots="dtlSlots"
|
>
|
<template #[item.name] v-for="item in dtlSlots" :key="item.name">
|
<BasicForm
|
:schemas="formSchema"
|
:ref="item.name"
|
:labelWidth="100"
|
:showActionButtonGroup="false"
|
>
|
<template #[sitem]="{ field }" v-for="sitem in item.slots" :key="sitem">
|
<a-button
|
class="mt-1 ml-1"
|
size="small"
|
@click="handleCustClick(field)"
|
:preIcon="item.preIcons[sitem]"
|
/>
|
</template>
|
</BasicForm>
|
<NormalModal
|
@register="registerEntity"
|
@success="(d, u) => handleEntSuccess(d, u, item.name)"
|
/>
|
</template>
|
</CustModal>
|
<RouteViewModal @register="registerRv" @success="RvItemSuccess" />
|
</div>
|
</template>
|
<script lang="ts" setup>
|
import { reactive, unref, h, onMounted, ref, nextTick } from 'vue';
|
import { BasicTable, useTable, TableAction } from '/@/components/Table';
|
import { BasicForm, FormSchema, FormActionType, FormProps } from '/@/components/Form/index';
|
import WoDrawer from './WoDrawer.vue';
|
import WoModal from './WoModal.vue';
|
import NormalModal from '/@/views/components/NormalModal.vue';
|
import RouteViewModal from '/@/views/components/RouteViewModal.vue';
|
import CustModal from '/@/views/components/CustModal.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';
|
import { GetSelectSuccess, OpenSelectItem, getFormSchema } from '/@/views/components/data';
|
|
const { t } = useI18n();
|
const cType = ref('');
|
const title = ref('工单导入');
|
const ctitle = ref('工单下发配置');
|
const mtitle = ref('工单列表');
|
const dtlSlots = ref([] as any[]);
|
const selectVals = ref({});
|
const { createMessage } = useMessage();
|
const [registerDrawer, { openDrawer }] = useDrawer();
|
const compState = reactive({
|
absolute: false,
|
loading: false,
|
tip: '加载中...',
|
});
|
const [registerEntity, { openModal: openEntModal }] = useModal();
|
const [registerRv, { openModal: openRvModal }] = useModal();
|
const [registerWo, { openModal: openWoModal }] = useModal();
|
const [registerItemAdd, { openModal: openItemModal }] = useModal();
|
const [registerCust, { openModal: openCustModal, closeModal }] = 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,
|
});
|
const formSchema = ref([] as FormSchema[]);
|
const woinfo = ref<Nullable<FormActionType>>(null);
|
const forminfo = ref<Nullable<FormActionType>>(null);
|
const prodinfo = ref<Nullable<FormActionType>>(null);
|
|
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) {
|
cType.value = 'BIZ_MES_WO_Config';
|
dtlSlots.value = [
|
{ name: 'woinfo', slots: [], preIcons: {}, title: '工单信息' },
|
{ name: 'prodinfo', slots: [], preIcons: {}, title: '产品信息' },
|
];
|
formSchema.value = getFormSchema(cType.value);
|
openCustModal(true, {
|
isUpdate: true,
|
ctype: cType,
|
title: '工艺配置',
|
width: '1000px',
|
RowKey: '',
|
formEl: { woinfo: woinfo.value, prodinfo: prodinfo.value }, //如果是多个表单,增加多个插槽
|
// preIcons: { add: 'search|svg', set: 'config|svg' },
|
// slots: ['add', 'set'], //给弹出框增加插槽标签数组
|
...record,
|
});
|
}
|
//下发
|
function handleRelease(record: Recordable) {
|
cType.value = 'BIZ_MES_WO';
|
dtlSlots.value = [
|
{
|
name: 'forminfo',
|
slots: ['add', 'set'],
|
preIcons: { add: 'search|svg', set: 'config|svg' },
|
title: '下发配置',
|
},
|
]; //如果是多个表单,增加多个插槽。slots是弹出框按钮的插槽,preIcons是插槽对应的按钮图标
|
formSchema.value = getFormSchema(cType.value);
|
nextTick(() => {
|
setTimeout(() => {
|
openCustModal(true, {
|
isUpdate: true, //是否更新操作
|
ctype: cType, //是哪个页面
|
title: '工单下发', //标题
|
width: '900px', //弹出框宽度
|
formEl: { forminfo: forminfo.value },
|
formElName: 'forminfo',
|
RowKeys: { add: 'ROUTE_CODE', set: 'ROUTE_CODE' }, //插槽的弹出框选择的code
|
...record,
|
});
|
}, 100);
|
closeModal();
|
openCustModal(true, {});
|
});
|
}
|
//取消下发
|
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, {
|
title: '物料列表',
|
schemas: [
|
{
|
field: 'ITEM_CODE',
|
component: 'Input',
|
label: '物料编码',
|
colProps: {
|
span: 12,
|
},
|
},
|
],
|
ItemColumns: [
|
{
|
title: t('物料编码'),
|
dataIndex: 'ITEM_CODE',
|
resizable: true,
|
sorter: true,
|
width: 200,
|
},
|
{
|
title: t('物料名称'),
|
dataIndex: 'ITEM_NAME',
|
resizable: true,
|
sorter: true,
|
width: 180,
|
},
|
],
|
tableName: 'BAS_ITEM',
|
rowKey: 'ITEM_CODE',
|
});
|
}
|
|
function handleItemSuccess(d, u) {
|
getForm().setFieldsValue({
|
ITEM_CODE: d.values['val'],
|
});
|
}
|
/* 弹出选择框选择成功后事件 */
|
function handleEntSuccess(d, u, item) {
|
var values = GetSelectSuccess(d, u, cType.value);
|
selectVals.value = values; //保存弹出框选择的结果
|
let _val = {};
|
_val[d.returnFieldName] = values[d.returnFieldName];
|
if (item == 'forminfo') {
|
forminfo.value.setFieldsValue(_val);
|
}
|
if (item == 'prodinfo') {
|
prodinfo.value.setFieldsValue(_val);
|
}
|
if (item == 'woinfo') {
|
woinfo.value.setFieldsValue(_val);
|
}
|
}
|
|
/* 弹出选择框 */
|
function handleCustClick(item) {
|
// openRvModal(true, {});
|
OpenSelectItem(openEntModal, cType.value, item, [openRvModal], selectVals.value['ID']);
|
}
|
function RvItemSuccess(d, u) {}
|
</script>
|