parent
9aec0fb1ea
commit
7ab790285f
11
web/src/common/regexpMap.ts
Normal file
11
web/src/common/regexpMap.ts
Normal file
@ -0,0 +1,11 @@
|
||||
export const regexpMap = {
|
||||
nd: /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/,
|
||||
m: /^[1]([3-9])[0-9]{9}$/,
|
||||
idcard: /^(\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$/,
|
||||
strictIdcard:
|
||||
/(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/,
|
||||
n: /^[0-9]+([.]{1}[0-9]+){0,1}$/,
|
||||
e: /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/,
|
||||
licensePlate:
|
||||
/^([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[a-zA-Z](([DFAG]((?![IO])[a-zA-Z0-9](?![IO]))[0-9]{4})|([0-9]{5}[DF]))|[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4,5}[A-Z0-9挂学警港澳]{1})$/
|
||||
}
|
@ -16,6 +16,10 @@ export const getSpaceDetail = (workspaceId: string) => {
|
||||
return axios.get(`/workspace/${workspaceId}`)
|
||||
}
|
||||
|
||||
export const getMemberList = () => {
|
||||
return axios.get('/workspace/member/list')
|
||||
}
|
||||
|
||||
export const deleteSpace = (workspaceId: string) => {
|
||||
return axios.delete(`/workspace/${workspaceId}`)
|
||||
}
|
||||
|
@ -31,6 +31,17 @@ const updateLogicConf = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const updateWhiteConf = () => {
|
||||
const baseConf = store.state.edit.schema.baseConf || {};
|
||||
if (baseConf.passwordSwitch && !baseConf.password) {
|
||||
return true;
|
||||
}
|
||||
if (baseConf.whitelistType!='ALL' && !baseConf.whitelist?.length) {
|
||||
return true;
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
const handlePublish = async () => {
|
||||
if (isPublishing.value) {
|
||||
return
|
||||
@ -46,6 +57,14 @@ const handlePublish = async () => {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if(updateWhiteConf()){
|
||||
isPublishing.value = false
|
||||
ElMessage.error('请检查问卷设置是否有误')
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
const saveData = buildData(store.state.edit.schema)
|
||||
if (!saveData.surveyId) {
|
||||
isPublishing.value = false
|
||||
|
@ -63,6 +63,17 @@ const updateLogicConf = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const updateWhiteConf = () => {
|
||||
const baseConf = store.state.edit.schema.baseConf || {};
|
||||
if (baseConf.passwordSwitch && !baseConf.password) {
|
||||
return true;
|
||||
}
|
||||
if (baseConf.whitelistType!='ALL' && !baseConf.whitelist?.length) {
|
||||
return true;
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
const timerHandle = ref<NodeJS.Timeout | number | null>(null)
|
||||
const triggerAutoSave = () => {
|
||||
if (autoSaveStatus.value === 'saving') {
|
||||
@ -114,6 +125,12 @@ const handleSave = async () => {
|
||||
return
|
||||
}
|
||||
|
||||
if(updateWhiteConf()){
|
||||
isSaving.value = false
|
||||
ElMessage.error('请检查问卷设置是否有误')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const res: any = await saveData()
|
||||
if (res.code === 200) {
|
||||
|
@ -9,16 +9,18 @@
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref, computed, defineProps, defineEmits, onMounted, nextTick } from 'vue'
|
||||
import { useStore } from 'vuex'
|
||||
import { ref, computed, defineProps, defineEmits, onMounted } from 'vue'
|
||||
import { FORM_CHANGE_EVENT_KEY } from '@/materials/setters/constant'
|
||||
import {
|
||||
getMemberList
|
||||
} from '@/management/api/space'
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
const props = defineProps({
|
||||
formConfig: Object,
|
||||
})
|
||||
const emit = defineEmits([FORM_CHANGE_EVENT_KEY])
|
||||
|
||||
const store = useStore();
|
||||
const treeRef = ref(null)
|
||||
const treeData = ref([])
|
||||
const defaultCheckedKeys = ref([])
|
||||
@ -30,57 +32,37 @@ const defaultProps = {
|
||||
const handleChange = () => {
|
||||
const key = props.formConfig.key;
|
||||
const userKeys = treeRef.value?.getCheckedKeys(true);
|
||||
if (userKeys.length > 100) {
|
||||
ElMessage.error('最多添加100个')
|
||||
return;
|
||||
}
|
||||
emit(FORM_CHANGE_EVENT_KEY, { key: key, value: userKeys });
|
||||
}
|
||||
|
||||
const spaceDetail = computed(() => {
|
||||
return store.state.list.spaceDetail
|
||||
})
|
||||
|
||||
|
||||
|
||||
const selectCount = computed(() => {
|
||||
return treeRef.value?.getCheckedKeys(true).length || 0
|
||||
})
|
||||
|
||||
const spaceMenus = computed(() => {
|
||||
return store.state.list.spaceMenus
|
||||
})
|
||||
|
||||
const getSpaceMenus = async () => {
|
||||
await store.dispatch('list/getSpaceList')
|
||||
spaceMenus.value.map((v) => {
|
||||
if (v.id == "group") {
|
||||
const promiseList = []
|
||||
v.children?.map((item) => {
|
||||
promiseList.push(store.dispatch('list/getSpaceDetail', item.id).then(() => {
|
||||
treeData.value.push({
|
||||
id: item.id,
|
||||
label: item.name,
|
||||
children: getChildren()
|
||||
})
|
||||
}))
|
||||
})
|
||||
Promise.all(promiseList).then(() => {
|
||||
nextTick(() => {
|
||||
defaultCheckedKeys.value = props.formConfig.value;
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const getChildren = () => {
|
||||
const members = [];
|
||||
if (spaceDetail.value?.members?.length > 0) {
|
||||
spaceDetail.value.members.map(v => {
|
||||
members.push({
|
||||
id: v.userId,
|
||||
label: v.username,
|
||||
})
|
||||
})
|
||||
const res = await getMemberList();
|
||||
if (res.code != 200) {
|
||||
ElMessage.error('获取空间成员列表失败');
|
||||
}
|
||||
return members
|
||||
const data = res.data;
|
||||
data.map((v) => {
|
||||
const members = v.members || [];
|
||||
treeData.value.push({
|
||||
id: v.ownerId,
|
||||
label: v.name,
|
||||
children: members?.map(v => ({
|
||||
id: v.userId,
|
||||
label: v.role,
|
||||
}))
|
||||
})
|
||||
})
|
||||
defaultCheckedKeys.value = props.formConfig.value;
|
||||
}
|
||||
|
||||
|
||||
|
@ -45,6 +45,8 @@
|
||||
|
||||
import { ref,nextTick } from 'vue'
|
||||
import { FORM_CHANGE_EVENT_KEY } from '@/materials/setters/constant'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { regexpMap } from '@/common/regexpMap.ts'
|
||||
|
||||
const props = defineProps({
|
||||
formConfig: Object,
|
||||
@ -56,12 +58,36 @@ const memberType = ref(props.formConfig.value[1] || 'MOBILE')
|
||||
const whiteVisible = ref(false)
|
||||
const whiteTextarea = ref(whitelist.value.join(','))
|
||||
|
||||
const regularMap = {
|
||||
MOBILE:regexpMap.m,
|
||||
EMAIL:regexpMap.e
|
||||
}
|
||||
|
||||
|
||||
const checkValRule = (list) => {
|
||||
let status = false;
|
||||
if (list.length > 100) {
|
||||
ElMessage.error('最多添加100个')
|
||||
return true;
|
||||
};
|
||||
const pattern = regularMap[memberType.value];
|
||||
if(!pattern) return false;
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
if (!pattern.test(list[i])) {
|
||||
status = true;
|
||||
ElMessage.error('数据格式错误,请检查后重新输入~')
|
||||
break;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const handleChange = () => {
|
||||
const keys = props.formConfig.keys;
|
||||
const list = whiteTextarea.value ? whiteTextarea.value.split(',') : []
|
||||
if(checkValRule(list)) return
|
||||
emit(FORM_CHANGE_EVENT_KEY, { key:keys[0], value: list });
|
||||
emit(FORM_CHANGE_EVENT_KEY, { key: keys[1], value: memberType.value })
|
||||
whiteVisible.value = false
|
||||
|
@ -6,18 +6,8 @@ import {
|
||||
set as _set
|
||||
} from 'lodash-es'
|
||||
import { INPUT, RATES, QUESTION_TYPE } from '@/common/typeEnum.ts'
|
||||
import { regexpMap } from '@/common/regexpMap.ts'
|
||||
|
||||
const regexpMap = {
|
||||
nd: /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/,
|
||||
m: /^[1]([3-9])[0-9]{9}$/,
|
||||
idcard: /^(\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$/,
|
||||
strictIdcard:
|
||||
/(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/,
|
||||
n: /^[0-9]+([.]{1}[0-9]+){0,1}$/,
|
||||
e: /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/,
|
||||
licensePlate:
|
||||
/^([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[a-zA-Z](([DFAG]((?![IO])[a-zA-Z0-9](?![IO]))[0-9]{4})|([0-9]{5}[DF]))|[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4,5}[A-Z0-9挂学警港澳]{1})$/
|
||||
}
|
||||
|
||||
const msgMap = {
|
||||
'*': '必填',
|
||||
|
@ -33,9 +33,9 @@ export const getEncryptInfo = () => {
|
||||
return axios.get('/clientEncrypt/getEncryptInfo')
|
||||
}
|
||||
|
||||
export const validate = ({ surveyPath,password, value }) => {
|
||||
export const validate = ({ surveyPath,password, whitelist }) => {
|
||||
return axios.post(`/responseSchema/${surveyPath}/validate`, {
|
||||
password,
|
||||
value
|
||||
whitelist
|
||||
})
|
||||
}
|
@ -71,19 +71,18 @@ const handleSubmit = async() => {
|
||||
surveyPath:surveyPath.value
|
||||
}
|
||||
if (isValue.value) {
|
||||
params.value = state.value
|
||||
params.whitelist = state.value
|
||||
}
|
||||
if(isPwd.value){
|
||||
params.password = state.password
|
||||
}
|
||||
|
||||
const res = await validate(params)
|
||||
if (res.code != 200) {
|
||||
ElMessage.error(res.errmsg || '验证失败')
|
||||
return
|
||||
}
|
||||
whiteVisible.value = false
|
||||
store.commit('setVerifyId', res.data.verifyId)
|
||||
store.commit('setWhiteData',params)
|
||||
}
|
||||
|
||||
watch(()=>baseConf.value, () => {
|
||||
|
@ -65,7 +65,7 @@ const renderData = computed(() => store.getters.renderData)
|
||||
const submitConf = computed(() => store.state?.submitConf || {})
|
||||
const logoConf = computed(() => store.state?.bottomConf || {})
|
||||
const surveyPath = computed(() => store.state?.surveyPath || '')
|
||||
const verifyId = computed(() => store.state?.verifyId || '')
|
||||
const whiteData = computed(() => store.state?.whiteData || {})
|
||||
|
||||
const validate = (cbk: (v: boolean) => void) => {
|
||||
const index = 0
|
||||
@ -81,11 +81,8 @@ const normalizationRequestBody = () => {
|
||||
surveyPath: surveyPath.value,
|
||||
data: JSON.stringify(formValues),
|
||||
difTime: Date.now() - enterTime,
|
||||
clientTime: Date.now()
|
||||
}
|
||||
|
||||
if(verifyId.value){
|
||||
result.verifyId = verifyId.value
|
||||
clientTime: Date.now(),
|
||||
...whiteData.value
|
||||
}
|
||||
|
||||
if (encryptInfo?.encryptType) {
|
||||
|
@ -50,7 +50,7 @@ export default {
|
||||
setRuleEgine(state, ruleEngine) {
|
||||
state.ruleEngine = ruleEngine
|
||||
},
|
||||
setVerifyId(state, verifyId) {
|
||||
state.verifyId = verifyId
|
||||
setWhiteData(state, data) {
|
||||
state.whiteData = data
|
||||
}
|
||||
}
|
||||
|
@ -13,5 +13,7 @@ export default {
|
||||
voteMap: {},
|
||||
encryptInfo: null,
|
||||
ruleEngine: null,
|
||||
verifyId:''
|
||||
whiteData: {
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user