|
@@ -7,40 +7,34 @@
|
|
|
</template>
|
|
|
|
|
|
<div class="checkbox-area">
|
|
|
- <el-checkbox v-model="showHeadboard" label="床头" border></el-checkbox>
|
|
|
- <el-checkbox v-model="showNightstand" label="床头柜" border></el-checkbox>
|
|
|
- <el-checkbox v-model="showBedframe" label="床架" border></el-checkbox>
|
|
|
+ <el-checkbox v-model="showHeadboardModel" label="床头" border></el-checkbox>
|
|
|
+ <el-checkbox v-model="showNightstandModel" label="床头柜" border></el-checkbox>
|
|
|
+ <el-checkbox v-model="showBedframeModel" label="床架" border></el-checkbox>
|
|
|
</div>
|
|
|
|
|
|
<div class="config-sections config-scroll-container">
|
|
|
<ConfigSection
|
|
|
- v-if="showHeadboard"
|
|
|
+ v-if="showHeadboardModel"
|
|
|
part-name="床头"
|
|
|
- :config-items="headboardConfigs"
|
|
|
- :config-item-options="configItemOptions"
|
|
|
- :config-value-options-map="configValueOptionsMap"
|
|
|
- @removeConfigItem="removeConfigItem('headboard', $event)"
|
|
|
- @addConfigItem="addConfigItem('headboard')"
|
|
|
+ v-model:selectedConfigItems="partsConfig.headboard"
|
|
|
+ :configItemOptions="configItemOptions"
|
|
|
+ :configValueOptionsMap="configValueOptionsMap"
|
|
|
/>
|
|
|
|
|
|
<ConfigSection
|
|
|
- v-if="showNightstand"
|
|
|
+ v-if="showNightstandModel"
|
|
|
part-name="床头柜"
|
|
|
- :config-items="nightstandConfigs"
|
|
|
- :config-item-options="configItemOptions"
|
|
|
- :config-value-options-map="configValueOptionsMap"
|
|
|
- @removeConfigItem="removeConfigItem('nightstand', $event)"
|
|
|
- @addConfigItem="addConfigItem('nightstand')"
|
|
|
+ v-model:selectedConfigItems="partsConfig.nightstand"
|
|
|
+ :configItemOptions="configItemOptions"
|
|
|
+ :configValueOptionsMap="configValueOptionsMap"
|
|
|
/>
|
|
|
|
|
|
<ConfigSection
|
|
|
- v-if="showBedframe"
|
|
|
+ v-if="showBedframeModel"
|
|
|
part-name="床架"
|
|
|
- :config-items="bedframeConfigs"
|
|
|
- :config-item-options="configItemOptions"
|
|
|
- :config-value-options-map="configValueOptionsMap"
|
|
|
- @removeConfigItem="removeConfigItem('bedframe', $event)"
|
|
|
- @addConfigItem="addConfigItem('bedframe')"
|
|
|
+ v-model:selectedConfigItems="partsConfig.bedframe"
|
|
|
+ :configItemOptions="configItemOptions"
|
|
|
+ :configValueOptionsMap="configValueOptionsMap"
|
|
|
/>
|
|
|
</div>
|
|
|
|
|
@@ -52,127 +46,83 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { ref, reactive } from "vue";
|
|
|
+import { PropType, computed } from "vue";
|
|
|
import ConfigSection from "./ConfigSection.vue";
|
|
|
import LjDialogNew from "@/components/LjDialog/index-new.vue";
|
|
|
|
|
|
-interface SelectOption {
|
|
|
- label: string;
|
|
|
- value: string;
|
|
|
-}
|
|
|
-
|
|
|
interface ConfigValue {
|
|
|
- pzid: number;
|
|
|
printid: number;
|
|
|
pznamemx: string;
|
|
|
}
|
|
|
-
|
|
|
-interface ConfigItem {
|
|
|
+interface ConfigItemOption {
|
|
|
pzid: number;
|
|
|
pzname: string;
|
|
|
- valueList: ConfigValue[];
|
|
|
+}
|
|
|
+interface SelectedConfigItem {
|
|
|
+ pzid: number;
|
|
|
selectedValue?: string;
|
|
|
}
|
|
|
|
|
|
-const showHeadboard = ref(true);
|
|
|
-const showNightstand = ref(true);
|
|
|
-const showBedframe = ref(false);
|
|
|
-
|
|
|
-// 下拉选项
|
|
|
-const configItemOptions: SelectOption[] = [
|
|
|
- { label: "颜色", value: "颜色" },
|
|
|
- { label: "材质", value: "材质" },
|
|
|
- { label: "款式", value: "款式" },
|
|
|
- { label: "尺寸", value: "尺寸" }
|
|
|
-];
|
|
|
-
|
|
|
-// 各配置项对应的选配值选项Map(key为配置项名)
|
|
|
-const configValueOptionsMap: Record<string, SelectOption[]> = {
|
|
|
- 颜色: [
|
|
|
- { label: "白色", value: "白色" },
|
|
|
- { label: "红色", value: "红色" },
|
|
|
- { label: "黑色", value: "黑色" }
|
|
|
- ],
|
|
|
- 材质: [
|
|
|
- { label: "实木", value: "实木" },
|
|
|
- { label: "皮质", value: "皮质" },
|
|
|
- { label: "布艺", value: "布艺" }
|
|
|
- ],
|
|
|
- 款式: [
|
|
|
- { label: "现代", value: "现代" },
|
|
|
- { label: "简约", value: "简约" }
|
|
|
- ],
|
|
|
- 尺寸: [
|
|
|
- { label: "90cm", value: "90cm" },
|
|
|
- { label: "120cm", value: "120cm" }
|
|
|
- ]
|
|
|
-};
|
|
|
-
|
|
|
-// 各部件配置数据
|
|
|
-const headboardConfigs = reactive<ConfigItem[]>([
|
|
|
- {
|
|
|
- pzid: 101,
|
|
|
- pzname: "颜色",
|
|
|
- valueList: [
|
|
|
- { pzid: 101, printid: 1, pznamemx: "白色" },
|
|
|
- { pzid: 101, printid: 2, pznamemx: "红色" }
|
|
|
- ],
|
|
|
- selectedValue: "白色"
|
|
|
+const props = defineProps({
|
|
|
+ showHeadboard: { type: Boolean, default: true },
|
|
|
+ showNightstand: { type: Boolean, default: true },
|
|
|
+ showBedframe: { type: Boolean, default: false },
|
|
|
+ partsConfig: {
|
|
|
+ type: Object as PropType<{
|
|
|
+ headboard: SelectedConfigItem[];
|
|
|
+ nightstand: SelectedConfigItem[];
|
|
|
+ bedframe: SelectedConfigItem[];
|
|
|
+ }>,
|
|
|
+ required: true
|
|
|
},
|
|
|
- {
|
|
|
- pzid: 201,
|
|
|
- pzname: "材质",
|
|
|
- valueList: [
|
|
|
- { pzid: 201, printid: 1, pznamemx: "皮质" },
|
|
|
- { pzid: 201, printid: 2, pznamemx: "布艺" }
|
|
|
- ],
|
|
|
- selectedValue: "皮质"
|
|
|
- }
|
|
|
+ configItemOptions: { type: Array as PropType<ConfigItemOption[]>, required: true },
|
|
|
+ configValueOptionsMap: { type: Object as PropType<Record<number, ConfigValue[]>>, required: true }
|
|
|
+});
|
|
|
+
|
|
|
+const emit = defineEmits([
|
|
|
+ "update:showHeadboard",
|
|
|
+ "update:showNightstand",
|
|
|
+ "update:showBedframe",
|
|
|
+ "update:partsConfig",
|
|
|
+ "cancel",
|
|
|
+ "submit",
|
|
|
+ "closed",
|
|
|
+ "update:modelValue"
|
|
|
]);
|
|
|
|
|
|
-const nightstandConfigs = reactive<ConfigItem[]>([
|
|
|
- {
|
|
|
- pzid: 201,
|
|
|
- pzname: "材质",
|
|
|
- valueList: [
|
|
|
- { pzid: 201, printid: 1, pznamemx: "皮质" },
|
|
|
- { pzid: 201, printid: 2, pznamemx: "布艺" }
|
|
|
- ],
|
|
|
- selectedValue: "皮质"
|
|
|
- }
|
|
|
-]);
|
|
|
+const showHeadboardModel = computed({
|
|
|
+ get: () => props.showHeadboard,
|
|
|
+ set: (val: boolean) => emit("update:showHeadboard", val)
|
|
|
+});
|
|
|
|
|
|
-const bedframeConfigs = reactive<ConfigItem[]>([]);
|
|
|
+const showNightstandModel = computed({
|
|
|
+ get: () => props.showNightstand,
|
|
|
+ set: (val: boolean) => emit("update:showNightstand", val)
|
|
|
+});
|
|
|
|
|
|
-const removeConfigItem = (part: string, index: number) => {
|
|
|
- if (part === "headboard") headboardConfigs.splice(index, 1);
|
|
|
- else if (part === "nightstand") nightstandConfigs.splice(index, 1);
|
|
|
- else if (part === "bedframe") bedframeConfigs.splice(index, 1);
|
|
|
-};
|
|
|
+const showBedframeModel = computed({
|
|
|
+ get: () => props.showBedframe,
|
|
|
+ set: (val: boolean) => emit("update:showBedframe", val)
|
|
|
+});
|
|
|
|
|
|
-const addConfigItem = (part: string) => {
|
|
|
- const newItem: ConfigItem = {
|
|
|
- pzid: Date.now(),
|
|
|
- pzname: "",
|
|
|
- valueList: [],
|
|
|
- selectedValue: ""
|
|
|
- };
|
|
|
- if (part === "headboard") headboardConfigs.push(newItem);
|
|
|
- else if (part === "nightstand") nightstandConfigs.push(newItem);
|
|
|
- else if (part === "bedframe") bedframeConfigs.push(newItem);
|
|
|
-};
|
|
|
-
|
|
|
-const emits = defineEmits(["cancel", "submit", "closed", "update:modelValue"]);
|
|
|
-const onCancel = () => {
|
|
|
- emits("cancel");
|
|
|
-};
|
|
|
+const onCancel = () => emit("cancel");
|
|
|
|
|
|
const onConfirm = () => {
|
|
|
- emits("submit", {});
|
|
|
-};
|
|
|
-const closed = () => {
|
|
|
- emits("closed");
|
|
|
+ const newParts = { ...props.partsConfig };
|
|
|
+
|
|
|
+ if (!showHeadboardModel.value) {
|
|
|
+ newParts.headboard = [];
|
|
|
+ }
|
|
|
+ if (!showNightstandModel.value) {
|
|
|
+ newParts.nightstand = [];
|
|
|
+ }
|
|
|
+ if (!showBedframeModel.value) {
|
|
|
+ newParts.bedframe = [];
|
|
|
+ }
|
|
|
+ emit("submit", newParts);
|
|
|
};
|
|
|
+
|
|
|
+const closed = () => emit("closed");
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss">
|