From 03c275439949875a857538df89a41696642c42b3 Mon Sep 17 00:00:00 2001
From: zhangwei <1504152376@qq.com>
Date: 星期一, 01 九月 2025 17:15:39 +0800
Subject: [PATCH] '首页公告与详情'

---
 src/views/system/dept/form.vue |   96 ++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 77 insertions(+), 19 deletions(-)

diff --git a/src/views/system/dept/form.vue b/src/views/system/dept/form.vue
index 98fd3eb..aebf30d 100644
--- a/src/views/system/dept/form.vue
+++ b/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,23 +8,46 @@
 import { Operation } from "@element-plus/icons-vue";
 import { getCaigoufangshiList } from "@/api/item/index";
 
-const { state } = useDept();
+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鍔ㄦ�佽幏鍙杔abel
+const selectedLabels = computed(() => {
+  return findLabelsByValues(
+    newFormInline.value.xingzhengquyu,
+    state.regionList
+  ).join("");
+});
 const props = withDefaults(defineProps<FormProps>(), {
   formInline: () => ({
+    id: "",
     projectCode: "", // 椤圭洰缂栧彿锛堝繀濉級
     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, // 閲囪喘浜哄悕绉帮紙鍙�夛級
-    xingzhengquyu: null, // 琛屾斂鍖哄煙锛堝彲閫夛級
+    xingzhengquyu: [], // 琛屾斂鍖哄煙锛堝彲閫夛級
     xingzhengquyuName: null, // 琛屾斂鍖哄煙鍚嶇О锛堝彲閫夛級
     jigoudaima: null, // 鏈烘瀯浠g爜锛堝彲閫夛級
     daimaleixing: null, // 浠g爜绫诲瀷锛堝彲閫夛級
@@ -52,6 +75,15 @@
 function getRef() {
   return ruleFormRef.value;
 }
+const handleChange = 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 () => {});
@@ -111,11 +143,12 @@
         </el-form-item>
       </re-col>
       <re-col :value="6" :xs="24" :sm="24">
-        <el-form-item label="閲囪喘鏂瑰紡">
+        <el-form-item label="閲囪喘鏂瑰紡" prop="caigoufangshi">
           <el-select
             v-model="newFormInline.caigoufangshi"
             placeholder="璇烽�夋嫨閲囪喘鏂瑰紡"
             style="width: 240px"
+            @change="selectChange"
           >
             <el-option
               v-for="item in state.caigoufangshiList"
@@ -137,16 +170,20 @@
         </el-form-item>
       </re-col>
       <re-col :value="6" :xs="24" :sm="24">
-        <el-form-item label="瀹氬埗瑙勫垝" prop="dingbiaoguize">
-          <el-checkbox-group
+        <el-form-item label="鎴愪氦鏂规硶" prop="dingbiaoguize">
+          <!-- <el-checkbox-group
             v-model="newFormInline.dingbiaoguize"
             placeholder="璇烽�夋嫨鐘舵��"
             clearable
             class="w-[100%]!"
           >
-            <el-checkbox label="鏈�浣庝环" :value="1" />
-            <el-checkbox label="缁煎悎璇勫垎" :value="0" />
-          </el-checkbox-group>
+            <el-checkbox label="鏈�浣庝环" value="鏈�浣庝环" />
+            <el-checkbox label="缁煎悎璇勫垎" value="缁煎悎璇勫垎" />
+          </el-checkbox-group> -->
+          <el-radio-group v-model="newFormInline.dingbiaoguize">
+            <el-radio value="鏈�浣庝环">鏈�浣庝环</el-radio>
+            <el-radio value="缁煎悎璇勫垎">缁煎悎璇勫垎</el-radio>
+          </el-radio-group>
         </el-form-item>
       </re-col>
       <re-col :value="6" :xs="24" :sm="24">
@@ -226,14 +263,14 @@
             class="w-full"
             :options="state.regionList"
             :props="{
-              value: 'id',
+              value: 'code',
               label: 'name',
-              emitPath: false,
               children: 'regions'
             }"
             clearable
             filterable
             placeholder="璇烽�夋嫨鍖哄煙"
+            @change="handleChange"
           />
         </el-form-item>
       </re-col>
@@ -336,7 +373,10 @@
         </p>
       </re-col>
       <re-col :value="6" :xs="24" :sm="24">
-        <el-form-item label="浠g悊鏈烘瀯鍚嶇О" prop="dailijigoumingcheng">
+        <el-form-item
+          label="浠g悊鏈烘瀯鍚嶇О"
+          :prop="nowRole.code == 'DLJG' ? 'dailijigoumingcheng' : ''"
+        >
           <el-input
             v-model="newFormInline.dailijigoumingcheng"
             clearable
@@ -345,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
@@ -354,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
@@ -363,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
@@ -372,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
@@ -381,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
@@ -390,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

--
Gitblit v1.9.1