refactor(orders): 移除 compatConfig 并优化 style-print 组件
移除所有组件中的 compatConfig 配置,以简化代码结构。在 style-print 组件中,新增 styleGroupDicts 和 getStyleGroupName 方法,用于动态加载和显示 StyleGroup 字典项,提升代码可维护性和可读性。
This commit is contained in:
parent
e8484a0b63
commit
d20f007a46
@ -9,7 +9,6 @@ import type { VxeTableInstance } from 'vxe-table';
|
|||||||
import JhiCamera from '@/shared/components/jhi_camera.vue';
|
import JhiCamera from '@/shared/components/jhi_camera.vue';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
compatConfig: { MODE: 3 },
|
|
||||||
name: 'StyleUpdate',
|
name: 'StyleUpdate',
|
||||||
setup() {
|
setup() {
|
||||||
const { t: $t } = useI18n();
|
const { t: $t } = useI18n();
|
||||||
|
|||||||
@ -11,7 +11,6 @@ import buildPaginationQuery from '@/shared/sort/sorts';
|
|||||||
import { property } from 'xe-utils';
|
import { property } from 'xe-utils';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
compatConfig: { MODE: 3 },
|
|
||||||
name: 'StylePrint',
|
name: 'StylePrint',
|
||||||
components: {
|
components: {
|
||||||
QrcodeVue,
|
QrcodeVue,
|
||||||
@ -33,6 +32,7 @@ export default defineComponent({
|
|||||||
const settingTypes = ref([]);
|
const settingTypes = ref([]);
|
||||||
const styleGroupTitle = ref([]); // 新增:存储 StyleGroup 标题
|
const styleGroupTitle = ref([]); // 新增:存储 StyleGroup 标题
|
||||||
const styleGroupPrefix = 'styleGroup'; // 新增:StyleGroup 前缀
|
const styleGroupPrefix = 'styleGroup'; // 新增:StyleGroup 前缀
|
||||||
|
const styleGroupDicts = ref(Array(6).fill([])); // 新增:存储每个 StyleGroup 的字典项
|
||||||
const style = ref({
|
const style = ref({
|
||||||
id: null,
|
id: null,
|
||||||
number: '',
|
number: '',
|
||||||
@ -131,6 +131,7 @@ export default defineComponent({
|
|||||||
// 保存 StyleGroup 标题
|
// 保存 StyleGroup 标题
|
||||||
styleGroupTitle.value = styleGroupTitleRes.data;
|
styleGroupTitle.value = styleGroupTitleRes.data;
|
||||||
|
|
||||||
|
await loadStyleGroupDicts();
|
||||||
// 加载款式明细
|
// 加载款式明细
|
||||||
await loadStyleDtls();
|
await loadStyleDtls();
|
||||||
}
|
}
|
||||||
@ -194,9 +195,34 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
// 加载 StyleGroup 字典项
|
||||||
loadStyle();
|
const loadStyleGroupDicts = async () => {
|
||||||
|
for (let i = 0; i < styleGroupTitle.value.length; i++) {
|
||||||
|
const groupKey = `${styleGroupPrefix}${i.toString().padStart(2, '0')}`;
|
||||||
|
const groupValue = style.value[groupKey];
|
||||||
|
if (!groupValue) continue;
|
||||||
|
try {
|
||||||
|
const res = await axios.get('api/dicts', {
|
||||||
|
params: {
|
||||||
|
parentNumber: { op: '=', value: groupKey },
|
||||||
|
status: { op: '=', value: '1' },
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
styleGroupDicts.value[i] = res.data;
|
||||||
|
} catch (e) {
|
||||||
|
styleGroupDicts.value[i] = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// 获取分组名称
|
||||||
|
const getStyleGroupName = (groupNumber, value) => {
|
||||||
|
if (!groupNumber) return '-';
|
||||||
|
const idx = styleGroupTitle.value.findIndex(item => item.number === groupNumber);
|
||||||
|
if (idx === -1) return '-';
|
||||||
|
const dictArr = styleGroupDicts.value[idx] || [];
|
||||||
|
const found = dictArr.find(item => item.number === value);
|
||||||
|
return found ? found.name : '-';
|
||||||
|
};
|
||||||
|
|
||||||
const getProductTypeName = computed(() => {
|
const getProductTypeName = computed(() => {
|
||||||
const productType = productTypes.value.find(item => item.number === style.value.productType);
|
const productType = productTypes.value.find(item => item.number === style.value.productType);
|
||||||
@ -220,6 +246,10 @@ export default defineComponent({
|
|||||||
return titleEntry ? titleEntry.name : $t(`jewpmsApp.style.${fieldName}`); // 回退到 i18n
|
return titleEntry ? titleEntry.name : $t(`jewpmsApp.style.${fieldName}`); // 回退到 i18n
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
loadStyle();
|
||||||
|
});
|
||||||
|
|
||||||
const downloadPdf = async () => {
|
const downloadPdf = async () => {
|
||||||
try {
|
try {
|
||||||
const element = document.getElementById('stylePrintContent');
|
const element = document.getElementById('stylePrintContent');
|
||||||
@ -272,11 +302,13 @@ export default defineComponent({
|
|||||||
getProductTypeName,
|
getProductTypeName,
|
||||||
getProcessTypeName,
|
getProcessTypeName,
|
||||||
getSettingTypeName,
|
getSettingTypeName,
|
||||||
getStyleGroupTitle, // 新增:导出方法
|
getStyleGroupTitle,
|
||||||
pdfBlob,
|
pdfBlob,
|
||||||
downloadPdf,
|
downloadPdf,
|
||||||
pdfPreviewRef,
|
pdfPreviewRef,
|
||||||
styleGroupTitle, // 确保暴露给模板
|
styleGroupTitle,
|
||||||
|
styleGroupDicts,
|
||||||
|
getStyleGroupName,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@ -65,7 +65,7 @@
|
|||||||
<template v-for="(group, idx) in styleGroupTitle" :key="group.number">
|
<template v-for="(group, idx) in styleGroupTitle" :key="group.number">
|
||||||
<div class="print-row">
|
<div class="print-row">
|
||||||
<div class="print-label">{{ group.name }}:</div>
|
<div class="print-label">{{ group.name }}:</div>
|
||||||
<div class="print-value">{{ style[group.number] }}</div>
|
<div class="print-value">{{ getStyleGroupName(group.number, style[group.number]) }}</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -9,7 +9,6 @@ import type { VxeToolbarInstance, VxeTableInstance, VxePagerEvents } from 'vxe-t
|
|||||||
import debounce from 'lodash/debounce';
|
import debounce from 'lodash/debounce';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
compatConfig: { MODE: 3 },
|
|
||||||
name: 'Style',
|
name: 'Style',
|
||||||
components: {
|
components: {
|
||||||
StreamBarcodeReader,
|
StreamBarcodeReader,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user