gaoluyang
2026-09-20 e449a5408265e4bd1f6c66f5be28a42efac444ee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
<template>
  <view class="sales-account">
    <PageHeader title="销售报价"
                @back="goBack" />
    <view class="search-section">
      <view class="search-bar">
        <view class="search-input">
          <up-input class="search-text"
                    v-model="query.quotationNo"
                    placeholder="请输入报价单号搜索"
                    clearable
                    @change="getList" />
        </view>
        <view class="filter-button"
              @click="showFilter = true">
          <up-icon name="list"
                   size="24"
                   color="#999"></up-icon>
        </view>
      </view>
    </view>
    <view class="tabs-section">
      <up-tabs v-model="tabValue"
               :list="tabList"
               itemStyle="width: 20%;height: 80rpx;"
               @change="onTabChange" />
    </view>
    <view v-if="quotationList.length > 0"
          class="ledger-list">
      <view v-for="item in quotationList"
            :key="item.id"
            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>
            </view>
            <text class="item-id">{{ item.quotationNo || "-" }}</text>
          </view>
          <up-tag :text="item.status || '待审批'"
                  :type="getStatusType(item.status)"
                  size="mini"
                  shape="circle" />
        </view>
        <up-divider></up-divider>
        <view class="item-details">
          <view class="detail-row">
            <text class="detail-label">客户名称</text>
            <text class="detail-value">{{ item.customer || "-" }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">所属项目</text>
            <text class="detail-value">{{ item.projectName || "-" }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">业务员</text>
            <text class="detail-value">{{ item.salesperson || "-" }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">报价日期</text>
            <text class="detail-value">{{ item.quotationDate || "-" }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">有效期至</text>
            <text class="detail-value">{{ item.validDate || "-" }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">报价金额</text>
            <text class="detail-value highlight">{{ formatAmount(item.totalAmount) }}</text>
          </view>
          <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">
          <up-button class="action-btn"
                     size="small"
                     type="primary"
                     :disabled="!canEdit(item)"
                     @click="goEdit(item)">
            编辑
          </up-button>
          <up-button class="action-btn"
                     size="small"
                     @click="goDetail(item)">详情</up-button>
          <up-button class="action-btn"
                     size="small"
                     type="error"
                     plain
                     @click="handleDelete(item)">
            删除
          </up-button>
        </view>
      </view>
    </view>
    <view v-else
          class="no-data">
      <text>暂无销售报价数据</text>
    </view>
    <view class="fab-button"
          @click="goAdd">
      <up-icon name="plus"
               size="28"
               color="#ffffff"></up-icon>
    </view>
 
    <FilterPanel v-model:show="showFilter"
                 :model-value="query"
                 title="报价筛选"
                 :fields="filterFields"
                 @search="onFilterSearch"
                 @reset="onFilterSearch" />
  </view>
</template>
 
<script setup>
  import { computed, reactive, ref } from "vue";
  import { onShow } from "@dcloudio/uni-app";
  import PageHeader from "@/components/PageHeader.vue";
  import FilterPanel from "@/components/FilterPanel.vue";
  import {
    deleteQuotation,
    getQuotationList,
  } from "@/api/salesManagement/salesQuotation";
  import { loadProjectOptions } from "@/utils/projectOptions";
 
  const quotationList = ref([]);
  const showFilter = ref(false);
  const projectOptions = ref([]);
 
  const query = reactive({
    quotationNo: "",
    projectId: "",
  });
 
  const filterFields = computed(() => [
    {
      prop: "quotationNo",
      label: "报价单号",
      type: "input",
      placeholder: "请输入报价单号",
    },
    {
      prop: "projectId",
      label: "所属项目",
      type: "select",
      options: projectOptions.value,
    },
  ]);
 
  const tabList = reactive([
    { name: "全部", value: "" },
    { name: "待审批", value: "待审批" },
    { name: "审核中", value: "审核中" },
    { name: "通过", value: "通过" },
    { name: "拒绝", value: "拒绝" },
  ]);
  const tabValue = ref(0);
 
  const page = {
    current: -1,
    size: -1,
  };
 
  const goBack = () => {
    uni.navigateBack();
  };
 
  const goAdd = () => {
    uni.removeStorageSync("salesQuotationDetail");
    uni.navigateTo({ url: "/pages/sales/salesQuotation/edit" });
  };
 
  const goEdit = item => {
    if (!canEdit(item)) return;
    uni.setStorageSync("salesQuotationDetail", item || {});
    uni.navigateTo({ url: `/pages/sales/salesQuotation/edit?id=${item.id}` });
  };
 
  const goDetail = item => {
    uni.setStorageSync("salesQuotationDetail", item || {});
    uni.navigateTo({ url: `/pages/sales/salesQuotation/detail?id=${item.id}` });
  };
 
  const canEdit = item => ["待审批", "拒绝"].includes(item?.status);
 
  const onTabChange = val => {
    tabValue.value = val.index;
    getList();
  };
 
  const getCurrentStatus = () => {
    const currentTab = tabList[tabValue.value];
    return currentTab?.value || "";
  };
 
  const formatAmount = amount => {
    const num = Number(amount || 0);
    return `¥${num.toFixed(2)}`;
  };
 
  const getStatusType = status => {
    const statusMap = {
      待审批: "info",
      审核中: "primary",
      通过: "success",
      拒绝: "danger",
    };
    return statusMap[status] || "info";
  };
 
  const getList = () => {
    uni.showLoading({ title: "加载中...", mask: true });
    getQuotationList({
      ...page,
      quotationNo: query.quotationNo,
      projectId: query.projectId || undefined,
      status: getCurrentStatus(),
    })
      .then(res => {
        const records = res?.data?.records || res?.records || [];
        quotationList.value = Array.isArray(records) ? records : [];
      })
      .catch(() => {
        uni.showToast({ title: "查询失败", icon: "error" });
      })
      .finally(() => {
        uni.hideLoading();
      });
  };
 
  // FilterPanel 只回吐筛选值,写回 query 后统一查询
  const onFilterSearch = values => {
    Object.assign(query, values);
    getList();
  };
 
  let projectsLoaded = false;
 
  const loadProjects = () => {
    if (projectsLoaded) return;
    projectsLoaded = true;
    loadProjectOptions()
      .then(options => {
        projectOptions.value = options;
      })
      .catch(() => {
        projectsLoaded = false;
      });
  };
 
  const handleDelete = item => {
    if (!item?.id) return;
    uni.showModal({
      title: "删除确认",
      content: "确认删除该报价单吗?",
      success: res => {
        if (!res.confirm) return;
        uni.showLoading({ title: "处理中...", mask: true });
        deleteQuotation(item.id)
          .then(() => {
            uni.showToast({ title: "删除成功", icon: "success" });
            getList();
          })
          .catch(() => {
            uni.showToast({ title: "删除失败", icon: "error" });
          })
          .finally(() => {
            uni.hideLoading();
          });
      },
    });
  };
 
  onShow(() => {
    getList();
    loadProjects();
  });
</script>
 
<style scoped lang="scss">
  @import "@/styles/sales-common.scss";
 
  .tabs-section {
    background: #ffffff;
    padding: 0 12px 8px 12px;
  }
 
  .item-index {
    max-width: 180rpx;
    text-align: center;
  }
 
  .detail-value {
    max-width: 70%;
    word-break: break-all;
  }
</style>