update: 更新供应商 客户管理

This commit is contained in:
admin 2024-03-28 16:55:03 +08:00
parent f4d6f63137
commit 84e20696b1
9 changed files with 228 additions and 78 deletions

View File

@ -7,9 +7,10 @@
ref="form" ref="form"
:labelWidth="100" :labelWidth="100"
:labelStyle="{ padding: '0rpx 10rpx' }" :labelStyle="{ padding: '0rpx 10rpx' }"
:errorType="'border-bottom'"
> >
<u-form-item <u-form-item
:prop="`formData[${item.key}]`" :prop="`formData.${item.key}`"
:label="item.name" :label="item.name"
:required="item.required" :required="item.required"
v-for="(item, index) in formAttrList" v-for="(item, index) in formAttrList"
@ -61,7 +62,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { CustomerApi, StockCardApi } from "@/services"; import { CustomerApi, StockCardApi } from "@/services";
import { formatDate } from "@/utils"; import { formatDate } from "@/utils";
import { DeviceType, ImagesType, OrderType } from "@/utils/enum"; import { DeviceType, ImagesType, OrderType, StockCardType } from "@/utils/enum";
import { onLoad } from "@dcloudio/uni-app"; import { onLoad } from "@dcloudio/uni-app";
import _ from "underscore"; import _ from "underscore";
@ -69,16 +70,22 @@ const model1 = reactive<any>({
formData: {}, formData: {},
}); });
const rules = ref({ const rules = ref({
"userInfo.userName": { "formData.stockCardName": {
type: "string", type: "string",
required: true, required: true,
message: "请输入手机号", message: "请选择出库卡",
trigger: ["blur", "change"], trigger: ["blur", "change"],
}, },
"userInfo.password": { "formData.name": {
type: "string", type: "string",
required: true, required: true,
message: "请输入密码", message: "请输入客户名称",
trigger: ["blur", "change"],
},
"formData.contacts": {
type: "string",
required: true,
message: "请输入联系人",
trigger: ["blur", "change"], trigger: ["blur", "change"],
}, },
}); });
@ -130,8 +137,32 @@ const handleSelect = (key: string, v: any) => {
model1.formData.stockCardId = v.id; model1.formData.stockCardId = v.id;
} }
}; };
const form = ref();
const check = () => {
return new Promise((resolve) => {
form.value
.validate()
.then((res: boolean) => {
resolve(res);
})
.catch((errors: any) => {
resolve(false);
uni.showToast({
icon: "none",
title: errors[0].message || "校验失败",
});
});
});
};
const save = () => { const save = () => {
check().then((res) => {
if (res) {
startSave();
}
});
};
const startSave = () => {
if (model1.formData.id) { if (model1.formData.id) {
CustomerApi.updateCustomUser(model1.formData).then((res) => { CustomerApi.updateCustomUser(model1.formData).then((res) => {
if (res.code === 200) { if (res.code === 200) {
@ -152,7 +183,7 @@ const save = () => {
}; };
const getStockCardList = () => { const getStockCardList = () => {
StockCardApi.getStockCardList({ pageNum: 1, pageSize: 10 }).then((res) => { StockCardApi.getStockCardList({ pageNum: 1, pageSize: 10000, type: StockCardType.Shipment }).then((res) => {
if (res.code === 200) { if (res.code === 200) {
contrlModalParams.stockCard.list = (res.data as any).list.map( contrlModalParams.stockCard.list = (res.data as any).list.map(
(item: any) => { (item: any) => {

View File

@ -7,9 +7,10 @@
ref="form" ref="form"
:labelWidth="100" :labelWidth="100"
:labelStyle="{ padding: '0rpx 10rpx' }" :labelStyle="{ padding: '0rpx 10rpx' }"
:errorType="'border-bottom'"
> >
<u-form-item <u-form-item
:prop="`formData[${item.key}]`" :prop="`formData.${item.key}`"
:label="item.name" :label="item.name"
:required="item.required" :required="item.required"
v-for="(item, index) in formAttrList" v-for="(item, index) in formAttrList"
@ -61,7 +62,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { StockCardApi, SupplierApi } from "@/services"; import { StockCardApi, SupplierApi } from "@/services";
import { formatDate } from "@/utils"; import { formatDate } from "@/utils";
import { DeviceType, ImagesType, OrderType } from "@/utils/enum"; import { DeviceType, ImagesType, OrderType, StockCardType } from "@/utils/enum";
import { onLoad } from "@dcloudio/uni-app"; import { onLoad } from "@dcloudio/uni-app";
import _ from "underscore"; import _ from "underscore";
@ -69,16 +70,22 @@ const model1 = reactive<any>({
formData: {}, formData: {},
}); });
const rules = ref({ const rules = ref({
"userInfo.userName": { "formData.stockCardName": {
type: "string", type: "string",
required: true, required: true,
message: "请输入手机号", message: "请选择卡号",
trigger: ["blur", "change"], trigger: ["blur", "change"],
}, },
"userInfo.password": { "formData.name": {
type: "string", type: "string",
required: true, required: true,
message: "请输入密码", message: "请输入供应商",
trigger: ["blur", "change"],
},
"formData.supplierTypeName": {
type: "string",
required: true,
message: "请选择供应商分类",
trigger: ["blur", "change"], trigger: ["blur", "change"],
}, },
}); });
@ -195,7 +202,32 @@ const handleSelect = (key: string, v: any) => {
} }
}; };
const form = ref();
const check = () => {
return new Promise((resolve) => {
form.value
.validate()
.then((res: boolean) => {
resolve(res);
})
.catch((errors: any) => {
resolve(false);
uni.showToast({
icon: "none",
title: errors[0].message || "校验失败",
});
});
});
};
const save = () => { const save = () => {
check().then((res) => {
if (res) {
startSave();
}
});
};
const startSave = () => {
if (model1.formData.id) { if (model1.formData.id) {
SupplierApi.updateSupplierUser(model1.formData).then((res) => { SupplierApi.updateSupplierUser(model1.formData).then((res) => {
if (res.code === 200) { if (res.code === 200) {
@ -224,7 +256,7 @@ const getSupplierTypeList = () => {
}; };
const getStockCardList = () => { const getStockCardList = () => {
StockCardApi.getStockCardList({ pageNum: 1, pageSize: 10 }).then((res) => { StockCardApi.getStockCardList({ pageNum: 1, pageSize: 100000, type: StockCardType.Receive }).then((res) => {
if (res.code === 200) { if (res.code === 200) {
contrlModalParams.stockCard.list = (res.data as any).list.map( contrlModalParams.stockCard.list = (res.data as any).list.map(
(item: any) => { (item: any) => {

View File

@ -12,26 +12,38 @@
></u-search> ></u-search>
<view class="btn" @click="add"> 新增 </view> <view class="btn" @click="add"> 新增 </view>
</view> </view>
<view class="box">
<view v-for="(item, index) in pageList.list" :key="index"> <page-view
<view> @loadList="
<view>{{ item.name }}</view> (v) => {
<view>联系人{{ item.contacts }}</view> getList(v);
<view>卡号{{ item.cardCode }}</view> }
</view> "
<view class="op-box"> :noMoreData="pageList.noMoreData"
<view class="btn" @click="edit(item)"> 编辑 </view> :list="pageList.list"
<view class="btn" @click="deleteCustomer(item)"> 删除 </view> :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="deleteCustomer(item)"> 删除 </view>
</view>
</view> </view>
</view> </view>
</view> </page-view>
</view> </view>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { CustomerApi } from "@/services"; import { CustomerApi } from "@/services";
import { UsersType } from "@/utils/enum";
const keyword = ref(""); import PageView from "@/components/PageView/index.vue";
const state = reactive<any>({ const state = reactive<any>({
name: "", name: "",
}); });
@ -41,6 +53,13 @@ const pageList: PageResult<Customer> = reactive({
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
}); });
const resetPageList = () => {
pageList.noMoreData = false;
pageList.total = 0;
pageList.list = [];
pageList.pageNum = 1;
pageList.pageSize = 10;
};
const add = () => { const add = () => {
uni.navigateTo({ uni.navigateTo({
url: "/pagesApp/components/addCustomer", // url: "/pagesApp/components/addCustomer", //
@ -53,36 +72,46 @@ const edit = (item: any) => {
JSON.stringify(item), // JSON.stringify(item), //
}); });
}; };
const handleSearch = () => {
resetPageList();
getList();
};
const deleteCustomer = (item: any) => { const deleteCustomer = (item: any) => {
CustomerApi.updateCustomUser({ isDeleted: true, id: item.id }).then((res) => { CustomerApi.updateCustomUser({ isDeleted: true, id: item.id }).then((res) => {
if (res.code === 200) { if (res.code === 200) {
getCustomUserPage(); getList();
} }
}); });
}; };
const handleSearch = () => {
getCustomUserPage(); const getList = (v?: boolean) => {
}; if (v) {
const getCustomUserPage = () => { if (Math.ceil(pageList.total / pageList.pageSize) > pageList.pageNum) {
pageList.pageNum++;
} else {
pageList.noMoreData = true;
return;
}
}
let params: any = { let params: any = {
pageSize: 10, pageSize: pageList.pageSize,
pageNum: 1, pageNum: pageList.pageNum,
name: state.name, name: state.name,
}; };
if (state.supplierTypeId > -1) { if (state.supplierTypeId > -1) {
params.supplierTypeId = state.supplierTypeId; params.supplierTypeId = state.supplierTypeId;
} }
pageList.isLoading = true;
CustomerApi.getCustomUserPage(params).then((res) => { CustomerApi.getCustomUserPage(params).then((res) => {
if (res.code === 200) { if (res.code === 200) {
if (res.code === 200) { pageList.isLoading = false;
(pageList as any).list = (res.data as any).list; (pageList as any).list = (res.data as any).list;
} pageList.total = (res.data as any).total;
} }
}); });
}; };
onMounted(() => { onMounted(() => {
getCustomUserPage(); getList();
}); });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -92,12 +121,18 @@ onMounted(() => {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
.type {
display: flex;
margin-right: 20rpx;
font-size: 28rpx;
color: #000000;
}
.btn { .btn {
background: #00dcee; background: #00dcee;
border-radius: 24rpx; border-radius: 24rpx;
border: 1px solid #00dcee; border: 1px solid #00dcee;
font-weight: 500; font-weight: 500;
font-size: 26rpx; font-size: 28rpx;
color: #ffffff; color: #ffffff;
margin-left: 50rpx; margin-left: 50rpx;
padding: 6rpx 30rpx; padding: 6rpx 30rpx;
@ -107,9 +142,9 @@ onMounted(() => {
background: #ffffff; background: #ffffff;
box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(5, 68, 37, 0.12); box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(5, 68, 37, 0.12);
border-radius: 13rpx; border-radius: 13rpx;
padding: 0rpx 20rpx; padding: 10rpx 20rpx;
font-weight: 400; font-weight: 400;
font-size: 26rpx; font-size: 28rpx;
color: #000000; color: #000000;
line-height: 41rpx; line-height: 41rpx;
margin-top: 30rpx; margin-top: 30rpx;
@ -118,6 +153,7 @@ onMounted(() => {
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
padding: 20rpx 0rpx; padding: 20rpx 0rpx;
.op-box { .op-box {
display: flex; display: flex;
.btn + .btn { .btn + .btn {
@ -127,10 +163,15 @@ onMounted(() => {
background: #ff9d55; background: #ff9d55;
border-radius: 24rpx; border-radius: 24rpx;
font-weight: 500; font-weight: 500;
font-size: 26rpx; font-size: 28rpx;
color: #ffffff; color: #ffffff;
padding: 6rpx 30rpx; padding: 6rpx 30rpx;
} }
.btn_text {
font-weight: 500;
font-size: 24rpx;
color: #00dcee;
}
} }
} }
> view + view { > view + view {

View File

@ -174,6 +174,7 @@ const getList = (v?: boolean) => {
return; return;
} }
} }
pageList.isLoading = true;
ReceiveApi.getOrderPage({ ReceiveApi.getOrderPage({
pageSize: pageList.pageSize, pageSize: pageList.pageSize,
pageNumber: pageList.pageNum, pageNumber: pageList.pageNum,
@ -181,7 +182,11 @@ const getList = (v?: boolean) => {
isDeleted: true, isDeleted: true,
}).then((res) => { }).then((res) => {
if (res.code === 200) { if (res.code === 200) {
(pageList as any).list = res.data.list; pageList.isLoading = false;
(pageList as any).list = pageList.list.concat(
res.data.list
);
pageList.total = (res.data as any).total;
} }
}); });
}; };

View File

@ -86,9 +86,11 @@ const getList = (v?: boolean) => {
let params: any = { let params: any = {
roleName: state.name, roleName: state.name,
}; };
pageList.isLoading = true;
ProfileApi.getRoleList(params).then((res) => { ProfileApi.getRoleList(params).then((res) => {
if (res.code === 200) { if (res.code === 200) {
if (res.code === 200) { if (res.code === 200) {
pageList.isLoading = false;
(pageList as any).list = res.data as any; (pageList as any).list = res.data as any;
pageList.total = (res.data as any).total pageList.total = (res.data as any).total
} }

View File

@ -197,14 +197,19 @@ const getList = (v?: boolean) => {
return; return;
} }
} }
pageList.isLoading = true;
ShipmentApi.getOrderPage({ ShipmentApi.getOrderPage({
pageSize: pageList.pageSize, pageSize: pageList.pageSize,
pageNumber: pageList.pageNum, pageNumber: pageList.pageNum,
userName: keyword.value, userName: keyword.value,
isDeleted: true, isDeleted: true,
}).then((res) => { }).then((res: any) => {
if (res.code === 200) { if (res.code === 200) {
(pageList as any).list = res.data.list; pageList.isLoading = false;
(pageList as any).list = pageList.list.concat(
res.data.list
);
pageList.total = (res.data as any).total;
} }
}); });
}; };

View File

@ -96,10 +96,8 @@ const getList = (v?: boolean) => {
} }
GoodsApi.getPage(params).then((res) => { GoodsApi.getPage(params).then((res) => {
if (res.code === 200) { if (res.code === 200) {
if (res.code === 200) { (pageList as any).list = (pageList as any).list.concat((res.data as any).list);
(pageList as any).list = (pageList as any).list.concat((res.data as any).list);
pageList.total = (res.data as any).total pageList.total = (res.data as any).total
}
} }
}); });
}; };

View File

@ -16,18 +16,30 @@
<view class="btn" @click="addSupplier"> 新增 </view> <view class="btn" @click="addSupplier"> 新增 </view>
</view> </view>
<view class="box" v-for="(item, index) in pageList.list" :key="index"> <page-view
<view> @loadList="
(v) => {
getList(v);
}
"
:noMoreData="pageList.noMoreData"
:list="pageList.list"
:height="100"
:isLoading="pageList.isLoading"
>
<view class="box" v-for="(item, index) in pageList.list" :key="index">
<view> <view>
<view>{{ item.name }}</view> <view>
<view>卡号{{ item.cardCode }}</view> <view>{{ item.name }}</view>
</view> <view>卡号{{ item.cardCode }}</view>
<view class="op-box"> </view>
<view class="btn" @click="edit(item)"> 编辑 </view> <view class="op-box">
<view class="btn" @click="update(item)"> 删除 </view> <view class="btn" @click="edit(item)"> 编辑 </view>
<view class="btn" @click="update(item)"> 删除 </view>
</view>
</view> </view>
</view> </view>
</view> </page-view>
</view> </view>
<u-action-sheet <u-action-sheet
:actions="state.typeList" :actions="state.typeList"
@ -42,6 +54,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { SupplierApi } from "@/services"; import { SupplierApi } from "@/services";
import { UsersType } from "@/utils/enum"; import { UsersType } from "@/utils/enum";
import PageView from "@/components/PageView/index.vue";
const state = reactive<any>({ const state = reactive<any>({
name: "", name: "",
supplierTypeId: -1, supplierTypeId: -1,
@ -54,19 +67,29 @@ const pageList: PageResult<User> = reactive({
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
}); });
const resetPageList = () => {
pageList.noMoreData = false;
pageList.total = 0;
pageList.list = [];
pageList.pageNum = 1;
pageList.pageSize = 10;
};
const handleSelect = (v: any) => { const handleSelect = (v: any) => {
state.supplierTypeId = v.id; state.supplierTypeId = v.id;
getUserList(); resetPageList()
getList();
}; };
const handleSearch = () => { const handleSearch = () => {
getUserList(); resetPageList()
getList();
}; };
const update = (item: any) => { const update = (item: any) => {
SupplierApi.updateSupplierUser({ isDeleted: true, id: item.id }).then( SupplierApi.updateSupplierUser({ isDeleted: true, id: item.id }).then(
(res) => { (res) => {
if (res.code === 200) { if (res.code === 200) {
getUserList(); resetPageList()
getList();
} }
} }
); );
@ -79,27 +102,36 @@ const edit = (item: any) => {
JSON.stringify(item), // JSON.stringify(item), //
}); });
}; };
const getUserList = () => { const getList = (v?: boolean) => {
if (v) {
if (Math.ceil(pageList.total / pageList.pageSize) > pageList.pageNum) {
pageList.pageNum++;
} else {
pageList.noMoreData = true;
return;
}
}
let params: any = { let params: any = {
pageSize: 10, pageSize: pageList.pageSize,
pageNum: 1, pageNum: pageList.pageNum,
name: state.name, name: state.name,
}; };
if (state.supplierTypeId > -1) { if (state.supplierTypeId > -1) {
params.supplierTypeId = state.supplierTypeId; params.supplierTypeId = state.supplierTypeId;
} }
pageList.isLoading = true;
SupplierApi.getSupplierUserPage(params).then((res) => { SupplierApi.getSupplierUserPage(params).then((res) => {
if (res.code === 200) { if (res.code === 200) {
if (res.code === 200) { pageList.isLoading = false;
(pageList as any).list = (res.data as any).list; (pageList as any).list = (res.data as any).list;
} pageList.total = (res.data as any).total;
} }
}); });
}; };
const getSupplierTypeList = () => { const getSupplierTypeList = () => {
SupplierApi.getSupplierTypeList().then((res) => { SupplierApi.getSupplierTypeList().then((res:any) => {
if (res.code === 200) { if (res.code === 200) {
state.typeList = res.data; state.typeList = [{id: -1, name: '全部'}].concat(res.data);
} }
}); });
}; };
@ -109,7 +141,7 @@ const addSupplier = () => {
}); });
}; };
onMounted(() => { onMounted(() => {
getUserList(); getList();
getSupplierTypeList(); getSupplierTypeList();
}); });
</script> </script>
@ -141,7 +173,7 @@ onMounted(() => {
background: #ffffff; background: #ffffff;
box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(5, 68, 37, 0.12); box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(5, 68, 37, 0.12);
border-radius: 13rpx; border-radius: 13rpx;
padding: 0rpx 20rpx; padding: 10rpx 20rpx;
font-weight: 400; font-weight: 400;
font-size: 28rpx; font-size: 28rpx;
color: #000000; color: #000000;

View File

@ -21,6 +21,8 @@
" "
:noMoreData="pageList.noMoreData" :noMoreData="pageList.noMoreData"
:list="pageList.list" :list="pageList.list"
:height="100"
:isLoading="pageList.isLoading"
> >
<view class="box"> <view class="box">
<view v-for="(item, index) in pageList.list" :key="index"> <view v-for="(item, index) in pageList.list" :key="index">
@ -105,13 +107,15 @@ const getList = (v?: boolean) => {
pageNum: pageList.pageNum, pageNum: pageList.pageNum,
name: state.name, name: state.name,
}; };
pageList.isLoading = true;
ProfileApi.getUserListByPage(params).then((res) => { ProfileApi.getUserListByPage(params).then((res) => {
if (res.code === 200) { if (res.code === 200) {
(pageList as any).list = (pageList as any).list.concat( pageList.isLoading = false;
(res.data as any).list (pageList as any).list = (pageList as any).list.concat(
); (res.data as any).list
pageList.total = (res.data as any).total; );
} pageList.total = (res.data as any).total;
}
}); });
}; };