PublicRange.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <div class="public-range-container">
  3. <!-- 统一使用带标题容器的结构,确保标题对齐 -->
  4. <!-- FC区域 - 支持可插拔控制 -->
  5. <div class="form-section" v-if="showFc">
  6. <div class="section-title fc-title">FC</div>
  7. <div class="section-content fc-content">
  8. <el-checkbox-group v-model="modelValue.brandCode">
  9. <el-checkbox
  10. v-for="dict in yamadaFcBrand"
  11. :key="dict.value"
  12. :label="dict.value"
  13. style="margin-right: 60px;"
  14. >
  15. {{ dict.label }}
  16. </el-checkbox>
  17. </el-checkbox-group>
  18. </div>
  19. </div>
  20. <!-- 業種区域 - 原有可插拔控制 -->
  21. <div class="form-section" v-if="showBusinessType">
  22. <div class="section-title">業種</div>
  23. <div class="section-content">
  24. <el-checkbox-group v-model="modelValue.businessTypeCode">
  25. <el-checkbox
  26. v-for="dict in yamadaBusinessType"
  27. :key="dict.value"
  28. :label="dict.value"
  29. style="margin-right: 32px;"
  30. >
  31. {{ dict.label }}
  32. </el-checkbox>
  33. </el-checkbox-group>
  34. </div>
  35. </div>
  36. <!-- エリア区域 - 支持可插拔控制 -->
  37. <div class="form-section" v-if="showArea">
  38. <div class="section-title">エリア</div>
  39. <div class="area-header-row">
  40. <RegionTree
  41. class="region-tree-container"
  42. :treeData="regionTree"
  43. @check-change="handleCheckChange"
  44. />
  45. </div>
  46. </div>
  47. </div>
  48. </template>
  49. <script setup>
  50. import { defineProps, defineEmits, watch } from 'vue';
  51. import RegionTree from './RegionTree.vue';
  52. const props = defineProps({
  53. modelValue: {
  54. type: Object,
  55. required: true,
  56. default: () => ({
  57. brandCode: [],
  58. businessTypeCode: [],
  59. regions: []
  60. })
  61. },
  62. regionTree: {
  63. type: Array,
  64. required: true,
  65. default: () => []
  66. },
  67. yamadaFcBrand: {
  68. type: Array,
  69. required: true,
  70. default: () => []
  71. },
  72. yamadaBusinessType: {
  73. type: Array,
  74. required: true,
  75. default: () => []
  76. },
  77. // 業種显示控制
  78. showBusinessType: {
  79. type: Boolean,
  80. default: false
  81. },
  82. // FC显示控制
  83. showFc: {
  84. type: Boolean,
  85. default: false
  86. },
  87. // エリア显示控制
  88. showArea: {
  89. type: Boolean,
  90. default: true
  91. }
  92. });
  93. const emits = defineEmits([
  94. 'update:modelValue',
  95. 'check-change'
  96. ]);
  97. const handleCheckChange = (regionId, isChecked) => {
  98. emits('check-change', regionId, isChecked);
  99. };
  100. watch(
  101. () => props.modelValue,
  102. (newValue) => {
  103. emits('update:modelValue', newValue);
  104. },
  105. { deep: true }
  106. );
  107. </script>
  108. <style scoped>
  109. .public-range-container {
  110. margin-top: 10px;
  111. padding-left: 60px; /* 统一左侧内边距,确保整体左对齐 */
  112. }
  113. /* 统一的区块样式,标题和内容横向排列 */
  114. .form-section {
  115. display: flex;
  116. align-items: flex-start; /* 标题和内容顶部对齐 */
  117. margin-top: 15px;
  118. }
  119. /* 标题容器 - 固定宽度确保垂直对齐 */
  120. .section-title {
  121. width: 60px; /* 固定宽度,确保三个标题垂直对齐 */
  122. margin-right: 20px; /* 标题与内容的间距 */
  123. font-size: 14px;
  124. color: #606266;
  125. font-weight: 700;
  126. text-align: left; /* 首字母对齐关键:左对齐 */
  127. padding-top: 4px; /* 与复选框组件基线对齐 */
  128. }
  129. /* FC区域特殊样式 - 加宽标题与内容间距 */
  130. .fc-title {
  131. margin-right: 30px; /* 比默认增加10px间距 */
  132. }
  133. /* 内容区域 - 占剩余宽度 */
  134. .section-content {
  135. flex: 1; /* 内容区域自适应剩余宽度 */
  136. align-items: flex-start;
  137. }
  138. /* 确保复选框与单选框垂直对齐 */
  139. ::v-deep .el-checkbox {
  140. display: inline-flex;
  141. align-items: center;
  142. margin-bottom: 8px; /* 增加垂直方向间距 */
  143. }
  144. ::v-deep .el-checkbox__input {
  145. margin-top: -2px; /* 微调复选框位置,与单选框对齐 */
  146. }
  147. .area-header-row {
  148. display: flex;
  149. align-items: flex-start;
  150. }
  151. /* 区域树特殊样式调整 */
  152. .region-tree-container {
  153. margin-top: -4px; /* 微调与标题的垂直对齐 */
  154. }
  155. /* 响应式调整 */
  156. @media (max-width: 768px) {
  157. .public-range-container {
  158. padding-left: 13%; /* 移动端左侧百分比对齐 */
  159. }
  160. .section-title {
  161. width: 50px; /* 移动端标题宽度微调 */
  162. margin-right: 15px;
  163. }
  164. .fc-title {
  165. margin-right: 15px; /* 移动端恢复默认间距 */
  166. }
  167. }
  168. </style>