diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index b6b4c48..70da636 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -21,7 +21,8 @@ const isError = ref(false) const taskDescribe = ref('') const origin = window.location.href -const taskId = ref('') +const taskId = ref('28') +const taskType = ref(2) if (origin.indexOf('=') > -1) { taskId.value = origin.split('=')[1] @@ -32,6 +33,10 @@ const getTaskDetailsData = async () => { const { data: res } = await getTaskDetailsApi({ id: taskId.value, }) + + taskType.value = res.type + + console.log(res, '数据源') if (res.code == 200) { isError.value = false taskDescribe.value = res.data.taskDescribe @@ -45,7 +50,9 @@ getTaskDetailsData() // 填写意见按钮 const onSubmitOptions = () => { - uni.redirectTo({ url: `/pages/opinion/index?taskId=${taskId.value}` }) + uni.redirectTo({ + url: `/pages/opinion/index?taskId=${taskId.value}&taskType=${taskType.value}`, + }) } diff --git a/src/pages/opinion/index.vue b/src/pages/opinion/index.vue index d9a30c0..08e7df8 100644 --- a/src/pages/opinion/index.vue +++ b/src/pages/opinion/index.vue @@ -10,7 +10,7 @@ labelWidth="auto" class="opinion-form" > - + - + { - if (option.taskId) { - opinionModel.value.taskId = option.taskId - } -}) - -const fileList = ref([]) - const opinionRules = ref({ - // userName: [ - // { - // type: 'string', - // required: true, - // message: '请填写姓名', - // trigger: ['blur', 'change'], - // }, - // { - // pattern: /^[\u4e00-\u9fa5]{2,6}$/, - // // 正则检验前先将值转为字符串 - // transform(value) { - // return String(value) - // }, - // message: '请填写正确的姓名', - // }, - // ], + userName: [], userPhone: [ - // { - // type: 'string', - // required: true, - // message: '请填写电话', - // trigger: ['blur', 'change'], - // }, - { pattern: /^1[3-9]\d{9}$/, // 正则检验前先将值转为字符串 @@ -165,6 +135,45 @@ const opinionRules = ref({ ], }) +const isRequired = ref(false) + +onLoad((option) => { + if (option.taskId) { + opinionModel.value.taskId = option.taskId + } + if (option.taskType && option.taskType == 1) { + isRequired.value = true + + opinionRules.value.userName = [ + { + type: 'string', + required: true, + message: '请填写姓名', + trigger: ['blur', 'change'], + }, + { + pattern: /^[\u4e00-\u9fa5]{2,6}$/, + // 正则检验前先将值转为字符串 + transform(value) { + return String(value) + }, + message: '请填写正确的姓名', + }, + ] + opinionRules.value.userPhone.push({ + type: 'string', + required: true, + message: '请填写电话', + trigger: ['blur', 'change'], + }) + } + if (option.taskType && option.taskType == 2) { + isRequired.value = false + } +}) + +const fileList = ref([]) + // 表单实例 const opinionModelRef = ref(null)