zhangwei
9 天以前 03c275439949875a857538df89a41696642c42b3
src/views/system/dept/form.vue
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { onMounted, ref, reactive } from "vue";
import { onMounted, ref, reactive, computed } from "vue";
import ReCol from "@/components/ReCol";
import { formRules } from "./utils/rule";
import { FormProps } from "./utils/types";
@@ -9,6 +9,27 @@
import { getCaigoufangshiList } from "@/api/item/index";
const { state, nowRole } = useDept(ref({}));
// 递归查找label的函数
const findLabelsByValues = (values, options, currentLabels = []) => {
  if (!values.length || !options) return currentLabels;
  const [firstValue, ...restValues] = values;
  const matched = options.find(item => item.code === firstValue);
  if (matched) {
    currentLabels.push(matched.name);
    // 继续查找下一级
    return findLabelsByValues(restValues, matched.regions, currentLabels);
  }
  return currentLabels;
};
// 计算属性:根据selectedValue动态获取label
const selectedLabels = computed(() => {
  return findLabelsByValues(
    newFormInline.value.xingzhengquyu,
    state.regionList
  ).join("");
});
const props = withDefaults(defineProps<FormProps>(), {
  formInline: () => ({
    id: "",
@@ -55,7 +76,7 @@
  return ruleFormRef.value;
}
const handleChange = value => {
  console.log(value);
  newFormInline.value.xingzhengquyuName = selectedLabels.value;
};
const selectChange = value => {
  let obj = state.caigoufangshiList.find(item => {
@@ -149,7 +170,7 @@
        </el-form-item>
      </re-col>
      <re-col :value="6" :xs="24" :sm="24">
        <el-form-item label="定制规划" prop="dingbiaoguize">
        <el-form-item label="成交方法" prop="dingbiaoguize">
          <!-- <el-checkbox-group
            v-model="newFormInline.dingbiaoguize"
            placeholder="请选择状态"