fix:内部信息显示bug
This commit is contained in:
parent
7da14980a4
commit
ea55922915
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<view class="form-row" title="">
|
||||
<view class="form-row" @click="handleClick">
|
||||
<view class="form-row__label">
|
||||
{{ name }}<text v-if="required" class="form-cell--required"></text>
|
||||
</view>
|
||||
@ -10,6 +10,8 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
const emit = defineEmits(['click'])
|
||||
|
||||
defineProps({
|
||||
name: {
|
||||
default: ''
|
||||
@ -22,6 +24,10 @@ defineProps({
|
||||
default: ''
|
||||
}
|
||||
})
|
||||
|
||||
function handleClick(e) {
|
||||
emit('click', e)
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
@import url(./cell-style.css);
|
||||
|
||||
100
components/form-template/form-cell/form-tag-picker.vue
Normal file
100
components/form-template/form-cell/form-tag-picker.vue
Normal file
@ -0,0 +1,100 @@
|
||||
<template>
|
||||
<common-cell :name="name" :required="required" @click="open">
|
||||
<view class="form-content__wrapper">
|
||||
<view class="flex-main-content truncate" :class="displayText ? '' : 'form__placeholder'">
|
||||
{{ displayText || placeholder }}
|
||||
</view>
|
||||
<view v-if="displayText && !disableChange" class="form-arrow" @click.stop="clear">
|
||||
<uni-icons type="closeempty" size="18" color="#bbb" />
|
||||
</view>
|
||||
<uni-icons class="form-arrow" type="arrowright"></uni-icons>
|
||||
</view>
|
||||
</common-cell>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, onBeforeUnmount, onMounted } from 'vue';
|
||||
import commonCell from '../common-cell.vue';
|
||||
|
||||
const emits = defineEmits(['change']);
|
||||
const props = defineProps({
|
||||
form: { type: Object, default: () => ({}) },
|
||||
name: { default: '' },
|
||||
required: { type: Boolean, default: false },
|
||||
title: { default: '' },
|
||||
range: { type: Array, default: () => [] },
|
||||
disableChange: { type: Boolean, default: false },
|
||||
});
|
||||
|
||||
const placeholder = computed(() => `请选择${props.name || ''}`);
|
||||
|
||||
const value = computed(() => {
|
||||
const v = props.form?.[props.title];
|
||||
return Array.isArray(v) ? v.map(String).filter(Boolean) : [];
|
||||
});
|
||||
|
||||
const valueToLabel = computed(() => {
|
||||
const map = new Map();
|
||||
const r = Array.isArray(props.range) ? props.range : [];
|
||||
r.forEach((i) => {
|
||||
if (typeof i === 'string') map.set(String(i), String(i));
|
||||
else if (i && typeof i === 'object') {
|
||||
const val = i.value ?? i.id ?? i.key ?? i.label ?? i.name ?? '';
|
||||
const label = i.label ?? i.name ?? i.text ?? String(val);
|
||||
if (val) map.set(String(val), String(label || val));
|
||||
}
|
||||
});
|
||||
return map;
|
||||
});
|
||||
|
||||
const displayText = computed(() => {
|
||||
if (!value.value.length) return '';
|
||||
const labels = value.value.map((id) => valueToLabel.value.get(id) || id);
|
||||
return labels.join('、');
|
||||
});
|
||||
|
||||
const eventName = `select_tag_${Date.now()}_${Math.random().toString(16).slice(2)}`;
|
||||
|
||||
function open() {
|
||||
if (props.disableChange) return;
|
||||
console.log('[debug][wxapp][tagPicker] open click');
|
||||
uni.setStorageSync('ykt_tag_list_selections', value.value);
|
||||
const url = `/pages/library/tag-list/tag-list?eventName=${eventName}`;
|
||||
uni.navigateTo({
|
||||
url,
|
||||
fail: (e) => {
|
||||
console.error('[debug][wxapp][tagPicker] navigateTo fail:', url, e);
|
||||
const msg = e && typeof e === 'object' && e.errMsg ? e.errMsg : '跳转失败';
|
||||
uni.showToast({ title: msg, icon: 'none' });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function clear() {
|
||||
emits('change', { title: props.title, value: [] });
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
console.log('[debug][wxapp][tagPicker] mounted:', props.title);
|
||||
uni.$on(eventName, (data) => {
|
||||
const next = Array.isArray(data) ? data.map(String).filter(Boolean) : [];
|
||||
emits('change', { title: props.title, value: next });
|
||||
});
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
uni.$off(eventName);
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import '../cell-style.css';
|
||||
|
||||
.form-content__wrapper {
|
||||
line-height: 42rpx;
|
||||
}
|
||||
|
||||
.flex-main-content {
|
||||
line-height: 42rpx;
|
||||
}
|
||||
</style>
|
||||
@ -38,11 +38,36 @@
|
||||
:disableChange="disableChange"
|
||||
@change="change"
|
||||
/>
|
||||
<form-tag-picker
|
||||
v-else-if="attrs.type === 'tagPicker'"
|
||||
v-bind="attrs"
|
||||
:form="form"
|
||||
:disableChange="disableChange"
|
||||
@change="change"
|
||||
/>
|
||||
<form-run-time v-else-if="attrs.type === 'runTime'" v-bind="attrs" :form="form" :disableChange="disableChange" @change="change" />
|
||||
<form-files v-else-if="attrs.type === 'files'" v-bind="attrs" :form="form" :disableChange="disableChange" @change="change" />
|
||||
<view v-else-if="attrs.type || attrs.name || attrs.title" class="py-20rpx px-30rpx border-bottom text-28rpx text-gray-500">
|
||||
{{ attrs.name || attrs.title }}(暂不支持:{{ attrs.type }})
|
||||
</view>
|
||||
<form-select
|
||||
v-else-if="Array.isArray(attrs.range) && attrs.range.length"
|
||||
v-bind="attrs"
|
||||
:form="form"
|
||||
:disableChange="disableChange"
|
||||
@change="change"
|
||||
/>
|
||||
<form-textarea
|
||||
v-else-if="String(attrs.type || '').toLowerCase().includes('textarea')"
|
||||
v-bind="attrs"
|
||||
:form="form"
|
||||
:disableChange="disableChange"
|
||||
@change="change"
|
||||
/>
|
||||
<form-input
|
||||
v-else-if="attrs.type || attrs.name || attrs.title"
|
||||
v-bind="attrs"
|
||||
:form="form"
|
||||
:disableChange="disableChange"
|
||||
@change="change"
|
||||
/>
|
||||
|
||||
<!--
|
||||
<form-operation v-else-if="attrs.title === 'surgicalHistory'" v-bind="attrs" :form="form" @change="change"
|
||||
@ -71,6 +96,7 @@ import formSelectImage from './form-select-image.vue';
|
||||
import formSurgicalHistory from './form-surgical-history.vue';
|
||||
import formPositiveFind from './form-positive-find.vue';
|
||||
import formDiagnosisPicker from './form-diagnosis-picker.vue';
|
||||
import formTagPicker from './form-tag-picker.vue';
|
||||
|
||||
defineProps({
|
||||
form: {
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
<template>
|
||||
<template v-for="item in formItems" :key="item.title">
|
||||
<form-cell v-bind="item" :form="form" :disableChange="disabledMap[item.title]" @change="change" />
|
||||
<form-cell v-bind="item" :form="formModel" :disableChange="disabledMap[item.title]" @change="change" />
|
||||
</template>
|
||||
</template>
|
||||
<script setup>
|
||||
import { computed, provide, ref } from 'vue';
|
||||
import verifyForm from './verify.js';
|
||||
import { createAliasedForm } from '@/utils/form-alias';
|
||||
|
||||
import FormCell from './form-cell/index.vue';
|
||||
|
||||
@ -54,6 +55,8 @@ const formItems = computed(() => {
|
||||
.map((i) => ({ ...i }));
|
||||
})
|
||||
|
||||
const formModel = computed(() => createAliasedForm(props.form, props.items));
|
||||
|
||||
const rules = computed(() => ({ ...customRule.value, ...props.rule }));
|
||||
|
||||
function addRule(arg1, arg2) {
|
||||
@ -78,7 +81,7 @@ function change(data) {
|
||||
|
||||
function verify() {
|
||||
const visible = formItems.value.filter((i) => i && !i.hidden);
|
||||
return verifyForm(visible, rules.value, props.form)
|
||||
return verifyForm(visible, rules.value, formModel.value)
|
||||
}
|
||||
|
||||
defineExpose({ verify })
|
||||
|
||||
@ -12,6 +12,7 @@ const FormRule = {
|
||||
selectAndOther: checkInput,
|
||||
selectAndImage: checkListItem,
|
||||
multiSelectAndOther: checkMultiList,
|
||||
tagPicker: checkMultiList,
|
||||
files: checkFiles,
|
||||
runTime: checkInput,
|
||||
}
|
||||
|
||||
@ -158,6 +158,12 @@
|
||||
"navigationBarTitleText": "诊断"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/library/tag-list/tag-list",
|
||||
"style": {
|
||||
"navigationBarTitleText": "标签"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/others/edit-positive-find",
|
||||
"style": {
|
||||
|
||||
@ -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')
|
||||
|
||||
@ -129,6 +129,15 @@ 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 : {};
|
||||
}
|
||||
|
||||
async function loadBaseTemplate() {
|
||||
const corpId = String(account.value?.corpId || doctorInfo.value?.corpId || '') || '';
|
||||
if (!corpId) return;
|
||||
@ -142,7 +151,7 @@ async function loadBaseTemplate() {
|
||||
return;
|
||||
}
|
||||
|
||||
const temp = res?.data && typeof res.data === 'object' ? res.data : res;
|
||||
const temp = unwrapTemplate(res);
|
||||
const list = Array.isArray(temp.templateList) ? temp.templateList : [];
|
||||
baseItems.value = list
|
||||
.filter((i) => i && i.fieldStatus !== 'disable')
|
||||
|
||||
@ -95,7 +95,7 @@ function normalizeTemplateItem(item) {
|
||||
const customTypeMap = {
|
||||
customerSource: 'select',
|
||||
customerStage: 'select',
|
||||
tag: 'multiSelectAndOther',
|
||||
tag: 'tagPicker',
|
||||
reference: 'input',
|
||||
selectWwuser: 'select',
|
||||
files: 'files',
|
||||
@ -144,12 +144,139 @@ function normalizeTemplateItem(item) {
|
||||
return next;
|
||||
}
|
||||
|
||||
function unwrapTemplate(res) {
|
||||
// 兼容后端返回结构:{ success, data: { data: template } } / { success, data: template } / { templateList: [] }
|
||||
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 ensureInternalDefaults(list, { stageOptions = [], tagOptions = [] } = {}) {
|
||||
const items = Array.isArray(list) ? [...list] : [];
|
||||
const has = (title) => items.some((i) => i && String(i.title || '') === title);
|
||||
|
||||
// 与 mobile 内部信息页一致:标签 / 备注 / 阶段
|
||||
if (!has('tagIds')) {
|
||||
items.unshift({
|
||||
title: 'tagIds',
|
||||
name: '标签',
|
||||
type: 'tag',
|
||||
operateType: 'formCell',
|
||||
required: false,
|
||||
wordLimit: 200,
|
||||
range: tagOptions,
|
||||
});
|
||||
}
|
||||
if (!has('notes')) {
|
||||
items.push({
|
||||
title: 'notes',
|
||||
name: '备注',
|
||||
type: 'textarea',
|
||||
operateType: 'formCell',
|
||||
required: false,
|
||||
wordLimit: 200,
|
||||
});
|
||||
}
|
||||
if (!has('customerStage')) {
|
||||
items.push({
|
||||
title: 'customerStage',
|
||||
name: '阶段',
|
||||
type: 'customerStage',
|
||||
operateType: 'formCell',
|
||||
required: false,
|
||||
range: stageOptions,
|
||||
});
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
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 = [];
|
||||
|
||||
// 形态1:[{ groupName, tag: [{id,name}] }]
|
||||
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('标签');
|
||||
}
|
||||
|
||||
async function loadInternalTemplate() {
|
||||
const corpId = String(account.value?.corpId || doctorInfo.value?.corpId || '') || '';
|
||||
if (!corpId) return;
|
||||
|
||||
loading('加载中...');
|
||||
const res = await api('getCurrentTemplate', { corpId, templateType: 'internalTemplate' });
|
||||
const [res, stageRes, tagRes] = await Promise.all([
|
||||
api('getCurrentTemplate', { corpId, templateType: 'internalTemplate' }),
|
||||
api('getCustomerType', { corpId }),
|
||||
api('getCorpTags', { corpId }),
|
||||
]);
|
||||
hideLoading();
|
||||
|
||||
if (!res?.success) {
|
||||
@ -157,12 +284,32 @@ async function loadInternalTemplate() {
|
||||
return;
|
||||
}
|
||||
|
||||
const temp = res?.data && typeof res.data === 'object' ? res.data : res;
|
||||
const list = Array.isArray(temp.templateList) ? temp.templateList : [];
|
||||
console.log('[debug][wxapp][patient-inner-info] corpId:', corpId);
|
||||
console.log('[debug][wxapp][patient-inner-info] getCustomerType:', stageRes);
|
||||
console.log('[debug][wxapp][patient-inner-info] getCorpTags:', tagRes);
|
||||
|
||||
const stageOptions = parseCustomerStageOptions(stageRes);
|
||||
const tagOptions = parseTagOptions(tagRes);
|
||||
console.log('[debug][wxapp][patient-inner-info] parsed stageOptions:', stageOptions.length, stageOptions);
|
||||
console.log('[debug][wxapp][patient-inner-info] parsed tagOptions:', tagOptions.length, tagOptions);
|
||||
|
||||
const temp = unwrapTemplate(res);
|
||||
const list = ensureInternalDefaults(Array.isArray(temp.templateList) ? temp.templateList : [], { stageOptions, tagOptions }).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;
|
||||
});
|
||||
items.value = list
|
||||
.filter((i) => i && i.fieldStatus !== 'disable')
|
||||
.filter((i) => i.operateType !== 'onlyRead')
|
||||
.map(normalizeTemplateItem);
|
||||
|
||||
const debugStage = items.value.find(isStageItem);
|
||||
const debugTag = items.value.find(isTagItem);
|
||||
console.log('[debug][wxapp][patient-inner-info] final stage item:', debugStage);
|
||||
console.log('[debug][wxapp][patient-inner-info] final tag item:', debugTag);
|
||||
}
|
||||
|
||||
onLoad(async () => {
|
||||
@ -235,6 +382,7 @@ function buildPayload(base, inner) {
|
||||
if (payload.gender && !payload.sex) payload.sex = payload.gender;
|
||||
if (payload.idNo && !payload.idCard) payload.idCard = payload.idNo;
|
||||
if (payload.idType && !payload.cardType) payload.cardType = payload.idType;
|
||||
if (payload.tag && !payload.tagIds) payload.tagIds = payload.tag;
|
||||
if (Array.isArray(payload.teamId)) payload.teamId = payload.teamId[0] || '';
|
||||
|
||||
if (payload.customerSource && typeof payload.customerSource === 'string') {
|
||||
|
||||
224
pages/library/tag-list/tag-list.vue
Normal file
224
pages/library/tag-list/tag-list.vue
Normal file
@ -0,0 +1,224 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<scroll-view scroll-y class="scroll">
|
||||
<view v-for="(group, idx) in tagGroups" :key="group.id || idx" class="group">
|
||||
<view class="group-title">
|
||||
<text>{{ group.groupName || '标签' }}</text>
|
||||
<text v-if="group.createType === 'corpAsync'" class="hint">(企微标签)</text>
|
||||
</view>
|
||||
<view class="tags">
|
||||
<view
|
||||
v-for="tag in group.tag"
|
||||
:key="tag.id"
|
||||
class="tag"
|
||||
:class="selectedMap[tag.id] ? 'active' : ''"
|
||||
@click="toggle(tag.id)"
|
||||
>
|
||||
{{ tag.name }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="spacer" />
|
||||
</scroll-view>
|
||||
|
||||
<view class="footer">
|
||||
<view class="btn plain" @click="cancel">取消</view>
|
||||
<view class="btn primary" @click="save">确定</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
|
||||
import api from '@/utils/api';
|
||||
import useAccountStore from '@/store/account';
|
||||
import { hideLoading, loading, toast } from '@/utils/widget';
|
||||
|
||||
const accountStore = useAccountStore();
|
||||
const account = computed(() => accountStore.account);
|
||||
const doctorInfo = computed(() => accountStore.doctorInfo);
|
||||
|
||||
const eventName = ref('change-tag-list');
|
||||
const selections = ref([]);
|
||||
const tagGroups = ref([]);
|
||||
|
||||
const selectedMap = computed(() =>
|
||||
selections.value.reduce((m, id) => {
|
||||
m[String(id)] = true;
|
||||
return m;
|
||||
}, {})
|
||||
);
|
||||
|
||||
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.list)) return d.list;
|
||||
if (Array.isArray(d.data)) return d.data;
|
||||
if (d.data && typeof d.data === 'object') {
|
||||
if (Array.isArray(d.data.list)) return d.data.list;
|
||||
if (Array.isArray(d.data.data)) return d.data.data;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
function normalizeGroups(list) {
|
||||
const groups = Array.isArray(list) ? list : [];
|
||||
return groups
|
||||
.map((g) => {
|
||||
const tag = Array.isArray(g?.tag) ? g.tag : Array.isArray(g?.tags) ? g.tags : [];
|
||||
return {
|
||||
id: g?.id || g?._id || g?.groupId || '',
|
||||
groupName: g?.groupName || g?.name || '',
|
||||
createType: g?.createType || '',
|
||||
tag: (Array.isArray(tag) ? tag : [])
|
||||
.map((t) => ({
|
||||
id: String(t?.id || t?._id || t?.tagId || ''),
|
||||
name: String(t?.name || t?.label || ''),
|
||||
}))
|
||||
.filter((t) => t.id && t.name),
|
||||
};
|
||||
})
|
||||
.filter((g) => g.tag.length > 0);
|
||||
}
|
||||
|
||||
function getCorpId() {
|
||||
const env = __VITE_ENV__;
|
||||
return String(account.value?.corpId || doctorInfo.value?.corpId || env.MP_CORP_ID || '');
|
||||
}
|
||||
|
||||
async function loadTags() {
|
||||
const corpId = getCorpId();
|
||||
if (!corpId) return;
|
||||
|
||||
loading('加载中...');
|
||||
const res = await api('getCorpTags', { corpId });
|
||||
hideLoading();
|
||||
if (!res?.success) {
|
||||
toast(res?.message || '获取标签失败');
|
||||
tagGroups.value = [];
|
||||
return;
|
||||
}
|
||||
const list = unwrapListPayload(res);
|
||||
tagGroups.value = normalizeGroups(list);
|
||||
}
|
||||
|
||||
function toggle(id) {
|
||||
const key = String(id);
|
||||
if (!key) return;
|
||||
if (selectedMap.value[key]) {
|
||||
selections.value = selections.value.filter((i) => String(i) !== key);
|
||||
} else {
|
||||
selections.value = [...selections.value, key];
|
||||
}
|
||||
}
|
||||
|
||||
function cancel() {
|
||||
uni.navigateBack();
|
||||
}
|
||||
|
||||
function save() {
|
||||
const list = selections.value.map(String).filter(Boolean);
|
||||
uni.$emit(eventName.value, list);
|
||||
uni.navigateBack();
|
||||
}
|
||||
|
||||
onLoad(async (query) => {
|
||||
if (query?.eventName) eventName.value = String(query.eventName);
|
||||
const cached = uni.getStorageSync('ykt_tag_list_selections');
|
||||
uni.removeStorageSync('ykt_tag_list_selections');
|
||||
selections.value = Array.isArray(cached) ? cached.map(String).filter(Boolean) : [];
|
||||
await loadTags();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page {
|
||||
height: 100vh;
|
||||
background: #fff;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.scroll {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.group {
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.group-title {
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
margin-bottom: 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10rpx;
|
||||
}
|
||||
|
||||
.hint {
|
||||
font-size: 22rpx;
|
||||
color: #5d8aff;
|
||||
}
|
||||
|
||||
.tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.tag {
|
||||
max-width: 100%;
|
||||
padding: 12rpx 20rpx;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 16rpx;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.2em;
|
||||
color: #333;
|
||||
background: #fff;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.tag.active {
|
||||
color: #fff;
|
||||
border-color: #5d8aff;
|
||||
background: #5d8aff;
|
||||
}
|
||||
|
||||
.spacer {
|
||||
height: 120rpx;
|
||||
}
|
||||
|
||||
.footer {
|
||||
padding: 24rpx 30rpx calc(24rpx + env(safe-area-inset-bottom));
|
||||
display: flex;
|
||||
gap: 20rpx;
|
||||
border-top: 1px solid #eee;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.btn {
|
||||
flex: 1;
|
||||
height: 88rpx;
|
||||
line-height: 88rpx;
|
||||
border-radius: 12rpx;
|
||||
font-size: 30rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.btn.plain {
|
||||
background: #fff;
|
||||
color: #666;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.btn.primary {
|
||||
background: #5d8aff;
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
||||
@ -101,6 +101,10 @@ export default [
|
||||
path: 'pages/library/diagnosis-list',
|
||||
meta: { title: '诊断', login: false },
|
||||
},
|
||||
{
|
||||
path: 'pages/library/tag-list/tag-list',
|
||||
meta: { title: '标签', login: false },
|
||||
},
|
||||
{
|
||||
path: 'pages/others/edit-positive-find',
|
||||
meta: { title: '阳性发现', login: false },
|
||||
|
||||
@ -3,6 +3,9 @@ import request from "./http";
|
||||
const urlsConfig = {
|
||||
corp: {
|
||||
getCorpMemberHomepageInfo: 'getCorpMemberHomepageInfo',
|
||||
// 企业信息/标签
|
||||
getCorpInfo: 'getCorpInfo',
|
||||
getCorpTags: 'getCorpTags',
|
||||
getTeamBaseInfo: 'getTeamBaseInfo',
|
||||
getTeamData: 'getTeamData',
|
||||
getTeamBymember: 'getTeamBymember',
|
||||
@ -71,6 +74,8 @@ const urlsConfig = {
|
||||
updateMedicalRecord: 'updateMedicalRecord',
|
||||
removeMedicalRecord: 'removeMedicalRecord',
|
||||
getCustomerMedicalRecord: 'getCustomerMedicalRecord',
|
||||
// 客户阶段
|
||||
getCustomerType: 'getCustomerType',
|
||||
},
|
||||
wecom: {
|
||||
addContactWay: 'addContactWay'
|
||||
|
||||
66
utils/form-alias.js
Normal file
66
utils/form-alias.js
Normal file
@ -0,0 +1,66 @@
|
||||
export const GLOBAL_FIELD_ALIASES = {
|
||||
// 内部信息 / HIS 相关字段可能后续改名:这里做最小兜底,保证“有值就能显示”
|
||||
hisCardNo: ['hisOutpatientNo', 'hisClinicNo', 'hisCardNumber'],
|
||||
idCard: ['idNo', 'idNumber'],
|
||||
sex: ['gender'],
|
||||
cardType: ['idType'],
|
||||
};
|
||||
|
||||
function isEmpty(v) {
|
||||
if (v === null || v === undefined) return true;
|
||||
if (Array.isArray(v)) return v.length === 0;
|
||||
if (typeof v === 'string') return v.trim() === '';
|
||||
return false;
|
||||
}
|
||||
|
||||
function buildAliasCandidates(items) {
|
||||
const itemList = Array.isArray(items) ? items : [];
|
||||
const map = {};
|
||||
|
||||
// 支持模板项自带别名:aliasTitles / aliases
|
||||
itemList.forEach((it) => {
|
||||
const title = it?.title;
|
||||
if (!title) return;
|
||||
const aliases = Array.isArray(it?.aliasTitles)
|
||||
? it.aliasTitles
|
||||
: Array.isArray(it?.aliases)
|
||||
? it.aliases
|
||||
: [];
|
||||
if (!aliases.length) return;
|
||||
map[String(title)] = aliases.map((i) => String(i)).filter(Boolean);
|
||||
});
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
function uniq(arr) {
|
||||
const out = [];
|
||||
const seen = new Set();
|
||||
arr.forEach((i) => {
|
||||
const v = String(i || '');
|
||||
if (!v || seen.has(v)) return;
|
||||
seen.add(v);
|
||||
out.push(v);
|
||||
});
|
||||
return out;
|
||||
}
|
||||
|
||||
export function createAliasedForm(form, items) {
|
||||
const local = buildAliasCandidates(items);
|
||||
return new Proxy(form || {}, {
|
||||
get(target, prop) {
|
||||
if (typeof prop !== 'string') return target[prop];
|
||||
|
||||
const direct = target[prop];
|
||||
if (!isEmpty(direct)) return direct;
|
||||
|
||||
const candidates = uniq([...(local[prop] || []), ...(GLOBAL_FIELD_ALIASES[prop] || [])]);
|
||||
for (const k of candidates) {
|
||||
const v = target[k];
|
||||
if (!isEmpty(v)) return v;
|
||||
}
|
||||
return direct;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user