freight-web/src/pagesApp/customerMgt.vue

204 lines
4.8 KiB
Vue
Raw Normal View History

2024-03-04 07:10:11 +00:00
<template>
<view class="c-card">
<view class="search">
<u-search
placeholder="请输入客户名称"
2024-03-16 13:26:04 +00:00
v-model="state.name"
2024-03-04 07:10:11 +00:00
:showAction="false"
:bgColor="'#fff'"
:borderColor="'rgba(0, 0, 0, 0.1)'"
:placeholderColor="'#C1C1C1'"
2024-03-16 13:26:04 +00:00
@search="handleSearch()"
2024-03-04 07:10:11 +00:00
></u-search>
2024-03-16 13:26:04 +00:00
<view class="btn" @click="add"> 新增 </view>
2024-03-04 07:10:11 +00:00
</view>
2024-03-28 08:55:03 +00:00
<page-view
@loadList="
(v) => {
getList(v);
}
"
:noMoreData="pageList.noMoreData"
:list="pageList.list"
:height="100"
:isLoading="pageList.isLoading"
>
<view class="box">
<view v-for="(item, index) in pageList.list" :key="index">
<view>
<view>{{ item.name }}</view>
<view>联系人{{ item.contacts }}</view>
<view>卡号{{ item.cardCode }}</view>
</view>
<view class="op-box">
<view class="btn" @click="edit(item)"> 编辑 </view>
<view class="btn" @click="handleModal(true, item.id)"> 删除 </view>
2024-03-28 08:55:03 +00:00
</view>
2024-03-04 07:10:11 +00:00
</view>
</view>
2024-03-28 08:55:03 +00:00
</page-view>
2024-03-04 07:10:11 +00:00
</view>
<SmallModal
:title="'确认删除吗?'"
:content="'确认删除后,不能恢复!'"
:okText="'确认删除'"
:isMain="true"
:show="isShowCancelModal"
@handleModal="(v:boolean) => {handleModal(v, deleteId)}"
@handleOk="handleOk()"
/>
2024-03-04 07:10:11 +00:00
</template>
<script setup lang="ts">
2024-03-16 13:26:04 +00:00
import { CustomerApi } from "@/services";
2024-03-28 08:55:03 +00:00
import { UsersType } from "@/utils/enum";
import PageView from "@/components/PageView/index.vue";
import type { Customer } from "@/types/user";
import SmallModal from "@/components/Modal/smallModal.vue";
const isShowCancelModal = ref(false);
const deleteId = ref(0);
const handleModal = (v: boolean, id: number) => {
isShowCancelModal.value = v;
deleteId.value = id;
};
const handleOk = () => {
deleteCustomer({id: deleteId.value})
};
2024-03-16 13:26:04 +00:00
const state = reactive<any>({
name: "",
});
const pageList: PageResult<Customer> = reactive({
total: 0,
list: [],
pageNum: 1,
pageSize: 10,
});
2024-03-28 08:55:03 +00:00
const resetPageList = () => {
pageList.noMoreData = false;
pageList.total = 0;
pageList.list = [];
pageList.pageNum = 1;
pageList.pageSize = 10;
};
2024-03-16 13:26:04 +00:00
const add = () => {
uni.navigateTo({
url: "/pagesApp/components/addCustomer", // 要跳转到的页面路径
});
};
const edit = (item: any) => {
uni.navigateTo({
url:
"/pagesApp/components/addCustomer?title=编辑客户&item=" +
JSON.stringify(item), // 要跳转到的页面路径
});
};
2024-03-28 08:55:03 +00:00
const handleSearch = () => {
resetPageList();
getList();
};
2024-03-16 13:26:04 +00:00
const deleteCustomer = (item: any) => {
CustomerApi.updateCustomUser({ isDeleted: true, id: item.id }).then((res) => {
if (res.code === 200) {
2024-03-28 08:55:03 +00:00
getList();
2024-03-16 13:26:04 +00:00
}
});
};
2024-03-28 08:55:03 +00:00
const getList = (v?: boolean) => {
if (v) {
if (Math.ceil(pageList.total / pageList.pageSize) > pageList.pageNum) {
pageList.pageNum++;
} else {
pageList.noMoreData = true;
return;
}
}
2024-03-16 13:26:04 +00:00
let params: any = {
2024-03-28 08:55:03 +00:00
pageSize: pageList.pageSize,
pageNum: pageList.pageNum,
2024-03-16 13:26:04 +00:00
name: state.name,
};
if (state.supplierTypeId > -1) {
params.supplierTypeId = state.supplierTypeId;
}
2024-03-28 08:55:03 +00:00
pageList.isLoading = true;
2024-03-16 13:26:04 +00:00
CustomerApi.getCustomUserPage(params).then((res) => {
if (res.code === 200) {
2024-03-28 08:55:03 +00:00
pageList.isLoading = false;
(pageList as any).list = (res.data as any).list;
pageList.total = (res.data as any).total;
2024-03-16 13:26:04 +00:00
}
});
};
onMounted(() => {
2024-03-28 08:55:03 +00:00
getList();
2024-03-16 13:26:04 +00:00
});
2024-03-04 07:10:11 +00:00
</script>
<style lang="scss" scoped>
.c-card {
margin: 30rpx 25rpx;
.search {
display: flex;
align-items: center;
justify-content: space-between;
2024-03-28 08:55:03 +00:00
.type {
display: flex;
margin-right: 20rpx;
font-size: 28rpx;
color: #000000;
}
2024-03-04 07:10:11 +00:00
.btn {
background: #00dcee;
border-radius: 24rpx;
border: 1px solid #00dcee;
font-weight: 500;
2024-03-28 08:55:03 +00:00
font-size: 28rpx;
2024-03-04 07:10:11 +00:00
color: #ffffff;
margin-left: 50rpx;
padding: 6rpx 30rpx;
}
}
.box {
background: #ffffff;
box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(5, 68, 37, 0.12);
border-radius: 13rpx;
2024-03-28 08:55:03 +00:00
padding: 10rpx 20rpx;
2024-03-04 07:10:11 +00:00
font-weight: 400;
2024-03-28 08:55:03 +00:00
font-size: 28rpx;
2024-03-04 07:10:11 +00:00
color: #000000;
line-height: 41rpx;
margin-top: 30rpx;
> view {
display: flex;
align-items: center;
justify-content: space-between;
padding: 20rpx 0rpx;
2024-03-28 08:55:03 +00:00
2024-03-16 13:26:04 +00:00
.op-box {
display: flex;
.btn + .btn {
margin-left: 20rpx;
}
.btn {
background: #ff9d55;
border-radius: 24rpx;
font-weight: 500;
2024-03-28 08:55:03 +00:00
font-size: 28rpx;
2024-03-16 13:26:04 +00:00
color: #ffffff;
padding: 6rpx 30rpx;
}
2024-03-28 08:55:03 +00:00
.btn_text {
font-weight: 500;
font-size: 24rpx;
color: #00dcee;
}
2024-03-04 07:10:11 +00:00
}
}
> view + view {
border-top: 1px solid rgba(233, 233, 233, 0.76);
}
}
}
</style>