提交任务-样式微调
This commit is contained in:
parent
f479d0d5a0
commit
62d84fcc38
|
|
@ -58,8 +58,8 @@
|
||||||
{
|
{
|
||||||
"path": "pages/submit-task/index",
|
"path": "pages/submit-task/index",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "提交详情",
|
"navigationBarTitleText": "提交详情"
|
||||||
"navigationStyle": "custom"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,17 @@
|
||||||
<template>
|
<template>
|
||||||
|
|
||||||
<view class="submit-task-page">
|
<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>
|
<scroll-view class="content-scroll" scroll-y>
|
||||||
|
<view style="padding: 16px">
|
||||||
|
|
||||||
|
|
||||||
<!-- 输入提交说明 -->
|
<!-- 输入提交说明 -->
|
||||||
<view class="form-item">
|
<view class="form-item">
|
||||||
<view class="form-icon">📄⚙️</view>
|
<view class="form-icon"></view>
|
||||||
<textarea
|
<textarea
|
||||||
v-model="formData.description"
|
v-model="formData.description"
|
||||||
class="description-input"
|
class="description-input"
|
||||||
|
|
@ -70,6 +68,7 @@
|
||||||
<view class="remove-btn" @click="removeFile(index)">✕</view>
|
<view class="remove-btn" @click="removeFile(index)">✕</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
|
|
||||||
<!-- 进度选择弹窗 -->
|
<!-- 进度选择弹窗 -->
|
||||||
|
|
@ -78,7 +77,7 @@
|
||||||
<view class="modal-title">选择任务进度</view>
|
<view class="modal-title">选择任务进度</view>
|
||||||
<view class="progress-content">
|
<view class="progress-content">
|
||||||
<slider
|
<slider
|
||||||
:value="formData.progress || 0"
|
:value="tempProgress !== null ? tempProgress : 0"
|
||||||
:min="0"
|
:min="0"
|
||||||
:max="100"
|
:max="100"
|
||||||
:step="10"
|
:step="10"
|
||||||
|
|
@ -91,7 +90,7 @@
|
||||||
class="progress-option"
|
class="progress-option"
|
||||||
v-for="progress in progressOptions"
|
v-for="progress in progressOptions"
|
||||||
:key="progress"
|
:key="progress"
|
||||||
:class="{ active: formData.progress === progress }"
|
:class="{ active: tempProgress === progress }"
|
||||||
@click="selectProgress(progress)"
|
@click="selectProgress(progress)"
|
||||||
>
|
>
|
||||||
<text>{{ progress }}%</text>
|
<text>{{ progress }}%</text>
|
||||||
|
|
@ -177,9 +176,10 @@ const onProgressChange = (e) => {
|
||||||
tempProgress.value = e.detail.value;
|
tempProgress.value = e.detail.value;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 选择进度
|
// 选择进度(点击按钮直接确认)
|
||||||
const selectProgress = (progress) => {
|
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);
|
formData.value.images.splice(index, 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 选择文件
|
// 选择文件(安卓平台)
|
||||||
const chooseFiles = () => {
|
const chooseFiles = () => {
|
||||||
// #ifdef H5 || APP-PLUS
|
const remainingCount = 5 - formData.value.files.length;
|
||||||
uni.showActionSheet({
|
if (remainingCount <= 0) {
|
||||||
itemList: ['从相册选择', '拍照'],
|
uni.showToast({
|
||||||
success: (res) => {
|
title: '最多只能添加5个文件',
|
||||||
if (res.tapIndex === 0) {
|
icon: 'none'
|
||||||
// 从相册选择
|
});
|
||||||
uni.chooseImage({
|
return;
|
||||||
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];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
uni.showToast({
|
|
||||||
title: '暂不支持文件选择',
|
|
||||||
icon: 'none'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// #endif
|
|
||||||
|
|
||||||
// #ifdef MP
|
// 安卓平台使用 plus API 调用原生文件选择器
|
||||||
uni.chooseFile({
|
if (typeof plus !== 'undefined') {
|
||||||
count: 5 - formData.value.files.length,
|
try {
|
||||||
type: 'file',
|
const Intent = plus.android.importClass('android.content.Intent');
|
||||||
success: (res) => {
|
const main = plus.android.runtimeMainActivity();
|
||||||
const files = res.tempFiles.map(file => ({
|
|
||||||
name: file.name || `file_${Date.now()}.${file.path.split('.').pop()}`,
|
// 创建文件选择 Intent
|
||||||
path: file.path,
|
const intent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||||
size: file.size
|
intent.setType('*/*');
|
||||||
}));
|
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
formData.value.files = [...formData.value.files, ...files];
|
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); // 允许多选
|
||||||
},
|
|
||||||
fail: (err) => {
|
// 启动文件选择器
|
||||||
console.error('选择文件失败:', err);
|
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 {
|
||||||
|
// 调用原始的 onActivityResult
|
||||||
|
if (originalOnActivityResult) {
|
||||||
|
originalOnActivityResult(requestCode, resultCode, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error('打开文件选择器失败:', error);
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '选择文件失败',
|
title: '文件选择功能暂不可用',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
} else {
|
||||||
// #endif
|
uni.showToast({
|
||||||
|
title: '当前环境不支持文件选择',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 删除文件
|
// 删除文件
|
||||||
|
|
@ -278,6 +349,20 @@ const removeFile = (index) => {
|
||||||
formData.value.files.splice(index, 1);
|
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 = () => {
|
const handleSubmit = () => {
|
||||||
if (!canSubmit.value) {
|
if (!canSubmit.value) {
|
||||||
|
|
@ -326,14 +411,7 @@ const handleSubmit = () => {
|
||||||
// 提交成功后,将数据传递回任务详情页
|
// 提交成功后,将数据传递回任务详情页
|
||||||
const submitRecord = {
|
const submitRecord = {
|
||||||
userName: '当前用户', // TODO: 从用户信息获取
|
userName: '当前用户', // TODO: 从用户信息获取
|
||||||
time: new Date().toLocaleString('zh-CN', {
|
time: formatTimeToChinese(new Date()),
|
||||||
year: 'numeric',
|
|
||||||
month: '2-digit',
|
|
||||||
day: '2-digit',
|
|
||||||
hour: '2-digit',
|
|
||||||
minute: '2-digit',
|
|
||||||
second: '2-digit'
|
|
||||||
}).replace(/\//g, '-'),
|
|
||||||
content: submitData.description || '',
|
content: submitData.description || '',
|
||||||
progress: submitData.progress,
|
progress: submitData.progress,
|
||||||
attachments: [
|
attachments: [
|
||||||
|
|
@ -406,7 +484,7 @@ const handleSubmit = () => {
|
||||||
/* 内容滚动区域 */
|
/* 内容滚动区域 */
|
||||||
.content-scroll {
|
.content-scroll {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
padding: 16px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 表单项 */
|
/* 表单项 */
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<view>
|
|
||||||
|
|
||||||
<scroll-view class="content-scroll" scroll-y>
|
<scroll-view class="content-scroll" scroll-y>
|
||||||
<!-- 任务状态栏 -->
|
<!-- 任务状态栏 -->
|
||||||
|
|
@ -141,7 +141,7 @@
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
|
@ -152,6 +152,24 @@ import { onLoad,onShow } from '@dcloudio/uni-app';
|
||||||
const activeTab = ref('info');
|
const activeTab = ref('info');
|
||||||
const showMenuIndex = ref(-1);
|
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({
|
const task = ref({
|
||||||
id: null,
|
id: null,
|
||||||
|
|
@ -166,7 +184,7 @@ const task = ref({
|
||||||
submitRecords: [
|
submitRecords: [
|
||||||
{
|
{
|
||||||
userName: "张珊珊",
|
userName: "张珊珊",
|
||||||
time: "2025-10-20 15:20:56",
|
time: formatTimeToChinese(new Date('2025-10-20 15:20:56')),
|
||||||
content: "任务内容任务。这里是详细的任务描述,可以包含多行文本。根据实际需求,这里可以展示任务的详细要求、步骤说明、注意事项等。任务内容应该清晰明了,便于负责人理解和执行。",
|
content: "任务内容任务。这里是详细的任务描述,可以包含多行文本。根据实际需求,这里可以展示任务的详细要求、步骤说明、注意事项等。任务内容应该清晰明了,便于负责人理解和执行。",
|
||||||
attachments: [
|
attachments: [
|
||||||
{ type: "image" },
|
{ type: "image" },
|
||||||
|
|
@ -178,7 +196,7 @@ const task = ref({
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
userName: "李志",
|
userName: "李志",
|
||||||
time: "2025-10-20 15:20:56",
|
time: formatTimeToChinese(new Date('2025-10-20 15:20:56')),
|
||||||
content: "任务内容任务。这里是详细的任务描述,可以包含多行文本。根据实际需求,这里可以展示任务的详细要求、步骤说明、注意事项等。任务内容应该清晰明了,便于负责人理解和执行。",
|
content: "任务内容任务。这里是详细的任务描述,可以包含多行文本。根据实际需求,这里可以展示任务的详细要求、步骤说明、注意事项等。任务内容应该清晰明了,便于负责人理解和执行。",
|
||||||
attachments: [
|
attachments: [
|
||||||
{ type: "file", name: "AA_573_1280.JPG" }
|
{ type: "file", name: "AA_573_1280.JPG" }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user