优化项目列表和添加项目

This commit is contained in:
WindowBird 2025-11-18 16:02:59 +08:00
parent 37b81d188a
commit a9234a69b2
3 changed files with 45 additions and 27 deletions

View File

@ -108,7 +108,8 @@ export const getProjectDetail = (id) => {
export const createProject = (data) => {
return uni.$uv.http.post('bst/project', data, {
custom: {
auth: true
auth: true,
catch: true // 允许在 catch 中处理错误
}
});
};

View File

@ -45,7 +45,7 @@
<view class="form-row">
<view class="form-item half">
<text class="form-label required">项目金额</text>
<text class="form-label ">项目金额</text>
<input
class="form-input"
v-model="formData.amount"
@ -64,7 +64,7 @@
</view>
<view class="form-item">
<text class="form-label required">客户</text>
<text class="form-label ">客户</text>
<view class="picker-input" @click="openCustomerPicker">
<text>{{ formData.customerName || '请选择客户' }}</text>
<text class="picker-arrow"></text>
@ -305,11 +305,12 @@ const pendingDateField = ref('');
const canSubmit = computed(() => {
return (
!!formData.value.name &&
!!formData.value.customerId &&
!!formData.value.amount &&
formData.value.memberList.length > 0 &&
!submitting.value
!!formData.value.name
// &&
// !!formData.value.customerId &&
// !!formData.value.amount &&
// formData.value.memberList.length > 0 &&
// !submitting.value
);
});
@ -533,7 +534,7 @@ const loadProjectDetail = async (id) => {
amount: merged.amount != null ? String(merged.amount) : '',
customerId: merged.customerId ? String(merged.customerId) : merged.customerId,
customerName: merged.customerName || '',
expireTime: normalizeDateString(merged.expireTime),
expireTime: merged.expireTime,
projectTags: merged.projectTags || '',
remark: merged.remark || '',
developmentCost: safeNumberToString(merged.developmentCost),
@ -584,15 +585,15 @@ const buildPayload = () => {
amount: parseNumber(formData.value.amount),
customerId: formData.value.customerId,
customerName: formData.value.customerName,
expireTime: formData.value.expireTime || null,
expireTime: formData.value.expireTime,
projectTags: formData.value.projectTags || '',
remark: formData.value.remark || '',
developmentCost: parseNumber(formData.value.developmentCost),
developmentTime: formData.value.developmentTime || null,
developmentTime: formatDateTimeForPayload(formData.value.developmentTime),
middleCost: parseNumber(formData.value.middleCost),
middleTime: formData.value.middleTime || null,
middleTime: formatDateTimeForPayload(formData.value.middleTime),
afterCost: parseNumber(formData.value.afterCost),
afterTime: formData.value.afterTime || null,
afterTime: formatDateTimeForPayload(formData.value.afterTime),
attaches: formData.value.attaches.map((file, index) => ({
name: file.name || getFileNameFromUrl(file.path),
url: file.path,
@ -622,7 +623,16 @@ const safeNumberToString = (value) => {
const normalizeDateString = (value) => {
if (!value) return '';
return value.split(' ')[0];
return value.replace('T', ' ').split(' ')[0];
};
const formatDateTimeForPayload = (value) => {
if (!value) return null;
const cleaned = value.replace('T', ' ').trim();
if (cleaned.includes(':')) {
return cleaned;
}
return `${cleaned} 00:00:00`;
};
const normalizeAttaches = (value) => {
@ -688,8 +698,8 @@ const formatDate = (timestamp) => {
}
.custom-navbar {
height: 56px;
padding: 0 16px;
padding: 20px 20px;
display: flex;
align-items: flex-end;
background: #fff;
@ -697,11 +707,12 @@ const formatDate = (timestamp) => {
}
.navbar-content {
margin-top: 15px;
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: 10px;
}
.nav-btn {
@ -803,6 +814,7 @@ const formatDate = (timestamp) => {
align-items: center;
font-size: 14px;
color: #111;
box-sizing: border-box;
}
.form-textarea {
@ -917,7 +929,7 @@ const formatDate = (timestamp) => {
}
.col.role {
width: 180px;
width: 140px;
}
.col.action {
@ -1000,7 +1012,7 @@ const formatDate = (timestamp) => {
padding: 16px;
display: flex;
flex-direction: column;
max-height: 80%;
}
.modal-header {
@ -1021,7 +1033,7 @@ const formatDate = (timestamp) => {
}
.search-box {
margin-bottom: 12px;
//margin-bottom: 12px;
}
.search-input {
@ -1034,6 +1046,7 @@ const formatDate = (timestamp) => {
.member-list {
height: 600px;
margin: 12px 0;
}
.member-item {
@ -1074,8 +1087,8 @@ const formatDate = (timestamp) => {
.modal-actions {
display: flex;
gap: 12px;
margin-top: 12px;
justify-content: space-between;
}
</style>

View File

@ -133,13 +133,17 @@
<view class="card-title">{{ project.name }}</view>
<!-- 项目标签和描述 -->
<view class="card-tags-row">
<view class="tag-circle" :style="{ backgroundColor: getTagColor(project) }">
<text class="tag-text">{{ getTagText(project) }}</text>
</view>
<!-- <view class="card-tags-row">-->
<!-- <view class="tag-circle" :style="{ backgroundColor: getTagColor(project) }">-->
<!-- <text class="tag-text">{{ getTagText(project) }}</text>-->
<!-- </view>-->
<!-- <text class="member-text">{{ project.createName }}</text>-->
<!-- </view>-->
<view class="card-tags-row" v-if="project.remark">
<text class="card-description" v-if="project.remark">{{ project.remark }}</text>
</view>
<!-- 操作标签 -->
<view class="action-tags" v-if="project.tags && project.tags.length > 0">
<view