提交 9f0b65b2 编写于 作者: 钟一霄's avatar 钟一霄

**V1.0.1.250205-260428**

1. 值班日志提交新增附件表单项
2. 领导查看表单新增对应附件表单项
3. 接口更新
上级 7d037dc2
流水线 #41593 已失败 ,包含阶段
因为 它太大了无法显示 源差异 。您可以改为 查看blob。
......@@ -98,6 +98,11 @@ export function LeadLogInit(signid) {
return requestGet(`/api/SignRecord/api/SignRecord/LeadLogInit?signid=${signid}`)
}
export function LeadLogInitNew(signid) {
//领导日志初始化(新)
return requestGet(`/api/SignRecord/api/SignRecord/LeadLogInitNew?signid=${signid}`)
}
/**
* Attendance
*/
......@@ -111,6 +116,11 @@ export function ImageUpLoad(data) {
return requestPost(`/api/Attendance/ImageUpLoad`, data)
}
export function FileUpload(data) {
//附件上传
return requestPost(`/api/UploadFiles/api/UploadFiles/FileUpload`, data)
}
export function AttendanceSubmit(data) {
//考勤打卡
return requestPost(`/api/Attendance/AttendanceSubmit`, data)
......
import { type AxiosRequestConfig } from "axios";
/**
* 领导日志初始化(新)
* /api/SignRecord/api/SignRecord/LeadLogInitNew
*/
export declare function getApiSignRecordApiSignRecordLeadLogInitNew(params: GetApiSignRecordApiSignRecordLeadLogInitNewParams, config?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<{
code: number;
status: string;
msg: string;
msg_detail: string;
response: string;
}, any>>;
export interface GetApiSignRecordApiSignRecordLeadLogInitNewParams {
signid?: string;
}
import request from "../../../../util/axios.js";
/**
* 领导日志初始化(新)
* /api/SignRecord/api/SignRecord/LeadLogInitNew
*/
export function getApiSignRecordApiSignRecordLeadLogInitNew(params, config) {
const paramsInput = {
signid: params.signid,
};
return request.get(`/api/SignRecord/api/SignRecord/LeadLogInitNew`, {
params: paramsInput,
...config,
});
}
......@@ -4,3 +4,4 @@ export * from "./postApiSignRecordApiSignRecordSignInOrOut";
export * from "./getApiSignRecordApiSignRecordSignSetSave";
export * from "./postApiSignRecordApiSignRecordSignLogSave";
export * from "./getApiSignRecordApiSignRecordLeadLogInit";
export * from "./getApiSignRecordApiSignRecordLeadLogInitNew";
......@@ -4,3 +4,4 @@ export * from "./postApiSignRecordApiSignRecordSignInOrOut";
export * from "./getApiSignRecordApiSignRecordSignSetSave";
export * from "./postApiSignRecordApiSignRecordSignLogSave";
export * from "./getApiSignRecordApiSignRecordLeadLogInit";
export * from "./getApiSignRecordApiSignRecordLeadLogInitNew";
export * from "./postApiUploadFilesApiUploadFilesFileUpload";
export * from "./postApiUploadFilesApiUploadFilesFileUpload";
import { type AxiosRequestConfig } from "axios";
/**
* 附件上传
* /api/UploadFiles/api/UploadFiles/FileUpload
*/
export declare function postApiUploadFilesApiUploadFilesFileUpload(input?: PostApiUploadFilesApiUploadFilesFileUploadInput, config?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<{
code: number;
status: string;
msg: string;
msg_detail: string;
response: string;
}, any>>;
export interface PostApiUploadFilesApiUploadFilesFileUploadInput {
data?: unknown;
}
import request from "../../../../util/axios.js";
/**
* 附件上传
* /api/UploadFiles/api/UploadFiles/FileUpload
*/
export function postApiUploadFilesApiUploadFilesFileUpload(input, config) {
return request.post(`/api/UploadFiles/api/UploadFiles/FileUpload`, input, config);
}
......@@ -8,6 +8,7 @@ export * from "./Message";
export * from "./MessageConfig";
export * from "./SignRecord";
export * from "./TimeTask";
export * from "./UploadFiles";
export * from "./UserInfo";
export * from "./UserRole";
export * from "./Watch";
......
......@@ -8,6 +8,7 @@ export * from "./Message";
export * from "./MessageConfig";
export * from "./SignRecord";
export * from "./TimeTask";
export * from "./UploadFiles";
export * from "./UserInfo";
export * from "./UserRole";
export * from "./Watch";
......
......@@ -103,7 +103,7 @@
<span>{{ item.watchtypename + '-' + item.dept + '-' + item.campusname }}</span></van-tag>
</template>
</van-cell>
<van-cell class="cardContent" title="值班班级">
<van-cell class="cardContent" title="值班班级/地点">
<template #extra>
<span>{{ item.watch_remark }}</span>
</template>
......@@ -205,16 +205,30 @@
:close-on-click-overlay="false"
style="height: 80%;"
title="值班日志">
<div style="padding: 16px;">
<van-field
id="teacherLog"
v-model="allLog"
autosize
label="教师日志"
label-align="top"
readonly
type="textarea"
/>
<div style="padding: 16px;height: calc(100% - 70px);overflow-y: auto;">
<div v-for="(item, index) in allLogList" :key="index" style="margin-bottom: 16px;border: 1px solid #f1f1f1;border-radius: 8px;padding: 10px;">
<van-field
:model-value="item.str || ''"
autosize
:label="`教师日志${index + 1}`"
label-align="top"
readonly
type="textarea"
/>
<van-field label="附件" label-align="top">
<template #input>
<div v-if="!item.file_list || !item.file_list.length" style="color: #999;">无附件</div>
<van-uploader
v-else
:model-value="getLeadLogUploaderList(item.file_list)"
:deletable="false"
:show-upload="false"
preview-size="72"
readonly
/>
</template>
</van-field>
</div>
<van-sticky :offset-bottom="16" container="VAS" position="bottom">
<van-button block type="primary" @click="copyLog">复制</van-button>
</van-sticky>
......@@ -248,6 +262,20 @@
show-word-limit
type="textarea"
/>
<van-field label="附件" label-align="top">
<template #input>
<van-uploader
v-model="signList.logFileList"
:accept="signList.fileAccept"
:after-read="afterReadLogFile"
:before-read="beforeReadLogFile"
:max-count="5"
multiple
preview-size="72"
@delete="onDeleteLogFile"
/>
</template>
</van-field>
</div>
<div
......@@ -361,6 +389,9 @@ let signList = reactive({
checked: [],
floatingBubble: false,
logId: '',
logFileList: [],
uploadedFileResList: [],
fileAccept: '.jpg,.jpeg,.png,.gif,.bmp,.webp,.xls,.xlsx,.doc,.docx,.pdf',
is_lead: 0,
sign: 9,
watchtypeid: '',
......@@ -418,6 +449,27 @@ const signImgUrl = ref('')
const logAcStShow = ref(false)
// 领导获取的教师日志
const allLog = ref('')
const allLogList = ref([])
const getLeadFileUrl = (fileItem = {}) => {
const rawPath = fileItem.path || fileItem.file_path || fileItem.url || ''
if (!rawPath) return ''
if (/^https?:\/\//i.test(rawPath)) return rawPath
const normalizedPath = rawPath.startsWith('/') ? rawPath : `/${rawPath}`
if (normalizedPath.startsWith('/DutyManagement/')) {
return `${window.location.origin}${normalizedPath}`
}
return `${window.location.origin}/DutyManagement${normalizedPath}`
}
const getLeadLogUploaderList = (fileList = []) => {
if (!Array.isArray(fileList)) return []
return fileList.map((fileItem, index) => ({
url: getLeadFileUrl(fileItem),
name: fileItem.file_name || fileItem.name || `附件${index + 1}`,
isImage: /\.(jpg|jpeg|png|gif|bmp|webp)$/i.test((fileItem.suffix || '').toLowerCase()) || /\.(jpg|jpeg|png|gif|bmp|webp)$/i.test((fileItem.file_name || fileItem.name || '').toLowerCase()),
}))
}
const tabs = (e) => {
......@@ -460,6 +512,7 @@ const submitLog = async () => {
let data = {
sign_id: signList.logId,
content: signList.message,
file_list: signList.uploadedFileResList,
}
const res = await api.SignLogSave(data)
if (res.code === 1) showSuccessToast(res.msg)
......@@ -470,11 +523,93 @@ const submitLog = async () => {
await search1()
}
const normalizeLogFileList = (rawFileList) => {
if (!rawFileList) return []
if (Array.isArray(rawFileList)) return rawFileList
if (typeof rawFileList === 'string') {
try {
const parsed = JSON.parse(rawFileList)
return Array.isArray(parsed) ? parsed : []
} catch (error) {
return []
}
}
return []
}
const getFilePreviewUrl = (fileItem = {}) => {
return fileItem.file_path || fileItem.filePath || fileItem.url || fileItem.link || ''
}
const getFileDisplayName = (fileItem = {}, index = 0) => {
return fileItem.fileName || fileItem.file_name || fileItem.name || `附件${index + 1}`
}
const dutyLog = (e) => {
signList.logId = e.signid
signList.message = e.content
const existedFiles = normalizeLogFileList(e.file_list)
signList.uploadedFileResList = existedFiles.map((item) => ({...item}))
signList.logFileList = existedFiles.map((item, index) => ({
url: getFilePreviewUrl(item),
name: getFileDisplayName(item, index),
status: 'done',
uploadedRes: item,
isImage: /\.(jpg|jpeg|png|gif|bmp|webp)$/i.test(getFileDisplayName(item, index)),
}))
signList.showCenter = true
}
const isAllowedLogFile = (fileObj) => {
const file = fileObj?.file || fileObj
if (!file || !file.name) return false
const fileName = file.name.toLowerCase()
const ext = fileName.includes('.') ? fileName.substring(fileName.lastIndexOf('.')) : ''
const allowExtList = [
'.jpg', '.jpeg', '.png', '.gif', '.bmp', '.webp',
'.xls', '.xlsx',
'.doc', '.docx',
'.pdf',
]
return allowExtList.includes(ext)
}
const beforeReadLogFile = (file) => {
if (Array.isArray(file)) {
return file.every((item) => isAllowedLogFile(item))
}
return isAllowedLogFile(file)
}
const afterReadLogFile = async (file, detail) => {
const fileItems = Array.isArray(file) ? file : [file]
for (const item of fileItems) {
item.status = 'uploading'
item.message = '上传中...'
const formData = new FormData()
formData.append('file', item.file)
const res = await api.FileUpload(formData)
if (res.code === 1) {
item.status = 'done'
item.message = ''
item.uploadedRes = res.response
signList.uploadedFileResList.push(res.response)
} else {
item.status = 'failed'
item.message = '上传失败'
showFailToast(res.msg_detail || res.msg || '上传失败')
const index = signList.logFileList.findIndex((cur) => cur === item)
if (index > -1) signList.logFileList.splice(index, 1)
}
}
}
const onDeleteLogFile = (file, detail) => {
const deletedRes = file?.uploadedRes
if (!deletedRes) return
const index = signList.uploadedFileResList.findIndex((item) => item === deletedRes)
if (index > -1) signList.uploadedFileResList.splice(index, 1)
}
const search = async () => {
let data = {
"dep_id": signList.dept_id,
......@@ -931,10 +1066,17 @@ function leadLog(obj) {
type: "loading",
});
logAcStShow.value = true
api.LeadLogInit(obj.signid).then(res => {
api.LeadLogInitNew(obj.signid).then(res => {
// console.log(res)
if (res.code == 1) {
allLog.value = res.response
if (Array.isArray(res.response)) {
allLogList.value = res.response
} else if (typeof res.response === 'string') {
allLogList.value = [{str: res.response, file_list: []}]
} else {
allLogList.value = []
}
closeToast()
} else {
closeToast()
......@@ -945,10 +1087,16 @@ function leadLog(obj) {
// 复制教师日志
function copyLog() {
const copyText = allLogList.value.map((item, index) => {
const title = item.str || ''
const files = (item.file_list || []).map((file) => file.file_name || file.name || file.path || '').filter(Boolean)
const fileText = files.length ? `附件:${files.join(',')}` : '附件:无'
return `${index + 1}. ${title}\n${fileText}`
}).join('\n\n')
// 创建input元素
const el = document.createElement('input')
// 给input元素赋值需要复制的文本
el.setAttribute('value', allLog.value)
el.setAttribute('value', copyText)
// 将input元素插入页面
document.body.appendChild(el)
// 选中input元素的文本
......
......@@ -122,7 +122,7 @@
width: 100%;
"
>
V1.0.1.250205-250325 </span>
V1.0.1.250205-260428 </span>
</div>
</div>
</div>
......
......@@ -65,7 +65,7 @@ axiosInstance.interceptors.request.use(
// 在发送请求之前可以进行一些处理,例如添加认证信息、日志等
let token = Cookies.get('admin-token')
config.headers['Authorization'] = 'Bearer ' + token
if (config.url.indexOf('ImageUpLoad') != -1)
if (config.data instanceof FormData || config.url.indexOf('ImageUpLoad') != -1 || config.url.indexOf('FileUpload') != -1)
config.headers['Content-Type'] = 'multipart/form-data'
refreshTokenAction()
return config;
......
......@@ -24,7 +24,7 @@ export default defineConfig({
// 这里的ccc可乱写, 是拼接在url后面的地址 如果接口中没有统一的后缀可自定义
// 如果有统一后缀, 如api, 直接写api即可, 也不用rewrite了
"/DutyManagement": {
target: "https://asc.hnasct.cn/", // 真实接口地址, 后端给的基地址
target: "https://develop.hnasct.cn/", // 真实接口地址, 后端给的基地址
changeOrigin: true, // 允许跨域
// rewrite: (path) => path.replace(/^\/DutyManagement/, ""), // 将ccc替换为空
},
......
Markdown 格式
0% or
您添加了 0 人 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册 或