yanzai 1 year ago
commit 2db552425b

@ -19,7 +19,7 @@ class QuestionQuestionController extends Controller
if (mb_strlen($question) > 200) { if (mb_strlen($question) > 200) {
return \Yz::echoError('题目过长'); return \Yz::echoError('题目过长');
} }
$type_array = ['select', 'input']; $type_array = ['select', 'input', 'city', 'date'];
if (!in_array($type, $type_array)) { if (!in_array($type, $type_array)) {
return \Yz::echoError('题目类型异常'); return \Yz::echoError('题目类型异常');
} }
@ -45,7 +45,7 @@ class QuestionQuestionController extends Controller
if (mb_strlen($question) > 200) { if (mb_strlen($question) > 200) {
return \Yz::echoError('题目过长'); return \Yz::echoError('题目过长');
} }
$type_array = ['select', 'input']; $type_array = ['select', 'input', 'city', 'date'];
if (!in_array($type, $type_array)) { if (!in_array($type, $type_array)) {
return \Yz::echoError('题目类型异常'); return \Yz::echoError('题目类型异常');
} }

@ -16,15 +16,16 @@ class QuestionnaireController extends Controller
foreach ($question as $key => $value) { foreach ($question as $key => $value) {
$list[] = [ $list[] = [
'id' => $value->question, 'id' => $value->question,
'title' => $value->name, 'title' => $value->name,
'icon' => $value->icon, 'icon' => $value->icon,
'desc' => $value->desc, 'desc' => $value->desc,
]; ];
} }
return \Yz::Return(true, '操作完成', [ return \Yz::Return(true, '操作完成', [
'list' => $list 'list' => $list
]); ]);
} }
public function get(Request $request) public function get(Request $request)
{ {
$id = $request->post('id'); $id = $request->post('id');
@ -34,7 +35,7 @@ class QuestionnaireController extends Controller
return \Yz::echoError('问卷不存在'); return \Yz::echoError('问卷不存在');
} }
$question_ids = json_decode($question->questions, true); $question_ids = json_decode($question->questions, true);
$person_info = DB::table('web_user_person')->where('id', $person)->first(); $person_info = DB::table('web_user_person')->where('id', $person)->first();
$list = self::getList($person_info, $question_ids); $list = self::getList($person_info, $question_ids);
return \Yz::Return(true, '操作完成', [ return \Yz::Return(true, '操作完成', [
'info' => $question, 'info' => $question,
@ -57,8 +58,9 @@ class QuestionnaireController extends Controller
'question' => $question->question, 'question' => $question->question,
'value' => '', 'value' => '',
]; ];
if ($question->type == 'input') { if (in_array($question->type, ['input', 'date', 'city'])) {
$item_data['value'] = $question->option['input']['value']; $v = $question->option['input']['value'];
$item_data['value'] = $v;
$item_data['placeholder'] = $question->option['input']['placeholder']; $item_data['placeholder'] = $question->option['input']['placeholder'];
} else { } else {
$item_data['value'] = ''; $item_data['value'] = '';
@ -89,6 +91,19 @@ class QuestionnaireController extends Controller
} }
$v = str_replace('${体重}', '', $v); $v = str_replace('${体重}', '', $v);
$v = str_replace('${身高}', '', $v); $v = str_replace('${身高}', '', $v);
$v = str_replace('${今日日期}', date('Y-m-d'), $v);
if ($v == '${省市县}') {
$v = [[
'value' => '11',
'text' => '北京市'
], [
'value' => '1101',
'text' => '市辖区'
], [
'value' => '110101',
'text' => '东城区'
]];
}
$item_data['value'] = $v; $item_data['value'] = $v;
$list[] = $item_data; $list[] = $item_data;
} }

@ -240,7 +240,7 @@ class QuestionnairesLogsController extends Controller
foreach ($question_questions as $value) { foreach ($question_questions as $value) {
$id = $value->id; $id = $value->id;
$option = json_decode($value->option, true); $option = json_decode($value->option, true);
if ($value->type === 'input') { if (in_array($value->type, ['input', 'date', 'city'])) {
if ($option['input']['value'] === '${体重}') { if ($option['input']['value'] === '${体重}') {
if (isset($question_map["q{$id}"])) { if (isset($question_map["q{$id}"])) {
$weight = $question_map["q{$id}"]['value']; $weight = $question_map["q{$id}"]['value'];

@ -381,7 +381,7 @@ onMounted(() => {
</el-table-column> </el-table-column>
<el-table-column label="题目配置"> <el-table-column label="题目配置">
<template #default="scope"> <template #default="scope">
<div v-if="scope.row.type === 'input'" class="select_item_wrapper"> <div v-if="['input','date','city'].includes(scope.row.type)" class="select_item_wrapper">
<span class="title_wrapper">占位符</span <span class="title_wrapper">占位符</span
><span style="margin: 0 10px">{{ scope.row.option.input.placeholder }}</span> ><span style="margin: 0 10px">{{ scope.row.option.input.placeholder }}</span>
<span v-if="!!scope.row.option.input.value" class="title_wrapper"></span <span v-if="!!scope.row.option.input.value" class="title_wrapper"></span

@ -309,7 +309,7 @@
<view :ref="configRef"></view> <view :ref="configRef"></view>
</view> </view>
<view v-if="question_list.length !== 0"> <view v-if="question_list.length !== 0">
<view v-if="question_info.type === '检前评估'"> <view>
<view class="banner_wrapper"> <view class="banner_wrapper">
<view @click="getQuestionLogPush()" class="push_log_wrapper">带入上次答题记录</view> <view @click="getQuestionLogPush()" class="push_log_wrapper">带入上次答题记录</view>
<image src="@/static/assets/question/banner.png"></image> <image src="@/static/assets/question/banner.png"></image>
@ -320,7 +320,7 @@
<view @click="submitClick()" class="submit_button_wrapper">提交</view> <view @click="submitClick()" class="submit_button_wrapper">提交</view>
<view class="submit_blank_wrapper"></view> <view class="submit_blank_wrapper"></view>
</view> </view>
<view v-else> <view v-if="false">
<view class="q2_banner_wrapper"> <view class="q2_banner_wrapper">
<view class="q2_banner_text_wrapper">健康问卷</view> <view class="q2_banner_text_wrapper">健康问卷</view>
<image src="@/static/assets/question/q2banner.png"></image> <image src="@/static/assets/question/q2banner.png"></image>

@ -0,0 +1,95 @@
<script setup>
/**
* name
* usersa0ChunLuyu
* date2024年9月11日 19:24:50
*/
import {
ref,
onMounted
} from 'vue'
import {
$api,
$response
} from '@/api'
import {
useStore
} from '@/store'
const $emit = defineEmits(['setValue'])
const $store = useStore()
const address_data = ref([])
const getAddressData = async () => {
const response = await $api('AddressData')
$response(response, () => {
address_data.value = response.data.data.map((i) => {
return {
text: i.name,
value: i.code,
children: i.children.map((ii) => {
return {
text: ii.name,
value: ii.code,
children: ii.children.map((iii) => {
return {
text: iii.name,
value: iii.code
}
})
}
})
}
})
getUserInfo();
})
}
const $props = defineProps({
info: {
type: Object,
default: () => {
return {
id: 0
}
}
},
index: {
type: String,
default: ''
}
});
const mountedAction = () => {
getAddressData()
}
const onKeyInput = (e) => {
$emit('setValue', $props.index, e.detail.value)
}
onMounted(() => {
mountedAction()
})
</script>
<template>
<view>
<view class="input_wrapper">
<uni-data-picker v-if="address_data.length !== 0" v-model="$props.info['value']" placeholder="请选择地址"
popup-title="请选择城市" :localdata="address_data" :step-searh="true" @change="onKeyInput">
</uni-data-picker>
</view>
</view>
</template>
<style scoped>
.input_wrapper {
width: 100%;
height: 60rpx;
margin-top: 20rpx;
}
.input_wrapper input {
height: 60rpx;
line-height: 60rpx;
padding-left: 20rpx;
}
</style>

@ -0,0 +1,85 @@
<script setup>
/**
* name
* usersa0ChunLuyu
* date2024年9月11日 19:24:50
*/
import {
ref,
onMounted
} from 'vue'
import {
$api,
$response
} from '@/api'
import {
useStore
} from '@/store'
const $emit = defineEmits(['setValue'])
const $store = useStore()
const $props = defineProps({
info: {
type: Object,
default: () => {
return {
id: 0
}
}
},
index: {
type: String,
default: ''
}
});
const mountedAction = () => {
}
const onKeyInput = (e) => {
$emit('setValue', $props.index, e.detail.value)
}
const getEndDate = () => {
const date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
month = month > 9 ? month : '0' + month;
day = day > 9 ? day : '0' + day;
return `${year}-${month}-${day}`;
}
onMounted(() => {
mountedAction()
})
</script>
<template>
<view>
<view class="input_wrapper">
<picker mode="date" :value="$props.info['value']" :end="getEndDate" @change="onKeyInput">
<view class="date_show_wrapper">{{ $props.info['value'] }}</view>
</picker>
</view>
</view>
</template>
<style scoped>
.date_show_wrapper {
margin-left: 10px;
}
.input_wrapper {
width: 100%;
height: 60rpx;
border-radius: 6rpx;
line-height: 60rpx;
border: 1rpx #cccccc solid;
margin-top: 20rpx;
}
.input_wrapper input {
height: 60rpx;
line-height: 60rpx;
padding-left: 20rpx;
}
</style>

@ -17,6 +17,8 @@
} from '@/store' } from '@/store'
import InputComponent from './input.vue' import InputComponent from './input.vue'
import SelectComponent from './select.vue' import SelectComponent from './select.vue'
import DateComponent from './date.vue'
import CityComponent from './city.vue'
const $emit = defineEmits(['setValue']) const $emit = defineEmits(['setValue'])
const $store = useStore() const $store = useStore()
const $props = defineProps({ const $props = defineProps({
@ -130,6 +132,12 @@
<view v-else-if="$props.info.type === 'select'"> <view v-else-if="$props.info.type === 'select'">
<SelectComponent @setValue="setValue" :index="$props.index" :info="$props.info"></SelectComponent> <SelectComponent @setValue="setValue" :index="$props.index" :info="$props.info"></SelectComponent>
</view> </view>
<view v-else-if="$props.info.type === 'date'">
<DateComponent @setValue="setValue" :index="$props.index" :info="$props.info"></DateComponent>
</view>
<view v-else-if="$props.info.type === 'city'">
<CityComponent @setValue="setValue" :index="$props.index" :info="$props.info"></CityComponent>
</view>
</view> </view>
</view> </view>
</template> </template>

Loading…
Cancel
Save