update: 细节优化

This commit is contained in:
admin 2024-05-20 09:24:03 +08:00
parent b71988a8f0
commit dc95484bf5
8 changed files with 190 additions and 70 deletions

View File

@ -3,7 +3,7 @@
<u-form <u-form
labelPosition="left" labelPosition="left"
:model="model1" :model="model1"
:rules="rules" :rules="model1.formData.id ? rules2 : rules1"
ref="form" ref="form"
:labelWidth="100" :labelWidth="100"
:labelStyle="{ padding: '0rpx 10rpx' }" :labelStyle="{ padding: '0rpx 10rpx' }"
@ -13,7 +13,7 @@
: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 model1.formData.id ? formAttrList2 : formAttrList1"
:key="index" :key="index"
@click="item.fn" @click="item.fn"
> >
@ -35,7 +35,9 @@
:maxlength="item.key === 'password' ? 8 : -1" :maxlength="item.key === 'password' ? 8 : -1"
@change="(e:any) => {handleInput(e, item)}" @change="(e:any) => {handleInput(e, item)}"
:disabled="item.type === 'select'" :disabled="item.type === 'select'"
:disabledColor="['性别', '用户角色'].indexOf(item.name) > -1?'#ffffff':'#f5f7fa'" :disabledColor="
['性别', '用户角色'].indexOf(item.name) > -1 ? '#ffffff' : '#f5f7fa'
"
@clear="handleClear(item)" @clear="handleClear(item)"
> >
<template #suffix> <template #suffix>
@ -49,7 +51,7 @@
</template> </template>
</u-form-item> </u-form-item>
</u-form> </u-form>
<block v-for="(item, index) in formAttrList" :key="index"> <block v-for="(item, index) in model1.formData.id ? formAttrList2 : formAttrList1" :key="index">
<u-action-sheet <u-action-sheet
v-if="item.type === 'select'" v-if="item.type === 'select'"
:actions="contrlModalParams[item.childKey].list" :actions="contrlModalParams[item.childKey].list"
@ -73,8 +75,8 @@ import valid from "@/utils/validate";
import { onLoad } from "@dcloudio/uni-app"; import { onLoad } from "@dcloudio/uni-app";
import _ from "underscore"; import _ from "underscore";
const handleClear = (item: any) => { const handleClear = (item: any) => {
(model1.formData as any)[item.key] = ''; (model1.formData as any)[item.key] = "";
} };
const handleInput = (e: any, item: any) => { const handleInput = (e: any, item: any) => {
if (item.key === "phone") { if (item.key === "phone") {
const temp = e?.replace(valid.valid_number, ""); const temp = e?.replace(valid.valid_number, "");
@ -90,10 +92,9 @@ const handleInput = (e: any, item: any) => {
} }
}; };
const model1 = reactive<any>({ const model1 = reactive<any>({
formData: { formData: {},
},
}); });
const rules = ref({ const rules1 = ref({
"formData.userName": { "formData.userName": {
type: "string", type: "string",
required: true, required: true,
@ -107,6 +108,14 @@ const rules = ref({
trigger: ["blur", "change"], trigger: ["blur", "change"],
}, },
}); });
const rules2 = ref({
"formData.userName": {
type: "string",
required: true,
message: "请输入账号",
trigger: ["blur", "change"],
},
});
const contrlModalParams = reactive<any>({ const contrlModalParams = reactive<any>({
role: { role: {
isShow: false, isShow: false,
@ -129,7 +138,7 @@ const contrlModalParams = reactive<any>({
}, },
}); });
const formAttrList = reactive<any>([ const formAttrList1 = reactive<any>([
{ {
name: "姓名", name: "姓名",
key: "name", key: "name",
@ -174,6 +183,45 @@ const formAttrList = reactive<any>([
}, },
]); ]);
const formAttrList2 = reactive<any>([
{
name: "姓名",
key: "name",
type: "input",
},
{
name: "性别",
key: "genderName",
type: "select",
childKey: "gender",
fn: () => {
contrlModalParams.gender.isShow = true;
contrlModalParams.gender.title = "选择性别";
},
},
{
name: "用户角色",
key: "roleName",
type: "select",
childKey: "role",
fn: () => {
contrlModalParams.role.isShow = true;
contrlModalParams.role.title = "选择角色";
},
},
{
name: "账号",
key: "userName",
type: "input",
required: true,
},
{
name: "联系手机",
key: "phone",
type: "input",
},
]);
const handleSelect = (key: string, v: any) => { const handleSelect = (key: string, v: any) => {
contrlModalParams[key].isShow = false; contrlModalParams[key].isShow = false;
if (key === "role") { if (key === "role") {
@ -211,6 +259,7 @@ const save = () => {
return; return;
} }
} }
if (!model1.formData.id) {
if (model1.formData.password) { if (model1.formData.password) {
if (!valid.valid_password.pattern.test(model1.formData.password)) { if (!valid.valid_password.pattern.test(model1.formData.password)) {
uni.showToast({ uni.showToast({
@ -220,6 +269,8 @@ const save = () => {
return; return;
} }
} }
}
check().then((res) => { check().then((res) => {
if (res) { if (res) {
startSave(); startSave();
@ -229,15 +280,22 @@ const save = () => {
const startSave = () => { const startSave = () => {
if (model1.formData.id) { if (model1.formData.id) {
ProfileApi.updateUserById(model1.formData).then((res) => { ProfileApi.updateUserById({
name: model1.formData.name,
id: model1.formData.id,
roleIds: model1.formData.roleIds,
userName: model1.formData.userName,
phone: model1.formData.phone,
gender: model1.formData.gender,
}).then((res) => {
if (res.code === 200) { if (res.code === 200) {
uni.navigateBack() uni.navigateBack();
} }
}); });
} else { } else {
ProfileApi.addUser({ userType: 1, ...model1.formData }).then((res) => { ProfileApi.addUser({ userType: 1, ...model1.formData }).then((res) => {
if (res.code === 200) { if (res.code === 200) {
uni.navigateBack() uni.navigateBack();
} }
}); });
} }
@ -261,11 +319,11 @@ onMounted(() => {
onLoad((option) => { onLoad((option) => {
// ; // ;
const title = (option as any).title; const title = (option as any).title;
const obj = JSON.parse((option as any).item) const obj = JSON.parse((option as any).item);
model1.formData = {...obj, genderName: ['未知','男','女'][obj.gender]}; model1.formData = { ...obj, genderName: ["未知", "男", "女"][obj.gender] };
if (obj.roleVos.length > 0) { if (obj.roleVos.length > 0) {
model1.formData.roleIds = [obj.roleVos[0].id] model1.formData.roleIds = [obj.roleVos[0].id];
model1.formData.roleName = obj.roleVos[0].roleName model1.formData.roleName = obj.roleVos[0].roleName;
} }
// ; // ;
if (title) { if (title) {

View File

@ -91,7 +91,7 @@ const add = () => {
const edit = (item: any) => { const edit = (item: any) => {
uni.navigateTo({ uni.navigateTo({
url: url:
"/pagesApp/components/addRole?title=新增角色&item=" + "/pagesApp/components/addRole?title=编辑角色&item=" +
JSON.stringify(item), // JSON.stringify(item), //
}); });
}; };

View File

@ -109,7 +109,7 @@ const update = (item: any) => {
const edit = (item: any) => { const edit = (item: any) => {
uni.navigateTo({ uni.navigateTo({
url: url:
"/pagesApp/components/addShipmentProduct?title=编辑货产品&item=" + "/pagesApp/components/addShipmentProduct?title=编辑货产品&item=" +
JSON.stringify(item), // JSON.stringify(item), //
}); });
}; };

View File

@ -1,7 +1,7 @@
<template> <template>
<view class="baseinfo"> <view class="baseinfo">
<view class="box"> <view class="box">
<view> 用户 {{ profile.userName }} </view> <view> {{ profile.userName }} </view>
<view> 手机号码 {{ profile.phone }} </view> <view> 手机号码 {{ profile.phone }} </view>
</view> </view>
</view> </view>

View File

@ -17,9 +17,7 @@
<text class="address">{{ item.deviceName || "-" }}</text> <text class="address">{{ item.deviceName || "-" }}</text>
</view> </view>
<view> <view>
<text class="number" <text class="number">收货单号{{ item.receiptNumber }}</text>
>收货单号{{ item.receiptNumber }}</text
>
</view> </view>
<view> <view>
<text class="name">{{ item.userName }}</text> <text class="name">{{ item.userName }}</text>
@ -42,7 +40,11 @@
</view> </view>
<view class="flex-box"> <view class="flex-box">
<text>毛重{{ item.grossWeight }}kg</text> <text>毛重{{ item.grossWeight }}kg</text>
<text>单价{{ state.scaleStatus === 0 ? '未定价' : item.price + '元/KG'}}</text> <text
>单价{{
state.scaleStatus === 0 ? "未定价" : item.price + "元/KG"
}}</text
>
</view> </view>
<view class="btn-box"> <view class="btn-box">
<u-button <u-button
@ -85,9 +87,16 @@ const pageList: PageResult<Order> = 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 state = reactive({ const state = reactive({
scaleStatus: 0 scaleStatus: 0,
}) });
const isShowCancelModal = ref(false); const isShowCancelModal = ref(false);
const deleteId = ref(0); const deleteId = ref(0);
const handleModal = (v: boolean, id: number) => { const handleModal = (v: boolean, id: number) => {
@ -100,9 +109,20 @@ const handleScenePhoto = (imagesId: number) => {
}); });
}; };
const pricingDetail = (id: number) => { const pricingDetail = (id: number) => {
//
ReceiveApi.getDetailById({ id: id }).then((res: any) => {
if (res.code === 200) {
if (res.data.scaleStatus > 1) {
uni.showToast({title : '当前订单已处理'});
resetPageList();
getList();
} else {
uni.redirectTo({ uni.redirectTo({
url: "/pagesReceive/form/pricingForm?id=" + id, // url: "/pagesReceive/form/pricingForm?id=" + id, //
}); });
}
}
});
}; };
const getList = (v?: boolean) => { const getList = (v?: boolean) => {
@ -146,11 +166,11 @@ onLoad((option) => {
// //
if (state.scaleStatus === ScaleStatus.ToBePriced) { if (state.scaleStatus === ScaleStatus.ToBePriced) {
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: '待定价', title: "待定价",
}); });
} else if (state.scaleStatus === ScaleStatus.ToBeTare) { } else if (state.scaleStatus === ScaleStatus.ToBeTare) {
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: '待过皮重', title: "待过皮重",
}); });
} }
}); });

View File

@ -13,13 +13,13 @@
</view> </view>
</view> </view>
<view> <view>
<text class="btn" @click="handleScenePhoto((item.imagesId as number))" <text class="btn" @click="handleScenePhoto(item.imagesId as number)"
>现场照片</text >现场照片</text
> >
</view> </view>
</view> </view>
<view> <view>
<text class="desc">过磅时间{{ item.grossTime || '-' }}</text> <text class="desc">过磅时间{{ item.grossTime || "-" }}</text>
</view> </view>
<view class="flex-box"> <view class="flex-box">
<text>皮重{{ item.tare }}kg</text> <text>皮重{{ item.tare }}kg</text>
@ -29,12 +29,12 @@
text="点击作废" text="点击作废"
color="#E8E8E8" color="#E8E8E8"
:customStyle="{ color: '#999' }" :customStyle="{ color: '#999' }"
@click="handleModal(true, (item.id as any))" @click="handleModal(true, item.id as any)"
></u-button> ></u-button>
<u-button <u-button
type="primary" type="primary"
text="点击编辑" text="点击编辑"
@click="pricingDetail((item.id as any))" @click="pricingDetail(item.id as any)"
></u-button> ></u-button>
</view> </view>
</view> </view>
@ -53,18 +53,20 @@
import { ShipmentApi } from "@/services/index"; import { ShipmentApi } from "@/services/index";
import SmallModal from "@/components/Modal/smallModal.vue"; import SmallModal from "@/components/Modal/smallModal.vue";
interface PageResult<T> { const pageList: PageResult<Order> = reactive({
total: number; noMoreData: false,
list: T[];
pageNum: number;
pageSize: number;
}
const pageList: PageResult<Shipment> = reactive({
total: 0, total: 0,
list: [], list: [],
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 isShowCancelModal = ref(false); const isShowCancelModal = ref(false);
const deleteId = ref(0); const deleteId = ref(0);
const handleModal = (v: boolean, id: number) => { const handleModal = (v: boolean, id: number) => {
@ -77,14 +79,43 @@ const handleScenePhoto = (imagesId: number) => {
}); });
}; };
const pricingDetail = (id: string) => { const pricingDetail = (id: string) => {
//
debugger
ShipmentApi.getDetailById({ id: id }).then((res: any) => {
if (res.code === 200) {
if (res.data.scaleStatus > 1) {
uni.showToast({ title: "当前订单已处理" });
resetPageList();
getList();
} else {
uni.navigateTo({ uni.navigateTo({
url: "/pagesShipment/form/shipmentForm?id=" + id, // url: "/pagesShipment/form/shipmentForm?id=" + id, //
}); });
}
}
});
}; };
const getOrderList = () => {
ShipmentApi.getOrderPage({ pageNumber: 1, pageSize: 10, scaleStatus: 1 }).then((res) => { 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 = {
pageSize: pageList.pageSize,
pageNumber: pageList.pageNum,
scaleStatus: 1,
};
pageList.isLoading = true;
ShipmentApi.getOrderPage(params).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;
} }
}); });
}; };
@ -92,13 +123,13 @@ const handleOk = () => {
console.log(deleteId.value); console.log(deleteId.value);
ShipmentApi.deleteOrder({ ids: [deleteId.value] }).then((res) => { ShipmentApi.deleteOrder({ ids: [deleteId.value] }).then((res) => {
if (res.code === 200) { if (res.code === 200) {
getOrderList(); getList();
} }
}); });
}; };
onMounted(() => { onMounted(() => {
getOrderList(); getList();
}); });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -253,6 +253,7 @@ const getList = (v?: boolean) => {
}); });
}; };
onShow(() => { onShow(() => {
resetPageList()
getList(); getList();
}); });
onLoad((option) => { onLoad((option) => {

View File

@ -102,9 +102,21 @@ const handleScenePhoto = (id: any) => {
}); });
}; };
const pricingDetail = (id: string) => { const pricingDetail = (id: string) => {
console.log(state.scaleStatus) ShipmentApi.getDetailById({ id: id }).then((res: any) => {
if (res.code === 200) {
if (res.data.scaleStatus > 1) {
uni.showToast({ title: "当前订单已处理" });
resetPageList();
getList();
} else {
uni.navigateTo({ uni.navigateTo({
url: "/pagesShipment/form/shipmentForm?id=" + id + `&scaleStatus=${state.scaleStatus}`, // url:
"/pagesShipment/form/shipmentForm?id=" +
id +
`&scaleStatus=${state.scaleStatus}`, //
});
}
}
}); });
}; };
const getList = (v?: boolean) => { const getList = (v?: boolean) => {
@ -124,9 +136,7 @@ const getList = (v?: boolean) => {
}).then((res) => { }).then((res) => {
if (res.code === 200) { if (res.code === 200) {
pageList.isLoading = false; pageList.isLoading = false;
(pageList as any).list = ( (pageList as any).list = (pageList as any).list.concat(res.data.list);
pageList as any
).list.concat(res.data.list);
pageList.total = (res.data as any).total; pageList.total = (res.data as any).total;
} }
}); });
@ -146,19 +156,19 @@ onShow(() => {
}); });
const state = reactive({ const state = reactive({
scaleStatus: 0 scaleStatus: 0,
}) });
onLoad((option) => { onLoad((option) => {
// //
state.scaleStatus = parseInt((option as any).scaleStatus); state.scaleStatus = parseInt((option as any).scaleStatus);
// //
if (state.scaleStatus === ScaleStatus.ToBeShipment) { if (state.scaleStatus === ScaleStatus.ToBeShipment) {
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: '待出货', title: "待出货",
}); });
} else if (state.scaleStatus === ScaleStatus.ToBeGrossWeight) { } else if (state.scaleStatus === ScaleStatus.ToBeGrossWeight) {
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: '待过毛重', title: "待过毛重",
}); });
} }
}); });