From b58f53769f004fb0ba6b5aedf55ef602850c7c97 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期日, 20 九月 2026 15:46:05 +0800
Subject: [PATCH] 天津豹鸣app 1.部署修改

---
 src/components/FormPicker.vue |  184 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 184 insertions(+), 0 deletions(-)

diff --git a/src/components/FormPicker.vue b/src/components/FormPicker.vue
new file mode 100644
index 0000000..e6ad427
--- /dev/null
+++ b/src/components/FormPicker.vue
@@ -0,0 +1,184 @@
+<!--
+  閫氱敤琛ㄥ崟閫夋嫨椤�
+  鏀惧湪 u-form-item 閲屼娇鐢紝鏇夸唬鍚勯〉闈㈡墜鍐欑殑銆屽彧璇� u-input + up-action-sheet/up-datetime-picker銆嶇粍鍚堛��
+
+  涓嬫媺锛�
+    <u-form-item label="鎵�灞為」鐩�" prop="projectId" required border-bottom>
+      <FormPicker v-model="form.projectId" :display-text="form.projectName"
+                  type="select" title="閫夋嫨椤圭洰" :options="projectOptions"
+                  @change="onProjectChange" />
+    </u-form-item>
+
+  鏃ユ湡锛�
+    <u-form-item label="绔嬫鏃堕棿" prop="filingDate" required border-bottom>
+      <FormPicker v-model="form.filingDate" type="date" placeholder="璇烽�夋嫨绔嬫鏃堕棿" />
+    </u-form-item>
+
+  options 鏀寔涓夌鍐欐硶锛屽彇鍊间紭鍏堢骇锛�
+    鏄剧ず鏂囨湰  item.name 鈫� item.text 鈫� item.label 鈫� item.displayText
+    瀹為檯鍊�    item.value 鈫� item.id 鈫� item.code
+  涔熷彲浠ョ敤 label-key / value-key 鏄惧紡鎸囧畾銆�
+-->
+<template>
+  <view class="form-picker">
+    <u-input :modelValue="text"
+             :placeholder="placeholder"
+             :disabled="disabled"
+             :readonly="true"
+             :clearable="clearable && !disabled && !readonly"
+             @click="open"
+             @update:modelValue="onInputUpdate">
+      <template #suffix>
+        <u-icon v-if="!disabled && !readonly"
+                name="arrow-right"
+                color="#c0c4cc"
+                @click="open"></u-icon>
+      </template>
+    </u-input>
+
+    <up-action-sheet v-if="type === 'select'"
+                     :show="showSheet"
+                     :actions="actions"
+                     :title="title"
+                     @select="onSelect"
+                     @close="showSheet = false"></up-action-sheet>
+
+    <up-datetime-picker v-if="type === 'date'"
+                        :show="showPicker"
+                        v-model="pickerValue"
+                        :mode="dateMode"
+                        @confirm="onDateConfirm"
+                        @cancel="showPicker = false"></up-datetime-picker>
+  </view>
+</template>
+
+<script setup>
+  import { computed, ref } from "vue";
+  import { formatDateToYMD } from "@/utils/ruoyi";
+  import { parseDate } from "@/utils/warning";
+
+  const props = defineProps({
+    modelValue: {
+      type: [String, Number, Boolean, null],
+      default: "",
+    },
+    // select 涓嬫媺 | date 鏃ユ湡
+    type: {
+      type: String,
+      default: "select",
+    },
+    // 鐩存帴鎸囧畾鏄剧ず鏂囨湰锛涗笉浼犲垯鎸� options 鍙嶆煡
+    displayText: {
+      type: String,
+      default: "",
+    },
+    options: {
+      type: Array,
+      default: () => [],
+    },
+    title: {
+      type: String,
+      default: "",
+    },
+    placeholder: {
+      type: String,
+      default: "璇烽�夋嫨",
+    },
+    labelKey: {
+      type: String,
+      default: "",
+    },
+    valueKey: {
+      type: String,
+      default: "",
+    },
+    // 鏃ユ湡绮惧害锛歞ate | datetime | time | year-month
+    dateMode: {
+      type: String,
+      default: "date",
+    },
+    disabled: {
+      type: Boolean,
+      default: false,
+    },
+    readonly: {
+      type: Boolean,
+      default: false,
+    },
+    clearable: {
+      type: Boolean,
+      default: true,
+    },
+  });
+
+  const emit = defineEmits(["update:modelValue", "change"]);
+
+  const showSheet = ref(false);
+  const showPicker = ref(false);
+  const pickerValue = ref(Date.now());
+
+  const optionValue = item =>
+    props.valueKey
+      ? item?.[props.valueKey]
+      : (item?.value ?? item?.id ?? item?.code);
+
+  const optionLabel = item =>
+    props.labelKey
+      ? item?.[props.labelKey]
+      : (item?.name ?? item?.text ?? item?.label ?? item?.displayText ?? "");
+
+  const actions = computed(() =>
+    (props.options || []).map(item => ({
+      text: String(optionLabel(item) ?? ""),
+      value: optionValue(item),
+      data: item,
+    }))
+  );
+
+  const text = computed(() => {
+    if (props.displayText) return props.displayText;
+    if (props.modelValue === undefined || props.modelValue === null) return "";
+    if (props.type === "date") return String(props.modelValue);
+    const matched = (props.options || []).find(
+      item => String(optionValue(item)) === String(props.modelValue)
+    );
+    return matched ? String(optionLabel(matched)) : "";
+  });
+
+  const open = () => {
+    if (props.disabled || props.readonly) return;
+    if (props.type === "select") {
+      showSheet.value = true;
+      return;
+    }
+    const base = parseDate(props.modelValue);
+    pickerValue.value = base ? base.getTime() : Date.now();
+    showPicker.value = true;
+  };
+
+  // 鐢ㄦ埛鐐瑰嚮 u-input 鐨勬竻闄ゆ寜閽椂锛屾妸绌哄�煎悓姝ュ嚭鍘�
+  const onInputUpdate = value => {
+    if (value !== "" && value !== undefined) return;
+    emit("update:modelValue", "");
+    emit("change", "", null);
+  };
+
+  const onSelect = item => {
+    showSheet.value = false;
+    emit("update:modelValue", item.value);
+    emit("change", item.value, item.data);
+  };
+
+  const onDateConfirm = e => {
+    showPicker.value = false;
+    const value = formatDateToYMD(e.value);
+    emit("update:modelValue", value);
+    emit("change", value, null);
+  };
+</script>
+
+<style scoped lang="scss">
+  .form-picker {
+    width: 100%;
+  }
+</style>

--
Gitblit v1.9.3