zhangwencui
6 天以前 7ab410022cbf32fd0eb1fe94456a13c95d4a3f89
src/pages/cooperativeOffice/clientVisit/index.vue
@@ -1,40 +1,43 @@
<template>
  <view class="sales-accoun">
    <!-- 使用通用页面头部组件 -->
    <PageHeader title="客户拜访" @back="goBack" />
    <PageHeader title="客户拜访"
                @back="goBack" />
    <!-- 搜索和筛选区域 -->
    <view class="search-section">
      <view class="search-bar">
        <view class="search-input">
          <up-input
            class="search-text"
          <up-input class="search-text"
            placeholder="请输入客户名称"
            v-model="customerName"
            @blur="getList"
            clearable
          />
                    clearable />
        </view>
        <view class="filter-button" @click="getList">
          <u-icon name="search" size="24" color="#999"></u-icon>
        <view class="filter-button"
              @click="getList">
          <u-icon name="search"
                  size="24"
                  color="#999"></u-icon>
        </view>
      </view>
    </view>
    <!-- 拜访记录列表 -->
    <view class="ledger-list" v-if="visitList.length > 0">
      <view v-for="(item, index) in visitList" :key="index">
    <view class="ledger-list"
          v-if="visitList.length > 0">
      <view v-for="(item, index) in visitList"
            :key="index">
        <view class="ledger-item">
          <view class="item-header">
            <view class="item-left">
              <view class="document-icon">
                <up-icon name="file-text" size="16" color="#ffffff"></up-icon>
                <up-icon name="file-text"
                         size="16"
                         color="#ffffff"></up-icon>
              </view>
              <text class="item-id">客户:{{ item.customerName }}</text>
            </view>
          </view>
          <up-divider></up-divider>
          <view class="item-details">
            <view class="detail-row">
              <text class="detail-label">联系人</text>
@@ -60,92 +63,107 @@
              <text class="detail-label">拜访人</text>
              <text class="detail-value">{{ item.visitingPeople || '-' }}</text>
            </view>
            <view class="detail-row" v-if="item.remark">
            <view class="detail-row"
                  v-if="item.remark">
              <text class="detail-label">备注</text>
              <text class="detail-value">{{ item.remark }}</text>
            </view>
          </view>
          <!-- 按钮区域 -->
          <view class="action-buttons">
            <u-button
              type="primary"
            <u-button type="info"
              size="small"
              class="action-btn"
              @click="viewDetail(item)"
            >
                      @click="viewDetail(item)">
              查看详情
            </u-button>
            <u-button type="primary"
                      size="small"
                      class="action-btn"
                      @click="editVisit(item)">
              编辑
            </u-button>
            <u-button type="error"
                      size="small"
                      class="action-btn"
                      @click="deleteVisit(item)">
              删除
            </u-button>
          </view>
        </view>
      </view>
    </view>
    <view v-else class="no-data">
    <view v-else
          class="no-data">
      <text>暂无拜访记录</text>
    </view>
    <!-- 浮动新增按钮 -->
    <view class="fab-button" @click="addVisit">
      <up-icon name="plus" size="24" color="#ffffff"></up-icon>
    <view class="fab-button"
          @click="addVisit">
      <up-icon name="plus"
               size="24"
               color="#ffffff"></up-icon>
    </view>
  </view>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import PageHeader from '@/components/PageHeader.vue'
import { getVisitRecords } from '@/api/cooperativeOffice/clientVisit'
import useUserStore from "@/store/modules/user"
  import { ref, onMounted } from "vue";
  import { onShow } from "@dcloudio/uni-app";
  import PageHeader from "@/components/PageHeader.vue";
  import {
    getVisitRecords,
    delCustomer,
  } from "@/api/cooperativeOffice/clientVisit";
  import useUserStore from "@/store/modules/user";
// 替换 toast 方法
defineOptions({name: 'client-visit-index'})
const showToast = (message) => {
  defineOptions({ name: "client-visit-index" });
  const showToast = message => {
  uni.showToast({
    title: message,
    icon: 'none'
  })
}
      icon: "none",
    });
  };
import dayjs from "dayjs"
  import dayjs from "dayjs";
const userStore = useUserStore()
  const userStore = useUserStore();
// 搜索关键词
const customerName = ref('')
  const customerName = ref("");
// 拜访记录数据
const visitList = ref([])
  const visitList = ref([]);
// 返回上一页
const goBack = () => {
  uni.navigateBack()
}
    uni.navigateBack();
  };
// 查询列表
const getList = () => {
  showLoadingToast('加载中...')
    showLoadingToast("加载中...");
  const params = {
    current: -1,
    size: -1,
    customerName: customerName.value,
  }
    };
  getVisitRecords(params)
    .then((res) => {
      visitList.value = res.records || res.data?.records || []
      closeToast()
      .then(res => {
        visitList.value = res.records || res.data?.records || [];
        closeToast();
    })
    .catch(() => {
      closeToast()
      showToast('获取数据失败')
    })
}
        closeToast();
        showToast("获取数据失败");
      });
  };
// 显示加载提示
const showLoadingToast = (message) => {
  const showLoadingToast = message => {
  uni.showLoading({
    title: message,
    mask: true
      mask: true,
  });
};
@@ -157,26 +175,59 @@
// 新增拜访 - 跳转到登记页面
const addVisit = () => {
  uni.navigateTo({
    url: '/pages/cooperativeOffice/clientVisit/detail'
  })
      url: "/pages/cooperativeOffice/clientVisit/detail",
    });
  };
  // 编辑拜访 - 跳转到登记页面
  const editVisit = item => {
    uni.setStorageSync("clientVisit", item);
    // 编辑拜访跳转到登记页面
    uni.navigateTo({
      url: "/pages/cooperativeOffice/clientVisit/detail",
    });
  };
  // 删除拜访
  const deleteVisit = item => {
    uni.showModal({
      title: "删除确认",
      content: `确定要删除该拜访记录吗?`,
      success: res => {
        if (res.confirm) {
          deleteClientVisit(item.id);
}
      },
    });
  };
  // 删除拜访记录
  const deleteClientVisit = id => {
    showLoadingToast("删除中...");
    delCustomer(id)
      .then(() => {
        closeToast();
        showToast("删除成功");
        getList();
      })
      .catch(() => {
        closeToast();
        showToast("删除失败");
      });
  };
// 查看详情
const viewDetail = (item) => {
  uni.setStorageSync('clientVisit', item)
  const viewDetail = item => {
    uni.setStorageSync("clientVisit", item);
  // 查看详情跳转到只读展示页面
  uni.navigateTo({
    url: '/pages/cooperativeOffice/clientVisit/view'
  })
}
      url: "/pages/cooperativeOffice/clientVisit/view",
    });
  };
onMounted(() => {
  getList()
})
    getList();
  });
onShow(() => {
  getList()
})
    getList();
  });
</script>
<style scoped lang="scss">