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";
@@ -8,7 +8,28 @@
import { Operation } from "@element-plus/icons-vue";
import { getCaigoufangshiList } from "@/api/item/index";
const { state } = useDept(ref({}));
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: "",
@@ -16,12 +37,13 @@
    projectName: "", // 项目名称(必填)
    hangyepinmu: null, // 行业品目(可选)
    caigoufangshi: null, // 采购方式(可选)
    caigoufangshiName: null,
    caigouyusuan: null, // 采购预算(可选)
    dingbiaoguize: null, // 定标规则(可选)
    baomingfei: null, // 报名费(可选)
    toubiaobaozhengjin: null, // 投标保证金(可选)
    lianhetitoubiao: null, // 联合体投标(可选)
    kaibiaofangshi: null, // 开标方式(可选)
    kaibiaofangshi: "纸质标", // 开标方式(可选)
    shifoufenbao: "false", // 是否分包(可选)
    shifoutuisongxuanchuan: "true", // 是否推送宣传(可选)
    caigourenmingcheng: null, // 采购人名称(可选)
@@ -54,8 +76,15 @@
  return ruleFormRef.value;
}
const handleChange = value => {
  console.log(value);
  newFormInline.value.xingzhengquyuName = selectedLabels.value;
};
const selectChange = value => {
  let obj = state.caigoufangshiList.find(item => {
    return item.value == value;
  });
  newFormInline.value.caigoufangshiName = obj.label;
};
defineExpose({ getRef });
onMounted(async () => {});
</script>
@@ -119,6 +148,7 @@
            v-model="newFormInline.caigoufangshi"
            placeholder="请选择采购方式"
            style="width: 240px"
            @change="selectChange"
          >
            <el-option
              v-for="item in state.caigoufangshiList"
@@ -140,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="请选择状态"
@@ -343,7 +373,10 @@
        </p>
      </re-col>
      <re-col :value="6" :xs="24" :sm="24">
        <el-form-item label="代理机构名称" prop="dailijigoumingcheng">
        <el-form-item
          label="代理机构名称"
          :prop="nowRole.code == 'DLJG' ? 'dailijigoumingcheng' : ''"
        >
          <el-input
            v-model="newFormInline.dailijigoumingcheng"
            clearable
@@ -352,7 +385,10 @@
        </el-form-item>
      </re-col>
      <re-col :value="6" :xs="24" :sm="24">
        <el-form-item label="联系人" prop="dailiLianxiren">
        <el-form-item
          label="联系人"
          :prop="nowRole.code == 'DLJG' ? 'dailiLianxiren' : ''"
        >
          <el-input
            v-model="newFormInline.dailiLianxiren"
            clearable
@@ -361,7 +397,10 @@
        </el-form-item>
      </re-col>
      <re-col :value="6" :xs="24" :sm="24">
        <el-form-item label="联系电话" prop="dailiLianxidianhua">
        <el-form-item
          label="联系电话"
          :prop="nowRole.code == 'DLJG' ? 'dailiLianxidianhua' : ''"
        >
          <el-input
            v-model="newFormInline.dailiLianxidianhua"
            clearable
@@ -370,7 +409,10 @@
        </el-form-item>
      </re-col>
      <re-col :value="6" :xs="24" :sm="24">
        <el-form-item label="电子邮箱" prop="dailiDianziyoujian">
        <el-form-item
          label="电子邮箱"
          :prop="nowRole.code == 'DLJG' ? 'dailiDianziyoujian' : ''"
        >
          <el-input
            v-model="newFormInline.dailiDianziyoujian"
            clearable
@@ -379,7 +421,10 @@
        </el-form-item>
      </re-col>
      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="通信地址" prop="dailiTongxindizhi">
        <el-form-item
          label="通信地址"
          :prop="nowRole.code == 'DLJG' ? 'dailiTongxindizhi' : ''"
        >
          <el-input
            v-model="newFormInline.dailiTongxindizhi"
            clearable
@@ -388,7 +433,10 @@
        </el-form-item>
      </re-col>
      <re-col :value="6" :xs="24" :sm="24">
        <el-form-item label="项目经理" prop="dailiXiangmujingli">
        <el-form-item
          label="项目经理"
          :prop="nowRole.code == 'DLJG' ? 'dailiXiangmujingli' : ''"
        >
          <el-input
            v-model="newFormInline.dailiXiangmujingli"
            clearable
@@ -397,7 +445,10 @@
        </el-form-item>
      </re-col>
      <re-col :value="6" :xs="24" :sm="24">
        <el-form-item label="联系电话" prop="dailijingliLianxidianhua">
        <el-form-item
          label="联系电话"
          :prop="nowRole.code == 'DLJG' ? 'dailijingliLianxidianhua' : ''"
        >
          <el-input
            v-model="newFormInline.dailijingliLianxidianhua"
            clearable