提交任务-样式微调

This commit is contained in:
WindowBird 2025-11-05 15:52:46 +08:00
parent f479d0d5a0
commit 62d84fcc38
3 changed files with 168 additions and 72 deletions

View File

@ -58,8 +58,8 @@
{
"path": "pages/submit-task/index",
"style": {
"navigationBarTitleText": "提交详情",
"navigationStyle": "custom"
"navigationBarTitleText": "提交详情"
}
}
],

View File

@ -1,19 +1,17 @@
<template>
<view class="submit-task-page">
<!-- 自定义导航栏 -->
<view class="custom-navbar">
<view class="navbar-content">
<text class="nav-btn" @click="handleCancel"></text>
<text class="nav-title">提交详情</text>
<view class="nav-placeholder"></view>
</view>
</view>
<!-- 内容区域 -->
<scroll-view class="content-scroll" scroll-y>
<view style="padding: 16px">
<!-- 输入提交说明 -->
<view class="form-item">
<view class="form-icon">📄</view>
<view class="form-icon"></view>
<textarea
v-model="formData.description"
class="description-input"
@ -70,6 +68,7 @@
<view class="remove-btn" @click="removeFile(index)"></view>
</view>
</view>
</view>
</scroll-view>
<!-- 进度选择弹窗 -->
@ -78,7 +77,7 @@
<view class="modal-title">选择任务进度</view>
<view class="progress-content">
<slider
:value="formData.progress || 0"
:value="tempProgress !== null ? tempProgress : 0"
:min="0"
:max="100"
:step="10"
@ -91,7 +90,7 @@
class="progress-option"
v-for="progress in progressOptions"
:key="progress"
:class="{ active: formData.progress === progress }"
:class="{ active: tempProgress === progress }"
@click="selectProgress(progress)"
>
<text>{{ progress }}%</text>
@ -177,9 +176,10 @@ const onProgressChange = (e) => {
tempProgress.value = e.detail.value;
};
//
//
const selectProgress = (progress) => {
tempProgress.value = progress;
formData.value.progress = progress;
showProgressPicker.value = false;
};
//
@ -220,57 +220,128 @@ const removeImage = (index) => {
formData.value.images.splice(index, 1);
};
//
//
const chooseFiles = () => {
// #ifdef H5 || APP-PLUS
uni.showActionSheet({
itemList: ['从相册选择', '拍照'],
success: (res) => {
if (res.tapIndex === 0) {
//
uni.chooseImage({
count: 9,
success: (res) => {
//
const files = res.tempFilePaths.map((path, index) => ({
name: `image_${Date.now()}_${index}.jpg`,
path: path,
size: 0
}));
formData.value.files = [...formData.value.files, ...files];
const remainingCount = 5 - formData.value.files.length;
if (remainingCount <= 0) {
uni.showToast({
title: '最多只能添加5个文件',
icon: 'none'
});
return;
}
// 使 plus API
if (typeof plus !== 'undefined') {
try {
const Intent = plus.android.importClass('android.content.Intent');
const main = plus.android.runtimeMainActivity();
// Intent
const intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType('*/*');
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); //
//
main.startActivityForResult(intent, 1001);
//
const originalOnActivityResult = main.onActivityResult;
main.onActivityResult = (requestCode, resultCode, data) => {
if (requestCode === 1001) {
if (resultCode === -1 && data) { // RESULT_OK = -1
try {
const clipData = data.getClipData();
const files = [];
//
const getFileName = (uri) => {
try {
const cursor = main.getContentResolver().query(uri, null, null, null, null);
if (cursor && cursor.moveToFirst()) {
const nameIndex = cursor.getColumnIndex('_display_name');
if (nameIndex !== -1) {
const fileName = cursor.getString(nameIndex);
cursor.close();
return fileName;
}
cursor.close();
}
} catch (e) {
console.error('获取文件名失败:', e);
}
return null;
};
if (clipData) {
//
const count = clipData.getItemCount();
for (let i = 0; i < count && files.length < remainingCount; i++) {
const item = clipData.getItemAt(i);
const uri = item.getUri();
const uriString = uri.toString();
//
let fileName = getFileName(uri) || `file_${Date.now()}_${i}`;
files.push({
name: fileName,
path: uriString, // URI
size: 0
});
}
} else {
//
const uri = data.getData();
if (uri) {
const uriString = uri.toString();
let fileName = getFileName(uri) || `file_${Date.now()}`;
files.push({
name: fileName,
path: uriString, // URI
size: 0
});
}
}
if (files.length > 0) {
formData.value.files = [...formData.value.files, ...files];
}
// onActivityResult
if (originalOnActivityResult) {
main.onActivityResult = originalOnActivityResult;
}
} catch (error) {
console.error('处理文件选择结果失败:', error);
uni.showToast({
title: '处理文件失败',
icon: 'none'
});
}
}
});
} else {
uni.showToast({
title: '暂不支持文件选择',
icon: 'none'
});
}
}
});
// #endif
// #ifdef MP
uni.chooseFile({
count: 5 - formData.value.files.length,
type: 'file',
success: (res) => {
const files = res.tempFiles.map(file => ({
name: file.name || `file_${Date.now()}.${file.path.split('.').pop()}`,
path: file.path,
size: file.size
}));
formData.value.files = [...formData.value.files, ...files];
},
fail: (err) => {
console.error('选择文件失败:', err);
} else {
// onActivityResult
if (originalOnActivityResult) {
originalOnActivityResult(requestCode, resultCode, data);
}
}
};
} catch (error) {
console.error('打开文件选择器失败:', error);
uni.showToast({
title: '选择文件失败',
title: '文件选择功能暂不可用',
icon: 'none'
});
}
});
// #endif
} else {
uni.showToast({
title: '当前环境不支持文件选择',
icon: 'none'
});
}
};
//
@ -278,6 +349,20 @@ const removeFile = (index) => {
formData.value.files.splice(index, 1);
};
//
const formatTimeToChinese = (date) => {
const weekdays = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const weekday = weekdays[date.getDay()];
const hour = String(date.getHours()).padStart(2, '0');
const minute = String(date.getMinutes()).padStart(2, '0');
const second = String(date.getSeconds()).padStart(2, '0');
return `${year}${month}${day}${weekday} ${hour}:${minute}:${second}`;
};
//
const handleSubmit = () => {
if (!canSubmit.value) {
@ -326,14 +411,7 @@ const handleSubmit = () => {
//
const submitRecord = {
userName: '当前用户', // TODO:
time: new Date().toLocaleString('zh-CN', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
}).replace(/\//g, '-'),
time: formatTimeToChinese(new Date()),
content: submitData.description || '',
progress: submitData.progress,
attachments: [
@ -406,7 +484,7 @@ const handleSubmit = () => {
/* 内容滚动区域 */
.content-scroll {
flex: 1;
padding: 16px;
}
/* 表单项 */

View File

@ -1,5 +1,5 @@
<template>
<view>
<scroll-view class="content-scroll" scroll-y>
<!-- 任务状态栏 -->
@ -141,7 +141,7 @@
</view>
</view>
</view>
</template>
<script setup>
@ -152,6 +152,24 @@ import { onLoad,onShow } from '@dcloudio/uni-app';
const activeTab = ref('info');
const showMenuIndex = ref(-1);
//
const formatTimeToChinese = (date) => {
if (typeof date === 'string') {
//
date = new Date(date);
}
const weekdays = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const weekday = weekdays[date.getDay()];
const hour = String(date.getHours()).padStart(2, '0');
const minute = String(date.getMinutes()).padStart(2, '0');
const second = String(date.getSeconds()).padStart(2, '0');
return `${year}${month}${day}${weekday} ${hour}:${minute}:${second}`;
};
//
const task = ref({
id: null,
@ -166,7 +184,7 @@ const task = ref({
submitRecords: [
{
userName: "张珊珊",
time: "2025-10-20 15:20:56",
time: formatTimeToChinese(new Date('2025-10-20 15:20:56')),
content: "任务内容任务。这里是详细的任务描述,可以包含多行文本。根据实际需求,这里可以展示任务的详细要求、步骤说明、注意事项等。任务内容应该清晰明了,便于负责人理解和执行。",
attachments: [
{ type: "image" },
@ -178,7 +196,7 @@ const task = ref({
},
{
userName: "李志",
time: "2025-10-20 15:20:56",
time: formatTimeToChinese(new Date('2025-10-20 15:20:56')),
content: "任务内容任务。这里是详细的任务描述,可以包含多行文本。根据实际需求,这里可以展示任务的详细要求、步骤说明、注意事项等。任务内容应该清晰明了,便于负责人理解和执行。",
attachments: [
{ type: "file", name: "AA_573_1280.JPG" }