tempPush
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch, defineEmits, defineProps } from "vue";
|
||||
import { ref } from "vue";
|
||||
import ProductCraft from "@/components/ProductCraft";
|
||||
|
||||
const defaultCraftData = ref([
|
||||
@@ -156,6 +156,8 @@ const defaultCraftData = ref([
|
||||
},
|
||||
]);
|
||||
|
||||
const emits = defineEmits(["update:modelValue"]);
|
||||
|
||||
const handleCraftChange = (info) => {
|
||||
const { optionValue, itemIndex, data } = info;
|
||||
const currentItem = data[itemIndex];
|
||||
@@ -164,7 +166,9 @@ const handleCraftChange = (info) => {
|
||||
currentItem.options.forEach((opt) => {
|
||||
if (opt.value === optionValue) {
|
||||
} else {
|
||||
opt.checked = false;
|
||||
if (itemIndex != 5) {
|
||||
opt.checked = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -197,13 +201,50 @@ const handleCraftChange = (info) => {
|
||||
|
||||
// 3. 更新响应式数据
|
||||
defaultCraftData.value = data;
|
||||
handleDataInfo();
|
||||
};
|
||||
|
||||
//处理工艺数据
|
||||
const handleDataInfo = () => {
|
||||
let datainfo = [];
|
||||
defaultCraftData.value.forEach((craft) => {
|
||||
const selectedOption = craft.options.filter((opt) => {
|
||||
return opt.checked;
|
||||
});
|
||||
if (selectedOption && selectedOption.length > 0) {
|
||||
selectedOption.forEach((opt) => {
|
||||
let item = {};
|
||||
if (opt.checked) {
|
||||
item.type = opt.label;
|
||||
item.value = opt.value;
|
||||
if (opt.children) {
|
||||
let childItem = {};
|
||||
item.children = [];
|
||||
opt.children.forEach((child) => {
|
||||
if (child.id && child.value) {
|
||||
childItem[child.id] = child.value;
|
||||
} else {
|
||||
childItem.value = child.value;
|
||||
}
|
||||
});
|
||||
item.children.push(childItem);
|
||||
}
|
||||
}
|
||||
datainfo.push(item);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
emits("update:modelValue", datainfo);
|
||||
};
|
||||
|
||||
const verifyCraftData = () => {
|
||||
// 验证工艺数据的完整性和正确性
|
||||
|
||||
return { valid: true };
|
||||
return { valid: false, message: "工艺数据验证失败" };
|
||||
};
|
||||
handleDataInfo();
|
||||
|
||||
defineExpose({
|
||||
verifyCraftData,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user