diff --git a/components/archive-detail/customer-profile-tab.vue b/components/archive-detail/customer-profile-tab.vue index 47ba157..8178965 100644 --- a/components/archive-detail/customer-profile-tab.vue +++ b/components/archive-detail/customer-profile-tab.vue @@ -1,18 +1,6 @@ diff --git a/components/archive-detail/health-profile-tab.vue b/components/archive-detail/health-profile-tab.vue index 0a65209..ba41576 100644 --- a/components/archive-detail/health-profile-tab.vue +++ b/components/archive-detail/health-profile-tab.vue @@ -381,57 +381,57 @@ watch( diff --git a/components/archive-detail/service-info-tab.vue b/components/archive-detail/service-info-tab.vue index e928aae..7f8cf87 100644 --- a/components/archive-detail/service-info-tab.vue +++ b/components/archive-detail/service-info-tab.vue @@ -420,16 +420,16 @@ watch( - diff --git a/components/form-template/form-cell/form-positive-find.vue b/components/form-template/form-cell/form-positive-find.vue index 7576ef1..4b25961 100644 --- a/components/form-template/form-cell/form-positive-find.vue +++ b/components/form-template/form-cell/form-positive-find.vue @@ -101,8 +101,8 @@ function remove(idx) { - diff --git a/components/form-template/form-cell/form-tag-picker.vue b/components/form-template/form-cell/form-tag-picker.vue new file mode 100644 index 0000000..b863cd2 --- /dev/null +++ b/components/form-template/form-cell/form-tag-picker.vue @@ -0,0 +1,100 @@ + + + + + diff --git a/components/form-template/form-cell/index.vue b/components/form-template/form-cell/index.vue index da38666..439fccf 100644 --- a/components/form-template/form-cell/index.vue +++ b/components/form-template/form-cell/index.vue @@ -13,6 +13,7 @@ :disableChange="disableChange" @change="change" /> + + - - {{ attrs.name || attrs.title }}(暂不支持:{{ attrs.type }}) - + + + - + diff --git a/pages/case/archive-edit.vue b/pages/case/archive-edit.vue index 9f856a3..3f34a1e 100644 --- a/pages/case/archive-edit.vue +++ b/pages/case/archive-edit.vue @@ -74,7 +74,7 @@ function normalizeTemplateItem(item) { const customTypeMap = { customerSource: 'select', customerStage: 'select', - tag: 'multiSelectAndOther', + tag: 'tagPicker', reference: 'input', selectWwuser: 'select', files: 'files', @@ -121,6 +121,87 @@ function normalizeTemplateItem(item) { return next; } +function unwrapTemplate(res) { + const d = res?.data; + if (d && typeof d === 'object') { + if (d.data && typeof d.data === 'object') return d.data; + return d; + } + return res && typeof res === 'object' ? res : {}; +} + +function unwrapListPayload(res) { + const root = res && typeof res === 'object' ? res : {}; + const d = root.data && typeof root.data === 'object' ? root.data : root; + if (!d) return []; + if (Array.isArray(d)) return d; + if (Array.isArray(d.data)) return d.data; + if (Array.isArray(d.list)) return d.list; + if (d.data && typeof d.data === 'object') { + if (Array.isArray(d.data.data)) return d.data.data; + if (Array.isArray(d.data.list)) return d.data.list; + } + return []; +} + +function parseCustomerStageOptions(res) { + const list = unwrapListPayload(res); + return list + .map((i) => { + if (typeof i === 'string') return { label: i, value: i }; + const label = i?.name ?? i?.label ?? ''; + const value = i?.type ?? i?.value ?? i?.id ?? i?.key ?? label; + if (!label && (value === undefined || value === null || value === '')) return null; + return { label: String(label || value), value: String(value) }; + }) + .filter(Boolean); +} + +function parseTagOptions(res) { + const list = unwrapListPayload(res); + let flat = []; + if (list.length && typeof list[0] === 'object' && Array.isArray(list[0]?.tag)) { + flat = list.reduce((acc, g) => { + if (Array.isArray(g?.tag)) acc.push(...g.tag); + return acc; + }, []); + } else { + flat = list; + } + + const options = flat + .map((i) => { + if (typeof i === 'string') return { label: i, value: i }; + const label = i?.name ?? i?.label ?? i?.text ?? ''; + const value = i?.id ?? i?.value ?? i?.key ?? label; + if (!label && (value === undefined || value === null || value === '')) return null; + return { label: String(label || value), value: String(value) }; + }) + .filter(Boolean); + + const seen = new Set(); + return options.filter((i) => { + if (!i?.value) return false; + if (seen.has(i.value)) return false; + seen.add(i.value); + return true; + }); +} + +function isStageItem(i) { + const title = String(i?.title || ''); + const type = String(i?.type || ''); + const name = String(i?.name || ''); + return title === 'customerStage' || type === 'customerStage' || name.includes('阶段'); +} + +function isTagItem(i) { + const title = String(i?.title || ''); + const type = String(i?.type || ''); + const name = String(i?.name || ''); + return title === 'tagIds' || title === 'tag' || type === 'tag' || name.includes('标签'); +} + function getUserId() { const d = doctorInfo.value || {}; const a = account.value || {}; @@ -159,13 +240,17 @@ function loadFromStorage() { async function loadTemplates() { const corpId = getCorpId(); if (!corpId) return; - const [baseRes, internalRes] = await Promise.all([ + const [baseRes, internalRes, stageRes, tagRes] = await Promise.all([ api('getCurrentTemplate', { corpId, templateType: 'baseTemplate' }), api('getCurrentTemplate', { corpId, templateType: 'internalTemplate' }), + api('getCustomerType', { corpId }), + api('getCorpTags', { corpId }), ]); + const stageOptions = parseCustomerStageOptions(stageRes); + const tagOptions = parseTagOptions(tagRes); if (baseRes?.success) { - const temp = baseRes?.data && typeof baseRes.data === 'object' ? baseRes.data : baseRes; + const temp = unwrapTemplate(baseRes); const list = Array.isArray(temp.templateList) ? temp.templateList : []; baseItems.value = list .filter((i) => i && i.fieldStatus !== 'disable') @@ -174,8 +259,14 @@ async function loadTemplates() { } if (internalRes?.success) { - const temp = internalRes?.data && typeof internalRes.data === 'object' ? internalRes.data : internalRes; - const list = Array.isArray(temp.templateList) ? temp.templateList : []; + const temp = unwrapTemplate(internalRes); + const list = (Array.isArray(temp.templateList) ? temp.templateList : []).map((i) => { + const item = { ...(i || {}) }; + if (isStageItem(item) && (!Array.isArray(item.range) || item.range.length === 0)) item.range = stageOptions; + if (isTagItem(item) && (!Array.isArray(item.range) || item.range.length === 0)) item.range = tagOptions; + if (isTagItem(item) && item.title === 'tag') item.title = 'tagIds'; + return item; + }); internalItems.value = list .filter((i) => i && i.fieldStatus !== 'disable') .filter((i) => i.operateType !== 'onlyRead') diff --git a/pages/case/case.vue b/pages/case/case.vue index 2ca2d57..49472f3 100644 --- a/pages/case/case.vue +++ b/pages/case/case.vue @@ -4,7 +4,7 @@ {{ teamDisplay }} - + @@ -85,11 +85,11 @@