From 8e5dffb54462aabf5bcf160277a661d65106de40 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期一, 09 三月 2026 17:59:08 +0800
Subject: [PATCH] 进销存系统升级 1.部署修改

---
 src/views/personnelManagement/monthlyStatistics/components/bankSettingDia.vue |  188 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 188 insertions(+), 0 deletions(-)

diff --git a/src/views/personnelManagement/monthlyStatistics/components/bankSettingDia.vue b/src/views/personnelManagement/monthlyStatistics/components/bankSettingDia.vue
new file mode 100644
index 0000000..b5fad15
--- /dev/null
+++ b/src/views/personnelManagement/monthlyStatistics/components/bankSettingDia.vue
@@ -0,0 +1,188 @@
+<template>
+  <FormDialog
+    v-model="dialogVisible"
+    operation-type="edit"
+    title="璁剧疆鍙戞斁閾惰涓嬫媺鏁版嵁"
+    width="640px"
+    @close="handleClose"
+    @confirm="handleConfirm"
+    @cancel="handleCancel"
+  >
+    <el-form ref="formRef" :model="form" label-position="top">
+      <el-row :gutter="16">
+        <el-col :span="24" style="display: flex; justify-content: end; gap: 10px;margin-bottom: 10px">
+          <el-button type="primary" @click="addBank">鏂板閾惰</el-button>
+          <el-button @click="resetToEmpty">娓呯┖</el-button>
+        </el-col>
+      </el-row>
+
+      <el-table :data="form.banks" border style="width: 100%">
+        <el-table-column label="閾惰鍚嶇О" min-width="260">
+          <template #default="{ row }">
+            <el-input
+              v-model="row.bankName"
+              placeholder="渚嬪锛氫腑鍥藉伐鍟嗛摱琛�"
+              clearable
+              maxlength="50"
+              show-word-limit
+            />
+          </template>
+        </el-table-column>
+        <el-table-column label="鎿嶄綔" width="90" align="center">
+          <template #default="{ $index }">
+            <el-button type="danger" link @click="removeBank($index)">鍒犻櫎</el-button>
+          </template>
+        </el-table-column>
+      </el-table>
+      <div style="margin-top: 10px; color: #909399; font-size: 12px">
+        鎻愮ず锛氳繖閲岀淮鎶ょ殑鏄�滃彂鏀鹃摱琛屸�濅笅鎷夋閫夐」鏁版嵁锛涗繚瀛樺悗鍦ㄦ柊寤�/缂栬緫宸ヨ祫琛ㄤ腑鍙�夋嫨銆�
+      </div>
+    </el-form>
+  </FormDialog>
+</template>
+
+<script setup>
+import { computed, reactive, ref, toRefs, watch, getCurrentInstance } from "vue";
+import FormDialog from "@/components/Dialog/FormDialog.vue";
+import { bankAdd, bankDelete, bankList, bankUpdate } from "@/api/personnelManagement/bank.js";
+
+const emit = defineEmits(["update:modelValue", "close", "saved"]);
+const props = defineProps({
+  modelValue: { type: Boolean, default: false },
+});
+
+const { proxy } = getCurrentInstance();
+
+const dialogVisible = computed({
+  get: () => props.modelValue,
+  set: (val) => emit("update:modelValue", val),
+});
+
+const formRef = ref(null);
+
+const data = reactive({
+  form: {
+    banks: [],
+  },
+});
+
+const { form } = toRefs(data);
+
+function newKey() {
+  return Math.random().toString(36).slice(2);
+}
+
+const addBank = () => {
+  form.value.banks.push({
+    _key: newKey(),
+    id: undefined,
+    bankName: "",
+    _originBankName: "",
+  });
+};
+
+const removeBank = (index) => {
+  const row = form.value.banks?.[index];
+  if (!row) return;
+  // 鏈惤搴撶殑琛岋細鐩存帴绉婚櫎
+  if (!row.id) {
+    form.value.banks.splice(index, 1);
+    return;
+  }
+  // 宸茶惤搴擄細璋冪敤鍚庣鍒犻櫎
+  bankDelete([row.id]).then(() => {
+    proxy?.$modal?.msgSuccess?.("鍒犻櫎鎴愬姛");
+    form.value.banks.splice(index, 1);
+    emit("saved");
+  });
+};
+
+const resetToEmpty = () => {
+  if (!form.value.banks?.length) return;
+  const ids = form.value.banks.map((b) => b?.id).filter(Boolean);
+  // 鑻ュ叏閮ㄦ槸鏈繚瀛樿锛屽垯浠呮竻绌烘湰鍦�
+  if (!ids.length) {
+    form.value.banks = [];
+    return;
+  }
+  proxy?.$modal
+    ?.confirm?.("纭畾娓呯┖鎵�鏈夐摱琛屽悧锛�")
+    .then(() => bankDelete(ids))
+    .then(() => {
+      proxy?.$modal?.msgSuccess?.("娓呯┖鎴愬姛");
+      form.value.banks = [];
+      emit("saved");
+    })
+    .catch(() => {});
+};
+
+const loadSetting = () => {
+  return bankList().then((res) => {
+    const list = Array.isArray(res?.data) ? res.data : [];
+    form.value.banks = list.map((b) => ({
+      _key: newKey(),
+      id: b?.id,
+      bankName: b?.bankName ?? "",
+      _originBankName: b?.bankName ?? "",
+    }));
+  });
+};
+
+const openDialog = () => {
+  loadSetting();
+};
+
+watch(
+  () => dialogVisible.value,
+  (val) => {
+    if (val) openDialog();
+  }
+);
+
+const handleConfirm = () => {
+  const names = (form.value.banks || [])
+    .map((b) => (b?.bankName == null ? "" : String(b.bankName).trim()))
+    .filter((n) => n !== "");
+  const unique = Array.from(new Set(names));
+  if (!unique.length) {
+    proxy?.$modal?.msgWarning?.("璇疯嚦灏戞柊澧炰竴涓摱琛岄�夐」");
+    return;
+  }
+  if (unique.length !== names.length) {
+    proxy?.$modal?.msgWarning?.("閾惰鍚嶇О涓嶅彲閲嶅");
+    return;
+  }
+
+  const rows = form.value.banks.map((b) => ({
+    ...b,
+    bankName: b?.bankName == null ? "" : String(b.bankName).trim(),
+  }));
+
+  const toAdd = rows.filter((b) => !b.id && b.bankName);
+  const toUpdate = rows.filter((b) => b.id && b.bankName && b.bankName !== (b._originBankName ?? ""));
+
+  Promise.all([
+    ...toAdd.map((b) => bankAdd({ bankName: b.bankName })),
+    ...toUpdate.map((b) => bankUpdate({ id: b.id, bankName: b.bankName })),
+  ])
+    .then(() => loadSetting())
+    .then(() => {
+      proxy?.$modal?.msgSuccess?.("淇濆瓨鎴愬姛");
+      dialogVisible.value = false;
+      emit("saved", { options: unique });
+    });
+};
+
+const handleCancel = () => {
+  dialogVisible.value = false;
+};
+
+const handleClose = () => {
+  emit("close");
+};
+
+defineExpose({ openDialog });
+</script>
+
+<style scoped></style>
+

--
Gitblit v1.9.3