diff --git a/src/views/customer/customer.vue b/src/views/customer/customer.vue
index e0ff6fc..5dda237 100644
--- a/src/views/customer/customer.vue
+++ b/src/views/customer/customer.vue
@@ -88,7 +88,9 @@
}">
取消选择
-
+
+
+
@@ -223,6 +225,8 @@ import addCustomer from "@/views/customer/component/addCustomer";
import addOrder from "./component/addOrder";
import imports from "./component/imports.vue";
import longInsuranceDetail from './component/longInsuranceDetail.vue'
+import * as XLSX from "xlsx";
+import { saveAs } from "file-saver";
export default {
components: {
addCustomer,
@@ -350,6 +354,7 @@ export default {
{
label: "姓名",
width: "180",
+ prop: "name",
customFn: (row) => {
let getColor = () => {
if (row.near_age == 2) {
@@ -371,37 +376,19 @@ export default {
label: "区域",
prop: 'village',
width: 200,
- customFn: row => {
- return (
-
- {
- row.village?.reduce((pre, cur, index) => (pre + (index === 0 ? "" : "/") + cur.village_name),"")
- }
-
- )
- }
+ formatter: (row, column, cellValue) => cellValue?.reduce((pre, cur, index) => (pre + (index === 0 ? "" : "/") + cur.village_name),"")
},
{
label: "订单产品",
width: 220,
align: "left",
- customFn: (row) => {
- return (
-
- {" "}
- {row.orders
- .map((item) => {
- return item.product.name;
- })
- .toString()}{" "}
-
- );
- },
+ formatter: (row, column, cellValue) => row.orders?.reduce((pre, cur, index) => (pre + (index === 0 ? "" : ",") + cur.product?.name),""),
},
{
prop: "long_insurances",
width: 140,
label: "长护险回访数",
+ formatter: (row, column, cellValue) => cellValue?.length ?? 0,
customFn: row => {
return (
{
- return (
-
- {" "}
- {row.customer_address.filter((item) => {
- return item.default === 1;
- })[0]?.address ||
- row.customer_address[0]?.address ||
- "无"}{" "}
-
- );
- },
+ formatter: (row, column, cellValue) => (row.customer_address.find((item) => {
+ return item.default === 1;
+ })?.address ||
+ row.customer_address[0]?.address ||
+ "无"),
},
{
label: "上门地址数",
@@ -590,6 +571,55 @@ export default {
};
},
methods: {
+ async exportExcel(sheetName) {
+ let loading;
+ try {
+ loading = this.$loading({
+ lock:true,
+ background:"rgba(0,0,0,0.4)",
+ text:"正在导出..."
+ })
+ let copySelect = deepCopy(this.select);
+ copySelect.product_type_id = copySelect?.product_type_id.toString();
+ const res = await getList(
+ Object.assign(copySelect, { page: 1, page_size: 9999 }),false
+ );
+ if (res.data) {
+ let headers = this.tableItem.filter(i => i.prop).map((i) => {
+ return {
+ key: i.prop,
+ title: i.label,
+ formatter: i.formatter
+ };
+ });
+ const data = res.data.data.map((row) =>
+ headers.map((header) => {
+ if (header.formatter) {
+ return header.formatter(row, {}, row[header.key])??''
+ } else {
+ return row[header.key]??''
+ }
+ })
+ );
+ data.unshift(headers.map((header) => header.title));
+ const wb = XLSX.utils.book_new();
+ const ws = XLSX.utils.aoa_to_sheet(data);
+ XLSX.utils.book_append_sheet(wb, ws, sheetName.toString());
+ const wbout = XLSX.write(wb, {
+ bookType: "xlsx",
+ bookSST: true,
+ type: "array",
+ });
+ saveAs(
+ new Blob([wbout], { type: "application/octet-stream" }),
+ `${sheetName.toString()}.xlsx`
+ );
+ loading.close()
+ }
+ } catch (err) {
+ loading.close()
+ }
+ },
save,
async getLevelTypes() {
const types = await getparameter(