Skip to content

Commit

Permalink
Merge branch 'didi:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
webaddkevin authored Aug 4, 2024
2 parents bf338f7 + 9d89a1c commit 136cdfb
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 81 deletions.
2 changes: 1 addition & 1 deletion server/src/models/surveyResponse.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class SurveyResponse extends BaseEntity {
data: Record<string, any>;

@Column()
difTime: number;
diffTime: number;

@Column()
clientTime: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class DataStatisticService {
}
return {
...data,
difTime: (submitedData.difTime / 1000).toFixed(2),
diffTime: (submitedData.diffTime / 1000).toFixed(2),
createDate: moment(submitedData.createDate).format(
'YYYY-MM-DD HH:mm:ss',
),
Expand Down
2 changes: 1 addition & 1 deletion server/src/modules/survey/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function getListHeadByDataList(dataList) {
};
});
listHead.push({
field: 'difTime',
field: 'diffTime',
title: '答题耗时(秒)',
type: QUESTION_TYPE.TEXT,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class SurveyResponseController {
encryptType: Joi.string(),
sessionId: Joi.string(),
clientTime: Joi.number().required(),
difTime: Joi.number(),
diffTime: Joi.number(),
password: Joi.string().allow(null, ''),
whitelist: Joi.string().allow(null, ''),
}).validate(reqBody, { allowUnknown: true });
Expand All @@ -65,7 +65,7 @@ export class SurveyResponseController {
data,
sessionId,
clientTime,
difTime,
diffTime,
password,
whitelist: whitelistValue,
} = value;
Expand Down Expand Up @@ -254,7 +254,7 @@ export class SurveyResponseController {
surveyPath: value.surveyPath,
data: decryptedData,
clientTime,
difTime,
diffTime,
surveyId: responseSchema.pageId,
optionTextAndId,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class SurveyResponseService {
async createSurveyResponse({
data,
clientTime,
difTime,
diffTime,
surveyId,
surveyPath,
optionTextAndId,
Expand All @@ -22,7 +22,7 @@ export class SurveyResponseService {
data,
secretKeys: [],
clientTime,
difTime,
diffTime,
pageId: surveyId,
optionTextAndId,
});
Expand Down
2 changes: 1 addition & 1 deletion server/src/utils/messagePushing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('getPushingData', () => {
status: RECORD_STATUS.NEW,
date: 1711025113146,
},
difTime: 30518,
diffTime: 30518,
data: {
data458: '15000000000',
data515: '115019',
Expand Down
4 changes: 2 additions & 2 deletions web/src/management/pages/edit/components/MaterialGroup.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<draggable
v-model="renderData"
handle=".question-wrapper.isSelected"
filter=".question-wrapper.isSelected .question.isSelected"
handle=".question-wrapper.is-move"
filter=".question-wrapper.is-move .question.isSelected"
:preventOnFilter="false"
:group="DND_GROUP"
:onEnd="checkEnd"
Expand Down
14 changes: 11 additions & 3 deletions web/src/management/pages/edit/components/QuestionWrapper.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
<template>
<div
:class="itemClass"
:class="[itemClass, { 'is-move': isSelected || isMove }]"
@mouseenter="onMouseenter"
@mouseleave="onMouseleave"
@click="clickFormItem"
>
<div><slot v-if="moduleConfig.type !== 'section'"></slot></div>

<div :class="[showHover ? 'visibily' : 'hidden', 'hoverItem']">
<div class="item el-icon-rank" @click.stop.prevent="onMove">
<div
class="item el-icon-rank"
@click.stop.prevent
@mouseenter="setMoveState(true)"
@mouseleave="setMoveState(false)"
>
<i-ep-rank />
</div>
<div v-if="showUp" class="item" @click.stop.prevent="onMoveUp">
Expand Down Expand Up @@ -62,6 +67,7 @@ const emit = defineEmits(['changeSeq', 'select'])
const { getShowLogicText, hasShowLogic } = useShowLogicInfo(props.moduleConfig.field)
const isHover = ref(false)
const isMove = ref(false)
const itemClass = computed(() => {
return {
Expand Down Expand Up @@ -154,7 +160,9 @@ const onDelete = async () => {
}
}
const onMove = () => {}
const setMoveState = (state: boolean) => {
isMove.value = state
}
</script>

<style lang="scss" scoped>
Expand Down
139 changes: 72 additions & 67 deletions web/src/render/pages/RenderPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,128 +19,133 @@
</div>
</template>
<script setup lang="ts">
import { computed, ref } from 'vue'
import { storeToRefs } from 'pinia'
import { useRouter } from 'vue-router'
import { computed, ref } from "vue";
import { storeToRefs } from "pinia";
import { useRouter } from "vue-router";
// @ts-ignore
import communalLoader from '@materials/communals/communalLoader.js'
import MainRenderer from '../components/MainRenderer.vue'
import AlertDialog from '../components/AlertDialog.vue'
import ConfirmDialog from '../components/ConfirmDialog.vue'
import ProgressBar from '../components/ProgressBar.vue'
import communalLoader from "@materials/communals/communalLoader.js";
import MainRenderer from "../components/MainRenderer.vue";
import AlertDialog from "../components/AlertDialog.vue";
import ConfirmDialog from "../components/ConfirmDialog.vue";
import ProgressBar from "../components/ProgressBar.vue";
import { useSurveyStore } from '../stores/survey'
import { useQuestionStore } from '../stores/question'
import { submitForm } from '../api/survey'
import encrypt from '../utils/encrypt'
import { useSurveyStore } from "../stores/survey";
import { useQuestionStore } from "../stores/question";
import { submitForm } from "../api/survey";
import encrypt from "../utils/encrypt";
import useCommandComponent from '../hooks/useCommandComponent'
import useCommandComponent from "../hooks/useCommandComponent";
interface Props {
questionInfo?: any
isMobile?: boolean
questionInfo?: any;
isMobile?: boolean;
}
withDefaults(defineProps<Props>(), {
questionInfo: {},
isMobile: false
})
isMobile: false,
});
const HeaderContent = communalLoader.loadComponent('HeaderContent')
const MainTitle = communalLoader.loadComponent('MainTitle')
const SubmitButton = communalLoader.loadComponent('SubmitButton')
const LogoIcon = communalLoader.loadComponent('LogoIcon')
const HeaderContent = communalLoader.loadComponent("HeaderContent");
const MainTitle = communalLoader.loadComponent("MainTitle");
const SubmitButton = communalLoader.loadComponent("SubmitButton");
const LogoIcon = communalLoader.loadComponent("LogoIcon");
const mainRef = ref<any>()
const boxRef = ref<HTMLElement>()
const mainRef = ref<any>();
const boxRef = ref<HTMLElement>();
const alert = useCommandComponent(AlertDialog)
const confirm = useCommandComponent(ConfirmDialog)
const alert = useCommandComponent(AlertDialog);
const confirm = useCommandComponent(ConfirmDialog);
const router = useRouter()
const surveyStore = useSurveyStore()
const questionStore = useQuestionStore()
const router = useRouter();
const surveyStore = useSurveyStore();
const questionStore = useQuestionStore();
const renderData = computed(() => questionStore.renderData)
const { bannerConf, submitConf, bottomConf: logoConf, whiteData } = storeToRefs(surveyStore)
const surveyPath = computed(() => surveyStore.surveyPath || '')
const renderData = computed(() => questionStore.renderData);
const {
bannerConf,
submitConf,
bottomConf: logoConf,
whiteData,
} = storeToRefs(surveyStore);
const surveyPath = computed(() => surveyStore.surveyPath || "");
const validate = (cbk: (v: boolean) => void) => {
const index = 0
mainRef.value.$refs.formGroup[index].validate(cbk)
}
const index = 0;
mainRef.value.$refs.formGroup[index].validate(cbk);
};
const normalizationRequestBody = () => {
const enterTime = surveyStore.enterTime
const encryptInfo = surveyStore.encryptInfo as any
const formValues = surveyStore.formValues
const enterTime = surveyStore.enterTime;
const encryptInfo = surveyStore.encryptInfo as any;
const formValues = surveyStore.formValues;
const result: any = {
surveyPath: surveyPath.value,
data: JSON.stringify(formValues),
difTime: Date.now() - enterTime,
diffTime: Date.now() - enterTime,
clientTime: Date.now(),
...whiteData.value
}
...whiteData.value,
};
if (encryptInfo?.encryptType) {
result.encryptType = encryptInfo.encryptType
result.data = encrypt[result.encryptType as 'rsa']({
result.encryptType = encryptInfo.encryptType;
result.data = encrypt[result.encryptType as "rsa"]({
data: result.data,
secretKey: encryptInfo?.data?.secretKey
})
secretKey: encryptInfo?.data?.secretKey,
});
if (encryptInfo?.data?.sessionId) {
result.sessionId = encryptInfo.data.sessionId
result.sessionId = encryptInfo.data.sessionId;
}
} else {
result.data = JSON.stringify(result.data)
result.data = JSON.stringify(result.data);
}
return result
}
return result;
};
const submitSurver = async () => {
if (surveyPath.value.length > 8) {
router.push({ name: 'successPage' })
return
router.push({ name: "successPage" });
return;
}
try {
const params = normalizationRequestBody()
console.log(params)
const res: any = await submitForm(params)
const params = normalizationRequestBody();
console.log(params);
const res: any = await submitForm(params);
if (res.code === 200) {
router.push({ name: 'successPage' })
router.push({ name: "successPage" });
} else {
alert({
title: res.errmsg || '提交失败'
})
title: res.errmsg || "提交失败",
});
}
} catch (error) {
console.log(error)
console.log(error);
}
}
};
const handleSubmit = () => {
const confirmAgain = (surveyStore.submitConf as any).confirmAgain
const { again_text, is_again } = confirmAgain
const confirmAgain = (surveyStore.submitConf as any).confirmAgain;
const { again_text, is_again } = confirmAgain;
if (is_again) {
confirm({
title: again_text,
onConfirm: async () => {
try {
submitSurver()
submitSurver();
} catch (error) {
console.log(error)
console.log(error);
} finally {
confirm.close()
confirm.close();
}
}
})
},
});
} else {
submitSurver()
submitSurver();
}
}
};
</script>
<style scoped lang="scss">
.index {
Expand Down

0 comments on commit 136cdfb

Please sign in to comment.