gaoluyang
2 天以前 5db4ae754437adbbcffa8078b3017570ce9f9eb4
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
<template>
  <div class="app-container">
    <el-form :model="filters" :inline="true" label-width="80px">
      <el-form-item label="客户名称">
        <el-input v-model="filters.customerName" placeholder="请输入客户名称" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="getTableData"> 搜索 </el-button>
        <el-button @click="resetFilters"> 重置 </el-button>
        <el-button @click="handleOut"> 导出 </el-button>
      </el-form-item>
    </el-form>
    <div class="table_list">
      <PIMTable
        rowKey="id"
        :column="columns"
        :tableLoading="loading"
        :tableData="dataList"
        :page="{
          current: pagination.currentPage,
          size: pagination.pageSize,
          total: pagination.total,
        }"
        @pagination="changePage"
      ></PIMTable>
    </div>
  </div>
</template>
 
<script setup>
import { usePaginationApi } from "@/hooks/usePaginationApi";
import { getPurchaseList } from "@/api/procurementManagement/projectProfit";
import { onMounted, getCurrentInstance } from "vue";
import { ElMessageBox } from "element-plus";
 
const { proxy } = getCurrentInstance();
 
defineOptions({
  name: "项目利润",
});
 
const {
  loading,
  filters,
  columns,
  dataList,
  pagination,
  resetFilters,
  onCurrentChange,
} = usePaginationApi(
  getPurchaseList,
  {
    customerName: undefined,
  },
  [
    {
      label: "销售合同号",
      align: "center",
      prop: "customerContractNo",
    },
    {
      label: "客户名称",
      align: "center",
      prop: "customerName",
    },
    {
      label: "合同金额",
      align: "center",
      prop: "contractAmount",
    },
    {
      label: "采购金额",
      align: "center",
      prop: "purchaseAmount",
    },
    {
      label: "利润",
      align: "center",
      prop: "balance",
    },
    {
      label: "利润率",
      align: "center",
      prop: "balanceRatio",
    },
  ]
);
 
// 设置假数据
const mockData = [
  {
    customerContractNo: "HCKX20251220011",
    customerName: "巴楚县高宏军 - 新疆名利商贸有限公司",
    contractAmount: "10189.00",
    purchaseAmount: "6113.00",
    balance: "4076.00",
    balanceRatio: "40.0%"
  },
  {
    customerContractNo: "HCKX20251220002", 
    customerName: "喀什福新源商贸有限公司",
    contractAmount: "35321.00",
    purchaseAmount: "19436.00",
    balance: "15885.00",
    balanceRatio: "45.0%"
  },
  {
    customerContractNo: "HCKX20251220001",
    customerName: "郑州振亿商贸有限公司",
    contractAmount: "26491.00",
    purchaseAmount: "13245.50",
    balance: "13245.50",
    balanceRatio: "50.0%"
  },
  {
    customerContractNo: "HCKX20251220009",
    customerName: "阜康苗绪涛",
    contractAmount: "58868.00",
    purchaseAmount: "35321.00",
    balance: "23547.00",
    balanceRatio: "40.0%"
  },
  {
    customerContractNo: "HCKX20251210013",
    customerName: "河北援疆引擎科技有限公司",
    contractAmount: "41678.00",
    purchaseAmount: "18755.10",
    balance: "22922.90",
    balanceRatio: "55.0%"
  },
  {
    customerContractNo: "HCKX20251220015",
    customerName: "王文 - 阿克苏友鑫商贸有限公司",
    contractAmount: "37358.00",
    purchaseAmount: "20547.00",
    balance: "16811.00",
    balanceRatio: "45.0%"
  },
  {
    customerContractNo: "HCKX20251220010",
    customerName: "阿勒泰张蒙",
    contractAmount: "203773.60",
    purchaseAmount: "81509.44",
    balance: "122264.16",
    balanceRatio: "60.0%"
  },
  {
    customerContractNo: "HCKX20250930002",
    customerName: "乌鲁木齐市众筹商贸有限公司",
    contractAmount: "56612.30",
    purchaseAmount: "28306.15",
    balance: "28306.15",
    balanceRatio: "50.0%"
  },
  {
    customerContractNo: "HCKX20251220016",
    customerName: "新疆天润商贸有限公司",
    contractAmount: "89245.00",
    purchaseAmount: "53547.00",
    balance: "35698.00",
    balanceRatio: "40.0%"
  },
  {
    customerContractNo: "HCKX20251220017",
    customerName: "哈密市宏达贸易有限公司",
    contractAmount: "123456.00",
    purchaseAmount: "55555.20",
    balance: "67900.80",
    balanceRatio: "55.0%"
  },
  {
    customerContractNo: "HCKX20251220018",
    customerName: "伊犁哈萨克自治州贸易公司",
    contractAmount: "78912.00",
    purchaseAmount: "31564.80",
    balance: "47347.20",
    balanceRatio: "60.0%"
  },
  {
    customerContractNo: "HCKX20251220019",
    customerName: "克拉玛依石油贸易有限公司",
    contractAmount: "156789.00",
    purchaseAmount: "78394.50",
    balance: "78394.50",
    balanceRatio: "50.0%"
  },
  {
    customerContractNo: "HCKX20251220020",
    customerName: "石河子农业贸易公司",
    contractAmount: "234567.00",
    purchaseAmount: "129011.85",
    balance: "105555.15",
    balanceRatio: "45.0%"
  },
  {
    customerContractNo: "HCKX20251220021",
    customerName: "吐鲁番葡萄贸易有限公司",
    contractAmount: "98765.00",
    purchaseAmount: "59259.00",
    balance: "39506.00",
    balanceRatio: "40.0%"
  },
  {
    customerContractNo: "HCKX20251220022",
    customerName: "和田玉石贸易公司",
    contractAmount: "345678.00",
    purchaseAmount: "138271.20",
    balance: "207406.80",
    balanceRatio: "60.0%"
  }
];
 
// 重写获取表格数据的方法,使用假数据
const loadMockData = () => {
  loading.value = true;
  setTimeout(() => {
    dataList.value = mockData;
    pagination.total = mockData.length;
    loading.value = false;
  }, 500);
};
 
// 重写getTableData方法
const getTableData = () => {
  loadMockData();
};
 
const changePage = ({ page }) => {
  pagination.currentPage = page;
  onCurrentChange(page);
};
 
// 导出
const handleOut = () => {
  ElMessageBox.confirm("选中的内容将被导出,是否确认导出?", "导出", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning",
  })
    .then(() => {
      proxy.download("/purchase/report/export", {}, "项目利润.xlsx");
    })
    .catch(() => {
      proxy.$modal.msg("已取消");
    });
};
 
onMounted(() => {
  getTableData();
});
</script>
<style lang="scss" scoped>
.table_list {
  margin-top: unset;
}
</style>