yuan
5 天以前 336aa0c6affadffce030d93fb1ea901960f1e966
src/views/basicData/customerFileOpenSea/index.vue
@@ -1,6 +1,7 @@
<template>
  <div class="app-container">
    <div class="search_form">
    <div class="search_form"
         style="margin-bottom: 20px;">
      <div>
        <span class="search_title">客户名称:</span>
        <el-input v-model="searchForm.customerName"
@@ -202,39 +203,6 @@
        </div>
      </template>
    </el-dialog>
    <el-dialog v-model="assignDialogVisible"
               title="分配客户"
               width="500px"
               @close="closeAssignDialog">
      <el-form :model="assignForm"
               :rules="assignRules"
               ref="assignFormRef"
               label-width="100px">
        <el-form-item label="客户名称">
          <el-input v-model="assignForm.customerName"
                    disabled />
        </el-form-item>
        <el-form-item label="分配人员"
                      prop="maintainer">
          <el-select v-model="assignForm.maintainer"
                     placeholder="请选择分配人员"
                     style="width: 100%"
                     filterable>
            <el-option v-for="item in userList"
                       :key="item.userId || item.nickName"
                       :label="item.nickName"
                       :value="item.nickName" />
          </el-select>
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary"
                     @click="submitAssignForm">确认</el-button>
          <el-button @click="closeAssignDialog">取消</el-button>
        </div>
      </template>
    </el-dialog>
    <!-- 用户导入对话框 -->
    <el-dialog :title="upload.title"
               v-model="upload.open"
@@ -244,7 +212,8 @@
                 :limit="1"
                 accept=".xlsx, .xls"
                 :headers="upload.headers"
                 :action="upload.url + '?updateSupport=' + upload.updateSupport"
                 :action="upload.url"
                 :data="upload.data"
                 :disabled="upload.isUploading"
                 :before-upload="upload.beforeUpload"
                 :on-progress="upload.onProgress"
@@ -309,7 +278,8 @@
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitReminderForm">确认</el-button>
          <el-button type="primary"
                     @click="submitReminderForm">确认</el-button>
          <el-button @click="closeReminderDialog">取消</el-button>
        </div>
      </template>
@@ -392,7 +362,8 @@
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitNegotiationForm">确认</el-button>
          <el-button type="primary"
                     @click="submitNegotiationForm">确认</el-button>
          <el-button @click="closeNegotiationDialog">取消</el-button>
        </div>
      </template>
@@ -645,33 +616,25 @@
  import { onMounted, ref, reactive, getCurrentInstance, toRefs } from "vue";
  import { Search, Paperclip, Upload } from "@element-plus/icons-vue";
  import {
    addCustomer,
    delCustomer,
    getCustomer,
    listCustomer,
    updateCustomer,
    addCustomerFollow,
    updateCustomerFollow,
    delCustomerFollow,
    addReturnVisit,
    getReturnVisit,
  } from "@/api/basicData/customerFile.js";
  import {
    listCustomer,
    getCustomer,
    addCustomer,
    updateCustomer,
    delCustomer,
  } from "@/api/basicData/customer.js";
  import { ElMessageBox } from "element-plus";
  import { userListNoPage } from "@/api/system/user.js";
  import useUserStore from "@/store/modules/user";
  import { getToken } from "@/utils/auth.js";
  const { proxy } = getCurrentInstance();
  const userStore = useUserStore();
  const assignDialogVisible = ref(false);
  const assignFormRef = ref();
  const assignForm = reactive({
    id: undefined,
    customerName: "",
    maintainer: "",
  });
  const assignRules = {
    maintainer: [{ required: true, message: "请选择分配人员", trigger: "change" }],
  };
  // 回访提醒相关
  const reminderDialogVisible = ref(false);
@@ -769,7 +732,7 @@
    },
    {
      label: "地址及联系方式",
      prop: "addressPhone",
      prop: "companyAddress",
      width: 250,
    },
    {
@@ -820,31 +783,29 @@
      label: "操作",
      align: "center",
      fixed: "right",
      width: 320,
      width: 290,
      operation: [
        {
          name: "分配",
          name: "编辑",
          type: "text",
          showHide: row => !row.maintainer,
          clickFun: row => {
            openAssignDialog(row);
            openForm("edit", row);
          },
        },
        {
          name: "回收",
          name: "添加洽谈进度",
          type: "text",
          showHide: row => !!row.maintainer,
          clickFun: row => {
            recycleCustomer(row);
            openNegotiationDialog(row);
          },
        },
            {
               name: "编辑",
               type: "text",
               clickFun: row => {
                  openForm("edit", row);
               },
            },
        {
          name: "回访提醒",
          type: "text",
          clickFun: row => {
            openReminderDialog(row);
          },
        },
        {
          name: "详情",
          type: "text",
@@ -927,6 +888,7 @@
    headers: { Authorization: "Bearer " + getToken() },
    // 上传的地址
    url: import.meta.env.VITE_APP_BASE_API + "/basic/customer/importData",
    data: {},
    // 文件上传前的回调
    beforeUpload: file => {
      console.log("文件即将上传", file);
@@ -999,8 +961,8 @@
    tableLoading.value = true;
    listCustomer({ ...searchForm.value, ...page }).then(res => {
      tableLoading.value = false;
      tableData.value = res.records;
      page.total = res.total;
      tableData.value = res.data.records;
      page.total = res.data.total;
    });
  };
  // 表格选择数据
@@ -1099,68 +1061,6 @@
    proxy.resetForm("formRef");
    dialogFormVisible.value = false;
  };
  const ensureUserList = () => {
    if (userList.value.length) {
      return Promise.resolve();
    }
    return userListNoPage().then(res => {
      userList.value = res.data || [];
    });
  };
  const openAssignDialog = row => {
    assignForm.id = row.id;
    assignForm.customerName = row.customerName;
    assignForm.maintainer = row.maintainer || "";
    ensureUserList().then(() => {
      assignDialogVisible.value = true;
    });
  };
  const closeAssignDialog = () => {
    proxy.resetForm("assignFormRef");
    assignForm.id = undefined;
    assignForm.customerName = "";
    assignForm.maintainer = "";
    assignDialogVisible.value = false;
  };
  const submitAssignForm = () => {
    proxy.$refs.assignFormRef.validate(valid => {
      if (!valid) {
        return;
      }
      updateCustomer({
        id: assignForm.id,
        maintainer: assignForm.maintainer,
        maintenanceTime: getCurrentDate(),
      }).then(() => {
        proxy.$modal.msgSuccess("分配成功");
        closeAssignDialog();
        getList();
      });
    });
  };
  const recycleCustomer = row => {
    ElMessageBox.confirm("确认回收客户“" + row.customerName + "”吗?", "回收提示", {
      confirmButtonText: "确认",
      cancelButtonText: "取消",
      type: "warning",
    })
      .then(() => {
        return updateCustomer({
          id: row.id,
          maintainer: "",
          maintenanceTime: "",
        });
      })
      .then(() => {
        proxy.$modal.msgSuccess("回收成功");
        getList();
      })
      .catch(error => {
        if (error === "cancel" || error === "close") {
          proxy.$modal.msg("已取消");
        }
      });
  };
  // 导出
  const handleOut = () => {
    ElMessageBox.confirm("选中的内容将被导出,是否确认导出?", "导出", {
@@ -1179,14 +1079,6 @@
  const handleDelete = () => {
    let ids = [];
    if (selectedRows.value.length > 0) {
      // 检查是否有他人维护的数据
      const unauthorizedData = selectedRows.value.filter(
        item => item.maintainer !== userStore.nickName
      );
      if (unauthorizedData.length > 0) {
        proxy.$modal.msgWarning("不可删除他人维护的数据");
        return;
      }
      ids = selectedRows.value.map(item => item.id);
    } else {
      proxy.$modal.msgWarning("请选择数据");
@@ -1200,7 +1092,7 @@
      .then(() => {
        tableLoading.value = true;
        delCustomer(ids)
          .then(res => {
          .then(() => {
            proxy.$modal.msgSuccess("删除成功");
            getList();
          })
@@ -1269,8 +1161,6 @@
          };
        }
        console.log("提交回访提醒数据:", submitvalue.value);
        // 调用接口
        addReturnVisit(submitvalue.value)
          .then(res => {
@@ -1298,14 +1188,6 @@
    negotiationForm.followUpTime = "";
    negotiationForm.followerUserName = userStore.nickName; // 默认当前登录人
    negotiationForm.content = "";
    // {
    //    "customerId": 152,
    //    "followUpMethod": "电话沟通",
    //    "followUpLevel": "没有意向",
    //    "followUpTime": "2026-03-04T15:30:00",
    //    "followerUserName": "管理员账号",
    //    "content": "111"
    // }
    negotiationDialogVisible.value = true;
  };
@@ -1327,23 +1209,6 @@
        if (isEdit) {
          // 修改操作
          console.log("修改洽谈进度数据:", negotiationForm);
          // 这里可以调用更新接口
          // 实际项目中需要根据后端接口进行调整
          // 示例:updateCustomerFollow(negotiationForm).then(res => {
          //   // 更新本地数据
          //   const index = negotiationForm.editIndex;
          //   negotiationRecords.value[index] = {
          //     followUpTime: negotiationForm.followUpTime,
          //     followUpMethod: negotiationForm.followUpMethod,
          //     followUpLevel: negotiationForm.followUpLevel,
          //     followerUserName: negotiationForm.followerUserName,
          //     content: negotiationForm.content,
          //     id: negotiationForm.id,
          //   };
          //   proxy.$modal.msgSuccess("修改成功");
          //   closeNegotiationDialog();
          // });
          updateCustomerFollow(negotiationForm).then(res => {
            // 更新本地数据
            getCustomer(negotiationForm.customerId).then(res => {
@@ -1378,7 +1243,6 @@
  // 打开详情弹窗
  const openDetailDialog = row => {
    // 调用getCustomer接口获取客户详情
    getCustomer(row.id).then(res => {
      // 填充客户基本信息
      Object.assign(detailForm, res.data);
@@ -1528,7 +1392,7 @@
  const downloadAttachment = row => {
    if (row.url) {
      // proxy.download(row.url, {}, row.name);
      proxy.$download.name(row.url);
      proxy.$download.byUrl(row.url, row.originalFilename);
    } else {
      proxy.$modal.msgError("下载链接不存在");
    }