Merge branch '20260519-3.9.2版本-葛昊天分支'
This commit is contained in:
@@ -9,11 +9,13 @@ enum Api {
|
||||
deleteBatch = '/mes/material/material/deleteBatch',
|
||||
importExcel = '/mes/material/material/importExcel',
|
||||
exportXls = '/mes/material/material/exportXls',
|
||||
queryById = '/mes/material/material/queryById',
|
||||
}
|
||||
|
||||
export const getExportUrl = Api.exportXls;
|
||||
export const getImportUrl = Api.importExcel;
|
||||
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||
export const queryById = (params) => defHttp.get({ url: Api.queryById, params }, { successMessageMode: 'none' });
|
||||
|
||||
export const deleteOne = (params, handleSuccess) =>
|
||||
defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => handleSuccess());
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
<template>
|
||||
<BasicModal v-bind="$attrs" title="选择胶料" :width="960" @register="registerModal" @ok="handleOk">
|
||||
<BasicTable @register="registerTable" />
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicTable, useTable } from '/@/components/Table';
|
||||
import { list as materialList, queryById as queryMaterialById } from '../MesMaterial.api';
|
||||
import { columns as materialColumns, searchFormSchema as materialSearch } from '../MesMaterial.data';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
const emit = defineEmits(['register', 'select']);
|
||||
const { createMessage } = useMessage();
|
||||
|
||||
const selectedRow = ref<Recordable | null>(null);
|
||||
|
||||
const [registerTable, { reload, getSelectRowKeys, getSelectRows, setSelectedRowKeys, clearSelectedRowKeys }] = useTable({
|
||||
api: materialList,
|
||||
columns: materialColumns.slice(0, 6),
|
||||
rowKey: 'id',
|
||||
useSearchForm: true,
|
||||
formConfig: {
|
||||
labelWidth: 90,
|
||||
schemas: materialSearch,
|
||||
},
|
||||
pagination: { pageSize: 10 },
|
||||
canResize: false,
|
||||
showIndexColumn: false,
|
||||
immediate: true,
|
||||
beforeFetch: (params) => ({
|
||||
...params,
|
||||
enableFlag: params.enableFlag ?? 1,
|
||||
}),
|
||||
rowSelection: {
|
||||
type: 'radio',
|
||||
columnWidth: 48,
|
||||
onChange: (_keys, rows) => {
|
||||
selectedRow.value = rows?.[0] ?? null;
|
||||
},
|
||||
},
|
||||
clickToRowSelect: true,
|
||||
});
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
selectedRow.value = null;
|
||||
clearSelectedRowKeys?.();
|
||||
setModalProps({ confirmLoading: false });
|
||||
const materialId = data?.materialId as string | undefined;
|
||||
if (materialId) {
|
||||
setSelectedRowKeys?.([materialId]);
|
||||
try {
|
||||
const raw = await queryMaterialById({ id: materialId });
|
||||
const row = (raw as Recordable)?.materialName != null ? raw : (raw as Recordable)?.result;
|
||||
if (row) {
|
||||
selectedRow.value = row;
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
reload();
|
||||
});
|
||||
|
||||
async function handleOk() {
|
||||
const keys = (getSelectRowKeys?.() || []) as string[];
|
||||
let row = selectedRow.value || ((getSelectRows?.() || []) as Recordable[])[0];
|
||||
if (!row && keys.length) {
|
||||
try {
|
||||
const raw = await queryMaterialById({ id: keys[0] });
|
||||
row = (raw as Recordable)?.materialName != null ? raw : (raw as Recordable)?.result;
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
if (!row?.id) {
|
||||
createMessage.warning('请选择一条胶料信息');
|
||||
return;
|
||||
}
|
||||
emit('select', {
|
||||
materialId: row.id,
|
||||
materialName: row.materialName || '',
|
||||
aliasName: row.aliasName || '',
|
||||
materialCode: row.materialCode || '',
|
||||
});
|
||||
closeModal();
|
||||
}
|
||||
</script>
|
||||
@@ -85,8 +85,12 @@
|
||||
emit('select', {
|
||||
mixerMaterialId: row.id,
|
||||
materialName: row.materialName || '',
|
||||
materialCode: row.materialCode || '',
|
||||
materialDesc: row.materialDesc || '',
|
||||
materialKind: buildKind(row),
|
||||
minorCategoryId: row.minorCategoryId || '',
|
||||
majorCategoryText: row.majorCategoryId_dictText || '',
|
||||
minorCategoryText: row.minorCategoryId_dictText || '',
|
||||
});
|
||||
closeModal();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { Modal } from 'ant-design-vue';
|
||||
|
||||
enum Api {
|
||||
list = '/xslmes/mesXslFormulaSpec/list',
|
||||
save = '/xslmes/mesXslFormulaSpec/add',
|
||||
edit = '/xslmes/mesXslFormulaSpec/edit',
|
||||
deleteOne = '/xslmes/mesXslFormulaSpec/delete',
|
||||
deleteBatch = '/xslmes/mesXslFormulaSpec/deleteBatch',
|
||||
importExcel = '/xslmes/mesXslFormulaSpec/importExcel',
|
||||
exportXls = '/xslmes/mesXslFormulaSpec/exportXls',
|
||||
queryById = '/xslmes/mesXslFormulaSpec/queryById',
|
||||
queryLineList = '/xslmes/mesXslFormulaSpec/queryLineListByMainId',
|
||||
generateRubberCode = '/xslmes/mesXslFormulaSpec/generateRubberCode',
|
||||
getRubberContentSetting = '/xslmes/mesXslFormulaSpec/getRubberContentSetting',
|
||||
saveRubberContentSetting = '/xslmes/mesXslFormulaSpec/saveRubberContentSetting',
|
||||
}
|
||||
|
||||
export const getExportUrl = Api.exportXls;
|
||||
export const getImportUrl = Api.importExcel;
|
||||
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||
export const queryById = (params) => defHttp.get({ url: Api.queryById, params });
|
||||
export const queryLineListByMainId = (params) => defHttp.get({ url: Api.queryLineList, params });
|
||||
export const generateRubberCode = (params) =>
|
||||
defHttp.get({ url: Api.generateRubberCode, params }, { successMessageMode: 'none' });
|
||||
export const getRubberContentSetting = () => defHttp.get({ url: Api.getRubberContentSetting });
|
||||
export const saveRubberContentSetting = (params) => defHttp.post({ url: Api.saveRubberContentSetting, params });
|
||||
|
||||
export const deleteOne = (params, handleSuccess) =>
|
||||
defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => handleSuccess());
|
||||
|
||||
export const batchDelete = (params, handleSuccess) => {
|
||||
Modal.confirm({
|
||||
title: '确认删除',
|
||||
content: '是否删除选中数据',
|
||||
okText: '确认',
|
||||
cancelText: '取消',
|
||||
onOk: () =>
|
||||
defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => handleSuccess()),
|
||||
});
|
||||
};
|
||||
|
||||
export const saveOrUpdate = (params, isUpdate) => defHttp.post({ url: isUpdate ? Api.edit : Api.save, params });
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,168 @@
|
||||
<template>
|
||||
<div>
|
||||
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||
<template #tableTitle>
|
||||
<a-button type="primary" v-auth="'xslmes:mes_xsl_formula_spec:add'" @click="handleAdd" preIcon="ant-design:plus-outlined">
|
||||
新增
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
v-auth="'xslmes:mes_xsl_formula_spec:exportXls'"
|
||||
preIcon="ant-design:export-outlined"
|
||||
@click="onExportXls"
|
||||
>
|
||||
导出
|
||||
</a-button>
|
||||
<j-upload-button
|
||||
type="primary"
|
||||
v-auth="'xslmes:mes_xsl_formula_spec:importExcel'"
|
||||
preIcon="ant-design:import-outlined"
|
||||
@click="onImportXls"
|
||||
>
|
||||
导入
|
||||
</j-upload-button>
|
||||
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||
<template #overlay>
|
||||
<a-menu>
|
||||
<a-menu-item key="1" @click="batchHandleDelete">
|
||||
<Icon icon="ant-design:delete-outlined" />
|
||||
删除
|
||||
</a-menu-item>
|
||||
</a-menu>
|
||||
</template>
|
||||
<a-button v-auth="'xslmes:mes_xsl_formula_spec:deleteBatch'">
|
||||
批量操作
|
||||
<Icon icon="mdi:chevron-down" />
|
||||
</a-button>
|
||||
</a-dropdown>
|
||||
<super-query :config="superQueryConfig" @search="handleSuperQuery" />
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<TableAction :actions="getTableActions(record)" :dropDownActions="getDropDownAction(record)" />
|
||||
</template>
|
||||
</BasicTable>
|
||||
<MesXslFormulaSpecModal @register="registerModal" @success="handleSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="xslmes-mesXslFormulaSpec" setup>
|
||||
import { reactive } from 'vue';
|
||||
import { BasicTable, TableAction } from '/@/components/Table';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import Icon from '/@/components/Icon';
|
||||
import MesXslFormulaSpecModal from './components/MesXslFormulaSpecModal.vue';
|
||||
import { columns, searchFormSchema, superQuerySchema } from './MesXslFormulaSpec.data';
|
||||
import { list, deleteOne, batchDelete, getExportUrl, getImportUrl } from './MesXslFormulaSpec.api';
|
||||
|
||||
const queryParam = reactive<any>({});
|
||||
const [registerModal, { openModal }] = useModal();
|
||||
|
||||
const { tableContext, onExportXls, onImportXls } = useListPage({
|
||||
tableProps: {
|
||||
title: '配合示方',
|
||||
api: list,
|
||||
columns,
|
||||
canResize: true,
|
||||
formConfig: {
|
||||
schemas: searchFormSchema,
|
||||
labelWidth: 90,
|
||||
autoSubmitOnEnter: true,
|
||||
showAdvancedButton: true,
|
||||
},
|
||||
actionColumn: {
|
||||
title: '操作',
|
||||
dataIndex: 'action',
|
||||
width: 160,
|
||||
fixed: 'right',
|
||||
slots: { customRender: 'action' },
|
||||
},
|
||||
beforeFetch: (params) => Object.assign(params, queryParam),
|
||||
},
|
||||
exportConfig: {
|
||||
name: '配合示方',
|
||||
url: getExportUrl,
|
||||
params: queryParam,
|
||||
},
|
||||
importConfig: {
|
||||
url: getImportUrl,
|
||||
success: handleSuccess,
|
||||
},
|
||||
});
|
||||
|
||||
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||
const superQueryConfig = reactive(superQuerySchema);
|
||||
|
||||
function handleSuperQuery(params) {
|
||||
Object.keys(params).forEach((k) => {
|
||||
queryParam[k] = params[k];
|
||||
});
|
||||
reload();
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
openModal(true, { isUpdate: false, showFooter: true });
|
||||
}
|
||||
|
||||
function handleEdit(record: Recordable) {
|
||||
openModal(true, { record, isUpdate: true, showFooter: true });
|
||||
}
|
||||
|
||||
function handleDetail(record: Recordable) {
|
||||
openModal(true, { record, isUpdate: true, showFooter: false });
|
||||
}
|
||||
|
||||
function handleDelete(record: Recordable) {
|
||||
deleteOne({ id: record.id }, handleSuccess);
|
||||
}
|
||||
|
||||
function batchHandleDelete() {
|
||||
batchDelete({ ids: selectedRowKeys.value.join(',') }, handleSuccess);
|
||||
}
|
||||
|
||||
function handleSuccess() {
|
||||
reload();
|
||||
selectedRowKeys.value = [];
|
||||
}
|
||||
|
||||
function canEdit(record: Recordable) {
|
||||
return !record?.status || record.status === 'compile';
|
||||
}
|
||||
|
||||
function getTableActions(record: Recordable) {
|
||||
return [
|
||||
{
|
||||
label: '编辑',
|
||||
onClick: handleEdit.bind(null, record),
|
||||
auth: 'xslmes:mes_xsl_formula_spec:edit',
|
||||
ifShow: canEdit(record),
|
||||
},
|
||||
{
|
||||
label: '详情',
|
||||
onClick: handleDetail.bind(null, record),
|
||||
ifShow: !canEdit(record),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
function getDropDownAction(record: Recordable) {
|
||||
return [
|
||||
{ label: '详情', onClick: handleDetail.bind(null, record), ifShow: canEdit(record) },
|
||||
{
|
||||
label: '删除',
|
||||
popConfirm: { title: '是否确认删除', confirm: handleDelete.bind(null, record) },
|
||||
auth: 'xslmes:mes_xsl_formula_spec:delete',
|
||||
ifShow: canEdit(record),
|
||||
},
|
||||
];
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
:deep(.ant-table) {
|
||||
.ant-table-thead > tr > th {
|
||||
background: #fafafa;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,168 @@
|
||||
<template>
|
||||
<Popover
|
||||
v-model:open="popoverOpen"
|
||||
trigger="click"
|
||||
placement="bottomRight"
|
||||
:overlayClassName="`${prefixCls}__popover`"
|
||||
@open-change="handleOpenChange"
|
||||
>
|
||||
<template #title>
|
||||
<div :class="`${prefixCls}__title`">
|
||||
<Checkbox :indeterminate="indeterminate" :checked="checkAll" @change="onCheckAllChange">列展示</Checkbox>
|
||||
</div>
|
||||
</template>
|
||||
<template #content>
|
||||
<div :class="`${prefixCls}__list`">
|
||||
<CheckboxGroup v-model:value="draftCheckedList" :options="columnOptions" />
|
||||
</div>
|
||||
<div :class="`${prefixCls}__footer`">
|
||||
<a-button size="small" @click="handleReset">重置</a-button>
|
||||
<a-button size="small" type="primary" @click="handleSave">保存</a-button>
|
||||
</div>
|
||||
</template>
|
||||
<a-tooltip title="列设置">
|
||||
<a-button size="small" class="formula-line-column-setting-btn" @click.stop>
|
||||
<Icon icon="ant-design:setting-outlined" />
|
||||
</a-button>
|
||||
</a-tooltip>
|
||||
</Popover>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref, type PropType } from 'vue';
|
||||
import { Popover, Checkbox } from 'ant-design-vue';
|
||||
import type { CheckboxChangeEvent } from 'ant-design-vue/lib/checkbox/interface';
|
||||
import { Icon } from '/@/components/Icon';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import {
|
||||
FORMULA_LINE_LOCKED_COLUMN_KEYS,
|
||||
getFormulaLineColumnSettingItems,
|
||||
saveFormulaLineHiddenColumnKeys,
|
||||
type FormulaLineColumnSettingItem,
|
||||
} from '../MesXslFormulaSpec.data';
|
||||
|
||||
const CheckboxGroup = Checkbox.Group;
|
||||
const prefixCls = 'formula-line-column-setting';
|
||||
const { createMessage } = useMessage();
|
||||
|
||||
const props = defineProps({
|
||||
hiddenKeys: {
|
||||
type: Array as PropType<string[]>,
|
||||
default: () => [],
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:hiddenKeys', value: string[]): void;
|
||||
(e: 'change', value: string[]): void;
|
||||
}>();
|
||||
|
||||
const popoverOpen = ref(false);
|
||||
const columnItems = ref<FormulaLineColumnSettingItem[]>(getFormulaLineColumnSettingItems());
|
||||
const allKeys = computed(() => columnItems.value.map((item) => item.key));
|
||||
const lockableKeys = computed(() => columnItems.value.filter((item) => !item.locked).map((item) => item.key));
|
||||
|
||||
/** 弹窗内草稿勾选状态,保存后才应用到表格 */
|
||||
const draftCheckedList = ref<string[]>([]);
|
||||
|
||||
const columnOptions = computed(() =>
|
||||
columnItems.value.map((item) => ({
|
||||
label: item.title,
|
||||
value: item.key,
|
||||
disabled: item.locked,
|
||||
})),
|
||||
);
|
||||
|
||||
const checkAll = computed(() => {
|
||||
const keys = lockableKeys.value;
|
||||
return keys.length > 0 && keys.every((key) => draftCheckedList.value.includes(key));
|
||||
});
|
||||
|
||||
const indeterminate = computed(() => {
|
||||
const keys = lockableKeys.value;
|
||||
const checkedCount = keys.filter((key) => draftCheckedList.value.includes(key)).length;
|
||||
return checkedCount > 0 && checkedCount < keys.length;
|
||||
});
|
||||
|
||||
function ensureLockedChecked() {
|
||||
const next = new Set(draftCheckedList.value);
|
||||
FORMULA_LINE_LOCKED_COLUMN_KEYS.forEach((key) => next.add(key));
|
||||
draftCheckedList.value = Array.from(next);
|
||||
}
|
||||
|
||||
function syncDraftFromHidden(hiddenKeys: string[]) {
|
||||
const hiddenSet = new Set(hiddenKeys || []);
|
||||
draftCheckedList.value = allKeys.value.filter((key) => !hiddenSet.has(key));
|
||||
ensureLockedChecked();
|
||||
}
|
||||
|
||||
function buildHiddenKeysFromDraft() {
|
||||
ensureLockedChecked();
|
||||
return allKeys.value.filter((key) => !draftCheckedList.value.includes(key));
|
||||
}
|
||||
|
||||
function handleOpenChange(open: boolean) {
|
||||
if (open) {
|
||||
syncDraftFromHidden(props.hiddenKeys);
|
||||
}
|
||||
}
|
||||
|
||||
function onCheckAllChange(e: CheckboxChangeEvent) {
|
||||
draftCheckedList.value = e.target.checked ? [...allKeys.value] : [...FORMULA_LINE_LOCKED_COLUMN_KEYS];
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
draftCheckedList.value = [...allKeys.value];
|
||||
}
|
||||
|
||||
function handleSave() {
|
||||
const hiddenKeys = buildHiddenKeysFromDraft();
|
||||
saveFormulaLineHiddenColumnKeys(hiddenKeys);
|
||||
emit('update:hiddenKeys', hiddenKeys);
|
||||
emit('change', hiddenKeys);
|
||||
createMessage.success('保存成功');
|
||||
popoverOpen.value = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.formula-line-column-setting-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding-inline: 8px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="less">
|
||||
.formula-line-column-setting__popover {
|
||||
.formula-line-column-setting__title {
|
||||
min-width: 180px;
|
||||
}
|
||||
|
||||
.formula-line-column-setting__list {
|
||||
max-height: 320px;
|
||||
overflow-y: auto;
|
||||
margin-bottom: 8px;
|
||||
|
||||
.ant-checkbox-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.ant-checkbox-group-item {
|
||||
margin-inline-start: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.formula-line-column-setting__footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
padding-top: 4px;
|
||||
border-top: 1px solid #f0f0f0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,240 @@
|
||||
<template>
|
||||
|
||||
<BasicModal
|
||||
|
||||
v-bind="$attrs"
|
||||
|
||||
title="含胶率物料小类设置"
|
||||
|
||||
:width="640"
|
||||
|
||||
@register="registerModal"
|
||||
|
||||
@ok="handleSubmit"
|
||||
|
||||
>
|
||||
|
||||
<a-form layout="vertical" class="rubber-content-setting-form">
|
||||
|
||||
<a-form-item label="天然橡胶">
|
||||
|
||||
<a-select
|
||||
|
||||
v-model:value="formState.naturalMinorCategoryIds"
|
||||
|
||||
mode="multiple"
|
||||
|
||||
allowClear
|
||||
|
||||
showSearch
|
||||
|
||||
optionFilterProp="label"
|
||||
|
||||
placeholder="请选择计入天然橡胶的物料分类"
|
||||
|
||||
:options="minorCategoryOptions"
|
||||
|
||||
:loading="optionsLoading"
|
||||
|
||||
/>
|
||||
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="合成橡胶">
|
||||
|
||||
<a-select
|
||||
|
||||
v-model:value="formState.syntheticMinorCategoryIds"
|
||||
|
||||
mode="multiple"
|
||||
|
||||
allowClear
|
||||
|
||||
showSearch
|
||||
|
||||
optionFilterProp="label"
|
||||
|
||||
placeholder="请选择计入合成橡胶的物料分类"
|
||||
|
||||
:options="minorCategoryOptions"
|
||||
|
||||
:loading="optionsLoading"
|
||||
|
||||
/>
|
||||
|
||||
</a-form-item>
|
||||
|
||||
<div class="setting-tip">选项来自系统分类字典「MES物料分类」全部节点,保存后含胶率将按所选分类汇总明细行重量%。</div>
|
||||
|
||||
</a-form>
|
||||
|
||||
</BasicModal>
|
||||
|
||||
</template>
|
||||
|
||||
|
||||
|
||||
<script lang="ts" setup>
|
||||
|
||||
import { reactive, ref, watch } from 'vue';
|
||||
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
|
||||
import { getRubberContentSetting, saveRubberContentSetting } from '../MesXslFormulaSpec.api';
|
||||
|
||||
import { fetchMaterialCategoryOptions } from '../MesXslFormulaSpec.data';
|
||||
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
|
||||
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
|
||||
const { createMessage } = useMessage();
|
||||
|
||||
|
||||
|
||||
const optionsLoading = ref(false);
|
||||
|
||||
const minorCategoryOptions = ref<Array<{ label: string; value: string }>>([]);
|
||||
|
||||
const formState = reactive({
|
||||
|
||||
naturalMinorCategoryIds: [] as string[],
|
||||
|
||||
syntheticMinorCategoryIds: [] as string[],
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
const [registerModal, { setModalProps, closeModal, getOpen }] = useModalInner();
|
||||
|
||||
watch(
|
||||
() => getOpen.value,
|
||||
async (open) => {
|
||||
if (!open) {
|
||||
return;
|
||||
}
|
||||
setModalProps({ confirmLoading: false });
|
||||
await Promise.all([loadMinorCategoryOptions(), loadSetting()]);
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
|
||||
async function loadMinorCategoryOptions() {
|
||||
|
||||
optionsLoading.value = true;
|
||||
|
||||
try {
|
||||
|
||||
minorCategoryOptions.value = await fetchMaterialCategoryOptions();
|
||||
|
||||
if (!minorCategoryOptions.value.length) {
|
||||
|
||||
createMessage.warning('未加载到 MES物料分类,请先在分类字典中维护。');
|
||||
|
||||
}
|
||||
|
||||
} catch {
|
||||
|
||||
minorCategoryOptions.value = [];
|
||||
|
||||
createMessage.warning('加载 MES物料分类 失败,请检查分类字典是否已配置。');
|
||||
|
||||
} finally {
|
||||
|
||||
optionsLoading.value = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function loadSetting() {
|
||||
|
||||
try {
|
||||
|
||||
const raw = await getRubberContentSetting();
|
||||
|
||||
const setting = (raw as Recordable)?.naturalMinorCategoryIds != null ? raw : (raw as Recordable)?.result ?? raw;
|
||||
|
||||
formState.naturalMinorCategoryIds = [...((setting as Recordable)?.naturalMinorCategoryIds || [])];
|
||||
|
||||
formState.syntheticMinorCategoryIds = [...((setting as Recordable)?.syntheticMinorCategoryIds || [])];
|
||||
|
||||
} catch {
|
||||
|
||||
formState.naturalMinorCategoryIds = [];
|
||||
|
||||
formState.syntheticMinorCategoryIds = [];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function handleSubmit() {
|
||||
|
||||
try {
|
||||
|
||||
setModalProps({ confirmLoading: true });
|
||||
|
||||
await saveRubberContentSetting({
|
||||
|
||||
naturalMinorCategoryIds: formState.naturalMinorCategoryIds,
|
||||
|
||||
syntheticMinorCategoryIds: formState.syntheticMinorCategoryIds,
|
||||
|
||||
});
|
||||
|
||||
createMessage.success('保存成功');
|
||||
|
||||
closeModal();
|
||||
|
||||
emit('success', {
|
||||
|
||||
naturalMinorCategoryIds: [...formState.naturalMinorCategoryIds],
|
||||
|
||||
syntheticMinorCategoryIds: [...formState.syntheticMinorCategoryIds],
|
||||
|
||||
});
|
||||
|
||||
} finally {
|
||||
|
||||
setModalProps({ confirmLoading: false });
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<style scoped lang="less">
|
||||
|
||||
.rubber-content-setting-form {
|
||||
|
||||
padding-top: 8px;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
.setting-tip {
|
||||
|
||||
color: rgba(0, 0, 0, 0.45);
|
||||
|
||||
font-size: 12px;
|
||||
|
||||
line-height: 1.6;
|
||||
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -145,7 +145,6 @@ export const formSchema: FormSchema[] = [
|
||||
component: 'Input',
|
||||
componentProps: { disabled: true, bordered: false, placeholder: '保存后按创建人显示' },
|
||||
colProps: colHalf,
|
||||
itemProps: { class: 'ps-workflow-item' },
|
||||
},
|
||||
{
|
||||
label: '担当',
|
||||
@@ -225,7 +224,6 @@ export const formSchema: FormSchema[] = [
|
||||
component: 'Input',
|
||||
componentProps: { disabled: true, bordered: false },
|
||||
colProps: colHalf,
|
||||
itemProps: { class: 'ps-workflow-item' },
|
||||
ifShow: ({ values }) => !!values.proofreadBy,
|
||||
},
|
||||
{
|
||||
@@ -234,7 +232,6 @@ export const formSchema: FormSchema[] = [
|
||||
component: 'Input',
|
||||
componentProps: { disabled: true, bordered: false },
|
||||
colProps: colHalf,
|
||||
itemProps: { class: 'ps-workflow-item' },
|
||||
ifShow: ({ values }) => !!values.proofreadTime,
|
||||
},
|
||||
{
|
||||
@@ -243,7 +240,6 @@ export const formSchema: FormSchema[] = [
|
||||
component: 'Input',
|
||||
componentProps: { disabled: true, bordered: false },
|
||||
colProps: colHalf,
|
||||
itemProps: { class: 'ps-workflow-item' },
|
||||
ifShow: ({ values }) => !!values.auditBy,
|
||||
},
|
||||
{
|
||||
@@ -252,7 +248,6 @@ export const formSchema: FormSchema[] = [
|
||||
component: 'Input',
|
||||
componentProps: { disabled: true, bordered: false },
|
||||
colProps: colHalf,
|
||||
itemProps: { class: 'ps-workflow-item' },
|
||||
ifShow: ({ values }) => !!values.auditTime,
|
||||
},
|
||||
{
|
||||
@@ -261,7 +256,6 @@ export const formSchema: FormSchema[] = [
|
||||
component: 'Input',
|
||||
componentProps: { disabled: true, bordered: false },
|
||||
colProps: colHalf,
|
||||
itemProps: { class: 'ps-workflow-item' },
|
||||
ifShow: ({ values }) => !!values.approveBy,
|
||||
},
|
||||
{
|
||||
@@ -270,7 +264,6 @@ export const formSchema: FormSchema[] = [
|
||||
component: 'Input',
|
||||
componentProps: { disabled: true, bordered: false },
|
||||
colProps: colHalf,
|
||||
itemProps: { class: 'ps-workflow-item' },
|
||||
ifShow: ({ values }) => !!values.approveTime,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
@ok="handleSubmit"
|
||||
>
|
||||
<div class="ps-compile-modal-body">
|
||||
<BasicForm @register="registerForm" />
|
||||
<BasicForm @register="registerForm" name="MesXslMixerPsCompileForm" />
|
||||
</div>
|
||||
</BasicModal>
|
||||
</template>
|
||||
@@ -166,7 +166,13 @@
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
:deep(.ps-workflow-item) {
|
||||
:deep(#MesXslMixerPsCompileForm_compileBy),
|
||||
:deep(#MesXslMixerPsCompileForm_proofreadBy),
|
||||
:deep(#MesXslMixerPsCompileForm_proofreadTime),
|
||||
:deep(#MesXslMixerPsCompileForm_auditBy),
|
||||
:deep(#MesXslMixerPsCompileForm_auditTime),
|
||||
:deep(#MesXslMixerPsCompileForm_approveBy),
|
||||
:deep(#MesXslMixerPsCompileForm_approveTime) {
|
||||
margin-bottom: 8px;
|
||||
|
||||
.ant-form-item-label > label {
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
<template>
|
||||
<BasicModal v-bind="$attrs" title="选择密炼PS" :width="960" @register="registerModal" @ok="handleOk">
|
||||
<BasicTable @register="registerTable" />
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicTable, useTable } from '/@/components/Table';
|
||||
import type { FormSchema } from '/@/components/Table';
|
||||
import { list as mixerPsList, queryById as queryMixerPsById } from '../MesXslMixerPsCompile.api';
|
||||
import { columns as mixerPsColumns } from '../MesXslMixerPsCompile.data';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
const emit = defineEmits(['register', 'select']);
|
||||
const { createMessage } = useMessage();
|
||||
|
||||
const COMPILE_STATUS = 'compile';
|
||||
|
||||
const selectSearchSchema: FormSchema[] = [
|
||||
{ label: 'PS编码', field: 'psCode', component: 'JInput', colProps: { span: 8 } },
|
||||
{ label: '标题', field: 'title', component: 'JInput', colProps: { span: 8 } },
|
||||
];
|
||||
|
||||
const selectedRow = ref<Recordable | null>(null);
|
||||
|
||||
const [registerTable, { reload, getSelectRowKeys, getSelectRows, setSelectedRowKeys, clearSelectedRowKeys }] = useTable({
|
||||
api: mixerPsList,
|
||||
columns: mixerPsColumns.slice(0, 7),
|
||||
rowKey: 'id',
|
||||
useSearchForm: true,
|
||||
formConfig: {
|
||||
labelWidth: 90,
|
||||
schemas: selectSearchSchema,
|
||||
},
|
||||
pagination: { pageSize: 10 },
|
||||
canResize: false,
|
||||
showIndexColumn: false,
|
||||
immediate: true,
|
||||
beforeFetch: (params) => ({
|
||||
...params,
|
||||
status: COMPILE_STATUS,
|
||||
}),
|
||||
rowSelection: {
|
||||
type: 'radio',
|
||||
columnWidth: 48,
|
||||
onChange: (_keys, rows) => {
|
||||
selectedRow.value = rows?.[0] ?? null;
|
||||
},
|
||||
},
|
||||
clickToRowSelect: true,
|
||||
});
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
selectedRow.value = null;
|
||||
clearSelectedRowKeys?.();
|
||||
setModalProps({ confirmLoading: false });
|
||||
const psId = data?.psCompileId as string | undefined;
|
||||
if (psId) {
|
||||
setSelectedRowKeys?.([psId]);
|
||||
try {
|
||||
const raw = await queryMixerPsById({ id: psId });
|
||||
const row = (raw as Recordable)?.psCode != null ? raw : (raw as Recordable)?.result;
|
||||
if (row) {
|
||||
selectedRow.value = row;
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
reload();
|
||||
});
|
||||
|
||||
async function handleOk() {
|
||||
const keys = (getSelectRowKeys?.() || []) as string[];
|
||||
let row = selectedRow.value || ((getSelectRows?.() || []) as Recordable[])[0];
|
||||
if (!row && keys.length) {
|
||||
try {
|
||||
const raw = await queryMixerPsById({ id: keys[0] });
|
||||
row = (raw as Recordable)?.psCode != null ? raw : (raw as Recordable)?.result;
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
if (!row?.id) {
|
||||
createMessage.warning('请选择一条编制状态的密炼PS');
|
||||
return;
|
||||
}
|
||||
if (row.status && row.status !== COMPILE_STATUS) {
|
||||
createMessage.warning('仅可选择编制状态的密炼PS');
|
||||
return;
|
||||
}
|
||||
emit('select', {
|
||||
psCompileId: row.id,
|
||||
psCode: row.psCode || '',
|
||||
title: row.title || '',
|
||||
});
|
||||
closeModal();
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user