From a2d9fcb259621829bf4ec9680b5dbeac95ab5805 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 15 十月 2026 16:19:54 +0800
Subject: [PATCH] fix(crm): 销售目标达成分析默认查当前季度
---
src/views/mes/dv/spare/modules/form.vue | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 47 insertions(+), 0 deletions(-)
diff --git a/src/views/mes/dv/spare/modules/form.vue b/src/views/mes/dv/spare/modules/form.vue
new file mode 100644
index 0000000..dcea6a0
--- /dev/null
+++ b/src/views/mes/dv/spare/modules/form.vue
@@ -0,0 +1,47 @@
+<script setup lang="ts">
+import type { SpareSave } from '#/api/mes/dv/spare';
+import type { FormInstance } from 'ant-design-vue';
+import { reactive, ref } from 'vue';
+import { useVbenModal } from '@vben/common-ui';
+import { Alert, Form, Input, InputNumber, Select } from 'ant-design-vue';
+import { createSpare, getSpare, updateSpare } from '#/api/mes/dv/spare';
+const emit = defineEmits(['success']);
+const formRef = ref<FormInstance>();
+const saving = ref(false);
+const model = reactive<SpareSave>({ code: '', name: '', unit: '浠�', initialQuantity: 0, safetyQuantity: 0, status: 0 });
+const required = [{ required: true, message: '璇峰~鍐欐椤�' }];
+const [Modal, modalApi] = useVbenModal({
+ onBeforeClose: () => !saving.value,
+ async onOpenChange(open) {
+ if (!open) return;
+ Object.assign(model, { id: undefined, code: '', name: '', specification: '', unit: '浠�', location: '', initialQuantity: 0, safetyQuantity: 0, status: 0, remark: '' });
+ formRef.value?.clearValidate();
+ const { id } = modalApi.getData<{ id?: number }>();
+ if (id) { modalApi.lock(); try { Object.assign(model, await getSpare(id)); } finally { modalApi.unlock(); } }
+ },
+ async onConfirm() {
+ if (saving.value) return;
+ await formRef.value?.validate();
+ saving.value = true; modalApi.lock();
+ try { await (model.id ? updateSpare(model) : createSpare(model)); emit('success'); saving.value = false; await modalApi.close(); }
+ finally { saving.value = false; modalApi.unlock(); }
+ },
+});
+</script>
+<template>
+ <Modal :title="model.id ? '缂栬緫澶囦欢' : '鏂板澶囦欢'" class="w-full sm:w-[640px]">
+ <Alert class="mb-4" type="info" :message="model.id ? '搴撳瓨閫氳繃鍏ュ簱銆侀鐢ㄥ拰閫�鍥炲彉鏇淬�傚凡鏈夋祦姘村悗涓嶅彲淇敼璁¢噺鍗曚綅銆�' : '鍒濆搴撳瓨鐧昏鍚庝細淇濈暀娴佹按锛屽悗缁ˉ璐ц浣跨敤鍏ュ簱銆�'" />
+ <Form ref="formRef" :model="model" layout="vertical" class="grid grid-cols-1 gap-x-4 sm:grid-cols-2">
+ <Form.Item label="澶囦欢缂栫爜" name="code" :rules="required"><Input v-model:value="model.code" :maxlength="64" /></Form.Item>
+ <Form.Item label="澶囦欢鍚嶇О" name="name" :rules="required"><Input v-model:value="model.name" :maxlength="128" /></Form.Item>
+ <Form.Item label="瑙勬牸鍨嬪彿" name="specification"><Input v-model:value="model.specification" :maxlength="255" /></Form.Item>
+ <Form.Item label="璁¢噺鍗曚綅" name="unit" :rules="required"><Input v-model:value="model.unit" :maxlength="32" /></Form.Item>
+ <Form.Item label="瀛樻斁浣嶇疆" name="location"><Input v-model:value="model.location" :maxlength="128" /></Form.Item>
+ <Form.Item label="瀹夊叏搴撳瓨" name="safetyQuantity" :rules="required"><InputNumber v-model:value="model.safetyQuantity" :min="0" :precision="3" class="w-full" /></Form.Item>
+ <Form.Item v-if="!model.id" label="鍒濆搴撳瓨" name="initialQuantity" :rules="required"><InputNumber v-model:value="model.initialQuantity" :min="0" :precision="3" class="w-full" /></Form.Item>
+ <Form.Item label="鐘舵��" name="status"><Select v-model:value="model.status" :options="[{label:'鍚敤',value:0},{label:'鍋滅敤',value:1}]" /></Form.Item>
+ <Form.Item label="澶囨敞" name="remark" class="sm:col-span-2"><Input.TextArea v-model:value="model.remark" :maxlength="500" :rows="3" /></Form.Item>
+ </Form>
+ </Modal>
+</template>
+
--
Gitblit v1.9.3