|
@@ -33,7 +33,7 @@ class QuestionController extends Curd
|
|
|
{
|
|
|
[$where, $format, $limit, $field, $order] = $this->selectInput($request);
|
|
|
$where['content_category'] = 'WELLNESSQUESTION';
|
|
|
- $order = $request->get('order', 'desc');
|
|
|
+ $order = $request->get('order', 'ASC');
|
|
|
$field = $field ?? 'content_sort';
|
|
|
$query = $this->doSelect($where, $field, $order);
|
|
|
return $this->doFormat($query, $format, $limit);
|
|
@@ -76,7 +76,7 @@ class QuestionController extends Curd
|
|
|
}
|
|
|
}
|
|
|
if ($field) {
|
|
|
- $model = $model->orderBy($field, $order)->orderBy('content_addtimes','DESC');
|
|
|
+ $model = $model->orderBy($field, $order)->orderBy('content_addtimes', 'DESC');
|
|
|
}
|
|
|
return $model;
|
|
|
}
|
|
@@ -108,6 +108,44 @@ class QuestionController extends Curd
|
|
|
return $items;
|
|
|
}
|
|
|
|
|
|
+ public function selectList()
|
|
|
+ {
|
|
|
+ $questions = Content::where('content_category', 'WELLNESSQUESTION')
|
|
|
+ ->select('content_title', 'content_config_json')
|
|
|
+ ->orderBy('content_sort', 'asc')
|
|
|
+ ->get()
|
|
|
+ ->toArray();
|
|
|
+ foreach ($questions as &$question) {
|
|
|
+ if (!empty($question['content_config_json'])) {
|
|
|
+ $contentConfigJson = json_decode($question['content_config_json'], true);
|
|
|
+ foreach ($contentConfigJson as $item) {
|
|
|
+ $fields = SysField::whereIn('field_id', $item['field'])
|
|
|
+ ->select('field_id', 'field_form_key', 'field_form_type', 'field_refer_json')
|
|
|
+ ->orderByDesc('field_sort')
|
|
|
+ ->get()
|
|
|
+ ->toArray();
|
|
|
+ $fieldData = [];
|
|
|
+ foreach ($fields as $field) {
|
|
|
+ if (!empty($field['field_refer_json'])) {
|
|
|
+ $fieldData = [
|
|
|
+ 'form_type' => $field['field_form_type'],
|
|
|
+ 'form_key' => $field['field_form_key'],
|
|
|
+ 'field' => json_decode($field['field_refer_json'], true)
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $question['list'][] = [
|
|
|
+ 'question' => $item['question'],
|
|
|
+ 'fields' => $fieldData
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ unset($question['content_config_json']);
|
|
|
+ }
|
|
|
+
|
|
|
+ return json_success('success', $questions);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @Desc 问卷详情
|
|
|
* @Author Gorden
|