Compare commits
9 Commits
dev-基础路径改造
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f317e2960 | ||
|
|
196a67d6fd | ||
|
|
a3313064c0 | ||
|
|
ae2661ab26 | ||
|
|
c22f57b281 | ||
|
|
d25305aa0c | ||
|
|
289e697330 | ||
|
|
2c9be532dd | ||
|
|
0378c0523c |
69
components/form-template/auto-fill.js
Normal file
69
components/form-template/auto-fill.js
Normal file
@ -0,0 +1,69 @@
|
||||
const DATE_ONLY_RE = /^(\d{4})-(\d{1,2})-(\d{1,2})$/;
|
||||
|
||||
export function resolveAutoFillValue(item, form = {}) {
|
||||
const rule = item && item.autoFill;
|
||||
if (!rule || !rule.sourceField || !rule.type) return undefined;
|
||||
|
||||
const sourceValue = form ? form[rule.sourceField] : '';
|
||||
if (!sourceValue) return '';
|
||||
|
||||
if (rule.type === 'addDays') {
|
||||
const days = Number(rule.days);
|
||||
if (!Number.isFinite(days)) return '';
|
||||
return addDays(sourceValue, days);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function collectAutoFillChanges(items = [], form = {}) {
|
||||
if (!Array.isArray(items)) return [];
|
||||
|
||||
return items.reduce((changes, item) => {
|
||||
if (!item || !item.title) return changes;
|
||||
|
||||
const nextValue = resolveAutoFillValue(item, form);
|
||||
if (nextValue === undefined) return changes;
|
||||
|
||||
const currentValue = form && form[item.title] !== undefined && form[item.title] !== null
|
||||
? String(form[item.title])
|
||||
: '';
|
||||
if (currentValue !== nextValue) {
|
||||
changes.push({ title: item.title, value: nextValue });
|
||||
}
|
||||
return changes;
|
||||
}, []);
|
||||
}
|
||||
|
||||
function addDays(value, days) {
|
||||
const date = parseDateOnly(value);
|
||||
if (!date) return '';
|
||||
date.setUTCDate(date.getUTCDate() + days);
|
||||
return formatDateOnly(date);
|
||||
}
|
||||
|
||||
function parseDateOnly(value) {
|
||||
const match = String(value || '').trim().match(DATE_ONLY_RE);
|
||||
if (!match) return null;
|
||||
|
||||
const year = Number(match[1]);
|
||||
const month = Number(match[2]);
|
||||
const day = Number(match[3]);
|
||||
const date = new Date(Date.UTC(year, month - 1, day));
|
||||
|
||||
if (
|
||||
date.getUTCFullYear() !== year ||
|
||||
date.getUTCMonth() !== month - 1 ||
|
||||
date.getUTCDate() !== day
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
return date;
|
||||
}
|
||||
|
||||
function formatDateOnly(date) {
|
||||
const year = date.getUTCFullYear();
|
||||
const month = String(date.getUTCMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getUTCDate()).padStart(2, '0');
|
||||
return `${year}-${month}-${day}`;
|
||||
}
|
||||
@ -8,7 +8,7 @@
|
||||
<script setup>
|
||||
import { computed, provide, ref, watch } from 'vue';
|
||||
import verifyForm from './verify.js';
|
||||
import { collectAutoFillChanges } from './auto-fill.mjs';
|
||||
import { collectAutoFillChanges } from './auto-fill.js';
|
||||
|
||||
import FormCell from './form-cell/index.vue';
|
||||
// import CustomCell from './custom-cell/index.vue';
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<template #footer>
|
||||
<button-footer :showCancel="customerId ? true : false" cancelText="删除" confirmText="保存" @cancel="unBindArchive()"
|
||||
<button-footer :showCancel="customerId ? true : false" cancelText="删除" :confirmText="healthTypes.length?'下一步':'保存'" @cancel="unBindArchive()"
|
||||
@confirm="confirm()" />
|
||||
</template>
|
||||
</full-page>
|
||||
@ -57,6 +57,7 @@ const tempRef = ref(null);
|
||||
const verifyVisible = ref(false);
|
||||
const visible = ref(false);
|
||||
const referenceCustomer = ref(null)
|
||||
const healthTypes = ref([]);
|
||||
|
||||
const formData = computed(() => {
|
||||
return { ...customer.value, ...form.value, mobile: account.value?.mobile }
|
||||
@ -164,7 +165,17 @@ async function addArchive() {
|
||||
set('home-invite-team-info', { teamId: teamId.value })
|
||||
if (res && res.success) {
|
||||
uni.$emit('reloadTeamCustomers')
|
||||
getTeam(corpId.value, teamId.value, res.data.id);
|
||||
// getTeam(corpId.value, teamId.value, res.data.id);
|
||||
if (healthTypes.value.length) {
|
||||
const nextType = healthTypes.value[0];
|
||||
const nextTypes = healthTypes.value.slice(1);
|
||||
const url = `/pages/health/record?type=${nextType}&teamId=${teamId.value}&corpId=${corpId.value}&customerId=${res.data.id}&nextTypes=${nextTypes.join(',')}&source=afterArchive`
|
||||
uni.redirectTo({ url });
|
||||
} else {
|
||||
uni.redirectTo({
|
||||
url: `/pages/archive/archive-result?corpId=${corpId.value}&teamId=${teamId.value}&customerId=${res.data.id}`
|
||||
})
|
||||
}
|
||||
} else {
|
||||
toast(res?.message || '新增档案失败');
|
||||
}
|
||||
@ -205,6 +216,7 @@ async function init() {
|
||||
visible.value = true;
|
||||
}
|
||||
getExternalUserId(corpId.value);
|
||||
getTeam(corpId.value, teamId.value)
|
||||
}
|
||||
await getBaseForm();
|
||||
if (!customerId.value) {
|
||||
@ -285,18 +297,18 @@ async function getTeam(corpId, teamId, customerId) {
|
||||
const team = res.data;
|
||||
const qrcode = team && Array.isArray(team.qrcodes) ? team.qrcodes[0] : null;
|
||||
const healthTempList = qrcode && Array.isArray(qrcode.healthTempList) ? qrcode.healthTempList : [];
|
||||
const types = healthTempList.filter(i => typeof i.templateType === 'string' && i.templateType.trim() && i.archiveRecommend === true).map(i => i.templateType);
|
||||
if (types.length && customerId) {
|
||||
const nextType = types[0];
|
||||
const nextTypes = types.slice(1);
|
||||
const url = `/pages/health/record?type=${nextType}&teamId=${teamId}&corpId=${corpId}&customerId=${customerId}&nextTypes=${nextTypes.join(',')}&source=afterArchive`
|
||||
uni.redirectTo({ url });
|
||||
return
|
||||
}
|
||||
healthTypes.value = healthTempList.filter(i => typeof i.templateType === 'string' && i.templateType.trim() && i.archiveRecommend === true).map(i => i.templateType);
|
||||
// if (types.length && customerId) {
|
||||
// const nextType = types[0];
|
||||
// const nextTypes = types.slice(1);
|
||||
// const url = `/pages/health/record?type=${nextType}&teamId=${teamId}&corpId=${corpId}&customerId=${customerId}&nextTypes=${nextTypes.join(',')}&source=afterArchive`
|
||||
// uni.redirectTo({ url });
|
||||
// return
|
||||
// }
|
||||
}
|
||||
uni.redirectTo({
|
||||
url: `/pages/archive/archive-result?corpId=${corpId}&teamId=${teamId}&customerId=${customerId}`
|
||||
})
|
||||
// uni.redirectTo({
|
||||
// url: `/pages/archive/archive-result?corpId=${corpId}&teamId=${teamId}&customerId=${customerId}`
|
||||
// })
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -10,7 +10,8 @@
|
||||
</view>
|
||||
|
||||
<template #footer>
|
||||
<button-footer v-if="canEdit" confirmText="保存" :showCancel="false" @confirm="confirm()" />
|
||||
<button-footer v-if="canEdit" :confirmText="nextTypes.length ? '下一步' : '保存'" :showCancel="false"
|
||||
@confirm="confirm()" />
|
||||
</template>
|
||||
</full-page>
|
||||
</template>
|
||||
|
||||
@ -83,7 +83,8 @@ const consultItems = ref([
|
||||
]);
|
||||
const hideMenus = computed(() => {
|
||||
const result = {};
|
||||
if (!props.team || !props.team.creator) {
|
||||
// 非医助手团队
|
||||
if (!(props.team && props.team.createSource === 'yzs')) {
|
||||
result.chat = true;
|
||||
}
|
||||
return result;
|
||||
@ -92,7 +93,7 @@ const hideMenus = computed(() => {
|
||||
function handleItemClick(item) {
|
||||
// 聊天咨询需要选择咨询人
|
||||
if (item.needSelectConsultant) {
|
||||
if (!props.team || !props.team.creator) {
|
||||
if (!(props.team && props.team.createSource === 'yzs')) {
|
||||
return toast('该团队暂未开放咨询服务')
|
||||
}
|
||||
|
||||
|
||||
@ -146,7 +146,7 @@ const hasHealthTemp = computed(
|
||||
() =>
|
||||
qrcode.value &&
|
||||
Array.isArray(qrcode.value.healthTempList) &&
|
||||
qrcode.value.healthTempList.length > 0
|
||||
qrcode.value.healthTempList.filter(i => i && i.enable).length > 0
|
||||
);
|
||||
const baseInfo = computed(() =>
|
||||
qrcode.value &&
|
||||
|
||||
@ -15,7 +15,9 @@
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from "vue";
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { onLoad } from "@dcloudio/uni-app";
|
||||
import useAccount from '@/store/account';
|
||||
import api from "@/utils/api.js";
|
||||
import { loading, toast, hideLoading } from "@/utils/widget";
|
||||
|
||||
@ -24,6 +26,8 @@ import surveyCover from "./components/survey-cover.vue";
|
||||
import surveyQuestion from "./components/survey-question.vue";
|
||||
import surveyRecord from "./components/survey-record.vue";
|
||||
|
||||
const env = __VITE_ENV__;
|
||||
const appid = env.MP_WX_APP_ID;
|
||||
const corpId = ref('');
|
||||
const surveryId = ref('');
|
||||
const answerId = ref('');
|
||||
@ -32,7 +36,7 @@ const survey = ref(null);
|
||||
const emptyTxt = ref('')
|
||||
const customerName = ref('');
|
||||
const step = ref('cover');
|
||||
|
||||
const { login, getExternalUserId } = useAccount();
|
||||
const readonly = computed(() => survey.value && survey.value.submitTime);
|
||||
const list = computed(() => survey.value && Array.isArray(survey.value.list) ? survey.value.list : []);
|
||||
const showList = computed(() => {
|
||||
@ -80,7 +84,8 @@ async function init() {
|
||||
async function getAnswerRecord() {
|
||||
const res = await api('getAnswer', { corpId: corpId.value, surveryId: surveryId.value, answerId: answerId.value, memberId: memberId.value });
|
||||
if (res && res.success) {
|
||||
return res.record
|
||||
relateWxappp(res.record)
|
||||
return res.record;
|
||||
}
|
||||
return Promise.reject();
|
||||
}
|
||||
@ -108,17 +113,34 @@ async function submit({ list, score }) {
|
||||
}
|
||||
}
|
||||
|
||||
async function relateWxappp(record) {
|
||||
const { teamId, corpId, memberId } = record || {};
|
||||
if (!(teamId && corpId && memberId)) return;
|
||||
const account = await login();
|
||||
const externalUserId = await getExternalUserId(corpId);
|
||||
if (!externalUserId) return;
|
||||
const res = await api('relateWxappTeamByExternalUserId', {
|
||||
appid,
|
||||
openid: account.openid,
|
||||
teamId: teamId,
|
||||
corpId: corpId,
|
||||
memberId: memberId,
|
||||
externalUserId: externalUserId,
|
||||
})
|
||||
console.clear()
|
||||
console.log(res)
|
||||
}
|
||||
|
||||
onLoad(opts => {
|
||||
corpId.value = opts.corpId;
|
||||
surveryId.value = opts.surveryId;
|
||||
answerId.value = opts.answerId;
|
||||
memberId.value = opts.memberId;
|
||||
customerName.value = opts.name;
|
||||
customerName.value = decodeURIComponent(decodeURIComponent(opts.name || ''));
|
||||
init();
|
||||
})
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
@ -157,6 +157,7 @@ export default defineStore("accountStore", () => {
|
||||
const res = await api('getUnionidToExternalUserid', { unionid, openid, corpId }, false);
|
||||
const id = res && res.success && typeof res.data === 'string' && res.data.trim() ? res.data.trim() : '';
|
||||
externalUserId.value = id;
|
||||
return id;
|
||||
}
|
||||
|
||||
watch(hasImCorpId, n => {
|
||||
|
||||
@ -6,6 +6,10 @@ export const CORP_API_BASE_URL_MAP = {
|
||||
wwa54dfba0b5441ef1: "https://crm.gykqyy.com/ykt/",
|
||||
};
|
||||
|
||||
export const CORP_ID_ALIAS_MAP = {
|
||||
"wpLgjyawAAeRkCPQMp9-z5q-xEzK64nA": "wwa54dfba0b5441ef1",
|
||||
};
|
||||
|
||||
function normalizeBaseUrl(url) {
|
||||
return String(url || "").replace(/\/+$/, "");
|
||||
}
|
||||
@ -14,6 +18,11 @@ function getDefaultBaseUrl() {
|
||||
return normalizeBaseUrl(env.MP_API_BASE_URL);
|
||||
}
|
||||
|
||||
export function normalizeCorpId(corpId) {
|
||||
const normalizedCorpId = String(corpId || "").trim();
|
||||
return CORP_ID_ALIAS_MAP[normalizedCorpId] || normalizedCorpId;
|
||||
}
|
||||
|
||||
function readCachedContext() {
|
||||
if (typeof uni === "undefined" || typeof uni.getStorageSync !== "function") {
|
||||
return null;
|
||||
@ -75,12 +84,12 @@ function parseQueryString(queryString) {
|
||||
export function getCorpIdFromAppOptions(options = {}) {
|
||||
const query = options.query || options || {};
|
||||
const corpId = query.corpId || query.corpid || query.corp_id;
|
||||
if (corpId) return String(corpId).trim();
|
||||
if (corpId) return normalizeCorpId(corpId);
|
||||
|
||||
if (typeof query.q === "string") {
|
||||
const qParams = parseQueryString(safeDecode(query.q));
|
||||
const qCorpId = qParams.corpId || qParams.corpid || qParams.corp_id;
|
||||
if (qCorpId) return String(qCorpId).trim();
|
||||
if (qCorpId) return normalizeCorpId(qCorpId);
|
||||
}
|
||||
|
||||
return "";
|
||||
@ -93,7 +102,7 @@ export function initApiContextFromAppOptions(options = {}) {
|
||||
}
|
||||
|
||||
export function resolveApiContext(corpId) {
|
||||
const normalizedCorpId = String(corpId || "").trim();
|
||||
const normalizedCorpId = normalizeCorpId(corpId);
|
||||
|
||||
if (normalizedCorpId) {
|
||||
const configuredBaseUrl = CORP_API_BASE_URL_MAP[normalizedCorpId];
|
||||
|
||||
@ -14,7 +14,8 @@ const urlsConfig = {
|
||||
getWxappRelateTeams: 'getWxappRelateTeams',
|
||||
getTeamMemberAvatarsAndName: "getTeamMemberAvatarsAndName",
|
||||
getMiniAppHomeStats: "getMiniAppHomeStats",
|
||||
getResponsiblePerson: 'getTeamResponsiblePerson'
|
||||
getResponsiblePerson: 'getTeamResponsiblePerson',
|
||||
relateWxappTeamByExternalUserId: 'relateWxappTeamByExternalUserId'
|
||||
},
|
||||
|
||||
knowledgeBase: {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { loading, hideLoading } from "./widget";
|
||||
import { buildApiUrl, getDefaultUploadUrl } from "./api-base-config";
|
||||
import { buildApiUrl, getDefaultUploadUrl, normalizeCorpId } from "./api-base-config";
|
||||
|
||||
const defaultOptions = {
|
||||
header: {
|
||||
@ -96,6 +96,12 @@ async function refreshAccessToken() {
|
||||
const request = async (options = {}, showLoading = true) => {
|
||||
// 合并用户传入的配置和默认配置
|
||||
if (!options.data) options.data = {};
|
||||
if (options.data.corpId) {
|
||||
options.data = {
|
||||
...options.data,
|
||||
corpId: normalizeCorpId(options.data.corpId),
|
||||
};
|
||||
}
|
||||
|
||||
const config = {
|
||||
...defaultOptions,
|
||||
@ -201,12 +207,13 @@ export default request;
|
||||
export const uploadUrl = getDefaultUploadUrl();
|
||||
|
||||
export function getFullPath(path, corpId) {
|
||||
return buildApiUrl(path, corpId);
|
||||
return buildApiUrl(path, normalizeCorpId(corpId));
|
||||
}
|
||||
|
||||
|
||||
export function upload(path, corpId) {
|
||||
const currentUploadUrl = buildApiUrl("/upload", corpId);
|
||||
const normalizedCorpId = normalizeCorpId(corpId);
|
||||
const currentUploadUrl = buildApiUrl("/upload", normalizedCorpId);
|
||||
return new Promise((resolve) => {
|
||||
uni.uploadFile({
|
||||
url: currentUploadUrl,
|
||||
@ -216,7 +223,7 @@ export function upload(path, corpId) {
|
||||
success: (res) => {
|
||||
try {
|
||||
const url = JSON.parse(res.data).filePath;
|
||||
resolve(url ? getFullPath(url, corpId) : '')
|
||||
resolve(url ? getFullPath(url, normalizedCorpId) : '')
|
||||
} catch (e) {
|
||||
resolve()
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user