BedConfigModal.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <LjDialogNew v-bind="$attrs" width="600px" :closed="closed">
  3. <template #header>
  4. <div class="flx-1">
  5. <span class="text-h5-b">配置项值选择</span>
  6. </div>
  7. </template>
  8. <div class="checkbox-area">
  9. <el-checkbox v-model="showHeadboardModel" label="床头" border></el-checkbox>
  10. <el-checkbox v-model="showNightstandModel" label="床头柜" border></el-checkbox>
  11. <el-checkbox v-model="showBedframeModel" label="床架" border></el-checkbox>
  12. </div>
  13. <div class="config-sections config-scroll-container">
  14. <ConfigSection
  15. v-if="showHeadboardModel"
  16. part-name="床头"
  17. v-model:selectedConfigItems="partsConfig.headboard"
  18. :configItemOptions="headboardConfigOptions"
  19. :configValueOptionsMap="configValueOptionsMap"
  20. />
  21. <ConfigSection
  22. v-if="showNightstandModel"
  23. part-name="床头柜"
  24. v-model:selectedConfigItems="partsConfig.nightstand"
  25. :configItemOptions="nightstandConfigOptions"
  26. :configValueOptionsMap="configValueOptionsMap"
  27. />
  28. <ConfigSection
  29. v-if="showBedframeModel"
  30. part-name="床架"
  31. v-model:selectedConfigItems="partsConfig.bedframe"
  32. :configItemOptions="bedframeConfigOptions"
  33. :configValueOptionsMap="configValueOptionsMap"
  34. />
  35. </div>
  36. <template #footer>
  37. <el-button @click="onCancel">取消</el-button>
  38. <el-button type="primary" @click="onConfirm">确认配置</el-button>
  39. </template>
  40. </LjDialogNew>
  41. </template>
  42. <script setup lang="ts">
  43. import { PropType, computed } from "vue";
  44. import ConfigSection from "./ConfigSection.vue";
  45. import LjDialogNew from "@/components/LjDialog/index-new.vue";
  46. interface ConfigValue {
  47. printid: number;
  48. namemx: string;
  49. }
  50. interface ConfigItemOption {
  51. pzid: number;
  52. pzname: string;
  53. }
  54. interface SelectedConfigItem {
  55. pzid: number;
  56. selectedId: number;
  57. selectedValue?: string;
  58. }
  59. const props = defineProps({
  60. showHeadboard: { type: Boolean, default: true },
  61. showNightstand: { type: Boolean, default: true },
  62. showBedframe: { type: Boolean, default: false },
  63. headboardConfigOptions: { type: Array as PropType<ConfigItemOption[]>, required: true },
  64. nightstandConfigOptions: { type: Array as PropType<ConfigItemOption[]>, required: true },
  65. bedframeConfigOptions: { type: Array as PropType<ConfigItemOption[]>, required: true },
  66. configValueOptionsMap: { type: Object as PropType<Record<number, ConfigValue[]>>, required: true },
  67. partsConfig: {
  68. type: Object as PropType<{
  69. headboard: SelectedConfigItem[];
  70. nightstand: SelectedConfigItem[];
  71. bedframe: SelectedConfigItem[];
  72. }>,
  73. required: true
  74. }
  75. });
  76. const emit = defineEmits([
  77. "update:showHeadboard",
  78. "update:showNightstand",
  79. "update:showBedframe",
  80. "update:partsConfig",
  81. "cancel",
  82. "submit",
  83. "closed",
  84. "update:modelValue"
  85. ]);
  86. const showHeadboardModel = computed({
  87. get: () => props.showHeadboard,
  88. set: (val: boolean) => emit("update:showHeadboard", val)
  89. });
  90. const showNightstandModel = computed({
  91. get: () => props.showNightstand,
  92. set: (val: boolean) => emit("update:showNightstand", val)
  93. });
  94. const showBedframeModel = computed({
  95. get: () => props.showBedframe,
  96. set: (val: boolean) => emit("update:showBedframe", val)
  97. });
  98. const onCancel = () => emit("cancel");
  99. const onConfirm = () => {
  100. const newParts = { ...props.partsConfig };
  101. if (!showHeadboardModel.value) {
  102. newParts.headboard = [];
  103. }
  104. if (!showNightstandModel.value) {
  105. newParts.nightstand = [];
  106. }
  107. if (!showBedframeModel.value) {
  108. newParts.bedframe = [];
  109. }
  110. emit("submit", newParts);
  111. };
  112. const closed = () => emit("cancel");
  113. </script>
  114. <style lang="scss">
  115. .el-dialog {
  116. max-height: 80vh;
  117. display: flex;
  118. flex-direction: column;
  119. }
  120. </style>
  121. <style scoped lang="scss">
  122. .config-scroll-container {
  123. flex: 1;
  124. overflow-y: auto;
  125. padding-right: 4px;
  126. max-height: 50vh;
  127. }
  128. .checkbox-area {
  129. padding: 0 0 8px 0;
  130. border-bottom: 1px solid #ebeef5;
  131. display: flex;
  132. }
  133. .config-sections {
  134. padding: 8px 0px;
  135. }
  136. </style>