From 05a671e663de70616ab2a0b6ff269bfd44d1b75a Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期一, 22 九月 2025 10:03:14 +0800
Subject: [PATCH] 部署修改
---
src/views/basicInformation/mould/coal.vue | 320 ++++++++++++++++++-----------------------------------
1 files changed, 110 insertions(+), 210 deletions(-)
diff --git a/src/views/basicInformation/mould/coal.vue b/src/views/basicInformation/mould/coal.vue
index 7c8a9c7..5702bca 100644
--- a/src/views/basicInformation/mould/coal.vue
+++ b/src/views/basicInformation/mould/coal.vue
@@ -1,159 +1,47 @@
<template>
-<<<<<<< HEAD
- <div>
- <el-dialog
- v-model="dialogVisible"
- :title="title"
- width="800"
- :close-on-click-modal="false"
- :before-close="handleClose"
- >
- <el-form
- ref="formRef"
- style="max-width: 600px; margin: 0 auto"
- :model="formData"
- :rules="rules"
- label-width="auto"
- >
- <el-form-item label="鍗¤儭" prop="supplierName">
- <el-input
- v-model="formData.supplierName"
- placeholder="璇疯緭鍏ヤ緵璐у晢鍚嶇О"
- />
- </el-form-item>
- <el-form-item label="绾崇◣浜鸿瘑鍒彿" prop="identifyNumber">
- <el-input
- v-model="formData.identifyNumber"
- placeholder="璇疯緭鍏ョ撼绋庝汉璇嗗埆鍙�"
- />
- </el-form-item>
- <el-form-item label="缁忚惀鍦板潃" prop="address">
- <el-select v-model="formData.address" placeholder="璇烽�夋嫨缁忚惀鍦板潃">
- <el-option label="Zone one" value="shanghai" />
- <el-option label="Zone two" value="beijing" />
- </el-select>
- </el-form-item>
- <el-form-item label="閾惰璐︽埛" prop="bankAccount">
- <el-input v-model="formData.bankAccount" placeholder="璇疯緭鍏ラ摱琛岃处鎴�" />
- </el-form-item>
- <el-form-item>
- <el-button type="primary" @click="submitForm">
- 纭畾
- </el-button>
- </el-form-item>
- </el-form>
- </el-dialog>
- </div>
-</template>
-
-<script setup>
-import { ref, watch ,defineProps } from 'vue'
-
-const props = defineProps({
- beforeClose: {
- type: Function,
- default: () => {}
- },
- form: {
- type: Object,
- default: () => ({})
- },
- addOrEdit: {
- type: String,
- default: 'add'
- },
- title: {
- type: String,
- default: ''
- },
-})
-
-const emit = defineEmits(['submit', 'handleBeforeClose','update:coalDialogFormVisible'])
-
-// 琛ㄥ崟寮曠敤
-const formRef = ref(null)
-// 琛ㄥ崟鏁版嵁
-const formData = ref({ ...props.form })
-// 寮圭獥鍙鎬�
-const dialogVisible = defineModel("coalDialogFormVisible",{required:true,type:Boolean})
-
-// 鐩戝惉澶栭儴浼犲叆鐨勮〃鍗曟暟鎹彉鍖�
-watch(() => props.form, (newVal) => {
- formData.value = { ...newVal }
-}, { deep: true })
-
-// 鐩戝惉鍐呴儴寮圭獥鐘舵�佸彉鍖�
-watch(() => dialogVisible.value, (newVal) => {
- emit('update:coalDialogFormVisible', newVal)
-})
-
-// 鎻愪氦琛ㄥ崟
-const submitForm = async () => {
- if (!formRef.value) return
- await formRef.value.validate((valid, fields) => {
- if (valid) {
- emit('submit', formData.value)
- }
- })
-}
-// 鍙栨秷琛ㄥ崟
-const cancelForm = () => {
- emit('update:coalDialogFormVisible', false)
- formData.value = {}
-}
-// 閲嶇疆琛ㄥ崟
-const resetForm = () => {
- if (!formRef.value) return
- formRef.value.resetFields()
-}
-// 鍏抽棴寮圭獥
-const handleClose = () => {
- // 瑙﹀彂鐖剁粍浠剁殑鍏抽棴鍑芥暟
- emit("handleBeforeClose")
- emit('update:coalDialogFormVisible', false)
-}
-=======
<div>
<el-dialog
- v-model="dialogVisible"
- :title="title"
- width="800"
- :close-on-click-modal="false"
- :before-close="handleClose"
+ v-model="dialogVisible"
+ :title="title"
+ width="500"
+ :close-on-click-modal="false"
+ :before-close="handleClose"
>
<el-form
- ref="formRef"
- style="max-width: 600px; margin: 0 auto"
- :model="formData"
- :rules="rules"
- label-width="auto"
+ ref="formRef"
+ style="max-width: 600px; margin: 0 auto"
+ :model="formData"
+ :rules="rules"
+ label-width="120px"
>
- <el-form-item label="鍗¤儭" prop="supplierName">
+ <el-form-item label="鐓ょ鍚嶇О" prop="coal">
<el-input
- v-model="formData.supplierName"
- placeholder="璇疯緭鍏ヤ緵璐у晢鍚嶇О"
+ v-model="formData.coal"
+ placeholder="璇疯緭鍏ョ叅绉嶅悕绉�"
+ :disabled="isViewMode"
/>
</el-form-item>
- <el-form-item label="绾崇◣浜鸿瘑鍒彿" prop="identifyNumber">
+ <el-form-item label="缁存姢浜哄鍚�" prop="maintainerId">
<el-input
- v-model="formData.identifyNumber"
- placeholder="璇疯緭鍏ョ撼绋庝汉璇嗗埆鍙�"
+ :value="userStore.nickName || ''"
+ placeholder="缁存姢浜哄鍚�"
+ disabled
/>
</el-form-item>
- <el-form-item label="缁忚惀鍦板潃" prop="address">
- <el-select v-model="formData.address" placeholder="璇烽�夋嫨缁忚惀鍦板潃">
- <el-option label="Zone one" value="shanghai" />
- <el-option label="Zone two" value="beijing" />
- </el-select>
- </el-form-item>
- <el-form-item label="閾惰璐︽埛" prop="bankAccount">
+ <el-form-item label="缁存姢鏃ユ湡" prop="maintenanceDate">
<el-input
- v-model="formData.bankAccount"
- placeholder="璇疯緭鍏ラ摱琛岃处鎴�"
+ :value="getCurrentDate()"
+ placeholder="缁存姢鏃ユ湡"
+ disabled
/>
</el-form-item>
- <el-form-item>
- <el-button type="primary" @click="submitForm"> 纭畾 </el-button>
+
+ <el-form-item class="dialog-footer">
+ <el-button v-if="addOrEdit === 'edit'" @click="resetForm">閲嶇疆</el-button>
+ <el-button v-if="addOrEdit === 'add'||addOrEdit.includes('viewRow')" @click="cancelForm">鍙栨秷</el-button>
+ <el-button type="primary" @click="submitForm" v-if="!isViewMode">
+ 纭畾
+ </el-button>
</el-form-item>
</el-form>
</el-dialog>
@@ -161,110 +49,122 @@
</template>
<script setup>
-import { ref, watch, defineProps } from "vue";
+import {ref, watch, defineProps, reactive, onMounted} from 'vue'
+import {addOrEditCoalInfo} from '@/api/basicInformation/coal'
+import useUserStore from '@/store/modules/user'
+
+const userStore = useUserStore()
const props = defineProps({
beforeClose: {
type: Function,
- default: () => {},
+ default: () => {
+ }
},
form: {
type: Object,
- default: () => ({}),
+ default: () => ({})
},
addOrEdit: {
type: String,
- default: "add",
+ default: 'add'
},
title: {
type: String,
- default: "",
+ default: ''
},
-});
-
-const emit = defineEmits([
- "submit",
- "handleBeforeClose",
- "update:coalDialogFormVisible",
-]);
-
-// 琛ㄥ崟寮曠敤
-const formRef = ref(null);
-// 琛ㄥ崟鏁版嵁
-const formData = ref({ ...props.form });
-// 寮圭獥鍙鎬�
-const dialogVisible = defineModel("coalDialogFormVisible", {
+})
+const isViewMode = computed(() => props.addOrEdit.includes("viewRow"));
+const copyForm = defineModel("copyForm", {
required: true,
- type: Boolean,
+ type: Object,
});
+
+const emit = defineEmits(['submit', 'handleBeforeClose', 'update:coalDialogFormVisible'])
+// 琛ㄥ崟寮曠敤
+const formRef = ref(null)
+// 琛ㄥ崟鏁版嵁
+const formData = ref({...props.form})
+// 寮圭獥鍙鎬�
+const dialogVisible = defineModel("coalDialogFormVisible", {required: true, type: Boolean})
// 鐩戝惉澶栭儴浼犲叆鐨勮〃鍗曟暟鎹彉鍖�
-watch(
- () => props.form,
- (newVal) => {
- formData.value = { ...newVal };
- },
- { deep: true }
-);
+watch(() => props.form, (newVal) => {
+ formData.value = {...newVal}
+ // 濡傛灉鏄柊澧炴ā寮忥紝璁剧疆缁存姢浜�
+ if (props.addOrEdit === 'add' && userStore.id) {
+ formData.value.maintainerId = userStore.id
+ }
+}, {deep: true})
// 鐩戝惉鍐呴儴寮圭獥鐘舵�佸彉鍖�
-watch(
- () => dialogVisible.value,
- (newVal) => {
- emit("update:coalDialogFormVisible", newVal);
- }
-);
+watch(() => dialogVisible.value, (newVal) => {
+ emit('update:coalDialogFormVisible', newVal)
+})
// 鎻愪氦琛ㄥ崟
const submitForm = async () => {
- if (!formRef.value) return;
- await formRef.value.validate((valid, fields) => {
+ if (!formRef.value) return
+ await formRef.value.validate(async (valid, fields) => {
if (valid) {
- emit("submit", formData.value);
+
+ // 纭繚maintainerId鏈夊��
+ if (!formData.value.maintainerId) {
+ formData.value.maintainerId = userStore.id
+ }
+
+ // 璁剧疆缁存姢鏃ユ湡
+ formData.value.maintenanceDate = getCurrentDate()
+
+ let result = await addOrEditCoalInfo({
+ ...formData.value,
+ })
+ let obj = {
+ title: props.title,
+ result,
+ }
+ emit('submit', obj)
}
- });
-};
+ })
+}
// 鍙栨秷琛ㄥ崟
const cancelForm = () => {
- emit("update:coalDialogFormVisible", false);
- formData.value = {};
-};
+ emit('update:coalDialogFormVisible', false)
+ formData.value = {}
+}
// 閲嶇疆琛ㄥ崟
const resetForm = () => {
- if (!formRef.value) return;
- formRef.value.resetFields();
-};
+ if (!formRef.value) return
+ formData.value = JSON.parse(JSON.stringify(copyForm.value));
+ // formRef.value.resetFields()
+}
// 鍏抽棴寮圭獥
const handleClose = () => {
// 瑙﹀彂鐖剁粍浠剁殑鍏抽棴鍑芥暟
- emit("handleBeforeClose");
- emit("update:coalDialogFormVisible", false);
-};
->>>>>>> master
+ emit("handleBeforeClose")
+ emit('update:coalDialogFormVisible', false)
+}
const rules = reactive({
- supplierName: [
- { required: true, message: "璇疯緭鍏ヤ緵璐у晢鍚嶇О", trigger: "blur" },
- ],
- identifyNumber: [
- { required: true, message: "璇锋纭緭鍏ョ撼绋庝汉璇嗗埆鍙�", trigger: "blur" },
- { min: 17, max: 20, message: "璇疯緭鍏�17-20浣嶇撼绋庝汉璇嗗埆鍙�", trigger: "blur" },
- ],
- address: [
- {
- required: true,
- message: "璇烽�夋嫨缁忚惀鍦板潃",
- trigger: "change",
- },
- ],
- bankAccount: [{ required: true, message: "璇疯緭鍏ラ摱琛岃处鎴�", trigger: "blur" }],
- bank: [{ required: true, message: "璇疯緭鍏ュ紑鎴疯", trigger: "blur" }],
- contacts: [{ required: true, message: "璇疯緭鍏ュ紑鎴疯", trigger: "blur" }],
- contactsPhone: [
- { required: true, message: "璇疯緭鍏ヨ仈绯讳汉", trigger: "blur" },
- { min: 11, max: 11, message: "璇疯緭鍏�11浣嶈仈绯讳汉鐢佃瘽", trigger: "blur" },
+ coal: [
+ {required: true, message: "璇疯緭鍏ョ叅绉嶅悕绉�", trigger: "blur"},
],
});
+
+// 鑾峰彇褰撳墠鏃ユ湡骞舵牸寮忓寲涓� YYYY-MM-DD
+function getCurrentDate() {
+ const today = new Date();
+ const year = today.getFullYear();
+ const month = String(today.getMonth() + 1).padStart(2, '0'); // 鏈堜唤浠�0寮�濮�
+ const day = String(today.getDate()).padStart(2, '0');
+ return `${year}-${month}-${day}`;
+}
</script>
-<style lang="sass" scoped>
+<style lang="scss" scoped>
+.dialog-footer {
+ display: flex;
+ margin-top: 20px;
+ flex-direction: column;
+ align-items: flex-end;
+}
</style>
\ No newline at end of file
--
Gitblit v1.9.3