|
|
@@ -9,32 +9,40 @@
|
|
|
background-color="#fdf6ec "
|
|
|
/>
|
|
|
</view>
|
|
|
+ <view class="task-form-fields">
|
|
|
+ <view class="task-form-field" v-for="item in taskFieldConfigList" :key="item.id">
|
|
|
+ <template v-if="isSingleSelect(item.taskFiledType)">
|
|
|
+ <SingleSelect
|
|
|
+ :key="item.id"
|
|
|
+ :taskFieldConfig="item"
|
|
|
+ :taskFieldDict="taskFieldDict"
|
|
|
+ v-model:label="form.value[item.id].label"
|
|
|
+ v-model:value="form.value[item.id].value"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <wd-button @click="submit">主要按钮</wd-button>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { computed, ref } from 'vue'
|
|
|
-
|
|
|
import { onLoad } from '@dcloudio/uni-app'
|
|
|
|
|
|
-import { getTaskContentConfigByTaskTypeIdApi } from '@/services/modules/task/taskFrom/index.ts'
|
|
|
+import SingleSelect from './components/SingleSelect.vue'
|
|
|
+import { useNavigation } from './composables/useNavigation'
|
|
|
+import { useTaskForm } from './composables/useTaskForm'
|
|
|
+import { useTaskNotice } from './composables/useTaskNotice'
|
|
|
|
|
|
-interface DynamicFormState {
|
|
|
- values: {
|
|
|
- [key: string]: {
|
|
|
- label: string
|
|
|
- value: string | number | boolean
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
+const { setNavigationTitle } = useNavigation()
|
|
|
|
|
|
-const form = ref<DynamicFormState>({
|
|
|
- values: {},
|
|
|
-})
|
|
|
+const { showNotice, noticeText, setNotice } = useTaskNotice()
|
|
|
+
|
|
|
+const { form, taskFieldConfigList, taskFieldDict, loadTaskForm } = useTaskForm()
|
|
|
|
|
|
-const getTaskContentConfigByTaskTypeId = async (id: string) => {
|
|
|
- const res = await getTaskContentConfigByTaskTypeIdApi(id)
|
|
|
- console.log('res', res)
|
|
|
+const isSingleSelect = (taskFiledType: string) => {
|
|
|
+ return ['domain', 'select'].includes(taskFiledType)
|
|
|
}
|
|
|
|
|
|
type PageLoadOptions = {
|
|
|
@@ -42,52 +50,15 @@ type PageLoadOptions = {
|
|
|
taskId?: string
|
|
|
}
|
|
|
|
|
|
-const setNavigationTitle = (title?: string) => {
|
|
|
- if (!title) return
|
|
|
-
|
|
|
- uni.setNavigationBarTitle({
|
|
|
- title,
|
|
|
- })
|
|
|
+const submit = () => {
|
|
|
+ console.log('form.value', form.value)
|
|
|
}
|
|
|
|
|
|
-const showNotice = ref(false)
|
|
|
-const noticeText = ref('')
|
|
|
-
|
|
|
-const setNotice = () => {
|
|
|
- const showNoticeTaskIds = ['13', '14', '81', '99999']
|
|
|
-
|
|
|
- let text = ''
|
|
|
- if (!showNoticeTaskIds.includes(taskId.value)) return
|
|
|
- switch (taskId.value) {
|
|
|
- case '13':
|
|
|
- text = '请以合法方式获取任务所需信息且不得侵犯任何商业秘密,否则将因此承担民/刑事责任。'
|
|
|
- break
|
|
|
- case '14':
|
|
|
- text = '请勿统方,否则您将可能被医疗机构处罚并反馈至相关企业且被企业追究法律责任。'
|
|
|
- break
|
|
|
- case '81':
|
|
|
- text = '注意该任务仅支持采集已购买产品的终端!'
|
|
|
- break
|
|
|
- case '99999':
|
|
|
- text = '测试qaqaq'
|
|
|
- break
|
|
|
- default:
|
|
|
- break
|
|
|
- }
|
|
|
-
|
|
|
- showNotice.value = true
|
|
|
- noticeText.value = text
|
|
|
-}
|
|
|
-
|
|
|
-const taskId = ref('')
|
|
|
-
|
|
|
onLoad(async (options: PageLoadOptions = {}) => {
|
|
|
setNavigationTitle(options.taskTitle)
|
|
|
- taskId.value = options.taskId ?? ''
|
|
|
-
|
|
|
- setNotice()
|
|
|
-
|
|
|
- await getTaskContentConfigByTaskTypeId('99999')
|
|
|
+ const taskId = options.taskId ?? ''
|
|
|
+ setNotice(taskId)
|
|
|
+ await loadTaskForm('99999')
|
|
|
})
|
|
|
</script>
|
|
|
|
|
|
@@ -95,9 +66,11 @@ onLoad(async (options: PageLoadOptions = {}) => {
|
|
|
.task-form {
|
|
|
background: #f2f2f2;
|
|
|
min-height: 100vh;
|
|
|
- padding: 20rpx 28rpx;
|
|
|
|
|
|
.workbench-notice {
|
|
|
+ background-color: #fff;
|
|
|
+ padding: 0 10rpx;
|
|
|
+ margin: 20rpx 0;
|
|
|
}
|
|
|
}
|
|
|
</style>
|