From 0bdc9b5ebb72ef4a25379d261c211ff9c0ca9b13 Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期四, 10 九月 2026 17:37:42 +0800
Subject: [PATCH] feat: 新增客户拜访记录功能
---
src/views/collaborativeApproval/customerVisit/index.vue | 165 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 164 insertions(+), 1 deletions(-)
diff --git a/src/views/collaborativeApproval/customerVisit/index.vue b/src/views/collaborativeApproval/customerVisit/index.vue
index 68396eb..69cae48 100644
--- a/src/views/collaborativeApproval/customerVisit/index.vue
+++ b/src/views/collaborativeApproval/customerVisit/index.vue
@@ -25,6 +25,9 @@
<el-form-item>
<el-button type="primary" @click="handleQuery">鎼滅储</el-button>
</el-form-item>
+ <el-form-item>
+ <el-button type="primary" @click="openAddDialog">鏂板</el-button>
+ </el-form-item>
</el-form>
</div>
<div class="table_list">
@@ -124,13 +127,73 @@
</div>
</template>
</el-dialog>
+ <!-- 鏂板寮圭獥 -->
+ <el-dialog
+ v-model="addVisible"
+ title="鏂板瀹㈡埛鎷滆璁板綍"
+ width="600px"
+ @close="closeAddDialog"
+ >
+ <el-form ref="addFormRef" :model="addForm" :rules="addRules" label-width="100px">
+ <el-form-item label="瀹㈡埛鍚嶇О" prop="customerId">
+ <el-select
+ v-model="addForm.customerId"
+ filterable
+ placeholder="璇烽�夋嫨瀹㈡埛"
+ style="width: 100%"
+ @change="handleCustomerChange"
+ >
+ <el-option
+ v-for="item in customerOptions"
+ :key="item.id"
+ :label="item.customerName"
+ :value="item.id"
+ />
+ </el-select>
+ </el-form-item>
+ <el-form-item label="鑱旂郴浜�" prop="contact">
+ <el-input v-model="addForm.contact" placeholder="璇疯緭鍏ヨ仈绯讳汉" />
+ </el-form-item>
+ <el-form-item label="鑱旂郴鐢佃瘽" prop="contactPhone">
+ <el-input v-model="addForm.contactPhone" placeholder="璇疯緭鍏ヨ仈绯荤數璇�" />
+ </el-form-item>
+ <el-form-item label="鎷滆鐩殑" prop="purposeVisit">
+ <el-input v-model="addForm.purposeVisit" placeholder="璇疯緭鍏ユ嫓璁跨洰鐨�" />
+ </el-form-item>
+ <el-form-item label="鎷滆鏃堕棿" prop="purposeDate">
+ <el-date-picker
+ v-model="addForm.purposeDate"
+ type="date"
+ value-format="YYYY-MM-DD"
+ placeholder="璇烽�夋嫨鎷滆鏃堕棿"
+ style="width: 100%"
+ />
+ </el-form-item>
+ <el-form-item label="鎷滆鍦扮偣" prop="visitAddress">
+ <el-input v-model="addForm.visitAddress" placeholder="璇疯緭鍏ユ嫓璁垮湴鐐�" />
+ </el-form-item>
+ <el-form-item label="鎷滆浜�" prop="visitingPeople">
+ <el-input v-model="addForm.visitingPeople" placeholder="璇疯緭鍏ユ嫓璁夸汉" />
+ </el-form-item>
+ <el-form-item label="澶囨敞" prop="remark">
+ <el-input v-model="addForm.remark" type="textarea" :rows="3" placeholder="璇疯緭鍏ュ娉�" />
+ </el-form-item>
+ </el-form>
+ <template #footer>
+ <div class="dialog-footer">
+ <el-button type="primary" :loading="addSubmitting" @click="submitAdd">纭</el-button>
+ <el-button @click="closeAddDialog">鍙栨秷</el-button>
+ </div>
+ </template>
+ </el-dialog>
</div>
</template>
<script setup>
import { ref, reactive, onMounted, getCurrentInstance } from 'vue'
import pagination from '@/components/PIMTable/Pagination.vue'
-import { getVisitRecords } from '@/api/collaborativeApproval/customerVisit.js'
+import { getVisitRecords, addVisitRecord } from '@/api/collaborativeApproval/customerVisit.js'
+import { getAllCustomerList } from '@/api/customerService/index.js'
const { proxy } = getCurrentInstance()
const tableData = ref([])
@@ -194,6 +257,106 @@
detailForm.value = {}
}
+// 鏂板鐩稿叧
+const addVisible = ref(false)
+const addSubmitting = ref(false)
+const addFormRef = ref(null)
+const customerOptions = ref([])
+const addForm = reactive({
+ customerId: '',
+ customerName: '',
+ contact: '',
+ contactPhone: '',
+ purposeVisit: '',
+ purposeDate: '',
+ visitAddress: '',
+ visitingPeople: '',
+ remark: '',
+})
+const addRules = {
+ customerId: [{ required: true, message: '璇烽�夋嫨瀹㈡埛', trigger: 'change' }],
+ purposeVisit: [{ required: true, message: '璇疯緭鍏ユ嫓璁跨洰鐨�', trigger: 'blur' }],
+ purposeDate: [{ required: true, message: '璇烽�夋嫨鎷滆鏃堕棿', trigger: 'change' }],
+ visitingPeople: [{ required: true, message: '璇疯緭鍏ユ嫓璁夸汉', trigger: 'blur' }],
+}
+
+// 鎵撳紑鏂板寮圭獥
+const openAddDialog = () => {
+ resetAddForm()
+ addVisible.value = true
+ // 鎳掑姞杞藉鎴蜂笅鎷夋暟鎹�
+ if (!customerOptions.value.length) {
+ getCustomerOptions()
+ }
+}
+
+// 鑾峰彇瀹㈡埛涓嬫媺鏁版嵁
+const getCustomerOptions = () => {
+ getAllCustomerList({ current: 1, size: 1000, total: 0 }).then((res) => {
+ customerOptions.value = (res.data?.records || []).map((item) => ({
+ id: item.id,
+ customerName: item.customerName,
+ contact: item.contactPerson,
+ contactPhone: item.contactPhone,
+ companyAddress: item.companyAddress,
+ }))
+ })
+}
+
+// 閫夋嫨瀹㈡埛鍚庡甫鍑鸿仈绯讳汉鍜岃仈绯荤數璇�
+const handleCustomerChange = (customerId) => {
+ const customer = customerOptions.value.find((item) => item.id === customerId)
+ addForm.customerName = customer?.customerName || ''
+ addForm.contact = customer?.contact || ''
+ addForm.contactPhone = customer?.contactPhone || ''
+ addForm.visitAddress = customer?.companyAddress || ''
+}
+
+// 閲嶇疆鏂板琛ㄥ崟
+const resetAddForm = () => {
+ Object.assign(addForm, {
+ customerId: '',
+ customerName: '',
+ contact: '',
+ contactPhone: '',
+ purposeVisit: '',
+ purposeDate: '',
+ visitAddress: '',
+ visitingPeople: '',
+ remark: '',
+ })
+ addFormRef.value?.resetFields()
+}
+
+// 鍏抽棴鏂板寮圭獥
+const closeAddDialog = () => {
+ addVisible.value = false
+ resetAddForm()
+}
+
+// 鎻愪氦鏂板
+const submitAdd = () => {
+ addFormRef.value.validate((valid) => {
+ if (!valid) return
+ const { customerId, ...data } = addForm
+ addSubmitting.value = true
+ addVisitRecord(data)
+ .then((res) => {
+ addSubmitting.value = false
+ if (res.code === 200) {
+ proxy.$modal.msgSuccess('鏂板鎴愬姛')
+ closeAddDialog()
+ handleQuery()
+ } else {
+ proxy.$modal.msgError(res.msg || '鏂板澶辫触')
+ }
+ })
+ .catch(() => {
+ addSubmitting.value = false
+ })
+ })
+}
+
onMounted(() => {
getList()
})
--
Gitblit v1.9.3