From 409a6c46741422f0d6dc00acc38b5f7dc1f35e9f Mon Sep 17 00:00:00 2001
From: tuqin <tuqin@tuqin.cn>
Date: 星期四, 24 九月 2026 10:53:07 +0800
Subject: [PATCH] feat: 现场需求前端改动

---
 src/views/collaborativeApproval/customerVisit/index.vue |  176 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 174 insertions(+), 2 deletions(-)

diff --git a/src/views/collaborativeApproval/customerVisit/index.vue b/src/views/collaborativeApproval/customerVisit/index.vue
index 68396eb..800ddab 100644
--- a/src/views/collaborativeApproval/customerVisit/index.vue
+++ b/src/views/collaborativeApproval/customerVisit/index.vue
@@ -24,6 +24,7 @@
         </el-form-item>
         <el-form-item>
           <el-button type="primary" @click="handleQuery">鎼滅储</el-button>
+          <el-button type="primary" @click="handleAdd">鏂板</el-button>
         </el-form-item>
       </el-form>
     </div>
@@ -43,9 +44,11 @@
         <el-table-column label="鎷滆鏃堕棿" prop="purposeDate" width="180" show-overflow-tooltip />
         <el-table-column label="鎷滆鍦扮偣" prop="visitAddress" min-width="200" show-overflow-tooltip />
         <el-table-column label="鎷滆浜�" prop="visitingPeople" width="120" show-overflow-tooltip />
-        <el-table-column fixed="right" label="鎿嶄綔" width="100" align="center">
+        <el-table-column fixed="right" label="鎿嶄綔" width="160" align="center">
           <template #default="scope">
             <el-button link type="primary" size="small" @click="viewDetail(scope.row)" style="color: #67C23A">鏌ョ湅</el-button>
+            <el-button link type="primary" size="small" @click="handleEdit(scope.row)">缂栬緫</el-button>
+            <el-button link type="danger" size="small" @click="handleDelete(scope.row)">鍒犻櫎</el-button>
           </template>
         </el-table-column>
       </el-table>
@@ -124,13 +127,73 @@
         </div>
       </template>
     </el-dialog>
+
+    <!-- 鏂板/缂栬緫寮圭獥 -->
+    <el-dialog
+      v-model="formVisible"
+      :title="formTitle"
+      width="600px"
+      @close="closeForm"
+    >
+      <el-form ref="formRef" :model="form" :rules="rules" label-width="100px">
+        <el-row :gutter="20">
+          <el-col :span="12">
+            <el-form-item label="瀹㈡埛鍚嶇О锛�" prop="customerName">
+              <el-input v-model="form.customerName" placeholder="璇疯緭鍏ュ鎴峰悕绉�" clearable />
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="鑱旂郴浜猴細" prop="contact">
+              <el-input v-model="form.contact" placeholder="璇疯緭鍏ヨ仈绯讳汉" clearable />
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="20">
+          <el-col :span="12">
+            <el-form-item label="鑱旂郴鐢佃瘽锛�" prop="contactPhone">
+              <el-input v-model="form.contactPhone" placeholder="璇疯緭鍏ヨ仈绯荤數璇�" clearable />
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="鎷滆浜猴細" prop="visitingPeople">
+              <el-input v-model="form.visitingPeople" placeholder="璇疯緭鍏ユ嫓璁夸汉" clearable />
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-form-item label="鎷滆鐩殑锛�" prop="purposeVisit">
+          <el-input v-model="form.purposeVisit" placeholder="璇疯緭鍏ユ嫓璁跨洰鐨�" clearable />
+        </el-form-item>
+        <el-form-item label="鎷滆鏃堕棿锛�" prop="purposeDate">
+          <el-date-picker
+            v-model="form.purposeDate"
+            type="datetime"
+            placeholder="璇烽�夋嫨鎷滆鏃堕棿"
+            value-format="YYYY-MM-DD HH:mm:ss"
+            format="YYYY-MM-DD HH:mm:ss"
+            style="width: 100%"
+          />
+        </el-form-item>
+        <el-form-item label="鎷滆鍦扮偣锛�" prop="visitAddress">
+          <el-input v-model="form.visitAddress" placeholder="璇疯緭鍏ユ嫓璁垮湴鐐�" clearable />
+        </el-form-item>
+        <el-form-item label="澶囨敞锛�" prop="remark">
+          <el-input v-model="form.remark" type="textarea" :rows="3" placeholder="璇疯緭鍏ュ娉�" />
+        </el-form-item>
+      </el-form>
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button @click="closeForm">鍙栨秷</el-button>
+          <el-button type="primary" :loading="submitting" @click="submitForm">纭畾</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, addVisit, updateVisit, delVisit } from '@/api/collaborativeApproval/customerVisit.js'
 
 const { proxy } = getCurrentInstance()
 const tableData = ref([])
@@ -194,6 +257,115 @@
   detailForm.value = {}
 }
 
+// ===== 鏂板 / 缂栬緫 =====
+const formVisible = ref(false)
+const formTitle = ref('鏂板瀹㈡埛鎷滆璁板綍')
+const formRef = ref(null)
+const submitting = ref(false)
+const form = reactive({
+  id: undefined,
+  customerName: '',
+  contact: '',
+  contactPhone: '',
+  visitingPeople: '',
+  purposeVisit: '',
+  purposeDate: '',
+  visitAddress: '',
+  remark: ''
+})
+const rules = {
+  customerName: [{ required: true, message: '璇疯緭鍏ュ鎴峰悕绉�', trigger: 'blur' }],
+  purposeVisit: [{ required: true, message: '璇疯緭鍏ユ嫓璁跨洰鐨�', trigger: 'blur' }],
+  purposeDate: [{ required: true, message: '璇烽�夋嫨鎷滆鏃堕棿', trigger: 'change' }],
+  visitAddress: [{ required: true, message: '璇疯緭鍏ユ嫓璁垮湴鐐�', trigger: 'blur' }]
+}
+
+const resetForm = () => {
+  Object.assign(form, {
+    id: undefined,
+    customerName: '',
+    contact: '',
+    contactPhone: '',
+    visitingPeople: '',
+    purposeVisit: '',
+    purposeDate: '',
+    visitAddress: '',
+    remark: ''
+  })
+  formRef.value?.clearValidate()
+}
+
+// 鏂板
+const handleAdd = () => {
+  resetForm()
+  formTitle.value = '鏂板瀹㈡埛鎷滆璁板綍'
+  formVisible.value = true
+}
+
+// 缂栬緫
+const handleEdit = (row) => {
+  resetForm()
+  Object.assign(form, {
+    id: row.id,
+    customerName: row.customerName,
+    contact: row.contact,
+    contactPhone: row.contactPhone,
+    visitingPeople: row.visitingPeople,
+    purposeVisit: row.purposeVisit,
+    purposeDate: row.purposeDate,
+    visitAddress: row.visitAddress,
+    remark: row.remark
+  })
+  formTitle.value = '缂栬緫瀹㈡埛鎷滆璁板綍'
+  formVisible.value = true
+}
+
+// 鍏抽棴寮圭獥
+const closeForm = () => {
+  formVisible.value = false
+  resetForm()
+}
+
+// 鎻愪氦锛堟柊澧炴垨缂栬緫锛�
+const submitForm = () => {
+  formRef.value.validate((valid) => {
+    if (!valid) return
+    submitting.value = true
+    const payload = { ...form }
+    const req = payload.id ? updateVisit(payload) : addVisit(payload)
+    req
+      .then((res) => {
+        if (res.code === 200) {
+          proxy.$modal.msgSuccess(payload.id ? '缂栬緫鎴愬姛' : '鏂板鎴愬姛')
+          formVisible.value = false
+          getList()
+        } else {
+          proxy.$modal.msgError(res.msg || '鎿嶄綔澶辫触')
+        }
+      })
+      .finally(() => {
+        submitting.value = false
+      })
+  })
+}
+
+// 鍒犻櫎
+const handleDelete = (row) => {
+  proxy.$modal
+    .confirm(`纭鍒犻櫎瀹㈡埛鈥�${row.customerName}鈥濈殑鎷滆璁板綍鍚楋紵`)
+    .then(() => {
+      delVisit(row.id).then((res) => {
+        if (res.code === 200) {
+          proxy.$modal.msgSuccess('鍒犻櫎鎴愬姛')
+          getList()
+        } else {
+          proxy.$modal.msgError(res.msg || '鍒犻櫎澶辫触')
+        }
+      })
+    })
+    .catch(() => {})
+}
+
 onMounted(() => {
   getList()
 })

--
Gitblit v1.9.3