|
@@ -79,6 +79,7 @@ import TaskDetailSummary from './TaskDetailSummary.vue'
|
|
|
|
|
|
|
|
const IMAGE_FIELD_TYPES = new Set(['img', 'sign'])
|
|
const IMAGE_FIELD_TYPES = new Set(['img', 'sign'])
|
|
|
const IMAGE_AND_FILE_FIELD_TYPE = 'imgandfile'
|
|
const IMAGE_AND_FILE_FIELD_TYPE = 'imgandfile'
|
|
|
|
|
+const FILE_URL_FIELD_TYPE = 'fileurl'
|
|
|
const DICT_FIELD_TYPES = new Set(['select', 'domain', 'multiple_select'])
|
|
const DICT_FIELD_TYPES = new Set(['select', 'domain', 'multiple_select'])
|
|
|
const FILE_EXTENSIONS = new Set(['pdf', 'ppt', 'pptx'])
|
|
const FILE_EXTENSIONS = new Set(['pdf', 'ppt', 'pptx'])
|
|
|
const FILE_DOWNLOAD_TIMEOUT = 60_000
|
|
const FILE_DOWNLOAD_TIMEOUT = 60_000
|
|
@@ -143,6 +144,7 @@ const dictLabelsByField = computed(() => {
|
|
|
* 对应的字典中获取 label,字典缺失或值无法完整匹配时直接回显 value。
|
|
* 对应的字典中获取 label,字典缺失或值无法完整匹配时直接回显 value。
|
|
|
* 其余情况在 item.label 为空时用 value 回显。
|
|
* 其余情况在 item.label 为空时用 value 回显。
|
|
|
* img、sign 类型转成图片列表;imgAndFile 根据值末尾来源标记转成图片或文件;
|
|
* img、sign 类型转成图片列表;imgAndFile 根据值末尾来源标记转成图片或文件;
|
|
|
|
|
+ * fileurl 解析 value 中的 JSON 数组,取 url 和 fileName 展示附件;
|
|
|
* 其余类型显示标准化后的 label。
|
|
* 其余类型显示标准化后的 label。
|
|
|
*/
|
|
*/
|
|
|
const contentFields = computed(() => {
|
|
const contentFields = computed(() => {
|
|
@@ -157,6 +159,10 @@ const contentFields = computed(() => {
|
|
|
label: resolveItemLabel(name, item),
|
|
label: resolveItemLabel(name, item),
|
|
|
}))
|
|
}))
|
|
|
const attachments = items.flatMap((item) => {
|
|
const attachments = items.flatMap((item) => {
|
|
|
|
|
+ if (isFileUrlFieldType(item.type)) {
|
|
|
|
|
+ return parseFileUrlAttachments(item.value)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
const attachmentValue = item.value.trim() || item.label
|
|
const attachmentValue = item.value.trim() || item.label
|
|
|
|
|
|
|
|
if (isImageFieldType(item.type)) {
|
|
if (isImageFieldType(item.type)) {
|
|
@@ -178,7 +184,12 @@ const contentFields = computed(() => {
|
|
|
.filter((attachment) => attachment.type === 'image')
|
|
.filter((attachment) => attachment.type === 'image')
|
|
|
.map((attachment) => attachment.url)
|
|
.map((attachment) => attachment.url)
|
|
|
const text = items
|
|
const text = items
|
|
|
- .filter((item) => !isImageFieldType(item.type) && !isImageAndFileFieldType(item.type))
|
|
|
|
|
|
|
+ .filter(
|
|
|
|
|
+ (item) =>
|
|
|
|
|
+ !isImageFieldType(item.type) &&
|
|
|
|
|
+ !isImageAndFileFieldType(item.type) &&
|
|
|
|
|
+ !isFileUrlFieldType(item.type)
|
|
|
|
|
+ )
|
|
|
.map((item) => item.label)
|
|
.map((item) => item.label)
|
|
|
.filter(Boolean)
|
|
.filter(Boolean)
|
|
|
.join('、')
|
|
.join('、')
|
|
@@ -222,6 +233,38 @@ const isImageAndFileFieldType = (type: string): boolean => {
|
|
|
return type.trim().toLowerCase() === IMAGE_AND_FILE_FIELD_TYPE
|
|
return type.trim().toLowerCase() === IMAGE_AND_FILE_FIELD_TYPE
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+const isFileUrlFieldType = (type: string): boolean => {
|
|
|
|
|
+ return type.trim().toLowerCase() === FILE_URL_FIELD_TYPE
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const parseFileUrlAttachments = (value: string): DetailAttachment[] => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const files: unknown = JSON.parse(value)
|
|
|
|
|
+ if (!Array.isArray(files)) return []
|
|
|
|
|
+
|
|
|
|
|
+ return files.flatMap((file): DetailAttachment[] => {
|
|
|
|
|
+ if (!file || typeof file.url !== 'string' || !file.url.trim()) return []
|
|
|
|
|
+
|
|
|
|
|
+ const name =
|
|
|
|
|
+ typeof file.fileName === 'string' && file.fileName.trim()
|
|
|
|
|
+ ? file.fileName.trim()
|
|
|
|
|
+ : extractFileName(file.url)
|
|
|
|
|
+ const ext = getFileExtension(name)
|
|
|
|
|
+
|
|
|
|
|
+ return [
|
|
|
|
|
+ {
|
|
|
|
|
+ type: isFileAttachment(getAttachmentSuffix(file.url), ext) ? 'file' : 'image',
|
|
|
|
|
+ url: toFullUrl(file.url),
|
|
|
|
|
+ name,
|
|
|
|
|
+ ext,
|
|
|
|
|
+ },
|
|
|
|
|
+ ]
|
|
|
|
|
+ })
|
|
|
|
|
+ } catch {
|
|
|
|
|
+ return []
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const parseAttachments = (value: string, fieldMode: 'image' | 'mixed'): DetailAttachment[] => {
|
|
const parseAttachments = (value: string, fieldMode: 'image' | 'mixed'): DetailAttachment[] => {
|
|
|
return value
|
|
return value
|
|
|
.split(',')
|
|
.split(',')
|