Commit 54346956 by 吴春元

考试系统

提交
parent 81a72517
// ignore_for_file: constant_identifier_names // ignore_for_file: constant_identifier_names
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:special_equipment_flutter/ui/examine/exam/exam_history_page.dart';
import 'package:special_equipment_flutter/ui/examine/exam/exam_page.dart';
import 'package:special_equipment_flutter/ui/examine/exam/exam_result_page.dart';
import 'package:special_equipment_flutter/ui/examine/test/test_page.dart';
import 'package:special_equipment_flutter/ui/examine/test/test_result_page.dart';
import 'package:special_equipment_flutter/ui/examine/test/test_setting_page.dart';
import 'package:special_equipment_flutter/ui/login/login_page.dart'; import 'package:special_equipment_flutter/ui/login/login_page.dart';
import 'package:special_equipment_flutter/ui/main/tab_home_page.dart'; import 'package:special_equipment_flutter/ui/main/tab_home_page.dart';
import 'package:special_equipment_flutter/ui/main/unit/equipment_personnel_page.dart'; import 'package:special_equipment_flutter/ui/main/unit/equipment_personnel_page.dart';
import 'package:special_equipment_flutter/ui/overseer/equipment_list_page.dart';
import 'package:special_equipment_flutter/ui/overseer/overseer_list_page.dart';
import 'package:special_equipment_flutter/ui/overseer/overseer_settings_page.dart';
import 'package:special_equipment_flutter/ui/overseer/unit_list_page.dart';
import 'package:special_equipment_flutter/ui/register/address_page.dart'; import 'package:special_equipment_flutter/ui/register/address_page.dart';
import 'package:special_equipment_flutter/ui/register/register_page1.dart'; import 'package:special_equipment_flutter/ui/register/register_page1.dart';
import 'package:special_equipment_flutter/ui/register/register_page2.dart'; import 'package:special_equipment_flutter/ui/register/register_page2.dart';
...@@ -97,6 +107,36 @@ class RouteString { ...@@ -97,6 +107,36 @@ class RouteString {
///生产单位:日管控、周排查、月调度 已完成详情 ///生产单位:日管控、周排查、月调度 已完成详情
static const String COMPLETED_DETAIL_SC = "/CompletedDetailSc"; static const String COMPLETED_DETAIL_SC = "/CompletedDetailSc";
///考核做题
static const String EXAM_PAGE = "/ExamPage";
///考核结果
static const String EXAM_RESULT_PAGE = "/ExamResultPage";
///考核历史
static const String EXAM_HISTORY_PAGE = "/ExamHistoryPage";
///测试练习
static const String TEST_PAGE = "/TestPage";
///监察人员设置
static const String OVERSEER_SETTINGS_PAGE = "/OverseerSettingsPage";
///监察人-选择单位
static const String UNIT_LIST_PAGE = "/UnitListPage";
///监察人-选择设备
static const String EQUIPMENT_LIST_PAGE = "/EquipmentListPage";
///监察人-考核列表
static const String OVERSEER_LIST_PAGE = "/OverseerListPage";
///测试练习结果页面
static const String TEST_RESULT_PAGE = "/TestResultPage";
///测试练习设置
static const String TEST_SETTING_PAGE = "/TestSettingPage";
static final routes = [ static final routes = [
///登录 ///登录
GetPage(name: LOGIN, page: () => const LoginPage()), GetPage(name: LOGIN, page: () => const LoginPage()),
...@@ -163,6 +203,37 @@ class RouteString { ...@@ -163,6 +203,37 @@ class RouteString {
GetPage( GetPage(
name: MONTH_COMPLETED_DETAIL_SY, name: MONTH_COMPLETED_DETAIL_SY,
page: () => MonthCompletedDetailSyPage()), page: () => MonthCompletedDetailSyPage()),
///考核做题
GetPage(name: EXAM_PAGE, page: () => ExamPage()),
///考核历史
GetPage(name: EXAM_HISTORY_PAGE, page: () => ExamHistoryPage()),
///测试练习
GetPage(name: TEST_PAGE, page: () => TestPage()),
///考核结果
GetPage(name: EXAM_RESULT_PAGE, page: () => ExamResultPage()),
///监察人设置考核
GetPage(name: OVERSEER_SETTINGS_PAGE, page: () => OverseerSettingsPage()),
///监察人选择单位
GetPage(name: UNIT_LIST_PAGE, page: () => UnitListPage()),
///监察人选择设备
GetPage(name: EQUIPMENT_LIST_PAGE, page: () => EquipmentListPage()),
///考核列表
GetPage(name: OVERSEER_LIST_PAGE, page: () => OverseerListPage()),
///测试练习结果
GetPage(name: TEST_RESULT_PAGE, page: () => TestResultPage()),
///测试练习设置
GetPage(name: TEST_SETTING_PAGE, page: () => TestSettingPage()),
// GetPage( // GetPage(
// name: "/shop", // name: "/shop",
// page: () => const ShopPage(), // page: () => const ShopPage(),
......
// ignore_for_file: unnecessary_brace_in_string_interps, non_constant_identifier_names // ignore_for_file: unnecessary_brace_in_string_interps, non_constant_identifier_names
class Api { class Api {
static var IS_DEBUG = true; static var IS_DEBUG = false;
static String URL = // static String URL =
IS_DEBUG ? "https://special.sxyztech.cn/" : "http://192.168.19.215:8181/"; // IS_DEBUG ? "https://special.sxyztech.cn/" : "http://192.168.19.165:2212/";
///演示 ip ///演示 ip
// static String URL = "http://47.92.138.92:8009/"; // static String URL = "http://47.92.138.92:8009/";
// static String URL = "http://192.168.19.189:8181/"; static String URL = "http://192.168.19.164:8087/";
// static String URL = "http://192.168.19.215:8181/";
// static String URL = "http://192.168.19.165:2212/";
static String START_URL = "special/a/", static String START_URL = "special/a/",
END_URL = "__ajax=true&mobileLogin=true"; END_URL = "__ajax=true&mobileLogin=true";
...@@ -167,4 +168,61 @@ class Api { ...@@ -167,4 +168,61 @@ class Api {
/// 公司账户-首页-设备对比表格 获取使用单位设备数量 /// 公司账户-首页-设备对比表格 获取使用单位设备数量
static String FIND_COUNT = "${URL + START_URL}device/deviceInfo/findCount"; static String FIND_COUNT = "${URL + START_URL}device/deviceInfo/findCount";
/// 获取考核题库
static String EXAMINE_QUESTIONS =
"${URL + START_URL}exam/examPaper/getQuestions";
/// 考核交卷
static String EXAMINE_QUESTIONS_SUBMIT =
"${URL + START_URL}exam/examPaper/submitPaper";
/// 测试练习交卷
static String EXAMINE_TEST_SUBMIT =
"${URL + START_URL}/exam/practicePaper/submitPaper";
/// 获取测试练习题库
static String TEST_QUESTIONS =
"${URL + START_URL}exam/practicePaper/getQuestions";
/// 获取单位列表
static String GET_UNIT_LIST =
"${URL + START_URL}sys/office/findByGradeAndParentIds";
/// 获取单位列表 设备类型
static String GET_EQUIPMENT_LIST =
"${URL + START_URL}sys/office/findDtoByOfficeIdAndTypeIdAndDel";
/// 获取单位-人员(安全总监、安全员)
static String GET_UNIT_PERSON =
"${URL + START_URL}sys/user/selectByOfficeAndRole";
/// 验证登录人是否有考试按钮
static String CHECK_HAVE_EXAM =
"${URL + START_URL}exam/examPerson/checkHaveExam";
/// 获取默认题数
static String FIND_QUESTION_NUM =
"${URL + START_URL}exam/examQuestionNum/findQuestionNum";
/// 获取考核列表
static String GET_OVERSEER_LIST =
"${URL + START_URL}exam/examPerson/findListApp";
/// 获取考核列表 删除
static String GET_OVERSEER_DELETE =
"${URL + START_URL}exam/examPerson/deleteAllApp";
/// 获取考核提交
static String GET_OVERSEER_SAVE = "${URL + START_URL}exam/examPerson/saveApp";
/// 根据设备类型获取总题数
static String FINT_QUESTION_TYPE =
"${URL + START_URL}exam/examQuestion/fintQuestionByType";
/// 考核 是否显示答案
static String SHOW_ANSWER = "${URL + START_URL}sys/dict/showAnswer";
/// 获取考核信息
// static String EXAMINE_PERSON = "${URL + START_URL}/exam/examPerson/checkHaveExam";
} }
...@@ -19,6 +19,16 @@ import 'package:special_equipment_flutter/model/detail/week/week_detail_bo.dart' ...@@ -19,6 +19,16 @@ import 'package:special_equipment_flutter/model/detail/week/week_detail_bo.dart'
import 'package:special_equipment_flutter/model/device_list_bo.dart'; import 'package:special_equipment_flutter/model/device_list_bo.dart';
import 'package:special_equipment_flutter/model/echart_bo.dart'; import 'package:special_equipment_flutter/model/echart_bo.dart';
import 'package:special_equipment_flutter/model/equipment_bo.dart'; import 'package:special_equipment_flutter/model/equipment_bo.dart';
import 'package:special_equipment_flutter/model/exam/eq_question_bo.dart';
import 'package:special_equipment_flutter/model/exam/equipment_list_bo.dart';
import 'package:special_equipment_flutter/model/exam/exam_result_bo.dart';
import 'package:special_equipment_flutter/model/exam/exam_unit_list.dart';
import 'package:special_equipment_flutter/model/exam/examine_person_bo.dart';
import 'package:special_equipment_flutter/model/exam/examine_questions_bo.dart';
import 'package:special_equipment_flutter/model/exam/find_question_num.dart';
import 'package:special_equipment_flutter/model/exam/show_answer_bo.dart';
import 'package:special_equipment_flutter/model/exam/test_questions_bo.dart';
import 'package:special_equipment_flutter/model/exam/unit_person_list_bo.dart';
import 'package:special_equipment_flutter/model/find_charge_list_bo.dart'; import 'package:special_equipment_flutter/model/find_charge_list_bo.dart';
import 'package:special_equipment_flutter/model/find_count_bo.dart'; import 'package:special_equipment_flutter/model/find_count_bo.dart';
import 'package:special_equipment_flutter/model/login_bo.dart'; import 'package:special_equipment_flutter/model/login_bo.dart';
...@@ -1175,6 +1185,384 @@ class HttpUtils { ...@@ -1175,6 +1185,384 @@ class HttpUtils {
}, onError: (e) {}); }, onError: (e) {});
} }
///考核
static Future getExamineQuestions(BuildContext context, inspectorsId,
examDate, typeId, questionNum, dxNum, pdNum, personId) async {
Map<String, dynamic> params = {
'user.id': StorageUtil.getInstance().getUserId(),
'inspectors.id': inspectorsId,
'examDate': examDate,
'type.id': typeId,
'questionNum': questionNum,
'dxNum': dxNum,
'pdNum': pdNum,
'personId': personId
};
var response = await NetUtils.get(
context,
'${Api.EXAMINE_QUESTIONS};JSESSIONID=${StorageUtil.getInstance().getJsessionId()}',
true,
params,
'正在获取题库...');
try {
BaseModel entity = BaseModel.fromJson(response);
Map<String, dynamic> resultData = entity.body;
ExamineQuestionsBo examineQuestionsBo =
ExamineQuestionsBo.fromJson(resultData);
if (entity.errorCode == "-1") {
return examineQuestionsBo;
} else {
ToastUtils.showCenter(entity.msg!);
return;
}
} catch (e) {
log(e.toString());
return {"message": e.toString()};
}
}
///考核提交
static Future getExamSubmit(BuildContext context, data) async {
Map<String, dynamic> params = {};
var response = await NetUtils.posts(
context,
'${Api.EXAMINE_QUESTIONS_SUBMIT};JSESSIONID=${StorageUtil.getInstance().getJsessionId()}',
true,
data,
params,
'交卷中');
try {
BaseModel entity = BaseModel.fromJson(response);
Map<String, dynamic> resultData = entity.body;
ExamResultBo examResultBo = ExamResultBo.fromJson(resultData);
if (entity.errorCode == "-1") {
return examResultBo;
} else {
ToastUtils.showCenter(entity.msg!);
return;
}
} catch (e) {
log(e.toString());
return {"message": e.toString()};
}
}
///测试练习提交
static Future getTestSubmit(BuildContext context, data) async {
Map<String, dynamic> params = {};
var response = await NetUtils.posts(
context,
'${Api.EXAMINE_TEST_SUBMIT};JSESSIONID=${StorageUtil.getInstance().getJsessionId()}',
true,
data,
params,
'交卷中');
try {
BaseModel entity = BaseModel.fromJson(response);
Map<String, dynamic> resultData = entity.body;
ExamResultBo examResultBo = ExamResultBo.fromJson(resultData);
if (entity.errorCode == "-1") {
return examResultBo;
} else {
ToastUtils.showCenter(entity.msg!);
return;
}
} catch (e) {
log(e.toString());
return {"message": e.toString()};
}
}
///获取练习题库
static Future getTestQuestions(
BuildContext context, typeId, questionNum, dxNum, pdNum) async {
Map<String, dynamic> params = {
'user.id': StorageUtil.getInstance().getUserId(),
'type.id': typeId,
'questionNum': questionNum,
'dxNum': dxNum,
'pdNum': pdNum
};
var response = await NetUtils.get(
context,
'${Api.TEST_QUESTIONS};JSESSIONID=${StorageUtil.getInstance().getJsessionId()}',
true,
params,
'正在获取题库...');
try {
BaseModel entity = BaseModel.fromJson(response);
Map<String, dynamic> resultData = entity.body;
TestQuestionsBo examineQuestionsBo = TestQuestionsBo.fromJson(resultData);
if (entity.errorCode == "-1") {
return examineQuestionsBo;
} else {
ToastUtils.showCenter(entity.msg!);
return;
}
} catch (e) {
log(e.toString());
return {"message": e.toString()};
}
}
///单位列表
static Future getUnitList(BuildContext context, parentId) async {
Map<String, dynamic> params = {'id': parentId};
var response = await NetUtils.get(
context,
'${Api.GET_UNIT_LIST};JSESSIONID=${StorageUtil.getInstance().getJsessionId()}',
true,
params);
try {
BaseModel entity = BaseModel.fromJson(response);
Map<String, dynamic> resultData = entity.body;
ExamUnitList examUnitList = ExamUnitList.fromJson(resultData);
if (entity.errorCode == "-1") {
return examUnitList;
} else {
ToastUtils.showCenter(entity.msg!);
return;
}
} catch (e) {
log(e.toString());
return {"message": e.toString()};
}
}
///设备类型
static Future getEquipmentList(BuildContext context, officeId) async {
Map<String, dynamic> params = {'officeId': officeId};
var response = await NetUtils.get(
context,
'${Api.GET_EQUIPMENT_LIST};JSESSIONID=${StorageUtil.getInstance().getJsessionId()}',
true,
params);
try {
BaseModel entity = BaseModel.fromJson(response);
Map<String, dynamic> resultData = entity.body;
EquipmentListBo equipmentListBo = EquipmentListBo.fromJson(resultData);
if (entity.errorCode == "-1") {
return equipmentListBo;
} else {
ToastUtils.showCenter(entity.msg!);
return;
}
} catch (e) {
log(e.toString());
return {"message": e.toString()};
}
}
///获取单位考试人员
static Future getUnitPerson(
BuildContext context, officeId, typeId, roleId) async {
Map<String, dynamic> params = {
'officeId': officeId,
'typeId': typeId,
'roleId': roleId
};
var response = await NetUtils.get(
context,
'${Api.GET_UNIT_PERSON};JSESSIONID=${StorageUtil.getInstance().getJsessionId()}',
true,
params);
try {
BaseModel entity = BaseModel.fromJson(response);
Map<String, dynamic> resultData = entity.body;
UnitPersonListBo unitPersonListBo = UnitPersonListBo.fromJson(resultData);
if (entity.errorCode == "-1") {
return unitPersonListBo;
} else {
ToastUtils.showCenter(entity.msg!);
return;
}
} catch (e) {
log(e.toString());
return {"message": e.toString()};
}
}
///获取默认题数
static Future getFindQuestionNum(BuildContext context) async {
Map<String, dynamic> params = {};
var response = await NetUtils.get(
context,
'${Api.FIND_QUESTION_NUM};JSESSIONID=${StorageUtil.getInstance().getJsessionId()}',
true,
params);
try {
BaseModel entity = BaseModel.fromJson(response);
Map<String, dynamic> resultData = entity.body;
FindQuestionNum findQuestionNum = FindQuestionNum.fromJson(resultData);
if (entity.errorCode == "-1") {
return findQuestionNum;
} else {
ToastUtils.showCenter(entity.msg!);
return;
}
} catch (e) {
log(e.toString());
return {"message": e.toString()};
}
}
///考核设置提交(监察人)
static Future getExamSettingSubmit(BuildContext context, data) async {
Map<String, dynamic> params = {};
var response = await NetUtils.posts(
context,
'${Api.GET_OVERSEER_SAVE};JSESSIONID=${StorageUtil.getInstance().getJsessionId()}',
true,
data,
params,
'提交中...');
try {
BaseModel entity = BaseModel.fromJson(response);
// Map<String, dynamic> resultData = entity.body;
// ExamResultBo examResultBo = ExamResultBo.fromJson(resultData);
if (entity.errorCode == "-1") {
return entity;
} else {
ToastUtils.showCenter(entity.msg!);
return;
}
} catch (e) {
log(e.toString());
return {"message": e.toString()};
}
}
///设置考核信息,权限
static Future getExaminePerson(BuildContext context) async {
Map<String, dynamic> params = {};
var response = await NetUtils.get(
context,
'${Api.CHECK_HAVE_EXAM};JSESSIONID=${StorageUtil.getInstance().getJsessionId()}',
false,
params);
try {
BaseModel entity = BaseModel.fromJson(response);
Map<String, dynamic> resultData = entity.body;
ExaminePersonBo examinePersonBo = ExaminePersonBo.fromJson(resultData);
if (entity.errorCode == "-1") {
return examinePersonBo;
} else {
ToastUtils.showCenter(entity.msg!);
return;
}
} catch (e) {
log(e.toString());
return {"message": e.toString()};
}
}
///获取考核列表
static Future getOverseerList(
BuildContext context, taskState, beginTime, unitType) async {
Map<String, dynamic> params = {
'delFlag': '0',
'userids': StorageUtil.getInstance().getUserId()
};
var response = await NetUtils.get(
context,
'${Api.GET_OVERSEER_LIST};JSESSIONID=${StorageUtil.getInstance().getJsessionId()}',
false,
params);
try {
BaseModel entity = BaseModel.fromJson(response);
Map<String, dynamic> resultData = entity.body;
DayControlListSyBo dayControlSyBo =
DayControlListSyBo.fromJson(resultData);
if (entity.errorCode == "-1") {
return dayControlSyBo;
} else {
ToastUtils.showCenter(entity.msg!);
return;
}
} catch (e) {
log(e.toString());
return {"message": e.toString()};
}
}
///考核列表删除
static Future getOverseerDelete(
BuildContext context, taskState, beginTime, unitType) async {
Map<String, dynamic> params = {'ids': '0'};
var response = await NetUtils.get(
context,
'${Api.GET_OVERSEER_DELETE};JSESSIONID=${StorageUtil.getInstance().getJsessionId()}',
false,
params);
try {
BaseModel entity = BaseModel.fromJson(response);
Map<String, dynamic> resultData = entity.body;
DayControlListSyBo dayControlSyBo =
DayControlListSyBo.fromJson(resultData);
if (entity.errorCode == "-1") {
return dayControlSyBo;
} else {
ToastUtils.showCenter(entity.msg!);
return;
}
} catch (e) {
log(e.toString());
return {"message": e.toString()};
}
}
///根据设备类型获取总题数
static Future getFindEqQuestionNum(BuildContext context, String type) async {
Map<String, dynamic> params = {"type": type};
var response = await NetUtils.get(
context,
'${Api.FINT_QUESTION_TYPE};JSESSIONID=${StorageUtil.getInstance().getJsessionId()}',
true,
params);
try {
BaseModel entity = BaseModel.fromJson(response);
Map<String, dynamic> resultData = entity.body;
EqQuestionBo findQuestionNum = EqQuestionBo.fromJson(resultData);
if (entity.errorCode == "-1") {
return findQuestionNum;
} else {
ToastUtils.showCenter(entity.msg!);
return;
}
} catch (e) {
log(e.toString());
return {"message": e.toString()};
}
}
///考核 是否显示答案
static Future getShowAnswer(BuildContext context) async {
Map<String, dynamic> params = {};
var response = await NetUtils.get(
context,
'${Api.SHOW_ANSWER};JSESSIONID=${StorageUtil.getInstance().getJsessionId()}',
false,
params);
try {
BaseModel entity = BaseModel.fromJson(response);
Map<String, dynamic> resultData = entity.body;
ShowAnswerBo mShowAnswerBo = ShowAnswerBo.fromJson(resultData);
if (entity.errorCode == "-1") {
return mShowAnswerBo;
} else {
ToastUtils.showCenter(entity.msg!);
return;
}
} catch (e) {
log(e.toString());
return {"message": e.toString()};
}
}
// HttpUtils.getList(context, _page, 20).then((value) { // HttpUtils.getList(context, _page, 20).then((value) {
// ListBo listBo = value; // ListBo listBo = value;
// print(listBo); // print(listBo);
......
class EqQuestionBo {
EqQuestionBo({
this.data,
});
EqQuestionBo.fromJson(dynamic json) {
data = json['data'] != null ? DataEq.fromJson(json['data']) : null;
}
DataEq? data;
EqQuestionBo copyWith({
DataEq? data,
}) =>
EqQuestionBo(
data: data ?? this.data,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
if (data != null) {
map['data'] = data?.toJson();
}
return map;
}
}
class DataEq {
DataEq({
this.num,
this.pdNum,
this.dxNum,
});
DataEq.fromJson(dynamic json) {
num = json['num'];
pdNum = json['pdNum'];
dxNum = json['dxNum'];
}
int? num;
int? pdNum;
int? dxNum;
DataEq copyWith({
int? num,
int? pdNum,
int? dxNum,
}) =>
DataEq(
num: num ?? this.num,
pdNum: pdNum ?? this.pdNum,
dxNum: dxNum ?? this.dxNum,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['num'] = num;
map['pdNum'] = pdNum;
map['dxNum'] = dxNum;
return map;
}
}
class EquipmentListBo {
EquipmentListBo({
this.list,
});
EquipmentListBo.fromJson(dynamic json) {
if (json['list'] != null) {
list = [];
json['list'].forEach((v) {
list?.add(EquiList.fromJson(v));
});
}
}
List<EquiList>? list;
EquipmentListBo copyWith({
List<EquiList>? list,
}) =>
EquipmentListBo(
list: list ?? this.list,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
if (list != null) {
map['list'] = list?.map((v) => v.toJson()).toList();
}
return map;
}
}
class EquiList {
EquiList({
this.id,
this.name,
});
EquiList.fromJson(dynamic json) {
id = json['id'];
name = json['NAME'];
}
String? id;
String? name;
EquiList copyWith({
String? id,
String? name,
}) =>
EquiList(
id: id ?? this.id,
name: name ?? this.name,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['NAME'] = name;
return map;
}
}
class ExamResultBo {
ExamResultBo({
this.data,
});
ExamResultBo.fromJson(dynamic json) {
data = json['data'] != null ? ExamResultData.fromJson(json['data']) : null;
}
ExamResultData? data;
ExamResultBo copyWith({
ExamResultData? data,
}) =>
ExamResultBo(
data: data ?? this.data,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
if (data != null) {
map['data'] = data?.toJson();
}
return map;
}
}
class ExamResultData {
ExamResultData({
this.id,
this.name,
this.questionNum,
this.score,
this.ccuracy,
this.user,
this.inspectors,
this.correct,
this.error,
this.adopt,
this.unit,
this.dxNum,
this.pdNum,
});
ExamResultData.fromJson(dynamic json) {
id = json['id'];
name = json['name'];
questionNum = json['questionNum'];
score = json['score'];
ccuracy = json['ccuracy'];
user = json['user'] != null ? User.fromJson(json['user']) : null;
inspectors = json['inspectors'] != null
? Inspectors.fromJson(json['inspectors'])
: null;
correct = json['correct'];
error = json['error'];
adopt = json['adopt'];
unit = json['unit'] != null ? Unit.fromJson(json['unit']) : null;
dxNum = json['dxNum'];
pdNum = json['pdNum'];
}
String? id;
String? name;
num? questionNum;
num? score;
num? ccuracy;
User? user;
Inspectors? inspectors;
num? correct;
num? error;
String? adopt;
Unit? unit;
num? dxNum;
num? pdNum;
ExamResultData copyWith({
String? id,
String? name,
num? questionNum,
num? score,
num? ccuracy,
User? user,
Inspectors? inspectors,
num? correct,
num? error,
String? adopt,
Unit? unit,
num? dxNum,
num? pdNum,
}) =>
ExamResultData(
id: id ?? this.id,
name: name ?? this.name,
questionNum: questionNum ?? this.questionNum,
score: score ?? this.score,
ccuracy: ccuracy ?? this.ccuracy,
user: user ?? this.user,
inspectors: inspectors ?? this.inspectors,
correct: correct ?? this.correct,
error: error ?? this.error,
adopt: adopt ?? this.adopt,
unit: unit ?? this.unit,
dxNum: dxNum ?? this.dxNum,
pdNum: pdNum ?? this.pdNum,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['name'] = name;
map['questionNum'] = questionNum;
map['score'] = score;
map['ccuracy'] = ccuracy;
if (user != null) {
map['user'] = user?.toJson();
}
if (inspectors != null) {
map['inspectors'] = inspectors?.toJson();
}
map['correct'] = correct;
map['error'] = error;
map['adopt'] = adopt;
if (unit != null) {
map['unit'] = unit?.toJson();
}
map['dxNum'] = dxNum;
map['pdNum'] = pdNum;
return map;
}
}
class Unit {
Unit({
this.id,
this.name,
this.sort,
this.hasChildren,
this.parentId,
});
Unit.fromJson(dynamic json) {
id = json['id'];
name = json['name'];
sort = json['sort'];
hasChildren = json['hasChildren'];
parentId = json['parentId'];
}
String? id;
String? name;
num? sort;
bool? hasChildren;
String? parentId;
Unit copyWith({
String? id,
String? name,
num? sort,
bool? hasChildren,
String? parentId,
}) =>
Unit(
id: id ?? this.id,
name: name ?? this.name,
sort: sort ?? this.sort,
hasChildren: hasChildren ?? this.hasChildren,
parentId: parentId ?? this.parentId,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['name'] = name;
map['sort'] = sort;
map['hasChildren'] = hasChildren;
map['parentId'] = parentId;
return map;
}
}
class Inspectors {
Inspectors({
this.id,
this.loginFlag,
this.roleNames,
this.admin,
});
Inspectors.fromJson(dynamic json) {
id = json['id'];
loginFlag = json['loginFlag'];
roleNames = json['roleNames'];
admin = json['admin'];
}
String? id;
String? loginFlag;
String? roleNames;
bool? admin;
Inspectors copyWith({
String? id,
String? loginFlag,
String? roleNames,
bool? admin,
}) =>
Inspectors(
id: id ?? this.id,
loginFlag: loginFlag ?? this.loginFlag,
roleNames: roleNames ?? this.roleNames,
admin: admin ?? this.admin,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['loginFlag'] = loginFlag;
map['roleNames'] = roleNames;
map['admin'] = admin;
return map;
}
}
class User {
User({
this.id,
this.loginFlag,
this.roleNames,
this.admin,
});
User.fromJson(dynamic json) {
id = json['id'];
loginFlag = json['loginFlag'];
roleNames = json['roleNames'];
admin = json['admin'];
}
String? id;
String? loginFlag;
String? roleNames;
bool? admin;
User copyWith({
String? id,
String? loginFlag,
String? roleNames,
bool? admin,
}) =>
User(
id: id ?? this.id,
loginFlag: loginFlag ?? this.loginFlag,
roleNames: roleNames ?? this.roleNames,
admin: admin ?? this.admin,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['loginFlag'] = loginFlag;
map['roleNames'] = roleNames;
map['admin'] = admin;
return map;
}
}
class ExamSettingSubmitBo {
ExamSettingSubmitBo({
this.aqzgPdNum,
this.aqzgXzNum,
this.aqyPdNum,
this.aqyXzNum,
this.aqzgIds,
this.aqyIds,
this.type,
});
ExamSettingSubmitBo.fromJson(dynamic json) {
aqzgPdNum = json['aqzgPdNum'];
aqzgXzNum = json['aqzgXzNum'];
aqyPdNum = json['aqyPdNum'];
aqyXzNum = json['aqyXzNum'];
aqzgIds = json['aqzgIds'] != null ? json['aqzgIds'].cast<String>() : [];
aqyIds = json['aqyIds'] != null ? json['aqyIds'].cast<String>() : [];
type = json['type'];
}
int? aqzgPdNum;
int? aqzgXzNum;
int? aqyPdNum;
int? aqyXzNum;
List<String>? aqzgIds;
List<String>? aqyIds;
String? type;
ExamSettingSubmitBo copyWith({
int? aqzgPdNum,
int? aqzgXzNum,
int? aqyPdNum,
int? aqyXzNum,
List<String>? aqzgIds,
List<String>? aqyIds,
String? type,
}) =>
ExamSettingSubmitBo(
aqzgPdNum: aqzgPdNum ?? this.aqzgPdNum,
aqzgXzNum: aqzgXzNum ?? this.aqzgXzNum,
aqyPdNum: aqyPdNum ?? this.aqyPdNum,
aqyXzNum: aqyXzNum ?? this.aqyXzNum,
aqzgIds: aqzgIds ?? this.aqzgIds,
aqyIds: aqyIds ?? this.aqyIds,
type: type ?? this.type,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['aqzgPdNum'] = aqzgPdNum;
map['aqzgXzNum'] = aqzgXzNum;
map['aqyPdNum'] = aqyPdNum;
map['aqyXzNum'] = aqyXzNum;
map['aqzgIds'] = aqzgIds;
map['aqyIds'] = aqyIds;
map['type'] = type;
return map;
}
}
class ExamUnitList {
ExamUnitList({
this.officeList,
});
ExamUnitList.fromJson(dynamic json) {
if (json['officeList'] != null) {
officeList = [];
json['officeList'].forEach((v) {
officeList?.add(OfficeList.fromJson(v));
});
}
}
List<OfficeList>? officeList;
ExamUnitList copyWith({
List<OfficeList>? officeList,
}) =>
ExamUnitList(
officeList: officeList ?? this.officeList,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
if (officeList != null) {
map['officeList'] = officeList?.map((v) => v.toJson()).toList();
}
return map;
}
}
class OfficeList {
OfficeList({
this.id,
this.name,
this.sort,
this.hasChildren,
this.parentId,
});
OfficeList.fromJson(dynamic json) {
id = json['id'];
name = json['name'];
sort = json['sort'];
hasChildren = json['hasChildren'];
parentId = json['parentId'];
}
String? id;
String? name;
num? sort;
bool? hasChildren;
String? parentId;
OfficeList copyWith({
String? id,
String? name,
num? sort,
bool? hasChildren,
String? parentId,
}) =>
OfficeList(
id: id ?? this.id,
name: name ?? this.name,
sort: sort ?? this.sort,
hasChildren: hasChildren ?? this.hasChildren,
parentId: parentId ?? this.parentId,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['name'] = name;
map['sort'] = sort;
map['hasChildren'] = hasChildren;
map['parentId'] = parentId;
return map;
}
}
class ExaminePersonBo {
ExaminePersonBo({
this.data,
this.success,
});
ExaminePersonBo.fromJson(dynamic json) {
data =
json['data'] != null ? DataExaminePerson.fromJson(json['data']) : null;
success = json['success'];
}
DataExaminePerson? data;
bool? success;
ExaminePersonBo copyWith({
DataExaminePerson? data,
bool? success,
}) =>
ExaminePersonBo(
data: data ?? this.data,
success: success ?? this.success,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
if (data != null) {
map['data'] = data?.toJson();
}
map['success'] = success;
return map;
}
}
class DataExaminePerson {
DataExaminePerson({
this.id,
this.inspectors,
this.user,
this.examDate,
this.pdNum,
this.xzNum,
this.type,
this.positionType,
});
DataExaminePerson.fromJson(dynamic json) {
id = json['id'];
inspectors = json['inspectors'] != null
? Inspectors.fromJson(json['inspectors'])
: null;
user = json['user'] != null ? User.fromJson(json['user']) : null;
examDate = json['examDate'];
pdNum = json['pdNum'];
xzNum = json['xzNum'];
type = json['type'] != null ? Type.fromJson(json['type']) : null;
positionType = json['positionType'];
}
String? id;
Inspectors? inspectors;
User? user;
String? examDate;
int? pdNum;
int? xzNum;
Type? type;
String? positionType;
DataExaminePerson copyWith({
String? id,
Inspectors? inspectors,
User? user,
String? examDate,
int? pdNum,
int? xzNum,
Type? type,
String? positionType,
}) =>
DataExaminePerson(
id: id ?? this.id,
inspectors: inspectors ?? this.inspectors,
user: user ?? this.user,
examDate: examDate ?? this.examDate,
pdNum: pdNum ?? this.pdNum,
xzNum: xzNum ?? this.xzNum,
type: type ?? this.type,
positionType: positionType ?? this.positionType,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
if (inspectors != null) {
map['inspectors'] = inspectors?.toJson();
}
if (user != null) {
map['user'] = user?.toJson();
}
map['examDate'] = examDate;
map['pdNum'] = pdNum;
map['xzNum'] = xzNum;
if (type != null) {
map['type'] = type?.toJson();
}
map['positionType'] = positionType;
return map;
}
}
class Type {
Type({
this.id,
this.name,
});
Type.fromJson(dynamic json) {
id = json['id'];
name = json['name'];
}
String? id;
String? name;
Type copyWith({
String? id,
String? name,
}) =>
Type(
id: id ?? this.id,
name: name ?? this.name,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['name'] = name;
return map;
}
}
class User {
User({
this.id,
this.loginFlag,
this.roleNames,
this.admin,
});
User.fromJson(dynamic json) {
id = json['id'];
loginFlag = json['loginFlag'];
roleNames = json['roleNames'];
admin = json['admin'];
}
String? id;
String? loginFlag;
String? roleNames;
bool? admin;
User copyWith({
String? id,
String? loginFlag,
String? roleNames,
bool? admin,
}) =>
User(
id: id ?? this.id,
loginFlag: loginFlag ?? this.loginFlag,
roleNames: roleNames ?? this.roleNames,
admin: admin ?? this.admin,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['loginFlag'] = loginFlag;
map['roleNames'] = roleNames;
map['admin'] = admin;
return map;
}
}
class Inspectors {
Inspectors({
this.id,
this.loginFlag,
this.roleNames,
this.admin,
});
Inspectors.fromJson(dynamic json) {
id = json['id'];
loginFlag = json['loginFlag'];
roleNames = json['roleNames'];
admin = json['admin'];
}
String? id;
String? loginFlag;
String? roleNames;
bool? admin;
Inspectors copyWith({
String? id,
String? loginFlag,
String? roleNames,
bool? admin,
}) =>
Inspectors(
id: id ?? this.id,
loginFlag: loginFlag ?? this.loginFlag,
roleNames: roleNames ?? this.roleNames,
admin: admin ?? this.admin,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['loginFlag'] = loginFlag;
map['roleNames'] = roleNames;
map['admin'] = admin;
return map;
}
}
class ExamineQuestionsBo {
ExamineQuestionsBo({
this.data,
});
ExamineQuestionsBo.fromJson(dynamic json) {
data = json['data'] != null ? Data.fromJson(json['data']) : null;
}
Data? data;
ExamineQuestionsBo copyWith({
Data? data,
}) =>
ExamineQuestionsBo(
data: data ?? this.data,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
if (data != null) {
map['data'] = data?.toJson();
}
return map;
}
}
class Data {
Data({
this.id,
this.createDate,
this.updateDate,
this.name,
this.questionint,
this.user,
this.inspectors,
this.adopt,
this.unit,
this.examDate,
this.type,
this.dxint,
this.pdint,
this.examQuestionList,
});
Data.fromJson(dynamic json) {
id = json['id'];
createDate = json['createDate'];
updateDate = json['updateDate'];
name = json['name'];
questionint = json['questionint'];
user = json['user'] != null ? User.fromJson(json['user']) : null;
inspectors = json['inspectors'] != null
? Inspectors.fromJson(json['inspectors'])
: null;
adopt = json['adopt'];
unit = json['unit'] != null ? Unit.fromJson(json['unit']) : null;
examDate = json['examDate'];
type = json['type'] != null ? Type.fromJson(json['type']) : null;
dxint = json['dxint'];
pdint = json['pdint'];
if (json['examQuestionList'] != null) {
examQuestionList = [];
json['examQuestionList'].forEach((v) {
examQuestionList?.add(ExamQuestionList.fromJson(v));
});
}
}
String? id;
String? createDate;
String? updateDate;
String? name;
int? questionint;
User? user;
Inspectors? inspectors;
String? adopt;
Unit? unit;
int? examDate;
Type? type;
int? dxint;
int? pdint;
List<ExamQuestionList>? examQuestionList;
Data copyWith({
String? id,
String? createDate,
String? updateDate,
String? name,
int? questionint,
User? user,
Inspectors? inspectors,
String? adopt,
Unit? unit,
int? examDate,
Type? type,
int? dxint,
int? pdint,
List<ExamQuestionList>? examQuestionList,
}) =>
Data(
id: id ?? this.id,
createDate: createDate ?? this.createDate,
updateDate: updateDate ?? this.updateDate,
name: name ?? this.name,
questionint: questionint ?? this.questionint,
user: user ?? this.user,
inspectors: inspectors ?? this.inspectors,
adopt: adopt ?? this.adopt,
unit: unit ?? this.unit,
examDate: examDate ?? this.examDate,
type: type ?? this.type,
dxint: dxint ?? this.dxint,
pdint: pdint ?? this.pdint,
examQuestionList: examQuestionList ?? this.examQuestionList,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['createDate'] = createDate;
map['updateDate'] = updateDate;
map['name'] = name;
map['questionint'] = questionint;
if (user != null) {
map['user'] = user?.toJson();
}
if (inspectors != null) {
map['inspectors'] = inspectors?.toJson();
}
map['adopt'] = adopt;
if (unit != null) {
map['unit'] = unit?.toJson();
}
map['examDate'] = examDate;
if (type != null) {
map['type'] = type?.toJson();
}
map['dxint'] = dxint;
map['pdint'] = pdint;
if (examQuestionList != null) {
map['examQuestionList'] =
examQuestionList?.map((v) => v.toJson()).toList();
}
return map;
}
}
class ExamQuestionList {
ExamQuestionList({
this.id,
this.content,
this.answer,
this.type,
this.questionType,
this.detailId,
this.sort,
this.examQuestionOptionList,
this.result,
});
ExamQuestionList.fromJson(dynamic json) {
id = json['id'];
content = json['content'];
answer = json['answer'];
type = json['type'];
questionType = json['questionType'];
detailId = json['detailId'];
sort = json['sort'];
if (json['examQuestionOptionList'] != null) {
examQuestionOptionList = [];
json['examQuestionOptionList'].forEach((v) {
examQuestionOptionList?.add(ExamQuestionOptionList.fromJson(v));
});
}
result = json['result'];
}
String? id;
String? content;
String? answer;
String? type;
String? questionType;
String? detailId;
int? sort;
List<ExamQuestionOptionList>? examQuestionOptionList;
String? result = '';
ExamQuestionList copyWith({
String? id,
String? content,
String? answer,
String? type,
String? questionType,
String? detailId,
int? sort,
List<ExamQuestionOptionList>? examQuestionOptionList,
String? result,
}) =>
ExamQuestionList(
id: id ?? this.id,
content: content ?? this.content,
answer: answer ?? this.answer,
type: type ?? this.type,
questionType: questionType ?? this.questionType,
detailId: detailId ?? this.detailId,
sort: sort ?? this.sort,
examQuestionOptionList:
examQuestionOptionList ?? this.examQuestionOptionList,
result: result ?? this.result,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['content'] = content;
map['answer'] = answer;
map['type'] = type;
map['questionType'] = questionType;
map['detailId'] = detailId;
map['sort'] = sort;
if (examQuestionOptionList != null) {
map['examQuestionOptionList'] =
examQuestionOptionList?.map((v) => v.toJson()).toList();
}
map['result'] = result;
return map;
}
}
class ExamQuestionOptionList {
ExamQuestionOptionList({
this.id,
this.content,
this.options,
this.question,
});
ExamQuestionOptionList.fromJson(dynamic json) {
id = json['id'];
content = json['content'];
options = json['options'];
question =
json['question'] != null ? Question.fromJson(json['question']) : null;
}
String? id;
String? content;
String? options;
Question? question;
bool? isSelected = false;
///隐藏式答案
bool? isAcquiesceSelected = false;
ExamQuestionOptionList copyWith({
String? id,
String? content,
String? options,
Question? question,
}) =>
ExamQuestionOptionList(
id: id ?? this.id,
content: content ?? this.content,
options: options ?? this.options,
question: question ?? this.question,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['content'] = content;
map['options'] = options;
if (question != null) {
map['question'] = question?.toJson();
}
return map;
}
}
class Question {
Question({
this.id,
});
Question.fromJson(dynamic json) {
id = json['id'];
}
String? id;
Question copyWith({
String? id,
}) =>
Question(
id: id ?? this.id,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
return map;
}
}
class Type {
Type({
this.id,
});
Type.fromJson(dynamic json) {
id = json['id'];
}
String? id;
Type copyWith({
String? id,
}) =>
Type(
id: id ?? this.id,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
return map;
}
}
class Unit {
Unit({
this.id,
this.parentIds,
this.name,
this.sort,
this.hasChildren,
this.type,
this.parentId,
});
Unit.fromJson(dynamic json) {
id = json['id'];
parentIds = json['parentIds'];
name = json['name'];
sort = json['sort'];
hasChildren = json['hasChildren'];
type = json['type'];
parentId = json['parentId'];
}
String? id;
String? parentIds;
String? name;
int? sort;
bool? hasChildren;
String? type;
String? parentId;
Unit copyWith({
String? id,
String? parentIds,
String? name,
int? sort,
bool? hasChildren,
String? type,
String? parentId,
}) =>
Unit(
id: id ?? this.id,
parentIds: parentIds ?? this.parentIds,
name: name ?? this.name,
sort: sort ?? this.sort,
hasChildren: hasChildren ?? this.hasChildren,
type: type ?? this.type,
parentId: parentId ?? this.parentId,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['parentIds'] = parentIds;
map['name'] = name;
map['sort'] = sort;
map['hasChildren'] = hasChildren;
map['type'] = type;
map['parentId'] = parentId;
return map;
}
}
class Inspectors {
Inspectors({
this.id,
this.loginFlag,
this.admin,
this.roleNames,
});
Inspectors.fromJson(dynamic json) {
id = json['id'];
loginFlag = json['loginFlag'];
admin = json['admin'];
roleNames = json['roleNames'];
}
String? id;
String? loginFlag;
bool? admin;
String? roleNames;
Inspectors copyWith({
String? id,
String? loginFlag,
bool? admin,
String? roleNames,
}) =>
Inspectors(
id: id ?? this.id,
loginFlag: loginFlag ?? this.loginFlag,
admin: admin ?? this.admin,
roleNames: roleNames ?? this.roleNames,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['loginFlag'] = loginFlag;
map['admin'] = admin;
map['roleNames'] = roleNames;
return map;
}
}
class User {
User({
this.id,
this.loginFlag,
this.admin,
this.roleNames,
});
User.fromJson(dynamic json) {
id = json['id'];
loginFlag = json['loginFlag'];
admin = json['admin'];
roleNames = json['roleNames'];
}
String? id;
String? loginFlag;
bool? admin;
String? roleNames;
User copyWith({
String? id,
String? loginFlag,
bool? admin,
String? roleNames,
}) =>
User(
id: id ?? this.id,
loginFlag: loginFlag ?? this.loginFlag,
admin: admin ?? this.admin,
roleNames: roleNames ?? this.roleNames,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['loginFlag'] = loginFlag;
map['admin'] = admin;
map['roleNames'] = roleNames;
return map;
}
}
class FindQuestionNum {
FindQuestionNum({
this.data,
});
FindQuestionNum.fromJson(dynamic json) {
data = json['data'] != null ? DataNum.fromJson(json['data']) : null;
}
DataNum? data;
FindQuestionNum copyWith({
DataNum? data,
}) =>
FindQuestionNum(
data: data ?? this.data,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
if (data != null) {
map['data'] = data?.toJson();
}
return map;
}
}
class DataNum {
DataNum({
this.id,
this.aqzjPd,
this.aqzjDx,
this.aqyPd,
this.aqyDx,
});
DataNum.fromJson(dynamic json) {
id = json['id'];
aqzjPd = json['aqzjPd'];
aqzjDx = json['aqzjDx'];
aqyPd = json['aqyPd'];
aqyDx = json['aqyDx'];
}
String? id;
int? aqzjPd;
int? aqzjDx;
int? aqyPd;
int? aqyDx;
DataNum copyWith({
String? id,
int? aqzjPd,
int? aqzjDx,
int? aqyPd,
int? aqyDx,
}) =>
DataNum(
id: id ?? this.id,
aqzjPd: aqzjPd ?? this.aqzjPd,
aqzjDx: aqzjDx ?? this.aqzjDx,
aqyPd: aqyPd ?? this.aqyPd,
aqyDx: aqyDx ?? this.aqyDx,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['aqzjPd'] = aqzjPd;
map['aqzjDx'] = aqzjDx;
map['aqyPd'] = aqyPd;
map['aqyDx'] = aqyDx;
return map;
}
}
class ShowAnswerBo {
ShowAnswerBo({
this.data,
});
ShowAnswerBo.fromJson(dynamic json) {
data = json['data'];
}
String? data;
ShowAnswerBo copyWith({
String? data,
}) =>
ShowAnswerBo(
data: data ?? this.data,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['data'] = data;
return map;
}
}
class TestQuestion {
List<Question>? question;
TestQuestion({this.question});
TestQuestion.fromJson(Map<String, dynamic> json) {
if (json['question'] != null) {
question = <Question>[];
json['question'].forEach((v) {
question!.add(Question.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.question != null) {
data['question'] = this.question!.map((v) => v.toJson()).toList();
}
return data;
}
}
class Question {
int? id;
String? type;
String? name;
String? title;
String? image;
List<Option>? option;
Question(
{this.id, this.type, this.name, this.title, this.image, this.option});
Question.fromJson(Map<String, dynamic> json) {
id = json['id'];
type = json['type'];
name = json['name'];
title = json['title'];
image = json['image'];
if (json['option'] != null) {
option = <Option>[];
json['option'].forEach((v) {
option!.add(new Option.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['type'] = this.type;
data['name'] = this.name;
data['title'] = this.title;
data['image'] = this.image;
if (this.option != null) {
data['option'] = this.option!.map((v) => v.toJson()).toList();
}
return data;
}
}
class Option {
String? answer;
bool? isSelected;
String? id;
Option({this.answer, this.isSelected, this.id});
Option.fromJson(Map<String, dynamic> json) {
answer = json['answer'];
isSelected = json['isSelected'];
id = json['id'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['answer'] = this.answer;
data['isSelected'] = this.isSelected;
data['id'] = this.id;
return data;
}
}
Map<String, dynamic> testQuestionJson = {
"question": [
{
"id": 1001,
"type": "1",
"name": "多选",
"title": "休克早期的临床表现是",
"image":
"https://img.qingwk.com/images/resource/f14231625/2019/05/05/19531_1303148556_fd.jpg",
"option": [
{"answer": "精神紧张,烦躁不安,心率增快,尿量减少", "isSelected": false, "id": "A"},
{"answer": "表情淡漠,感觉迟钝,脉搏减慢", "isSelected": false, "id": "B"},
{"answer": "血压下降,出冷汗,无尿", "isSelected": false, "id": "C"},
{"answer": "表情淡漠,皮肤出现瘀斑,血压下降", "isSelected": false, "id": "D"},
{"answer": "出冷汗,软弱无力,血压下降,皮肤发绀", "isSelected": false, "id": "E"}
]
},
{
"id": 1002,
"type": "0",
"name": "单选",
"title": "护理评估腹泻患儿重度脱水的主要依据,错误的是:()",
"image":
"https://picnew12.photophoto.cn/20171010/chuangyihuiseduojiaojihetuxingsucai-28744986_1.jpg",
"option": [
{"answer": "四肢厥冷", "isSelected": false, "id": "A"},
{"answer": "皮肤发花", "isSelected": false, "id": "B"},
{"answer": "血压轻度升高", "isSelected": false, "id": "C"},
{"answer": "少尿或无尿等休克症状", "isSelected": false, "id": "D"}
]
},
{
"id": 1003,
"type": "3",
"name": "判断",
"title":
"糖尿病酮症酸中毒患者早期酮症阶段仅有多尿、多饮、疲乏等,继之出现食欲不振、恶心、呕吐、头痛、嗜睡、呼吸深大(Kussmaul呼吸),呼气中出现烂苹果味;后期脱水明显,尿少、皮肤干燥、血压下降、休克、昏迷,以至死亡。()",
"image":
"https://img.qingwk.com/images/resource/f16733122/2019/02/24/202988_67998812894_fd.jpg",
"option": [
{"answer": "是", "isSelected": false, "id": "A"},
{"answer": "否", "isSelected": false, "id": "B"}
]
},
{
"id": 1004,
"type": "3",
"name": "判断",
"title": "贫血的临床表现主要是缺氧的病理生理改变所引起。()",
"image":
"https://tp.tucengyun.com/wp-content/uploads/2021/03/20210304132545488.jpg",
"option": [
{"answer": "是", "isSelected": false, "id": "A"},
{"answer": "否", "isSelected": false, "id": "B"}
]
}
]
};
class TestQuestionsBo {
TestQuestionsBo({
this.data,
});
TestQuestionsBo.fromJson(dynamic json) {
data = json['data'] != null ? DataTest.fromJson(json['data']) : null;
}
DataTest? data;
TestQuestionsBo copyWith({
DataTest? data,
}) =>
TestQuestionsBo(
data: data ?? this.data,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
if (data != null) {
map['data'] = data?.toJson();
}
return map;
}
}
class DataTest {
DataTest({
this.id,
this.createBy,
this.createDate,
this.updateBy,
this.updateDate,
this.name,
this.questionNum,
this.user,
this.adopt,
this.unit,
this.examDate,
this.dxNum,
this.pdNum,
this.examQuestionList,
});
DataTest.fromJson(dynamic json) {
id = json['id'];
createBy =
json['createBy'] != null ? CreateBy.fromJson(json['createBy']) : null;
createDate = json['createDate'];
updateBy =
json['updateBy'] != null ? UpdateBy.fromJson(json['updateBy']) : null;
updateDate = json['updateDate'];
name = json['name'];
questionNum = json['questionNum'];
user = json['user'] != null ? User.fromJson(json['user']) : null;
adopt = json['adopt'];
unit = json['unit'] != null ? Unit.fromJson(json['unit']) : null;
examDate = json['examDate'];
dxNum = json['dxNum'];
pdNum = json['pdNum'];
if (json['examQuestionList'] != null) {
examQuestionList = [];
json['examQuestionList'].forEach((v) {
examQuestionList?.add(ExamQuestionTestList.fromJson(v));
});
}
}
String? id;
CreateBy? createBy;
String? createDate;
UpdateBy? updateBy;
String? updateDate;
String? name;
num? questionNum;
User? user;
String? adopt;
Unit? unit;
String? examDate;
num? dxNum;
num? pdNum;
List<ExamQuestionTestList>? examQuestionList;
DataTest copyWith({
String? id,
CreateBy? createBy,
String? createDate,
UpdateBy? updateBy,
String? updateDate,
String? name,
num? questionNum,
User? user,
String? adopt,
Unit? unit,
String? examDate,
num? dxNum,
num? pdNum,
List<ExamQuestionTestList>? examQuestionList,
}) =>
DataTest(
id: id ?? this.id,
createBy: createBy ?? this.createBy,
createDate: createDate ?? this.createDate,
updateBy: updateBy ?? this.updateBy,
updateDate: updateDate ?? this.updateDate,
name: name ?? this.name,
questionNum: questionNum ?? this.questionNum,
user: user ?? this.user,
adopt: adopt ?? this.adopt,
unit: unit ?? this.unit,
examDate: examDate ?? this.examDate,
dxNum: dxNum ?? this.dxNum,
pdNum: pdNum ?? this.pdNum,
examQuestionList: examQuestionList ?? this.examQuestionList,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
if (createBy != null) {
map['createBy'] = createBy?.toJson();
}
map['createDate'] = createDate;
if (updateBy != null) {
map['updateBy'] = updateBy?.toJson();
}
map['updateDate'] = updateDate;
map['name'] = name;
map['questionNum'] = questionNum;
if (user != null) {
map['user'] = user?.toJson();
}
map['adopt'] = adopt;
if (unit != null) {
map['unit'] = unit?.toJson();
}
map['examDate'] = examDate;
map['dxNum'] = dxNum;
map['pdNum'] = pdNum;
if (examQuestionList != null) {
map['examQuestionList'] =
examQuestionList?.map((v) => v.toJson()).toList();
}
return map;
}
}
class ExamQuestionTestList {
ExamQuestionTestList({
this.id,
this.content,
this.answer,
this.type,
this.questionType,
this.detailId,
this.sort,
this.examQuestionOptionList,
this.result,
});
ExamQuestionTestList.fromJson(dynamic json) {
id = json['id'];
content = json['content'];
answer = json['answer'];
type = json['type'];
questionType = json['questionType'];
detailId = json['detailId'];
sort = json['sort'];
if (json['examQuestionOptionList'] != null) {
examQuestionOptionList = [];
json['examQuestionOptionList'].forEach((v) {
examQuestionOptionList?.add(ExamQuestionTestOptionList.fromJson(v));
});
}
result = json['result'];
}
String? id;
String? content;
String? answer;
String? type;
String? questionType;
String? detailId;
int? sort;
List<ExamQuestionTestOptionList>? examQuestionOptionList;
String? result = '';
ExamQuestionTestList copyWith({
String? id,
String? content,
String? answer,
String? type,
String? questionType,
String? detailId,
int? sort,
List<ExamQuestionTestOptionList>? examQuestionOptionList,
String? result,
}) =>
ExamQuestionTestList(
id: id ?? this.id,
content: content ?? this.content,
answer: answer ?? this.answer,
type: type ?? this.type,
questionType: questionType ?? this.questionType,
detailId: detailId ?? this.detailId,
sort: sort ?? this.sort,
examQuestionOptionList:
examQuestionOptionList ?? this.examQuestionOptionList,
result: result ?? this.result,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['content'] = content;
map['answer'] = answer;
map['type'] = type;
map['questionType'] = questionType;
map['detailId'] = detailId;
map['sort'] = sort;
if (examQuestionOptionList != null) {
map['examQuestionOptionList'] =
examQuestionOptionList?.map((v) => v.toJson()).toList();
}
map['result'] = result;
return map;
}
}
class ExamQuestionTestOptionList {
ExamQuestionTestOptionList({
this.id,
this.content,
this.options,
this.question,
});
ExamQuestionTestOptionList.fromJson(dynamic json) {
id = json['id'];
content = json['content'];
options = json['options'];
question =
json['question'] != null ? Question.fromJson(json['question']) : null;
}
String? id;
String? content;
String? options;
Question? question;
bool? isSelected = false;
String? flag = '';
ExamQuestionTestOptionList copyWith({
String? id,
String? content,
String? options,
Question? question,
}) =>
ExamQuestionTestOptionList(
id: id ?? this.id,
content: content ?? this.content,
options: options ?? this.options,
question: question ?? this.question,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['content'] = content;
map['options'] = options;
if (question != null) {
map['question'] = question?.toJson();
}
return map;
}
}
class Question {
Question({
this.id,
});
Question.fromJson(dynamic json) {
id = json['id'];
}
String? id;
Question copyWith({
String? id,
}) =>
Question(
id: id ?? this.id,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
return map;
}
}
class Unit {
Unit({
this.id,
this.sort,
this.hasChildren,
this.parentId,
});
Unit.fromJson(dynamic json) {
id = json['id'];
sort = json['sort'];
hasChildren = json['hasChildren'];
parentId = json['parentId'];
}
String? id;
num? sort;
bool? hasChildren;
String? parentId;
Unit copyWith({
String? id,
num? sort,
bool? hasChildren,
String? parentId,
}) =>
Unit(
id: id ?? this.id,
sort: sort ?? this.sort,
hasChildren: hasChildren ?? this.hasChildren,
parentId: parentId ?? this.parentId,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['sort'] = sort;
map['hasChildren'] = hasChildren;
map['parentId'] = parentId;
return map;
}
}
class User {
User({
this.id,
this.loginFlag,
this.roleNames,
this.admin,
});
User.fromJson(dynamic json) {
id = json['id'];
loginFlag = json['loginFlag'];
roleNames = json['roleNames'];
admin = json['admin'];
}
String? id;
String? loginFlag;
String? roleNames;
bool? admin;
User copyWith({
String? id,
String? loginFlag,
String? roleNames,
bool? admin,
}) =>
User(
id: id ?? this.id,
loginFlag: loginFlag ?? this.loginFlag,
roleNames: roleNames ?? this.roleNames,
admin: admin ?? this.admin,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['loginFlag'] = loginFlag;
map['roleNames'] = roleNames;
map['admin'] = admin;
return map;
}
}
class UpdateBy {
UpdateBy({
this.id,
this.loginFlag,
this.roleNames,
this.admin,
});
UpdateBy.fromJson(dynamic json) {
id = json['id'];
loginFlag = json['loginFlag'];
roleNames = json['roleNames'];
admin = json['admin'];
}
String? id;
String? loginFlag;
String? roleNames;
bool? admin;
UpdateBy copyWith({
String? id,
String? loginFlag,
String? roleNames,
bool? admin,
}) =>
UpdateBy(
id: id ?? this.id,
loginFlag: loginFlag ?? this.loginFlag,
roleNames: roleNames ?? this.roleNames,
admin: admin ?? this.admin,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['loginFlag'] = loginFlag;
map['roleNames'] = roleNames;
map['admin'] = admin;
return map;
}
}
class CreateBy {
CreateBy({
this.id,
this.loginFlag,
this.roleNames,
this.admin,
});
CreateBy.fromJson(dynamic json) {
id = json['id'];
loginFlag = json['loginFlag'];
roleNames = json['roleNames'];
admin = json['admin'];
}
String? id;
String? loginFlag;
String? roleNames;
bool? admin;
CreateBy copyWith({
String? id,
String? loginFlag,
String? roleNames,
bool? admin,
}) =>
CreateBy(
id: id ?? this.id,
loginFlag: loginFlag ?? this.loginFlag,
roleNames: roleNames ?? this.roleNames,
admin: admin ?? this.admin,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['loginFlag'] = loginFlag;
map['roleNames'] = roleNames;
map['admin'] = admin;
return map;
}
}
import 'package:special_equipment_flutter/model/exam/equipment_list_bo.dart';
class TestSubmitBo {
EquiList? mEquiList;
int? dxQuestionsNum;
int? pdQuestionsNum;
}
class UnitPersonListBo {
UnitPersonListBo({
this.userList,
});
UnitPersonListBo.fromJson(dynamic json) {
if (json['userList'] != null) {
userList = [];
json['userList'].forEach((v) {
userList?.add(UserLists.fromJson(v));
});
}
}
List<UserLists>? userList;
UnitPersonListBo copyWith({
List<UserLists>? userList,
}) =>
UnitPersonListBo(
userList: userList ?? this.userList,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
if (userList != null) {
map['userList'] = userList?.map((v) => v.toJson()).toList();
}
return map;
}
}
class UserLists {
UserLists({
this.id,
this.name,
this.loginFlag,
this.roleNames,
this.admin,
});
UserLists.fromJson(dynamic json) {
id = json['id'];
name = json['name'];
loginFlag = json['loginFlag'];
roleNames = json['roleNames'];
admin = json['admin'];
}
String? id;
String? name;
String? loginFlag;
String? roleNames;
bool? admin;
bool? isChecked = false;
UserLists copyWith({
String? id,
String? name,
String? loginFlag,
String? roleNames,
bool? admin,
}) =>
UserLists(
id: id ?? this.id,
name: name ?? this.name,
loginFlag: loginFlag ?? this.loginFlag,
roleNames: roleNames ?? this.roleNames,
admin: admin ?? this.admin,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['name'] = name;
map['loginFlag'] = loginFlag;
map['roleNames'] = roleNames;
map['admin'] = admin;
return map;
}
}
...@@ -10,6 +10,7 @@ class StandingConfig { ...@@ -10,6 +10,7 @@ class StandingConfig {
static const String SAFETY_OFFICER = "安全员"; static const String SAFETY_OFFICER = "安全员";
static const String SAFETY_DIRECTOR = "安全总监"; static const String SAFETY_DIRECTOR = "安全总监";
static const String PERSON_CHARGE = "主要负责人"; static const String PERSON_CHARGE = "主要负责人";
static const String INSPECTOR = "监察人员";
static const String SY_DEVICE = '客运索道,电梯,起重机械,锅炉,压力管道,压力容器,大型游乐设施,场车,气瓶'; static const String SY_DEVICE = '客运索道,电梯,起重机械,锅炉,压力管道,压力容器,大型游乐设施,场车,气瓶';
} }
...@@ -21,6 +22,14 @@ bool? isUnitRoles(rolesName) { ...@@ -21,6 +22,14 @@ bool? isUnitRoles(rolesName) {
} }
} }
bool? isInspectorRoles(rolesName) {
if (rolesName == StandingConfig.INSPECTOR) {
return true;
} else {
return false;
}
}
dynamic isRolesName(name) { dynamic isRolesName(name) {
switch (name) { switch (name) {
case '公司账户': case '公司账户':
...@@ -29,6 +38,8 @@ dynamic isRolesName(name) { ...@@ -29,6 +38,8 @@ dynamic isRolesName(name) {
return false; return false;
case '市场监管局': case '市场监管局':
return false; return false;
case StandingConfig.INSPECTOR:
return false;
default: default:
return true; return true;
} }
......
import 'package:flutter/material.dart';
/// 底部弹出Widget
/// 1、支持手势下拉关闭
/// 2、支持动画弹出收起
/// 3、支持弹出无法关闭
class DragBottomSheetWidget extends StatefulWidget {
DragBottomSheetWidget({
required Key key,
required this.builder,
this.duration,
this.childHeightRatio = 0.5,
this.onStateChange,
}) : super(key: key);
Function(bool)? onStateChange;
final double childHeightRatio;
final Duration? duration;
final ScrollableWidgetBuilder builder;
@override
State<DragBottomSheetWidget> createState() => DragBottomSheetWidgetState();
}
class DragBottomSheetWidgetState extends State<DragBottomSheetWidget>
with TickerProviderStateMixin {
final controller = DraggableScrollableController();
//是否可以关闭
bool isCanClose = true;
//是否展开
bool isExpand = false;
double verticalDistance = 0;
@override
void initState() {
super.initState();
}
@override
void dispose() {
controller.dispose();
super.dispose();
}
Future show({bool isCanClose = true}) {
return controller
.animateTo(1,
duration: widget.duration ?? const Duration(milliseconds: 200),
curve: Curves.linear)
.then((value) {
if (!isCanClose) {
setState(() {
this.isCanClose = isCanClose;
});
}
});
}
void hide() {
controller.animateTo(
0,
duration: widget.duration ?? const Duration(milliseconds: 200),
curve: Curves.linear,
);
}
void _dragJumpTo(double y) {
var size = y / MediaQuery.of(context).size.height;
controller.jumpTo(widget.childHeightRatio - size);
}
void _dragEndChange() {
controller.size >= widget.childHeightRatio / 2
? controller.animateTo(
1,
duration: widget.duration ?? const Duration(milliseconds: 200),
curve: Curves.linear,
)
: hide();
}
@override
Widget build(BuildContext context) {
return NotificationListener<DraggableScrollableNotification>(
onNotification: (notification) {
if (notification.extent == widget.childHeightRatio) {
if (!isExpand) {
isExpand = true;
widget.onStateChange?.call(true);
}
} else if (notification.extent < 0.00001) {
if (isExpand) {
isExpand = false;
widget.onStateChange?.call(false);
}
}
return true;
},
child: DraggableScrollableSheet(
initialChildSize: isCanClose && !isExpand ? 0 : widget.childHeightRatio,
minChildSize: isCanClose ? 0 : widget.childHeightRatio,
maxChildSize: widget.childHeightRatio,
expand: true,
snap: true,
controller: controller,
builder: (BuildContext context, ScrollController scrollController) {
return GestureDetector(
behavior: HitTestBehavior.translucent,
onVerticalDragDown: (details) {
verticalDistance = 0;
},
onVerticalDragUpdate: (details) {
verticalDistance += details.delta.dy;
_dragJumpTo(verticalDistance);
},
onVerticalDragEnd: (details) {
_dragEndChange();
},
child: widget.builder.call(context, scrollController),
);
},
),
);
}
}
import 'package:flutter/material.dart';
import 'package:special_equipment_flutter/common/color_const.dart';
import 'package:special_equipment_flutter/model/exam/examine_questions_bo.dart';
///单选、多选item布局
class ChoiceItem extends StatefulWidget {
final ExamQuestionOptionList option;
const ChoiceItem({Key? key, required this.option}) : super(key: key);
@override
_ChoiceItemState createState() => _ChoiceItemState();
}
class _ChoiceItemState extends State<ChoiceItem> {
@override
Widget build(BuildContext context) {
var options = widget.option;
return Container(
margin: const EdgeInsets.fromLTRB(15, 10, 15, 10),
child: Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Container(
height: 30,
width: 30,
margin: const EdgeInsets.fromLTRB(0, 0, 15, 0),
decoration: BoxDecoration(
///设置当前选中选项圆圈背景为蓝色、未选中选项圆圈背景为白色
color:
options.isSelected! ? ColorConst.themeBgColor : Colors.white,
///设置圆圈为蓝色
border: Border.all(
color: options.isSelected!
? ColorConst.themeBgColor
: ColorConst.themeBgColor),
borderRadius: const BorderRadius.all(Radius.circular(90)),
),
child: Center(
///设置选项A、B、C、D
child: Text(options.options!,
style: TextStyle(
///设置当前选中选项字母为白色、未选中选项字母为蓝色
color: options.isSelected!
? Colors.white
: ColorConst.themeBgColor,
//fontWeight: FontWeight.bold,
fontSize: 16.0)),
),
),
Flexible(
child: Text(
options.isAcquiesceSelected!
? '${options.content!}.'
: options.content!,
style: const TextStyle(fontSize: 14),
),
),
],
),
);
}
}
// import 'package:flutter/material.dart';
// import 'package:special_equipment_flutter/common/color_const.dart';
// import 'package:special_equipment_flutter/model/exam/examine_questions_bo.dart';
// import 'package:special_equipment_flutter/model/exam/test_question_bo.dart';
// import 'package:special_equipment_flutter/ui/examine/exam/custom/choice_item.dart';
//
// ///多选题
// class MultipleOption extends StatefulWidget {
// final ExamQuestionList question;
//
// const MultipleOption({Key? key, required this.question}) : super(key: key);
//
// @override
// _MultipleOptionState createState() => _MultipleOptionState();
// }
//
// class _MultipleOptionState extends State<MultipleOption> {
// @override
// Widget build(BuildContext context) {
// var question = widget.question;
// return ListView.builder(
// scrollDirection: Axis.vertical,
// shrinkWrap: true,
// itemCount: widget.question.examQuestionOptionList?.length,
// itemBuilder: (BuildContext context, int index) {
// var options = question.examQuestionOptionList![index];
// return InkWell(
// splashColor: ColorConst.themeBgColor,
// onTap: () {
// setState(() {
// options.isSelected!
// ? options.isSelected = false
// : options.isSelected = true;
// });
// },
// child: ChoiceItem(option: question.examQuestionOptionList![index]),
// );
// },
// );
// }
// }
import 'package:flutter/material.dart';
import 'package:special_equipment_flutter/common/color_const.dart';
import 'package:special_equipment_flutter/model/exam/examine_questions_bo.dart';
import 'package:special_equipment_flutter/ui/examine/exam/custom/choice_item.dart';
///单选(单选题、判断题)
class SingleOption extends StatefulWidget {
final ExamQuestionList question;
final PageController pageController;
final int index;
const SingleOption(
{Key? key,
required this.question,
required this.pageController,
required this.index})
: super(key: key);
@override
_SingleOptionState createState() => _SingleOptionState();
}
class _SingleOptionState extends State<SingleOption> {
@override
Widget build(BuildContext context) {
var question = widget.question;
return ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: widget.question.examQuestionOptionList?.length,
itemBuilder: (BuildContext context, int index) {
var options = question.examQuestionOptionList![index];
return InkWell(
splashColor: ColorConst.themeBgColor,
onTap: () {
setState(() {
//将其他选项全部置为false
question.examQuestionOptionList!
.forEach((element) => element.isSelected = false);
//将当前选项置为true
options.isSelected = true;
question.result = options.options;
//延时1秒
Future.delayed(const Duration(milliseconds: 500), () {
widget.pageController.jumpToPage(widget.index + 1);
});
});
},
child: ChoiceItem(option: options),
);
},
);
}
}
import 'package:flutter/material.dart';
///考核历史页面
class ExamHistoryPage extends StatefulWidget {
const ExamHistoryPage({super.key});
@override
State<ExamHistoryPage> createState() => _ExamHistoryPageState();
}
class _ExamHistoryPageState extends State<ExamHistoryPage> {
@override
Widget build(BuildContext context) {
return Container();
}
}
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sliding_up_panel/sliding_up_panel.dart';
import 'package:special_equipment_flutter/common/color_const.dart';
import 'package:special_equipment_flutter/dio/http_utils.dart';
import 'package:special_equipment_flutter/model/exam/exam_result_bo.dart';
import 'package:special_equipment_flutter/model/exam/examine_person_bo.dart';
import 'package:special_equipment_flutter/model/exam/examine_questions_bo.dart';
import 'package:special_equipment_flutter/model/exam/show_answer_bo.dart';
import 'package:special_equipment_flutter/ui/examine/exam/custom/choice_item.dart';
import 'package:special_equipment_flutter/utils/toast_utils.dart';
import 'package:special_equipment_flutter/widgets/app_bar/custom_app_bar_back.dart';
import 'package:special_equipment_flutter/widgets/custom_button.dart';
import '../../../common/route_string.dart';
import 'custom/bottom_sheet.dart';
///考核答题页面
class ExamPage extends StatefulWidget {
var arguments = Get.arguments;
ExamPage({super.key});
@override
createState() {
return ExamPageState();
}
}
class ExamPageState extends State<ExamPage> with TickerProviderStateMixin {
final GlobalKey<DragBottomSheetWidgetState> bottomSheetKey =
GlobalKey<DragBottomSheetWidgetState>();
bool isExpand = false;
final _pageController = PageController(initialPage: 0);
late int _currentPage = 0;
PanelController? controller = PanelController();
late final AnimationController _controller;
late final Animation<double> _animation;
Data? examineQuestionsBo; //题库总数据
List<ExamQuestionList>? examQuestionList = []; //题库列表数据
List<ExamQuestionList>? examQuestionDList = []; //选择题
List<ExamQuestionList>? examQuestionPList = []; //判断题
DataExaminePerson? mExaminePersonBo;
String? showAnswerData = '2';
@override
void initState() {
super.initState();
mExaminePersonBo = widget.arguments['mExaminePersonBo'];
getShowAnswer();
getQuestionsData();
_controller = AnimationController(
duration: const Duration(seconds: 2),
vsync: this,
)..forward();
_animation = CurvedAnimation(
parent: _controller,
curve: Curves.bounceOut,
);
}
///获取考核试卷
void getQuestionsData() {
// HttpUtils.getExamineQuestions(context, '1', '2024-05-17',
// '779d6023cd4148b49288eb3e3616a7e3', '2', 10, 10)
HttpUtils.getExamineQuestions(
context,
mExaminePersonBo!.inspectors!.id,
mExaminePersonBo!.examDate,
mExaminePersonBo!.type!.id,
mExaminePersonBo!.xzNum! + mExaminePersonBo!.pdNum!,
mExaminePersonBo!.xzNum,
mExaminePersonBo!.pdNum,
mExaminePersonBo!.id)
.then((value) {
ExamineQuestionsBo listBo = value;
if (mounted) {
setState(() {
examineQuestionsBo = listBo.data;
examQuestionList = examineQuestionsBo!.examQuestionList;
///答题卡标题、序号
for (var i = 0; i < examQuestionList!.length; i++) {
///单选
if (examQuestionList![i].questionType == '1') {
examQuestionDList!.add(examQuestionList![i]);
} else {
examQuestionPList!.add(examQuestionList![i]);
}
}
});
}
});
}
///考核 是否显示答案
void getShowAnswer() {
HttpUtils.getShowAnswer(context).then((value) {
ShowAnswerBo mShowAnswerBo = value;
if (mounted) {
setState(() {
showAnswerData = mShowAnswerBo.data;
});
}
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey[100],
appBar: AppBarCustom(
leading: IconButton(
iconSize: 20,
icon: const Icon(Icons.arrow_back_ios),
color: ColorConst.whiteColor,
onPressed: () {
Get.dialog(AlertDialog(
title: const Text("温馨提示"),
content: const Text("您确定要结束当前考试?"),
actionsPadding: const EdgeInsets.only(
left: 0, top: 0, bottom: 10, right: 20),
contentPadding: const EdgeInsets.only(
left: 20, top: 0, bottom: 10, right: 20),
titlePadding: const EdgeInsets.only(
left: 20, top: 20, bottom: 10, right: 20),
shape: const RoundedRectangleBorder(
// 这里设置shape属性
borderRadius: BorderRadius.all(Radius.circular(10.0))),
actions: <Widget>[
TextButton(
child: const Text("取消", style: TextStyle(fontSize: 16)),
onPressed: () {
Get.back();
},
),
TextButton(
child: const Text("确定", style: TextStyle(fontSize: 16)),
onPressed: () {
Get.back();
Get.back();
},
),
],
));
},
///这里设置了按钮的内边距为零,可以消除默认的16像素间距
padding: EdgeInsets.zero,
),
text: '考核',
height: 50,
),
///答题卡抽屉
body: SlidingUpPanel(
backdropEnabled: true,
controller: controller,
minHeight: 50,
maxHeight: 510,
///答题卡区
panel: Container(
color: Colors.grey[200],
child: Stack(
alignment: Alignment.bottomCenter,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
InkWell(
onTap: () {
setState(() {
if (controller!.isPanelClosed) {
controller!.open();
} else {
controller!.close();
}
});
},
child: Container(
padding: const EdgeInsets.only(top: 7, bottom: 6),
// color: Colors.grey[300],
child: Stack(
alignment: Alignment.centerRight,
children: [
Column(
children: [
Image.asset(
'assets/examine/answer_sheet_black_icon.png',
width: 20,
height: 20,
),
Container(
margin: const EdgeInsets.only(top: 2)),
const Text(
'答题卡',
style: TextStyle(fontSize: 12),
)
],
),
Container(
margin: const EdgeInsets.only(right: 15),
child: Text.rich(
softWrap: true,
TextSpan(children: [
TextSpan(
text: "${_currentPage + 1}",
style: const TextStyle(
fontSize: 20,
color: ColorConst.blueColor,
fontWeight: FontWeight.bold)),
TextSpan(
text: " /${examQuestionList!.length}",
style: const TextStyle(
fontSize: 15,
color: Colors.black87)),
])),
),
],
),
),
),
Container(
height: 380,
margin:
const EdgeInsets.only(top: 0, left: 10, right: 10),
padding: const EdgeInsets.all(10),
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(5)),
),
child: CustomScrollView(
primary: false,
shrinkWrap: true,
slivers: <Widget>[
SliverToBoxAdapter(
child: Column(
children: [
if (examQuestionDList!.isNotEmpty) ...{
buildSliverToBoxAdapter('选择题'),
buildAnswerSheetList(examQuestionDList),
},
if (examQuestionPList!.isNotEmpty) ...{
buildSliverToBoxAdapter('判断题'),
buildAnswerSheetList(examQuestionPList),
}
],
))
],
),
),
]),
buildSubmit()
],
),
),
///内容区
body: Column(children: [buildExpanded()]),
));
}
Container buildSliverToBoxAdapter(var text) {
return Container(
padding: const EdgeInsets.only(left: 0, top: 5, bottom: 0),
alignment: Alignment.centerLeft,
child: Text(
text,
style: const TextStyle(fontSize: 16, color: Colors.black),
),
);
}
///答题卡
Widget buildAnswerSheetList(List<ExamQuestionList>? examQuestionList) {
return GridView.builder(
shrinkWrap: true,
padding: const EdgeInsets.only(left: 10, top: 10, bottom: 10),
physics: const NeverScrollableScrollPhysics(),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 6,
crossAxisSpacing: 13,
mainAxisSpacing: 10,
childAspectRatio: 1, //子项的宽高比,值越大高度越高
),
itemCount: examQuestionList!.length,
itemBuilder: (context, index) {
return AnimatedBuilder(
animation: _animation,
builder: (context, child) {
return Transform.scale(
scale: _animation.value,
child: InkWell(
onTap: () {
_pageController.jumpToPage(examQuestionList[index].sort! - 1);
controller!.close();
},
child: Container(
height: 20,
width: 20,
decoration: BoxDecoration(
///设置当前选中选项圆圈背景为蓝色、未选中选项圆圈背景为白色
color: examQuestionList[index].result != null
? ColorConst.themeBgColor[700]
: Colors.white,
///设置圆圈为蓝色
border: Border.all(
color: examQuestionList[index].result != null
? ColorConst.themeBgColor
: ColorConst.greyD2Color),
borderRadius: const BorderRadius.all(Radius.circular(90)),
),
child: Center(
child: Text(examQuestionList[index].sort!.toString(),
style: TextStyle(
color: examQuestionList[index].result != null
? ColorConst.whiteColor
: ColorConst.dark9Color,
fontSize: 16.0)),
),
),
),
);
},
);
},
);
}
Expanded buildExpanded() {
return Expanded(
child: PageView.builder(
controller: _pageController,
itemCount: examQuestionList?.length,
itemBuilder: (BuildContext context, int index1) {
var questions = examQuestionList![index1];
return Column(
textDirection: TextDirection.ltr,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
///题干
questionStems(index1, questions),
///试题图片
// if (!StringUtils.strIsEmpty("${questions.image}")) ...[
// questionImage(context, questions)
// ],
// Visibility(child: questionImage(context, questions),visible:!StringUtils.strIsEmpty("${questions.image}")),
// SingleOption(
// question: questions,
// pageController: _pageController,
// index: index1,
// ),
ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: questions.examQuestionOptionList?.length,
itemBuilder: (BuildContext context, int index) {
var options = questions.examQuestionOptionList![index];
///showAnswerData==1 显示答案
if (showAnswerData == '1') {
if (questions.answer == options.options) {
options.isAcquiesceSelected = true;
}
}
return InkWell(
splashColor: ColorConst.themeBgColor,
onTap: () {
setState(() {
//将其他选项全部置为false
questions.examQuestionOptionList!
.forEach((element) => element.isSelected = false);
//将当前选项置为true
options.isSelected = true;
questions.result = options.options;
if (examQuestionList?.length == index1 + 1) {
controller!.open();
} else {
//延时1秒
Future.delayed(const Duration(milliseconds: 500), () {
_pageController.jumpToPage(index1 + 1);
});
}
});
},
child: ChoiceItem(option: options),
);
},
),
],
);
},
onPageChanged: (int index) {
setState(() {
_currentPage = index;
});
},
),
);
}
///题干
Container questionStems(int index, ExamQuestionList questions) {
return Container(
//设置内边距
padding: const EdgeInsets.only(top: 20, bottom: 10, left: 10, right: 10),
child: Stack(
children: [
Container(
width: 35,
height: 20,
margin: const EdgeInsets.fromLTRB(0, 2, 0, 0),
alignment: Alignment.center,
decoration: const BoxDecoration(
color: ColorConst.themeBgColor,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8),
topRight: Radius.circular(2),
bottomLeft: Radius.circular(2),
bottomRight: Radius.circular(8))),
child: Text(
questions.questionType == '1' ? '单选' : '判断',
style: const TextStyle(fontSize: 12, color: Colors.white),
),
),
Text("\t\t\t\t\t\t\t\t\t\t${index + 1}${questions.content}",
style: const TextStyle(
fontSize: 16, fontWeight: FontWeight.bold, height: 1.5)),
],
),
);
}
int noReplyNum = 0;
///交卷
Container buildSubmit() {
return Container(
margin: const EdgeInsets.only(top: 10, bottom: 0),
padding:
const EdgeInsets.only(left: 20, right: 20, top: 15, bottom: 15),
width: double.infinity,
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(5)),
),
child: GradientButton(
tapCallback: () {
noReplyNum = 0;
for (var i = 0; i < examQuestionList!.length; i++) {
if (examQuestionList![i].result == null) {
noReplyNum++;
}
}
Get.dialog(AlertDialog(
title: const Text("温馨提示"),
content: noReplyNum != 0
? /*Text("您还有 ${noReplyNum.toString()} 道题未作答\n您确定要提交考核试卷吗?")*/
Text.rich(
softWrap: true,
TextSpan(children: [
const TextSpan(
text: '您还有 ',
style: TextStyle(color: Colors.black),
),
TextSpan(
text: noReplyNum.toString(),
style: const TextStyle(
color: Colors.red,
fontWeight: FontWeight.bold,
fontSize: 25),
),
const TextSpan(
text: ' 道题未作答\n您确定要提交考核试卷吗?',
style: TextStyle(color: Colors.black),
),
]))
: const Text.rich(
softWrap: true,
TextSpan(children: [
TextSpan(
text: '试题已全部作答完成\n',
style: TextStyle(
color: Colors.green,
fontWeight: FontWeight.bold,
fontSize: 18),
),
TextSpan(
text: '您确定要提交考核试卷吗?',
style: TextStyle(color: Colors.black),
),
])),
actionsPadding: const EdgeInsets.only(
left: 0, top: 0, bottom: 10, right: 20),
contentPadding: const EdgeInsets.only(
left: 20, top: 0, bottom: 10, right: 20),
titlePadding: const EdgeInsets.only(
left: 20, top: 20, bottom: 10, right: 20),
shape: const RoundedRectangleBorder(
// 这里设置shape属性
borderRadius: BorderRadius.all(Radius.circular(10.0))),
actions: <Widget>[
TextButton(
child: const Text("取消", style: TextStyle(fontSize: 16)),
onPressed: () {
Get.back();
},
),
TextButton(
child: const Text("确定", style: TextStyle(fontSize: 16)),
onPressed: () {
//关闭弹窗
Get.back();
// printLog(
// "《考核-交卷》提交json数据----->${json.encode(examineQuestionsBo)}");
HttpUtils.getExamSubmit(context, examineQuestionsBo)
.then((value) {
ExamResultBo examResultBo = value;
if (mounted) {
setState(() {
var examResultDataBo = examResultBo.data;
ToastUtils.showCenter('试卷提交完成');
Get.offNamed(RouteString.EXAM_RESULT_PAGE,
arguments: {
'examResultDataBo': examResultDataBo
})?.then((value) {
if (value != null && value) {
//关闭当前页面
Get.back();
}
});
});
}
});
},
),
],
));
},
width: 300,
height: 40,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(10),
topRight: Radius.circular(20),
bottomLeft: Radius.circular(20),
bottomRight: Radius.circular(10)),
disable: false,
colors: const [ColorConst.blueColor, ColorConst.blue1Color],
child: const Text(
"交卷",
style: TextStyle(fontSize: 14, color: ColorConst.whiteColor),
)));
}
}
// import 'dart:convert';
//
// import 'package:flutter/material.dart';
// import 'package:get/get.dart';
// import 'package:sliding_up_panel/sliding_up_panel.dart';
// import 'package:special_equipment_flutter/common/color_const.dart';
// import 'package:special_equipment_flutter/dio/http_utils.dart';
// import 'package:special_equipment_flutter/model/exam/answer_sheet_bo.dart';
// import 'package:special_equipment_flutter/model/exam/exam_result_bo.dart';
// import 'package:special_equipment_flutter/model/exam/examine_questions_bo.dart';
// import 'package:special_equipment_flutter/ui/examine/exam/custom/choice_item.dart';
// import 'package:special_equipment_flutter/utils/log_util.dart';
// import 'package:special_equipment_flutter/utils/string_utils.dart';
// import 'package:special_equipment_flutter/utils/toast_utils.dart';
// import 'package:special_equipment_flutter/widgets/app_bar/custom_app_bar_back.dart';
// import 'package:special_equipment_flutter/widgets/custom_button.dart';
//
// import '../../../common/route_string.dart';
// import 'custom/bottom_sheet.dart';
// import 'custom/single_option.dart';
//
// ///考核答题页面
// class ExamPage extends StatefulWidget {
// const ExamPage({super.key});
//
// @override
// createState() {
// return ExamPageState();
// }
// }
//
// class ExamPageState extends State<ExamPage> with TickerProviderStateMixin {
// // late TestQuestion testQuestionModel;
//
// final GlobalKey<DragBottomSheetWidgetState> bottomSheetKey =
// GlobalKey<DragBottomSheetWidgetState>();
// bool isExpand = false;
// final _pageController = PageController(initialPage: 0);
// late int _currentPage = 0;
//
// PanelController? controller = PanelController();
// late final AnimationController _controller;
// late final Animation<double> _animation;
// Data? examineQuestionsBo;
// List<ExamQuestionList>? examQuestionList = [];
// AnswerSheetBo answerSheet1Bo = AnswerSheetBo();
// AnswerSheetBo answerSheet2Bo = AnswerSheetBo();
// List<AnswerSheetBo>? answerSheetBoList = [];
// List<ExamQuestionList>? examQuestionDList = [];
// List<ExamQuestionList>? examQuestionPList = [];
//
// @override
// void initState() {
// super.initState();
// getQuestionsData();
// // testQuestionModel = TestQuestion.fromJson(testQuestionJson);
// _controller = AnimationController(
// duration: const Duration(seconds: 2),
// vsync: this,
// )..forward();
// _animation = CurvedAnimation(
// parent: _controller,
// curve: Curves.bounceOut,
// );
// }
//
// ///获取考核试卷
// void getQuestionsData() {
// HttpUtils.getExamineQuestions(
// context, '1', '2024-05-17', 'de35ded54b064a3daf63886709482b78', '2')
// .then((value) {
// ExamineQuestionsBo listBo = value;
// if (mounted) {
// setState(() {
// examineQuestionsBo = listBo.data;
// examQuestionList = examineQuestionsBo!.examQuestionList;
//
// // answerSheet1Bo.name = '单选题';
// // answerSheet2Bo.name = '判断题';
// // List<SheetOption>? sheetOptionList1 = [];
// // List<SheetOption>? sheetOptionList2 = [];
//
// ///答题卡标题、序号
// for (var i = 0; i < examQuestionList!.length; i++) {
// ///单选
// if (examQuestionList![i].questionType == '1') {
// // SheetOption sheetOption = SheetOption();
// // sheetOption.num = i + 1;
// // sheetOptionList1.add(sheetOption);
// // answerSheet1Bo.sheetOption = sheetOptionList1;
// examQuestionDList!.add(examQuestionList![i]);
// } else {
// // SheetOption sheetOption = SheetOption();
// // sheetOption.num = i + 1;
// // sheetOptionList2.add(sheetOption);
// // answerSheet2Bo.sheetOption = sheetOptionList2;
// examQuestionPList!.add(examQuestionList![i]);
// }
// }
// // answerSheetBoList!.add(answerSheet1Bo);
// // answerSheetBoList!.add(answerSheet2Bo);
// });
// }
// });
// }
//
// @override
// Widget build(BuildContext context) {
// return Scaffold(
// backgroundColor: Colors.grey[100],
// appBar: AppBarCustom(
// leading: IconButton(
// iconSize: 20,
// icon: const Icon(Icons.arrow_back_ios),
// color: ColorConst.whiteColor,
// onPressed: () {
// Get.dialog(AlertDialog(
// title: const Text("温馨提示"),
// content: const Text("您确定要结束当前考试?"),
// actionsPadding: const EdgeInsets.only(
// left: 0, top: 0, bottom: 10, right: 20),
// contentPadding: const EdgeInsets.only(
// left: 20, top: 0, bottom: 10, right: 20),
// titlePadding: const EdgeInsets.only(
// left: 20, top: 20, bottom: 10, right: 20),
// shape: const RoundedRectangleBorder(
// // 这里设置shape属性
// borderRadius: BorderRadius.all(Radius.circular(10.0))),
// actions: <Widget>[
// TextButton(
// child: const Text("取消", style: TextStyle(fontSize: 16)),
// onPressed: () {
// Get.back();
// },
// ),
// TextButton(
// child: const Text("确定", style: TextStyle(fontSize: 16)),
// onPressed: () {
// Get.back(result: true);
// },
// ),
// ],
// ));
// },
//
// ///这里设置了按钮的内边距为零,可以消除默认的16像素间距
// padding: EdgeInsets.zero,
// ),
// text: '考核',
// height: 50,
// ),
//
// ///答题卡抽屉
// body: SlidingUpPanel(
// backdropEnabled: true,
// controller: controller,
// minHeight: 50,
// maxHeight: 510,
//
// ///答题卡区
// panel: Container(
// color: Colors.grey[200],
// child: Stack(
// alignment: Alignment.bottomCenter,
// children: [
// Column(
// crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// InkWell(
// onTap: () {
// setState(() {
// if (controller!.isPanelClosed) {
// controller!.open();
// } else {
// controller!.close();
// }
// });
// },
// child: Container(
// padding: const EdgeInsets.only(top: 7, bottom: 6),
// // color: Colors.grey[300],
// child: Stack(
// alignment: Alignment.centerRight,
// children: [
// Column(
// children: [
// Image.asset(
// 'assets/examine/answer_sheet_black_icon.png',
// width: 20,
// height: 20,
// ),
// Container(
// margin: const EdgeInsets.only(top: 2)),
// const Text(
// '答题卡',
// style: TextStyle(fontSize: 12),
// )
// ],
// ),
// Container(
// margin: const EdgeInsets.only(right: 15),
// child: Text.rich(
// softWrap: true,
// TextSpan(children: [
// TextSpan(
// text: "${_currentPage + 1}",
// style: const TextStyle(
// fontSize: 20,
// color: ColorConst.blueColor,
// fontWeight: FontWeight.bold)),
// TextSpan(
// text: " /${examQuestionList!.length}",
// style: const TextStyle(
// fontSize: 15,
// color: Colors.black87)),
// ])),
// ),
// ],
// ),
// ),
// ),
// Container(
// height: 380,
// margin:
// const EdgeInsets.only(top: 0, left: 10, right: 10),
// padding: const EdgeInsets.all(10),
// decoration: const BoxDecoration(
// color: Colors.white,
// borderRadius: BorderRadius.all(Radius.circular(5)),
// ),
// child: CustomScrollView(
// primary: false,
// shrinkWrap: true,
// slivers: <Widget>[
// SliverToBoxAdapter(child: buildColumn())
// ],
// ),
// ),
// ]),
// buildSubmit()
// ],
// ),
// ),
//
// ///内容区
// body: Column(children: [buildExpanded()]),
// ));
// }
//
// Column buildColumn() {
// return Column(
// children: [
// if (examQuestionDList!.isNotEmpty) ...{
// buildSliverToBoxAdapter2('选择题'),
// buildAnswerSheetList2(examQuestionDList),
// },
// if (examQuestionDList!.isNotEmpty) ...{
// buildSliverToBoxAdapter2('判断题'),
// buildAnswerSheetList2(examQuestionPList),
// }
// ],
// );
// }
//
// ListView buildListView() {
// return ListView.builder(
// shrinkWrap: true,
// physics: const NeverScrollableScrollPhysics(),
// padding: const EdgeInsets.only(top: 0, left: 0, right: 10, bottom: 0),
// itemCount: answerSheetBoList!.length,
// itemBuilder: (BuildContext context, int index) {
// ///检查项item内容
// return Column(
// children: [
// buildSliverToBoxAdapter(answerSheetBoList![index]),
// buildAnswerSheetList(answerSheetBoList![index]),
// ],
// );
// },
// );
// }
//
// ///答题卡
// Widget buildAnswerSheetList(AnswerSheetBo answerSheetBo) {
// return GridView.builder(
// shrinkWrap: true,
// padding: const EdgeInsets.only(left: 10, top: 10, bottom: 10),
// physics: const NeverScrollableScrollPhysics(),
// gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
// crossAxisCount: 6,
// crossAxisSpacing: 13,
// mainAxisSpacing: 10,
// childAspectRatio: 1, //子项的宽高比,值越大高度越高
// ),
// itemCount: answerSheetBo.sheetOption!.length,
// itemBuilder: (context, index) {
// return AnimatedBuilder(
// animation: _animation,
// builder: (context, child) {
// return Transform.scale(
// scale: _animation.value,
// child: InkWell(
// onTap: () {
// _pageController
// .jumpToPage(answerSheetBo.sheetOption![index].num! - 1);
// controller!.close();
// },
// child: Container(
// height: 20,
// width: 20,
// decoration: BoxDecoration(
// ///设置当前选中选项圆圈背景为蓝色、未选中选项圆圈背景为白色
// color: answerSheetBo.sheetOption![index].isSelect == true
// ? ColorConst.themeBgColor[700]
// : Colors.white,
//
// ///设置圆圈为蓝色
// border: Border.all(
// color:
// answerSheetBo.sheetOption![index].isSelect == true
// ? ColorConst.themeBgColor
// : ColorConst.greyD2Color),
// borderRadius: const BorderRadius.all(Radius.circular(90)),
// ),
// child: Center(
// child: Text(
// answerSheetBo.sheetOption![index].num.toString(),
// style: TextStyle(
//
// ///设置当前选中选项字母为白色、未选中选项字母为蓝色
// color: answerSheetBo.sheetOption![index].isSelect ==
// true
// ? ColorConst.themeBgColor
// : ColorConst.dark9Color,
// fontSize: 16.0)),
// ),
// ),
// ),
// );
// },
// );
// },
// );
// }
//
// ///答题卡
// Widget buildAnswerSheetList2(List<ExamQuestionList>? examQuestionList) {
// return GridView.builder(
// shrinkWrap: true,
// padding: const EdgeInsets.only(left: 10, top: 10, bottom: 10),
// physics: const NeverScrollableScrollPhysics(),
// gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
// crossAxisCount: 6,
// crossAxisSpacing: 13,
// mainAxisSpacing: 10,
// childAspectRatio: 1, //子项的宽高比,值越大高度越高
// ),
// itemCount: examQuestionList!.length,
// itemBuilder: (context, index) {
// return AnimatedBuilder(
// animation: _animation,
// builder: (context, child) {
// return Transform.scale(
// scale: _animation.value,
// child: InkWell(
// onTap: () {
// _pageController.jumpToPage(index);
// controller!.close();
// },
// child: Container(
// height: 20,
// width: 20,
// decoration: BoxDecoration(
// ///设置当前选中选项圆圈背景为蓝色、未选中选项圆圈背景为白色
// color: examQuestionList[index].result! != ''
// ? ColorConst.themeBgColor[700]
// : Colors.white,
//
// ///设置圆圈为蓝色
// border: Border.all(
// color: examQuestionList[index].result! != ''
// ? ColorConst.themeBgColor
// : ColorConst.greyD2Color),
// borderRadius: const BorderRadius.all(Radius.circular(90)),
// ),
// child: Center(
// child: Text((index + 1).toString(),
// style: TextStyle(
//
// ///设置当前选中选项字母为白色、未选中选项字母为蓝色
// color: examQuestionList[index].result! != ''
// ? ColorConst.whiteColor
// : ColorConst.dark9Color,
// fontSize: 16.0)),
// ),
// ),
// ),
// );
// },
// );
// },
// );
// }
//
// Container buildSliverToBoxAdapter2(var text) {
// return Container(
// padding: const EdgeInsets.only(left: 0, top: 5, bottom: 0),
// alignment: Alignment.centerLeft,
// child: Text(
// text,
// style: const TextStyle(fontSize: 16, color: Colors.black),
// ),
// );
// }
//
// Container buildSliverToBoxAdapter(AnswerSheetBo answerSheetBo) {
// return Container(
// padding: const EdgeInsets.only(left: 0, top: 5, bottom: 0),
// alignment: Alignment.centerLeft,
// child: Text(
// answerSheetBo.name!,
// style: const TextStyle(fontSize: 16, color: Colors.black),
// ),
// );
// }
//
// Expanded buildExpanded() {
// return Expanded(
// child: PageView.builder(
// controller: _pageController,
// itemCount: examQuestionList?.length,
// itemBuilder: (BuildContext context, int index1) {
// var questions = examQuestionList![index1];
// return Column(
// textDirection: TextDirection.ltr,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// ///题干
// questionStems(index1, questions),
//
// ///试题图片
// // if (!StringUtils.strIsEmpty("${questions.image}")) ...[
// // questionImage(context, questions)
// // ],
//
// // Visibility(child: questionImage(context, questions),visible:!StringUtils.strIsEmpty("${questions.image}")),
//
// SingleOption(
// question: questions,
// pageController: _pageController,
// index: index1,
// )
// ],
// );
// },
// onPageChanged: (int index) {
// setState(() {
// _currentPage = index;
// });
// },
// ),
// );
// }
//
// ///题干
// Container questionStems(int index, ExamQuestionList questions) {
// return Container(
// //设置内边距
// padding: const EdgeInsets.only(top: 20, bottom: 10, left: 10, right: 10),
// child: Stack(
// children: [
// Container(
// width: 35,
// height: 20,
// margin: const EdgeInsets.fromLTRB(0, 2, 0, 0),
// alignment: Alignment.center,
// decoration: const BoxDecoration(
// color: ColorConst.themeBgColor,
// borderRadius: BorderRadius.only(
// topLeft: Radius.circular(8),
// topRight: Radius.circular(2),
// bottomLeft: Radius.circular(2),
// bottomRight: Radius.circular(8))),
// child: Text(
// questions.questionType == '1' ? '单选' : '判断',
// style: const TextStyle(fontSize: 12, color: Colors.white),
// ),
// ),
// Text("\t\t\t\t\t\t\t\t\t${index + 1}、${questions.content}",
// style:
// const TextStyle(fontSize: 16, fontWeight: FontWeight.bold)),
// ],
// ),
// );
// }
//
// ///交卷
// Container buildSubmit() {
// return Container(
// margin: const EdgeInsets.only(top: 10, bottom: 0),
// padding:
// const EdgeInsets.only(left: 20, right: 20, top: 15, bottom: 15),
// width: double.infinity,
// decoration: const BoxDecoration(
// color: Colors.white,
// borderRadius: BorderRadius.all(Radius.circular(5)),
// ),
// child: GradientButton(
// tapCallback: () {
// Get.dialog(AlertDialog(
// title: const Text("温馨提示"),
// content: const Text("您确定要提交考核试卷吗?"),
// actionsPadding: const EdgeInsets.only(
// left: 0, top: 0, bottom: 10, right: 20),
// contentPadding: const EdgeInsets.only(
// left: 20, top: 0, bottom: 10, right: 20),
// titlePadding: const EdgeInsets.only(
// left: 20, top: 20, bottom: 10, right: 20),
// shape: const RoundedRectangleBorder(
// // 这里设置shape属性
// borderRadius: BorderRadius.all(Radius.circular(10.0))),
// actions: <Widget>[
// TextButton(
// child: const Text("取消", style: TextStyle(fontSize: 16)),
// onPressed: () {
// Get.back();
// },
// ),
// TextButton(
// child: const Text("确定", style: TextStyle(fontSize: 16)),
// onPressed: () {
// printLog(
// "《考核-交卷》提交json数据----->${json.encode(examineQuestionsBo)}");
//
// HttpUtils.getExamSubmit(context, examineQuestionsBo)
// .then((value) {
// ExamResultBo examResultBo = value;
// if (mounted) {
// setState(() {
// // var taskDayList = examResultBo.taskDayList;
//
// ToastUtils.showCenter('试卷提交完成');
// Get.offAllNamed(
// RouteString.EXAM_RESULT_PAGE,
// // arguments: {
// // 'argsData': widget.args,
// // 'listBo': list(index)
// // }
// );
// });
// }
// });
// },
// ),
// ],
// ));
// },
// width: 300,
// height: 40,
// borderRadius: const BorderRadius.only(
// topLeft: Radius.circular(10),
// topRight: Radius.circular(20),
// bottomLeft: Radius.circular(20),
// bottomRight: Radius.circular(10)),
// disable: false,
// colors: const [ColorConst.blueColor, ColorConst.blue1Color],
// child: const Text(
// "交卷",
// style: TextStyle(fontSize: 14, color: ColorConst.whiteColor),
// )));
// }
// }
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:special_equipment_flutter/common/color_const.dart';
import 'package:special_equipment_flutter/common/route_string.dart';
import 'package:special_equipment_flutter/dio/http_utils.dart';
import 'package:special_equipment_flutter/model/exam/exam_result_bo.dart';
import 'package:special_equipment_flutter/model/exam/examine_person_bo.dart';
import 'package:special_equipment_flutter/utils/eventbus_utils.dart';
import 'package:special_equipment_flutter/utils/toast_utils.dart';
import 'package:special_equipment_flutter/widgets/app_bar/custom_app_bar_back.dart';
import 'package:special_equipment_flutter/widgets/custom_button.dart';
///考核结果页面
class ExamResultPage extends StatefulWidget {
var arguments = Get.arguments;
// Data2? examResultDataBo;
ExamResultPage({super.key});
// ExamResultPage({super.key, this.examResultDataBo});
@override
State<ExamResultPage> createState() => _ExamResultPageState();
}
class _ExamResultPageState extends State<ExamResultPage> {
ExamResultData? examResultDataBo;
@override
void initState() {
// TODO: implement initState
super.initState();
// examResultDataBo = widget.examResultDataBo;
examResultDataBo = widget.arguments['examResultDataBo'];
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey[100],
appBar: AppBarCustom(
text: '考核结果',
height: 50,
leading: IconButton(
iconSize: 20,
icon: const Icon(Icons.arrow_back_ios),
color: ColorConst.whiteColor,
onPressed: () {
Get.back();
},
///这里设置了按钮的内边距为零,可以消除默认的16像素间距
padding: EdgeInsets.zero,
),
),
body: Container(
height: 300,
width: double.infinity,
margin: const EdgeInsets.only(top: 15, left: 15, right: 15, bottom: 15),
padding: const EdgeInsets.all(10),
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(5)),
),
child: Column(
children: [
const SizedBox(height: 10),
const Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'—————— ',
style: TextStyle(color: ColorConst.grayf5Color),
),
Text('本次考核成绩'),
Text(
' ——————',
style: TextStyle(color: ColorConst.grayf5Color),
)
],
),
const SizedBox(height: 10),
Text(
examResultDataBo!.score!.round().toString(),
style: TextStyle(
color:
examResultDataBo!.score! < 90 ? Colors.red : Colors.green,
fontSize: 20,
fontWeight: FontWeight.bold),
),
const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (examResultDataBo!.adopt == '1') ...[
Image.asset(
'assets/examine/pass_icon.png',
width: 100,
height: 100,
),
] else ...[
Image.asset(
'assets/examine/no_pass_icon.png',
width: 100,
height: 100,
),
],
Container(
height: 100,
width: 1,
color: ColorConst.grayf5Color,
margin: const EdgeInsets.only(left: 20, right: 40)),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text.rich(
softWrap: true,
TextSpan(children: [
const TextSpan(
text: "答对 ",
style:
TextStyle(fontSize: 14, color: Colors.grey)),
TextSpan(
text: "${examResultDataBo!.correct.toString()}题",
style: const TextStyle(
fontSize: 14, color: Colors.black87)),
])),
const SizedBox(height: 20),
Text.rich(
softWrap: true,
TextSpan(children: [
const TextSpan(
text: "答错 ",
style:
TextStyle(fontSize: 14, color: Colors.grey)),
TextSpan(
text: "${examResultDataBo!.error.toString()}题",
style: const TextStyle(
fontSize: 14, color: Colors.black87)),
])),
const SizedBox(height: 20),
Text.rich(
softWrap: true,
TextSpan(children: [
const TextSpan(
text: "总题 ",
style:
TextStyle(fontSize: 14, color: Colors.grey)),
TextSpan(
text:
"${examResultDataBo!.questionNum.toString()}题",
style: const TextStyle(
fontSize: 14, color: Colors.black87)),
])),
],
)
],
),
const SizedBox(height: 40),
GradientButton(
tapCallback: () {
if (examResultDataBo!.adopt == '1') {
//发出通知
EventBusUtils.getInstance()?.fire("1");
Get.back(result: true);
} else {
Get.back(result: true);
getClickQuestionsPerson();
}
},
width: 300,
height: 40,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(10),
topRight: Radius.circular(20),
bottomLeft: Radius.circular(20),
bottomRight: Radius.circular(10)),
disable: false,
colors: const [ColorConst.blueColor, ColorConst.blue1Color],
child: Text(
examResultDataBo!.adopt == '1' ? "关闭" : '继续答题',
style: const TextStyle(
fontSize: 14, color: ColorConst.whiteColor),
))
],
),
),
);
}
ExaminePersonBo? mExaminePersonBo;
///获取考核试卷
void getClickQuestionsPerson() {
HttpUtils.getExaminePerson(context).then((value) {
mExaminePersonBo = value;
if (mounted) {
setState(() {
if (mExaminePersonBo!.success!) {
Get.toNamed(RouteString.EXAM_PAGE,
arguments: {'mExaminePersonBo': mExaminePersonBo!.data})
?.then((value) {});
} else {
ToastUtils.showCenter('您目前暂无考核内容');
}
});
}
});
}
}
import 'package:flutter/material.dart';
/// 底部弹出Widget
/// 1、支持手势下拉关闭
/// 2、支持动画弹出收起
/// 3、支持弹出无法关闭
class DragBottomSheetWidget extends StatefulWidget {
DragBottomSheetWidget({
required Key key,
required this.builder,
this.duration,
this.childHeightRatio = 0.5,
this.onStateChange,
}) : super(key: key);
Function(bool)? onStateChange;
final double childHeightRatio;
final Duration? duration;
final ScrollableWidgetBuilder builder;
@override
State<DragBottomSheetWidget> createState() => DragBottomSheetWidgetState();
}
class DragBottomSheetWidgetState extends State<DragBottomSheetWidget>
with TickerProviderStateMixin {
final controller = DraggableScrollableController();
//是否可以关闭
bool isCanClose = true;
//是否展开
bool isExpand = false;
double verticalDistance = 0;
@override
void initState() {
super.initState();
}
@override
void dispose() {
controller.dispose();
super.dispose();
}
Future show({bool isCanClose = true}) {
return controller
.animateTo(1,
duration: widget.duration ?? const Duration(milliseconds: 200),
curve: Curves.linear)
.then((value) {
if (!isCanClose) {
setState(() {
this.isCanClose = isCanClose;
});
}
});
}
void hide() {
controller.animateTo(
0,
duration: widget.duration ?? const Duration(milliseconds: 200),
curve: Curves.linear,
);
}
void _dragJumpTo(double y) {
var size = y / MediaQuery.of(context).size.height;
controller.jumpTo(widget.childHeightRatio - size);
}
void _dragEndChange() {
controller.size >= widget.childHeightRatio / 2
? controller.animateTo(
1,
duration: widget.duration ?? const Duration(milliseconds: 200),
curve: Curves.linear,
)
: hide();
}
@override
Widget build(BuildContext context) {
return NotificationListener<DraggableScrollableNotification>(
onNotification: (notification) {
if (notification.extent == widget.childHeightRatio) {
if (!isExpand) {
isExpand = true;
widget.onStateChange?.call(true);
}
} else if (notification.extent < 0.00001) {
if (isExpand) {
isExpand = false;
widget.onStateChange?.call(false);
}
}
return true;
},
child: DraggableScrollableSheet(
initialChildSize: isCanClose && !isExpand ? 0 : widget.childHeightRatio,
minChildSize: isCanClose ? 0 : widget.childHeightRatio,
maxChildSize: widget.childHeightRatio,
expand: true,
snap: true,
controller: controller,
builder: (BuildContext context, ScrollController scrollController) {
return GestureDetector(
behavior: HitTestBehavior.translucent,
onVerticalDragDown: (details) {
verticalDistance = 0;
},
onVerticalDragUpdate: (details) {
verticalDistance += details.delta.dy;
_dragJumpTo(verticalDistance);
},
onVerticalDragEnd: (details) {
_dragEndChange();
},
child: widget.builder.call(context, scrollController),
);
},
),
);
}
}
import 'package:flutter/material.dart';
import 'package:special_equipment_flutter/common/color_const.dart';
import 'package:special_equipment_flutter/model/exam/examine_questions_bo.dart';
import 'package:special_equipment_flutter/model/exam/test_questions_bo.dart';
///单选、多选item布局
class ChoiceItem extends StatefulWidget {
final ExamQuestionTestOptionList option;
const ChoiceItem({Key? key, required this.option}) : super(key: key);
@override
_ChoiceItemState createState() => _ChoiceItemState();
}
class _ChoiceItemState extends State<ChoiceItem> {
@override
Widget build(BuildContext context) {
var options = widget.option;
return Container(
margin: const EdgeInsets.fromLTRB(15, 10, 15, 10),
child: Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Container(
height: 30,
width: 30,
margin: const EdgeInsets.fromLTRB(0, 0, 15, 0),
decoration: BoxDecoration(
///设置当前选中选项圆圈背景为蓝色、未选中选项圆圈背景为白色
color: bgColors(options.flag!),
///设置圆圈为蓝色
border: Border.all(color: bgColors3(options.flag!)!),
borderRadius: const BorderRadius.all(Radius.circular(90)),
),
child: Center(
///设置选项A、B、C、D
child: Text(optionsStr(options.flag!, options.options!)!,
style: TextStyle(
///设置当前选中选项字母为白色、未选中选项字母为蓝色
color: bgColors2(options.flag!),
//fontWeight: FontWeight.bold,
fontSize: 16.0)),
),
),
Flexible(
child: Text(
options.content!,
style: const TextStyle(fontSize: 14),
),
),
],
),
);
}
String? optionsStr(String flag, String options) {
if (flag == "1") {
return '✓';
} else if (flag == "0") {
return '✗';
} else {
return options;
}
}
Color? bgColors(String flag) {
if (flag == "1") {
return ColorConst.themeBgColor;
} else if (flag == "0") {
return ColorConst.red1BgColor;
} else {
return Colors.white;
}
}
Color? bgColors2(String flag) {
if (flag == "1") {
return Colors.white;
} else if (flag == "0") {
return Colors.white;
} else {
return ColorConst.themeBgColor;
}
}
Color? bgColors3(String flag) {
if (flag == "1") {
return ColorConst.themeBgColor;
} else if (flag == "0") {
return ColorConst.red1BgColor;
} else {
return ColorConst.themeBgColor;
}
}
}
import 'package:flutter/material.dart';
import 'package:special_equipment_flutter/common/color_const.dart';
import 'package:special_equipment_flutter/model/exam/test_questions_bo.dart';
import 'package:special_equipment_flutter/ui/examine/test/custom/choice_item.dart';
///单选(单选题、判断题)
class SingleOption extends StatefulWidget {
final ExamQuestionTestList question;
final PageController pageController;
final int index;
const SingleOption(
{Key? key,
required this.question,
required this.pageController,
required this.index})
: super(key: key);
@override
_SingleOptionState createState() => _SingleOptionState();
}
class _SingleOptionState extends State<SingleOption> {
@override
Widget build(BuildContext context) {
var question = widget.question;
return ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: widget.question.examQuestionOptionList?.length,
itemBuilder: (BuildContext context, int index) {
var options = question.examQuestionOptionList![index];
return InkWell(
splashColor: ColorConst.themeBgColor,
onTap: () {
setState(() {
if (question.result == null) {
//将其他选项全部置为false
question.examQuestionOptionList!
.forEach((element) => element.flag = '-1');
// //将当前选项置为true
// options.isSelected = true;
if (question.answer == options.options) {
options.flag = '1';
} else {
options.flag = '0';
}
question.result = options.options;
//延时1秒
// Future.delayed(const Duration(milliseconds: 500), () {
// widget.pageController.jumpToPage(widget.index + 1);
// });
}
});
},
child: ChoiceItem(option: options),
);
},
);
}
}
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sliding_up_panel/sliding_up_panel.dart';
import 'package:special_equipment_flutter/common/color_const.dart';
import 'package:special_equipment_flutter/dio/http_utils.dart';
import 'package:special_equipment_flutter/model/exam/exam_result_bo.dart';
import 'package:special_equipment_flutter/model/exam/test_questions_bo.dart';
import 'package:special_equipment_flutter/model/exam/test_setting_bo.dart';
import 'package:special_equipment_flutter/ui/examine/test/custom/bottom_sheet.dart';
import 'package:special_equipment_flutter/ui/examine/test/custom/choice_item.dart';
import 'package:special_equipment_flutter/utils/toast_utils.dart';
import 'package:special_equipment_flutter/widgets/app_bar/custom_app_bar_back.dart';
import 'package:special_equipment_flutter/widgets/custom_button.dart';
import '../../../common/route_string.dart';
///考核答题页面
class TestPage extends StatefulWidget {
var arguments = Get.arguments;
TestPage({super.key});
@override
createState() {
return TestPageState();
}
}
class TestPageState extends State<TestPage> with TickerProviderStateMixin {
final GlobalKey<DragBottomSheetWidgetState> bottomSheetKey =
GlobalKey<DragBottomSheetWidgetState>();
bool isExpand = false;
final _pageController = PageController(initialPage: 0);
late int _currentPage = 0;
PanelController? controller = PanelController();
late final AnimationController _controller;
late final Animation<double> _animation;
DataTest? examineQuestionsBo; //题库总数据
List<ExamQuestionTestList>? examQuestionList = []; //题库列表数据
List<ExamQuestionTestList>? examQuestionDList = []; //选择题
List<ExamQuestionTestList>? examQuestionPList = []; //判断题
TestSubmitBo? mTestSubmitBo;
@override
void initState() {
super.initState();
mTestSubmitBo = widget.arguments['mTestSubmitBo'];
getQuestionsData();
_controller = AnimationController(
duration: const Duration(seconds: 2),
vsync: this,
)..forward();
_animation = CurvedAnimation(
parent: _controller,
curve: Curves.bounceOut,
);
}
///获取考核试卷
void getQuestionsData() {
HttpUtils.getTestQuestions(
context, mTestSubmitBo!.mEquiList!.id, "0", "0", "0")
.then((value) {
TestQuestionsBo listBo = value;
if (mounted) {
setState(() {
examineQuestionsBo = listBo.data;
examQuestionList = examineQuestionsBo!.examQuestionList;
///答题卡标题、序号
for (var i = 0; i < examQuestionList!.length; i++) {
///单选
if (examQuestionList![i].questionType == '1') {
examQuestionDList!.add(examQuestionList![i]);
} else {
examQuestionPList!.add(examQuestionList![i]);
}
}
});
}
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBarCustom(
leading: IconButton(
iconSize: 20,
icon: const Icon(Icons.arrow_back_ios),
color: ColorConst.whiteColor,
onPressed: () {
Get.dialog(AlertDialog(
title: const Text("温馨提示"),
content: const Text("您确定要结束当前练习吗?"),
actionsPadding: const EdgeInsets.only(
left: 0, top: 0, bottom: 10, right: 20),
contentPadding: const EdgeInsets.only(
left: 20, top: 0, bottom: 10, right: 20),
titlePadding: const EdgeInsets.only(
left: 20, top: 20, bottom: 10, right: 20),
shape: const RoundedRectangleBorder(
// 这里设置shape属性
borderRadius: BorderRadius.all(Radius.circular(10.0))),
actions: <Widget>[
TextButton(
child: const Text("取消", style: TextStyle(fontSize: 16)),
onPressed: () {
Get.back();
},
),
TextButton(
child: const Text("确定", style: TextStyle(fontSize: 16)),
onPressed: () {
Get.back();
Get.back();
},
),
],
));
},
///这里设置了按钮的内边距为零,可以消除默认的16像素间距
padding: EdgeInsets.zero,
),
text: '测试练习',
height: 50,
),
///答题卡抽屉
body: SlidingUpPanel(
backdropEnabled: true,
controller: controller,
minHeight: 50,
maxHeight: 510,
///答题卡区
panel: Container(
color: Colors.grey[200],
child: Stack(
alignment: Alignment.bottomCenter,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
InkWell(
onTap: () {
setState(() {
if (controller!.isPanelClosed) {
controller!.open();
} else {
controller!.close();
}
});
},
child: Container(
padding: const EdgeInsets.only(top: 7, bottom: 6),
// color: Colors.grey[300],
child: Stack(
alignment: Alignment.centerRight,
children: [
Column(
children: [
Image.asset(
'assets/examine/answer_sheet_black_icon.png',
width: 20,
height: 20,
),
Container(
margin: const EdgeInsets.only(top: 2)),
const Text(
'答题卡',
style: TextStyle(fontSize: 12),
)
],
),
Container(
margin: const EdgeInsets.only(right: 15),
child: Text.rich(
softWrap: true,
TextSpan(children: [
TextSpan(
text: "${_currentPage + 1}",
style: const TextStyle(
fontSize: 20,
color: ColorConst.blueColor,
fontWeight: FontWeight.bold)),
TextSpan(
text: " /${examQuestionList!.length}",
style: const TextStyle(
fontSize: 15,
color: Colors.black87)),
])),
),
],
),
),
),
Container(
height: 380,
margin:
const EdgeInsets.only(top: 0, left: 10, right: 10),
padding: const EdgeInsets.all(10),
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(5)),
),
child: CustomScrollView(
primary: false,
shrinkWrap: true,
slivers: <Widget>[
SliverToBoxAdapter(
child: Column(
children: [
if (examQuestionDList!.isNotEmpty) ...{
buildSliverToBoxAdapter('选择题'),
buildAnswerSheetList(examQuestionDList),
},
if (examQuestionPList!.isNotEmpty) ...{
buildSliverToBoxAdapter('判断题'),
buildAnswerSheetList(examQuestionPList),
}
],
))
],
),
),
]),
buildSubmit()
],
),
),
///内容区
body: Column(children: [buildExpanded()]),
));
}
Container buildSliverToBoxAdapter(var text) {
return Container(
padding: const EdgeInsets.only(left: 0, top: 5, bottom: 0),
alignment: Alignment.centerLeft,
child: Text(
text,
style: const TextStyle(fontSize: 16, color: Colors.black),
),
);
}
///答题卡
Widget buildAnswerSheetList(List<ExamQuestionTestList>? examQuestionList) {
return GridView.builder(
shrinkWrap: true,
padding: const EdgeInsets.only(left: 10, top: 10, bottom: 10),
physics: const NeverScrollableScrollPhysics(),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 6,
crossAxisSpacing: 13,
mainAxisSpacing: 10,
childAspectRatio: 1, //子项的宽高比,值越大高度越高
),
itemCount: examQuestionList!.length,
itemBuilder: (context, index) {
return AnimatedBuilder(
animation: _animation,
builder: (context, child) {
return Transform.scale(
scale: _animation.value,
child: InkWell(
onTap: () {
_pageController.jumpToPage(examQuestionList[index].sort! - 1);
controller!.close();
},
child: Container(
height: 20,
width: 20,
decoration: BoxDecoration(
///设置当前选中选项圆圈背景为蓝色、未选中选项圆圈背景为白色
color: bgColors(examQuestionList[index]),
///设置圆圈为蓝色
border:
Border.all(color: bgColors2(examQuestionList[index])!),
borderRadius: const BorderRadius.all(Radius.circular(90)),
),
child: Center(
child: Text(examQuestionList[index].sort!.toString(),
style: TextStyle(
color: examQuestionList[index].result != null
? ColorConst.whiteColor
: ColorConst.dark9Color,
fontSize: 16.0)),
),
),
),
);
},
);
},
);
}
Color? bgColors2(ExamQuestionTestList examQuestionTestList) {
if (examQuestionTestList.result != null) {
///回答的和答案相同
if (examQuestionTestList.result == examQuestionTestList.answer) {
return ColorConst.themeBgColor;
} else {
return ColorConst.red1BgColor;
}
} else {
///如果result为空的话,说明还没有选择
return ColorConst.greyD2Color;
}
}
Color? bgColors(ExamQuestionTestList examQuestionTestList) {
if (examQuestionTestList.result != null) {
///回答的和答案相同
if (examQuestionTestList.result == examQuestionTestList.answer) {
return ColorConst.themeBgColor;
} else {
return ColorConst.red1BgColor;
}
} else {
///如果result为空的话,说明还没有选择
return Colors.white;
}
}
Expanded buildExpanded() {
return Expanded(
child: PageView.builder(
controller: _pageController,
itemCount: examQuestionList?.length,
itemBuilder: (BuildContext context, int index1) {
var questions = examQuestionList![index1];
return Column(
textDirection: TextDirection.ltr,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
///题干
questionStems(index1, questions),
///试题图片
// if (!StringUtils.strIsEmpty("${questions.image}")) ...[
// questionImage(context, questions)
// ],
// Visibility(child: questionImage(context, questions),visible:!StringUtils.strIsEmpty("${questions.image}")),
// SingleOption(
// question: questions,
// pageController: _pageController,
// index: index1,
// ),
ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: questions.examQuestionOptionList?.length,
itemBuilder: (BuildContext context, int index) {
var options = questions.examQuestionOptionList![index];
return InkWell(
splashColor: questions.result == null
? ColorConst.themeBgColor
: Colors.transparent,
onTap: () {
///如果已选择,禁止重新选择
if (questions.result != null) {
return;
}
setState(() {
//将其他选项全部置为false
questions.examQuestionOptionList!
.forEach((element) => element.flag = '-1');
// //将当前选项置为true
// options.isSelected = true;
if (questions.answer == options.options) {
options.flag = '1';
} else {
options.flag = '0';
}
questions.result = options.options;
if (examQuestionList?.length == index1 + 1) {
controller!.open();
} else {
//延时1秒
Future.delayed(const Duration(milliseconds: 500), () {
_pageController.jumpToPage(index1 + 1);
});
}
});
},
child: ChoiceItem(option: options),
);
},
),
Visibility(
visible:
examQuestionList![index1].result != null ? true : false,
child: Container(
margin: const EdgeInsets.only(
top: 20, bottom: 0, left: 15, right: 15),
padding: const EdgeInsets.only(
left: 20, right: 20, top: 10, bottom: 10),
width: double.infinity,
decoration: const BoxDecoration(
color: ColorConst.greyF2Color,
borderRadius: BorderRadius.all(Radius.circular(5)),
),
child: Row(
children: [
const Text(
"答案 ",
style: TextStyle(fontSize: 16),
),
Text(
"${examQuestionList![index1].answer}",
style: const TextStyle(
color: ColorConst.greenColor, fontSize: 18),
)
],
),
),
)
],
);
},
onPageChanged: (int index) {
setState(() {
_currentPage = index;
});
},
),
);
}
///题干
Container questionStems(int index, ExamQuestionTestList questions) {
return Container(
//设置内边距
padding: const EdgeInsets.only(top: 20, bottom: 10, left: 10, right: 10),
child: Stack(
children: [
Container(
width: 35,
height: 20,
margin: const EdgeInsets.fromLTRB(0, 2, 0, 0),
alignment: Alignment.center,
decoration: const BoxDecoration(
color: ColorConst.themeBgColor,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8),
topRight: Radius.circular(2),
bottomLeft: Radius.circular(2),
bottomRight: Radius.circular(8))),
child: Text(
questions.questionType == '1' ? '单选' : '判断',
style: const TextStyle(fontSize: 12, color: Colors.white),
),
),
Text("\t\t\t\t\t\t\t\t\t\t${index + 1}${questions.content}",
style: const TextStyle(
fontSize: 16, fontWeight: FontWeight.bold, height: 1.5)),
],
),
);
}
///交卷
Container buildSubmit() {
return Container(
margin: const EdgeInsets.only(top: 10, bottom: 0),
padding:
const EdgeInsets.only(left: 20, right: 20, top: 15, bottom: 15),
width: double.infinity,
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(5)),
),
child: GradientButton(
tapCallback: () {
Get.dialog(AlertDialog(
title: const Text("温馨提示"),
content: const Text("您确定要结束当前练习吗?"),
actionsPadding: const EdgeInsets.only(
left: 0, top: 0, bottom: 10, right: 20),
contentPadding: const EdgeInsets.only(
left: 20, top: 0, bottom: 10, right: 20),
titlePadding: const EdgeInsets.only(
left: 20, top: 20, bottom: 10, right: 20),
shape: const RoundedRectangleBorder(
// 这里设置shape属性
borderRadius: BorderRadius.all(Radius.circular(10.0))),
actions: <Widget>[
TextButton(
child: const Text("取消", style: TextStyle(fontSize: 16)),
onPressed: () {
Get.back();
},
),
TextButton(
child: const Text("确定", style: TextStyle(fontSize: 16)),
onPressed: () {
//关闭弹窗
Get.back();
Get.back();
// HttpUtils.getTestSubmit(context, examineQuestionsBo)
// .then((value) {
// ExamResultBo examResultBo = value;
// if (mounted) {
// setState(() {
// var testResultDataBo = examResultBo.data;
// ToastUtils.showCenter('试卷提交完成');
// Get.offNamed(RouteString.TEST_RESULT_PAGE,
// arguments: {
// 'testResultDataBo': testResultDataBo
// })?.then((value) {
// if (value != null && value) {
// //关闭当前页面
// Get.back();
// }
// });
// });
// }
// });
},
),
],
));
},
width: 300,
height: 40,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(10),
topRight: Radius.circular(20),
bottomLeft: Radius.circular(20),
bottomRight: Radius.circular(10)),
disable: false,
colors: const [ColorConst.blueColor, ColorConst.blue1Color],
child: const Text(
"关闭练习",
style: TextStyle(fontSize: 14, color: ColorConst.whiteColor),
)));
}
}
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:special_equipment_flutter/common/color_const.dart';
import 'package:special_equipment_flutter/model/exam/exam_result_bo.dart';
import 'package:special_equipment_flutter/widgets/app_bar/custom_app_bar_back.dart';
import 'package:special_equipment_flutter/widgets/custom_button.dart';
///测试结果页面
class TestResultPage extends StatefulWidget {
var arguments = Get.arguments;
TestResultPage({super.key});
@override
State<TestResultPage> createState() => _TestResultPageState();
}
class _TestResultPageState extends State<TestResultPage> {
ExamResultData? testResultDataBo;
@override
void initState() {
// TODO: implement initState
super.initState();
testResultDataBo = widget.arguments['testResultDataBo'];
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey[100],
appBar: AppBarCustom(
text: '测试练习结果',
height: 50,
leading: IconButton(
iconSize: 20,
icon: const Icon(Icons.arrow_back_ios),
color: ColorConst.whiteColor,
onPressed: () {
Get.back();
},
///这里设置了按钮的内边距为零,可以消除默认的16像素间距
padding: EdgeInsets.zero,
),
),
body: Container(
height: 300,
width: double.infinity,
margin: const EdgeInsets.only(top: 15, left: 15, right: 15, bottom: 15),
padding: const EdgeInsets.all(10),
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(5)),
),
child: Column(
children: [
const SizedBox(height: 10),
const Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'—————— ',
style: TextStyle(color: ColorConst.grayf5Color),
),
Text('本次考核成绩'),
Text(
' ——————',
style: TextStyle(color: ColorConst.grayf5Color),
)
],
),
const SizedBox(height: 10),
Text(
testResultDataBo!.score!.toString(),
style: TextStyle(
color:
testResultDataBo!.score! < 90 ? Colors.red : Colors.green,
fontSize: 20,
fontWeight: FontWeight.bold),
),
const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (testResultDataBo!.adopt == '1') ...[
Image.asset(
'assets/examine/pass_icon.png',
width: 100,
height: 100,
),
] else ...[
Image.asset(
'assets/examine/no_pass_icon.png',
width: 100,
height: 100,
),
],
Container(
height: 100,
width: 1,
color: ColorConst.grayf5Color,
margin: const EdgeInsets.only(left: 20, right: 40)),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text.rich(
softWrap: true,
TextSpan(children: [
const TextSpan(
text: "答对 ",
style:
TextStyle(fontSize: 14, color: Colors.grey)),
TextSpan(
text: "${testResultDataBo!.correct.toString()}题",
style: const TextStyle(
fontSize: 14, color: Colors.black87)),
])),
const SizedBox(height: 20),
Text.rich(
softWrap: true,
TextSpan(children: [
const TextSpan(
text: "答错 ",
style:
TextStyle(fontSize: 14, color: Colors.grey)),
TextSpan(
text: "${testResultDataBo!.error.toString()}题",
style: const TextStyle(
fontSize: 14, color: Colors.black87)),
])),
const SizedBox(height: 20),
Text.rich(
softWrap: true,
TextSpan(children: [
const TextSpan(
text: "总题 ",
style:
TextStyle(fontSize: 14, color: Colors.grey)),
TextSpan(
text:
"${testResultDataBo!.questionNum.toString()}题",
style: const TextStyle(
fontSize: 14, color: Colors.black87)),
])),
],
)
],
),
const SizedBox(height: 40),
GradientButton(
tapCallback: () {
Get.back();
},
width: 300,
height: 40,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(10),
topRight: Radius.circular(20),
bottomLeft: Radius.circular(20),
bottomRight: Radius.circular(10)),
disable: false,
colors: const [ColorConst.blueColor, ColorConst.blue1Color],
child: const Text(
"关闭",
style: TextStyle(fontSize: 14, color: ColorConst.whiteColor),
))
],
),
),
);
}
}
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:special_equipment_flutter/common/color_const.dart';
import 'package:special_equipment_flutter/common/route_string.dart';
import 'package:special_equipment_flutter/dio/http_utils.dart';
import 'package:special_equipment_flutter/model/exam/eq_question_bo.dart';
import 'package:special_equipment_flutter/model/exam/equipment_list_bo.dart';
import 'package:special_equipment_flutter/model/exam/test_setting_bo.dart';
import 'package:special_equipment_flutter/utils/storage_util.dart';
import 'package:special_equipment_flutter/utils/toast_utils.dart';
import 'package:special_equipment_flutter/widgets/custom_button.dart';
import 'package:special_equipment_flutter/widgets/custom_textfield.dart';
///测试练习设置
class TestSettingPage extends StatefulWidget {
TestSettingPage({super.key});
@override
State<TestSettingPage> createState() => _TestSettingPageState();
}
class _TestSettingPageState extends State<TestSettingPage> {
TextEditingController? equipmentText = TextEditingController();
FocusNode? equipmentFocusNode = FocusNode();
TextEditingController? singleText = TextEditingController();
FocusNode? singleZJFocusNode = FocusNode();
TextEditingController? judgmentText = TextEditingController();
FocusNode? judgmentZJFocusNode = FocusNode();
int allQuestions = 0;
EquiList? mEquiList;
DataEq? mDataEq;
@override
void initState() {
super.initState();
// getFindQuestionNum();
// getFindEqQuestionNum(true);
getEquipmentList();
}
///获取设备类型
void getEquipmentList() {
HttpUtils.getEquipmentList(context, StorageUtil.getInstance().getOfficeId())
.then((value) {
EquipmentListBo listBo = value;
if (mounted) {
setState(() {
try {
mEquiList = listBo.list![0];
equipmentText!.text = mEquiList!.name!;
} catch (e) {}
});
}
});
}
///获取题数
// void getFindQuestionNum() {
// HttpUtils.getFindQuestionNum(context).then((value) {
// FindQuestionNum listBo = value;
// if (mounted) {
// setState(() {
// DataNum dataNum = listBo.data!;
// singleText!.text = dataNum.aqyDx!.toString();
// judgmentText!.text = dataNum.aqyPd!.toString();
// allQuestions = dataNum.aqyDx! + dataNum.aqyPd!;
// });
// }
// });
// }
///根据设备类型获取总题数
// void getFindEqQuestionNum(isFirst) {
// HttpUtils.getFindEqQuestionNum(context, mEquiList!.id!).then((value) {
// EqQuestionBo listBo = value;
// if (mounted) {
// setState(() {
// mDataEq = listBo.data!;
// if (isFirst) {
// singleText!.text = mDataEq!.dxNum!.toString();
// judgmentText!.text = mDataEq!.pdNum!.toString();
// allQuestions = mDataEq!.dxNum! + mDataEq!.pdNum!;
// } else {
// if (int.parse(singleText!.text) > mDataEq!.dxNum!) {
// singleText!.text = mDataEq!.dxNum!.toString();
// allQuestions = (singleText!.text.isNotEmpty
// ? int.parse(singleText!.text)
// : 0) +
// (judgmentText!.text.isNotEmpty
// ? int.parse(judgmentText!.text)
// : 0);
// }
// if (int.parse(judgmentText!.text) > mDataEq!.pdNum!) {
// judgmentText!.text = mDataEq!.pdNum!.toString();
// allQuestions = (singleText!.text.isNotEmpty
// ? int.parse(singleText!.text)
// : 0) +
// (judgmentText!.text.isNotEmpty
// ? int.parse(judgmentText!.text)
// : 0);
// }
// }
// });
// }
// });
// }
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey[100],
body: Stack(
children: [
Image.asset('assets/home/rigister_bg.png'),
Container(
height: 230,
margin:
const EdgeInsets.only(left: 15, top: 130, right: 15, bottom: 0),
decoration: const BoxDecoration(
color: ColorConst.whiteColor,
borderRadius: BorderRadius.all(Radius.circular(10)),
),
child: CustomScrollView(
primary: false,
shrinkWrap: true,
slivers: <Widget>[
SliverToBoxAdapter(
child: Column(
children: [
buildUnitInformation(),
buildSubmit()
// const SizedBox(height: 30)
],
),
),
],
),
),
buildTopTitle(context)
],
),
);
}
///单位信息
Container buildUnitInformation() {
return Container(
margin: const EdgeInsets.only(left: 10, top: 10, right: 10, bottom: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
const SizedBox(height: 10),
const Row(children: [
Icon(Icons.touch_app, color: ColorConst.orangeColor, size: 15),
Text('设备类型', style: TextStyle(fontSize: 14))
]),
const SizedBox(height: 5),
CustomTextField(
enabled: true,
readOnly: true,
hintText: '请选择设备类型',
controller: equipmentText,
focusNode: equipmentFocusNode,
onTop: () {
Get.toNamed(RouteString.EQUIPMENT_LIST_PAGE, arguments: {
'officeId': StorageUtil.getInstance().getOfficeId()
})?.then((map) {
if (map != null) {
mEquiList = map;
setState(() {
equipmentText!.text = mEquiList!.name!;
// getFindEqQuestionNum(false);
});
}
});
}),
const SizedBox(height: 20),
// const Row(children: [
// Icon(Icons.drive_file_rename_outline_rounded,
// color: ColorConst.orangeColor, size: 15),
// Text('设置题数', style: TextStyle(fontSize: 14))
// ]),
// const SizedBox(height: 10),
// Container(
// padding:
// const EdgeInsets.only(left: 5, top: 0, right: 5, bottom: 0),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Row(children: [
// const Text('单选题数', style: TextStyle(fontSize: 14)),
// SizedBox(
// width: 40,
// height: 30,
// child: TextFormField(
// textAlign: TextAlign.center,
// inputFormatters: [
// FilteringTextInputFormatter.digitsOnly,
// LengthLimitingTextInputFormatter(3),
// // 设置输入长度限制
// ],
// focusNode: singleZJFocusNode,
// controller: singleText,
// onChanged: (num) {
// setState(() {
// if (mDataEq != null &&
// int.parse(num) > mDataEq!.dxNum!) {
// ToastUtils.showCenter('题库只有${mDataEq!.dxNum}道单选题');
// setState(() {
// singleText!.text = mDataEq!.dxNum.toString();
// });
// }
// allQuestions = (singleText!.text.isNotEmpty
// ? int.parse(singleText!.text)
// : 0) +
// (judgmentText!.text.isNotEmpty
// ? int.parse(judgmentText!.text)
// : 0);
// });
// },
// ),
// )
// ]),
// Row(children: [
// const Text('判断题数', style: TextStyle(fontSize: 14)),
// SizedBox(
// width: 40,
// height: 30,
// child: TextFormField(
// textAlign: TextAlign.center,
// inputFormatters: [
// FilteringTextInputFormatter.digitsOnly,
// LengthLimitingTextInputFormatter(3),
// ],
// focusNode: judgmentZJFocusNode,
// controller: judgmentText,
// onChanged: (num) {
// setState(() {
// if (mDataEq != null &&
// int.parse(num) > mDataEq!.pdNum!) {
// ToastUtils.showCenter('题库只有${mDataEq!.pdNum}道判断题');
// setState(() {
// judgmentText!.text = mDataEq!.pdNum.toString();
// });
// }
// allQuestions = (judgmentText!.text.isNotEmpty
// ? int.parse(judgmentText!.text)
// : 0) +
// (singleText!.text.isNotEmpty
// ? int.parse(singleText!.text)
// : 0);
// });
// },
// ),
// )
// ]),
// Text('总题数: ${allQuestions.toString()}',
// style: const TextStyle(color: Colors.grey, fontSize: 14)),
// ],
// ),
// ),
],
),
);
}
Container buildTopTitle(BuildContext context) {
return Container(
margin: const EdgeInsets.only(top: 50),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
IconButton(
onPressed: () {
Navigator.of(context).pop();
},
icon: const Icon(Icons.arrow_back, color: Colors.white),
iconSize: 30,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Container(
margin: const EdgeInsets.only(top: 5),
child: const Text(
'测试练习设置',
style: TextStyle(
fontSize: 23,
color: Colors.white,
fontWeight: FontWeight.bold),
)),
Container(
height: 3,
width: 50,
alignment: Alignment.topLeft,
margin: const EdgeInsets.only(top: 3, bottom: 3),
decoration: const BoxDecoration(
color: Colors.white54,
borderRadius: BorderRadius.all(Radius.circular(5)),
)),
const Text(
'',
style: TextStyle(fontSize: 12, color: Colors.white),
),
],
),
],
),
);
}
///交卷
Container buildSubmit() {
return Container(
margin: const EdgeInsets.only(top: 40, bottom: 0),
padding: const EdgeInsets.only(left: 20, right: 20, top: 15, bottom: 0),
width: double.infinity,
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(5)),
),
child: GradientButton(
tapCallback: () {
if (equipmentText!.text.isEmpty) {
ToastUtils.showCenter('请选择设备类型');
return;
}
// if (allQuestions == 0) {
// ToastUtils.showCenter('总题数不能为 0');
// return;
// }
TestSubmitBo mTestSubmitBo = TestSubmitBo();
mTestSubmitBo.mEquiList = mEquiList;
// mTestSubmitBo.dxQuestionsNum =
// singleText!.text.isNotEmpty ? int.parse(singleText!.text) : 0;
// mTestSubmitBo.pdQuestionsNum = judgmentText!.text.isNotEmpty
// ? int.parse(judgmentText!.text)
// : 0;
Get.offNamed(RouteString.TEST_PAGE,
arguments: {'mTestSubmitBo': mTestSubmitBo})?.then((value) {
if (value != null && value) {}
});
},
width: 300,
height: 40,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(10),
topRight: Radius.circular(20),
bottomLeft: Radius.circular(20),
bottomRight: Radius.circular(10)),
disable: false,
colors: const [ColorConst.blueColor, ColorConst.blue1Color],
child: const Text(
"去练习",
style: TextStyle(fontSize: 14, color: ColorConst.whiteColor),
)));
}
}
...@@ -100,9 +100,7 @@ class EditTextState extends State<EditTextWidget> ...@@ -100,9 +100,7 @@ class EditTextState extends State<EditTextWidget>
}); });
phoneController.value = phoneController.value.copyWith( phoneController.value = phoneController.value.copyWith(
text: Api.IS_DEBUG text: Api.IS_DEBUG ? StorageUtil.getInstance().getUserName() : 'tyjcr');
? StorageUtil.getInstance().getUserName()
: '15201506331');
passController.value = passController.value =
passController.value.copyWith(text: Api.IS_DEBUG ? '' : 'Aa123456.'); passController.value.copyWith(text: Api.IS_DEBUG ? '' : 'Aa123456.');
super.initState(); super.initState();
......
// ignore_for_file: prefer_typing_uninitialized_variables, library_private_types_in_public_api, use_build_context_synchronously // ignore_for_file: prefer_typing_uninitialized_variables, library_private_types_in_public_api, use_build_context_synchronously
import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:event_bus/event_bus.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
...@@ -13,6 +15,8 @@ import 'package:special_equipment_flutter/dio/http_utils.dart'; ...@@ -13,6 +15,8 @@ import 'package:special_equipment_flutter/dio/http_utils.dart';
import 'package:special_equipment_flutter/model/check_update.dart'; import 'package:special_equipment_flutter/model/check_update.dart';
import 'package:special_equipment_flutter/model/count_bo.dart'; import 'package:special_equipment_flutter/model/count_bo.dart';
import 'package:special_equipment_flutter/model/echart_bo.dart'; import 'package:special_equipment_flutter/model/echart_bo.dart';
import 'package:special_equipment_flutter/model/exam/eventbus_push.dart';
import 'package:special_equipment_flutter/model/exam/examine_person_bo.dart';
import 'package:special_equipment_flutter/model/find_charge_list_bo.dart'; import 'package:special_equipment_flutter/model/find_charge_list_bo.dart';
import 'package:special_equipment_flutter/model/find_count_bo.dart'; import 'package:special_equipment_flutter/model/find_count_bo.dart';
import 'package:special_equipment_flutter/model/office_device.dart'; import 'package:special_equipment_flutter/model/office_device.dart';
...@@ -23,6 +27,7 @@ import 'package:special_equipment_flutter/ui/common/data.dart'; ...@@ -23,6 +27,7 @@ import 'package:special_equipment_flutter/ui/common/data.dart';
import 'package:special_equipment_flutter/ui/main/echart/home_echart_tabs.dart'; import 'package:special_equipment_flutter/ui/main/echart/home_echart_tabs.dart';
import 'package:special_equipment_flutter/ui/main/unit/equipment_personnel_table.dart'; import 'package:special_equipment_flutter/ui/main/unit/equipment_personnel_table.dart';
import 'package:special_equipment_flutter/ui/main/unit/unit_grid_list.dart'; import 'package:special_equipment_flutter/ui/main/unit/unit_grid_list.dart';
import 'package:special_equipment_flutter/utils/eventbus_utils.dart';
import 'package:special_equipment_flutter/utils/size_config.dart'; import 'package:special_equipment_flutter/utils/size_config.dart';
import 'package:special_equipment_flutter/utils/storage_util.dart'; import 'package:special_equipment_flutter/utils/storage_util.dart';
import 'package:special_equipment_flutter/utils/toast_utils.dart'; import 'package:special_equipment_flutter/utils/toast_utils.dart';
...@@ -50,7 +55,8 @@ class _HomePageState extends State<HomePage> ...@@ -50,7 +55,8 @@ class _HomePageState extends State<HomePage>
var unitList = []; var unitList = [];
List<HomeMenuItem> checkItemList = [], List<HomeMenuItem> checkItemList = [],
checkItemRiskList = [], checkItemRiskList = [],
checkItemSettingsList = []; checkItemSettingsList = [],
checkItemExaminationList = [];
var unitId = '1', var unitId = '1',
unitName = '使用单位', unitName = '使用单位',
officeName, officeName,
...@@ -72,9 +78,14 @@ class _HomePageState extends State<HomePage> ...@@ -72,9 +78,14 @@ class _HomePageState extends State<HomePage>
List<OfficeDtoLists>? deviceList = []; List<OfficeDtoLists>? deviceList = [];
FindChargeListBo? chargeBo = FindChargeListBo(); FindChargeListBo? chargeBo = FindChargeListBo();
List<CountData>? findCountList = []; List<CountData>? findCountList = [];
ExaminePersonBo? mExaminePersonBo;
//声明,后面需要销毁
StreamSubscription? event;
@override @override
void initState() { void initState() {
getQuestionsPerson();
super.initState(); super.initState();
///获取版本 ///获取版本
...@@ -100,47 +111,9 @@ class _HomePageState extends State<HomePage> ...@@ -100,47 +111,9 @@ class _HomePageState extends State<HomePage>
StorageUtil.getInstance().set(SpKeys.UNIT_STATUS, unitId); StorageUtil.getInstance().set(SpKeys.UNIT_STATUS, unitId);
} }
// _requestPermission(); // _requestPermission();
///获取日管控、周排查、月调度数量 ///获取日管控、周排查、月调度数量
getCount(); getCount();
checkItemList.add(HomeMenuItem( getGirdviewData();
image: 'assets/home/day_control_white_icon.png',
name: '日管控',
isContains: roleNames.contains(StandingConfig.SAFETY_OFFICER)));
checkItemList.add(HomeMenuItem(
image: 'assets/home/weekly_survey_white_icon.png',
name: '周排查',
isContains: roleNames.contains(StandingConfig.SAFETY_DIRECTOR)));
checkItemList.add(HomeMenuItem(
image: 'assets/home/monthly_scheduling_white_icon.png',
name: '月调度',
isContains: roleNames.contains(StandingConfig.PERSON_CHARGE)));
checkItemRiskList.add(HomeMenuItem(
image: 'assets/home/risk_bg_icon.png',
name: '日整改',
isContains: roleNames.contains(StandingConfig.SAFETY_OFFICER)));
checkItemRiskList.add(HomeMenuItem(
image: 'assets/home/risk_bg_icon.png',
name: '周整改',
isContains: roleNames.contains(StandingConfig.SAFETY_DIRECTOR)));
checkItemRiskList.add(HomeMenuItem(
image: 'assets/home/risk_bg_icon.png',
name: '月整改',
isContains: roleNames.contains(StandingConfig.PERSON_CHARGE)));
checkItemSettingsList.add(HomeMenuItem(
image: 'assets/home/user_settings_icon.png',
name: '用户设置',
isContains: roleNames.contains(StandingConfig.SAFETY_OFFICER)));
checkItemSettingsList.add(HomeMenuItem(
image: 'assets/home/equipment_settings_icon.png',
name: '设备设置',
isContains: roleNames.contains(StandingConfig.SAFETY_DIRECTOR)));
checkItemSettingsList.add(HomeMenuItem(
image: 'assets/home/unit_settings_icon.png',
name: '单位设置',
isContains: roleNames.contains(StandingConfig.PERSON_CHARGE)));
_controller = AnimationController( _controller = AnimationController(
duration: const Duration(seconds: 2), duration: const Duration(seconds: 2),
...@@ -151,9 +124,88 @@ class _HomePageState extends State<HomePage> ...@@ -151,9 +124,88 @@ class _HomePageState extends State<HomePage>
parent: _controller, parent: _controller,
curve: Curves.bounceOut, curve: Curves.bounceOut,
); );
//通知监听
event = EventBusUtils.getInstance()?.on().listen((event) {
if (event.toString() == "1") {
//do something here
getQuestionsPerson();
}
});
getDeviceData(); getDeviceData();
} }
///获取考核试卷
void getQuestionsPerson() {
HttpUtils.getExaminePerson(context).then((value) {
mExaminePersonBo = value;
if (mounted) {
setState(() {
checkItemExaminationList.clear();
if (mExaminePersonBo!.success!) {
checkItemExaminationList.add(HomeMenuItem(
image: 'assets/examine/examine_icon.png',
name: '考核',
isContains: roleNames.contains(StandingConfig.SAFETY_OFFICER)));
} else {
checkItemExaminationList.add(HomeMenuItem(
image: 'assets/examine/examine_gary_icon.png',
name: '考核',
isContains: roleNames.contains(StandingConfig.SAFETY_OFFICER)));
}
checkItemExaminationList.add(HomeMenuItem(
image: 'assets/examine/examine_test_icon.png',
name: '测试练习',
isContains: roleNames.contains(StandingConfig.PERSON_CHARGE)));
// checkItemExaminationList.add(HomeMenuItem(
// image: 'assets/examine/examine_history_icon.png',
// name: '考核历史',
// isContains: roleNames.contains(StandingConfig.SAFETY_DIRECTOR)));
});
}
});
}
///获取考核试卷
void getClickQuestionsPerson() {
HttpUtils.getExaminePerson(context).then((value) {
mExaminePersonBo = value;
if (mounted) {
setState(() {
checkItemExaminationList.clear();
if (mExaminePersonBo!.success!) {
checkItemExaminationList.add(HomeMenuItem(
image: 'assets/examine/examine_icon.png',
name: '考核',
isContains: roleNames.contains(StandingConfig.SAFETY_OFFICER)));
Get.toNamed(RouteString.EXAM_PAGE,
arguments: {'mExaminePersonBo': mExaminePersonBo!.data})
?.then((value) {
// getQuestionsPerson();
});
} else {
checkItemExaminationList.add(HomeMenuItem(
image: 'assets/examine/examine_gary_icon.png',
name: '考核',
isContains: roleNames.contains(StandingConfig.SAFETY_OFFICER)));
ToastUtils.showCenter('您目前暂无考核内容');
}
checkItemExaminationList.add(HomeMenuItem(
image: 'assets/examine/examine_test_icon.png',
name: '测试练习',
isContains: roleNames.contains(StandingConfig.PERSON_CHARGE)));
// checkItemExaminationList.add(HomeMenuItem(
// image: 'assets/examine/examine_history_icon.png',
// name: '考核历史',
// isContains: roleNames.contains(StandingConfig.SAFETY_DIRECTOR)));
});
}
});
}
getDeviceData() { getDeviceData() {
if (!isUnitRoles(StorageUtil.getInstance().getRoleNames())!) { if (!isUnitRoles(StorageUtil.getInstance().getRoleNames())!) {
return; return;
...@@ -254,6 +306,8 @@ class _HomePageState extends State<HomePage> ...@@ -254,6 +306,8 @@ class _HomePageState extends State<HomePage>
///欢迎、身份 ///欢迎、身份
buildStanding(), buildStanding(),
///公司账户
if (isUnitRoles(StorageUtil.getInstance().getRoleNames())!) ...[ if (isUnitRoles(StorageUtil.getInstance().getRoleNames())!) ...[
///用户设置、设备设置、单位设置布局 ///用户设置、设备设置、单位设置布局
UnitGridList(onTapUser: () { UnitGridList(onTapUser: () {
...@@ -301,15 +355,126 @@ class _HomePageState extends State<HomePage> ...@@ -301,15 +355,126 @@ class _HomePageState extends State<HomePage>
///统计 ///统计
// buildSliverStatistics(context), // buildSliverStatistics(context),
///监察人员
] else if (isInspectorRoles(
StorageUtil.getInstance().getRoleNames())!) ...[
SliverToBoxAdapter(
child: Container(
margin: const EdgeInsets.only(left: 35, top: 20),
child: InkWell(
splashColor: ColorConst.green1Color,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: SizeConfig.isIpad()! ? 30 : 5),
Image.asset(
'assets/examine/examine_icon.png',
width: SizeConfig.isIpad()! ? 150 : 50,
height: SizeConfig.isIpad()! ? 150 : 50,
),
Container(
height: SizeConfig.isIpad()! ? 40 : 20,
margin: const EdgeInsets.only(top: 3),
child: Text(
'考核设置',
style: TextStyle(
fontSize: SizeConfig.isIpad()! ? 25 : 13,
color: Colors.black54),
),
)
],
),
onTap: () {
Get.toNamed(RouteString.OVERSEER_SETTINGS_PAGE,
arguments: {
// 'type': '1',
// 'tabIndex': 0,
// 'titleName': '考核'
})?.then((value) {
if (value != null && value) {}
});
},
),
),
)
] else ...[ ] else ...[
SliverToBoxAdapter(
child: Container(
margin: const EdgeInsets.only(top: 10, left: 0, right: 0),
padding: const EdgeInsets.all(10),
decoration: const BoxDecoration(
// color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(0)),
),
child: Column(
children: [
Row(
children: [
Image.asset(
'assets/examine/check_title_icon.png',
width: SizeConfig.isIpad()! ? 35 : 18,
height: SizeConfig.isIpad()! ? 35 : 18,
),
// Icon(
// Icons.equalizer,
// color: ColorConst.blueColor,
// size: SizeConfig.isIpad()! ? 35 : 18,
// ),
const SizedBox(width: 5),
Text(
'检查整改',
style: TextStyle(
color: Colors.black54,
fontSize: SizeConfig.isIpad()! ? 25 : 14,
fontWeight: FontWeight.bold),
),
],
),
],
))),
///日管控、周排查、月调度布局 ///日管控、周排查、月调度布局
buildSliverDayWeekMonth(), buildSliverDayWeekMonth(),
///日管控整改、周排查整改、月调度整改布局 ///日管控整改、周排查整改、月调度整改布局
buildSliverRiskDayWeekMonth(), buildSliverRiskDayWeekMonth(),
//TODO
SliverToBoxAdapter(
child: Container(
margin: const EdgeInsets.only(top: 0, left: 0, right: 0),
padding: const EdgeInsets.all(10),
decoration: const BoxDecoration(
// color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(5)),
),
child: Column(
children: [
Row(
children: [
Image.asset(
'assets/examine/exam_title_icon.png',
width: SizeConfig.isIpad()! ? 35 : 18,
height: SizeConfig.isIpad()! ? 35 : 18,
),
const SizedBox(width: 5),
Text(
'考核练习',
style: TextStyle(
color: Colors.black54,
fontSize: SizeConfig.isIpad()! ? 25 : 14,
fontWeight: FontWeight.bold),
),
],
),
// buildTitle(Icons.equalizer, '考核练习'),
// buildSliverGridExamination()
],
))),
buildSliverGridExamination(),
///统计 ///统计
buildSliverStatistics(context), // buildSliverStatistics(context),
] ]
], ],
), ),
...@@ -628,7 +793,7 @@ class _HomePageState extends State<HomePage> ...@@ -628,7 +793,7 @@ class _HomePageState extends State<HomePage>
crossAxisCount: checkItemList.length, crossAxisCount: checkItemList.length,
crossAxisSpacing: 1, crossAxisSpacing: 1,
mainAxisSpacing: 1, mainAxisSpacing: 1,
childAspectRatio: 1 / 0.83, //子项的宽高比,值越大高度越高 childAspectRatio: 1 / 0.80, //子项的宽高比,值越大高度越高
), ),
delegate: SliverChildBuilderDelegate( delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) { (BuildContext context, int index) {
...@@ -659,7 +824,7 @@ class _HomePageState extends State<HomePage> ...@@ -659,7 +824,7 @@ class _HomePageState extends State<HomePage>
crossAxisSpacing: 1, crossAxisSpacing: 1,
mainAxisSpacing: 1, mainAxisSpacing: 1,
childAspectRatio: childAspectRatio:
1 / (SizeConfig.isIpad()! ? 0.66 : 0.83), //子项的宽高比,值越大高度越高 1 / (SizeConfig.isIpad()! ? 0.66 : 0.75), //子项的宽高比,值越大高度越高
), ),
delegate: SliverChildBuilderDelegate( delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) { (BuildContext context, int index) {
...@@ -679,12 +844,43 @@ class _HomePageState extends State<HomePage> ...@@ -679,12 +844,43 @@ class _HomePageState extends State<HomePage>
); );
} }
///考核、考核历史、测试练习 布局
SliverPadding buildSliverGridExamination() {
return SliverPadding(
padding: const EdgeInsets.only(left: 0, right: 0, top: 0, bottom: 0),
// 使用SliverGrid来创建GridView
sliver: SliverGrid(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
crossAxisSpacing: 1,
mainAxisSpacing: 1,
childAspectRatio:
1 / (SizeConfig.isIpad()! ? 0.66 : 0.83), //子项的宽高比,值越大高度越高
),
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return AnimatedBuilder(
animation: _animation,
builder: (context, child) {
return Transform.scale(
scale: _animation.value,
child: buildExaminationItem(index),
);
},
);
},
childCount: checkItemExaminationList.length,
),
),
);
}
InkWell buildCheckRiskItem(index) { InkWell buildCheckRiskItem(index) {
return InkWell( return InkWell(
splashColor: ColorConst.green1Color, splashColor: ColorConst.green1Color,
child: Column( child: Column(
children: [ children: [
SizedBox(height: SizeConfig.isIpad()! ? 0 : 15), SizedBox(height: SizeConfig.isIpad()! ? 0 : 5),
Stack( Stack(
alignment: Alignment.center, alignment: Alignment.center,
children: [ children: [
...@@ -792,7 +988,7 @@ class _HomePageState extends State<HomePage> ...@@ -792,7 +988,7 @@ class _HomePageState extends State<HomePage>
child: Column( child: Column(
// mainAxisAlignment: MainAxisAlignment.center, // mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
SizedBox(height: SizeConfig.isIpad()! ? 40 : 15), SizedBox(height: SizeConfig.isIpad()! ? 30 : 5),
Stack( Stack(
alignment: Alignment.center, alignment: Alignment.center,
children: [ children: [
...@@ -894,6 +1090,76 @@ class _HomePageState extends State<HomePage> ...@@ -894,6 +1090,76 @@ class _HomePageState extends State<HomePage>
); );
} }
///考核、考核历史、测试练习 item布局
InkWell buildExaminationItem(index) {
return InkWell(
splashColor: ColorConst.green1Color,
child: Column(
children: [
SizedBox(height: SizeConfig.isIpad()! ? 30 : 5),
Stack(
alignment: Alignment.center,
children: [
Image.asset(
checkItemExaminationList[index].image,
width: SizeConfig.isIpad()! ? 150 : 50,
height: SizeConfig.isIpad()! ? 150 : 50,
),
],
),
buildBottomText(checkItemExaminationList[index].name),
],
),
onTap: () {
switch (index) {
///考核
case 0:
getClickQuestionsPerson();
// Get.toNamed(RouteString.EXAM_PAGE,
// arguments: {'type': '1', 'tabIndex': 0, 'titleName': '考核'})
// ?.then((value) {
// if (value != null && value) {}
// });
break;
///考核历史
case 1:
// Get.toNamed(RouteString.OVERSEER_SETTINGS_PAGE, arguments: {
// 'type': '2',
// 'tabIndex': 0,
// 'titleName': '考核历史'
// })?.then((value) {
// if (value != null && value) {}
// });
// Get.toNamed(RouteString.TEST_PAGE, arguments: {
// // 'type': '3',
// // 'tabIndex': 0,
// // 'titleName': '测试练习'
// })?.then((value) {
// if (value != null && value) {}
// });
Get.toNamed(RouteString.TEST_SETTING_PAGE, arguments: {})
?.then((value) {
if (value != null && value) {}
});
break;
///测试练习
case 2:
Get.toNamed(RouteString.EXAM_HISTORY_PAGE, arguments: {
'type': '2',
'tabIndex': 0,
'titleName': '考核历史'
})?.then((value) {
if (value != null && value) {}
});
break;
}
},
);
}
///欢迎、身份 ///欢迎、身份
SliverToBoxAdapter buildStanding() { SliverToBoxAdapter buildStanding() {
return SliverToBoxAdapter( return SliverToBoxAdapter(
...@@ -1514,6 +1780,48 @@ class _HomePageState extends State<HomePage> ...@@ -1514,6 +1780,48 @@ class _HomePageState extends State<HomePage>
_controller.dispose(); _controller.dispose();
} }
super.dispose(); super.dispose();
event?.cancel();
}
void getGirdviewData() {
checkItemList.add(HomeMenuItem(
image: 'assets/home/day_control_white_icon.png',
name: '日管控',
isContains: roleNames.contains(StandingConfig.SAFETY_OFFICER)));
checkItemList.add(HomeMenuItem(
image: 'assets/home/weekly_survey_white_icon.png',
name: '周排查',
isContains: roleNames.contains(StandingConfig.SAFETY_DIRECTOR)));
checkItemList.add(HomeMenuItem(
image: 'assets/home/monthly_scheduling_white_icon.png',
name: '月调度',
isContains: roleNames.contains(StandingConfig.PERSON_CHARGE)));
checkItemRiskList.add(HomeMenuItem(
image: 'assets/home/risk_bg_icon.png',
name: '日整改',
isContains: roleNames.contains(StandingConfig.SAFETY_OFFICER)));
checkItemRiskList.add(HomeMenuItem(
image: 'assets/home/risk_bg_icon.png',
name: '周整改',
isContains: roleNames.contains(StandingConfig.SAFETY_DIRECTOR)));
checkItemRiskList.add(HomeMenuItem(
image: 'assets/home/risk_bg_icon.png',
name: '月整改',
isContains: roleNames.contains(StandingConfig.PERSON_CHARGE)));
checkItemSettingsList.add(HomeMenuItem(
image: 'assets/home/user_settings_icon.png',
name: '用户设置',
isContains: roleNames.contains(StandingConfig.SAFETY_OFFICER)));
checkItemSettingsList.add(HomeMenuItem(
image: 'assets/home/equipment_settings_icon.png',
name: '设备设置',
isContains: roleNames.contains(StandingConfig.SAFETY_DIRECTOR)));
checkItemSettingsList.add(HomeMenuItem(
image: 'assets/home/unit_settings_icon.png',
name: '单位设置',
isContains: roleNames.contains(StandingConfig.PERSON_CHARGE)));
} }
// _requestPermission() async { // _requestPermission() async {
// // var camera = await Permission.camera.status; // // var camera = await Permission.camera.status;
......
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:special_equipment_flutter/dio/http_utils.dart';
import 'package:special_equipment_flutter/model/exam/equipment_list_bo.dart';
import 'package:special_equipment_flutter/model/exam/exam_unit_list.dart';
import 'package:special_equipment_flutter/utils/storage_util.dart';
import 'package:special_equipment_flutter/widgets/app_bar/custom_app_bar.dart';
///设备选择
class EquipmentListPage extends StatefulWidget {
var arguments = Get.arguments;
EquipmentListPage({super.key});
@override
State<EquipmentListPage> createState() => _EquipmentListPageState();
}
class _EquipmentListPageState extends State<EquipmentListPage> {
List<EquiList>? officeLists = [];
List<EquiList>? filterOfficeLists = [];
var officeId = '';
@override
void initState() {
super.initState();
officeId = widget.arguments['officeId'];
getEquipmentList();
}
///获取设备类型
void getEquipmentList() {
HttpUtils.getEquipmentList(context, officeId).then((value) {
EquipmentListBo listBo = value;
if (mounted) {
setState(() {
officeLists = listBo.list;
filterOfficeLists = officeLists;
});
}
});
}
void _filterData(String query) {
setState(() {
filterOfficeLists = officeLists!.where((EquiList item) {
return item.name!.toLowerCase().contains(query.toLowerCase());
}).toList();
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBarCustom(text: '选择设备', height: 50),
body: Column(
children: [
const SizedBox(height: 10),
Container(
margin: const EdgeInsets.only(left: 10, right: 10),
decoration: BoxDecoration(
color: Colors.grey[200],
borderRadius: BorderRadius.circular(10),
),
child: Row(
children: [
IconButton(
icon: const Icon(Icons.search),
onPressed: () {
// 处理搜索逻辑
},
),
Expanded(
child: TextField(
onChanged: (value) {
_filterData(value);
},
decoration: const InputDecoration(
hintText: '请输入搜索关键字',
border: InputBorder.none,
),
),
),
],
),
),
const SizedBox(height: 10),
Flexible(
child: ListView.builder(
shrinkWrap: true,
padding:
const EdgeInsets.only(top: 0, left: 0, bottom: 0, right: 0),
itemCount: filterOfficeLists!.length,
// 列表项数量
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {
setState(() {
Get.back(result: filterOfficeLists![index]);
});
},
child: Container(
padding: const EdgeInsets.only(
left: 30, right: 15, top: 10, bottom: 10),
child: Text(
filterOfficeLists![index].name!,
style: const TextStyle(fontSize: 18),
),
),
);
},
),
),
],
),
);
}
}
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:special_equipment_flutter/common/color_const.dart';
import 'package:special_equipment_flutter/common/edgeInsets_const.dart';
import 'package:special_equipment_flutter/dio/http_utils.dart';
import 'package:special_equipment_flutter/model/day_control_list_sy_bo.dart';
import 'package:special_equipment_flutter/widgets/app_bar/custom_app_bar.dart';
import 'package:special_equipment_flutter/widgets/divider_custom.dart';
///设置的考核列表
class OverseerListPage extends StatefulWidget {
const OverseerListPage({super.key});
@override
State<OverseerListPage> createState() => _OverseerListPageState();
}
class _OverseerListPageState extends State<OverseerListPage> {
final EasyRefreshController _controller = EasyRefreshController();
List<TaskDayList> list = [];
@override
void initState() {
super.initState();
// getData();
}
void getData() {
HttpUtils.getOverseerList(context, '0', '', '').then((value) {
DayControlListSyBo listBo = value;
if (mounted) {
setState(() {
var taskDayList = listBo.taskDayList;
list.clear();
list.addAll(taskDayList!);
_controller.finishRefresh();
});
}
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBarCustom(text: '考核列表', height: 50),
backgroundColor: Colors.grey[100],
body: Column(
children: [
Expanded(
flex: 1,
child: EasyRefresh(
firstRefresh: true,
enableControlFinishRefresh: true,
// enableControlFinishLoad: true,
// firstRefreshWidget: const FirstRefreshWidget(),
// emptyWidget: list.isEmpty
// ? EmptyImgWidget(
// title: '暂无数据,点击刷新',
// onTap: () {
// getData();
// })
// : null,
controller: _controller,
onRefresh: () async {
// page = 1;
// getData();
},
// onLoad: () async {
// page++;
// getList();
// },
child: buildBody(),
)),
],
),
);
}
Column buildBody() {
return Column(
children: [
//文章列表
ListView.separated(
shrinkWrap: true,
padding: const EdgeInsets.symmetric(
horizontal: EdgeInsetsConst.padding_horizontal),
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (BuildContext context, int index) {
return buildItem(index, context);
},
itemCount: 4,
separatorBuilder: (BuildContext context, int index) {
return const SizedBox(
height: 0,
);
},
),
],
);
}
InkWell buildItem(int index, BuildContext context) {
return InkWell(
onTap: () {
// Get.toNamed(RouteString.DAY_INSPECT_SUBMIT_SY,
// arguments: {'argsData': widget.args, 'listBo': list(index)})
// ?.then((value) {
// if (value != null && value) {
// getData();
// }
// });
},
child: buildCard(context, index),
);
}
Card buildCard(BuildContext context, int index) {
return Card(
elevation: 3,
margin: const EdgeInsets.only(left: 0, right: 0, top: 15, bottom: 0),
color: Colors.white,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(5)),
),
child: Container(
padding:
const EdgeInsets.only(left: 10, right: 10, top: 10, bottom: 10),
child: Column(
children: <Widget>[
const Column(
children: [
Text('山西盈中科技有限公司山西盈中科技有限公司',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18,
color: Colors.black87)),
Text('2024-05-21',
style: TextStyle(fontSize: 14, color: Colors.grey)),
],
),
///分割线
DividerCustom(Colors.grey[300], 8, 8, 0, 0),
Container(
margin:
const EdgeInsets.only(left: 8, top: 0, right: 0, bottom: 0),
child: const Row(children: [
Text('设备类型:',
style: TextStyle(
fontSize: 14,
color: ColorConst.blueColor,
fontWeight: FontWeight.bold)),
Text('电梯,锅炉', style: TextStyle()),
]),
),
Container(
padding:
const EdgeInsets.only(left: 10, top: 5, right: 5, bottom: 5),
margin:
const EdgeInsets.only(left: 0, top: 10, right: 0, bottom: 0),
decoration: const BoxDecoration(
color: ColorConst.grayf5Color,
borderRadius: BorderRadius.all(Radius.circular(10)),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Row(children: [
Text('安全总监:',
style: TextStyle(
fontSize: 14,
color: ColorConst.blueColor,
fontWeight: FontWeight.bold)),
Text('张三,李四', style: TextStyle()),
]),
const SizedBox(height: 5),
Container(
padding: const EdgeInsets.only(
left: 0, top: 0, right: 5, bottom: 0),
child: const Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('总题数:20',
style: TextStyle(color: Colors.grey, fontSize: 14)),
Text('单选题数:10',
style: TextStyle(color: Colors.grey, fontSize: 14)),
Text('判断题数:10',
style: TextStyle(color: Colors.grey, fontSize: 14)),
],
),
),
],
),
),
Container(
padding:
const EdgeInsets.only(left: 10, top: 5, right: 5, bottom: 5),
margin:
const EdgeInsets.only(left: 0, top: 10, right: 0, bottom: 0),
decoration: const BoxDecoration(
color: ColorConst.grayf5Color,
borderRadius: BorderRadius.all(Radius.circular(10)),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Row(children: [
Text('安全员:',
style: TextStyle(
fontSize: 14,
color: ColorConst.blueColor,
fontWeight: FontWeight.bold)),
Text('张三,李四', style: TextStyle()),
]),
const SizedBox(height: 5),
Container(
padding: const EdgeInsets.only(
left: 0, top: 0, right: 5, bottom: 0),
child: const Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('总题数:20',
style: TextStyle(color: Colors.grey, fontSize: 14)),
Text('单选题数:10',
style: TextStyle(color: Colors.grey, fontSize: 14)),
Text('判断题数:10',
style: TextStyle(color: Colors.grey, fontSize: 14)),
],
),
),
],
),
),
const SizedBox(
height: 5,
)
// buildSubmits(context, index),
],
),
),
);
}
}
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:get/get.dart';
import 'package:special_equipment_flutter/common/color_const.dart';
import 'package:special_equipment_flutter/common/route_string.dart';
import 'package:special_equipment_flutter/dio/http_utils.dart';
import 'package:special_equipment_flutter/model/base/base_model.dart';
import 'package:special_equipment_flutter/model/exam/eq_question_bo.dart';
import 'package:special_equipment_flutter/model/exam/equipment_list_bo.dart';
import 'package:special_equipment_flutter/model/exam/exam_setting_submit_bo.dart';
import 'package:special_equipment_flutter/model/exam/exam_unit_list.dart';
import 'package:special_equipment_flutter/model/exam/find_question_num.dart';
import 'package:special_equipment_flutter/model/exam/unit_person_list_bo.dart';
import 'package:special_equipment_flutter/utils/storage_util.dart';
import 'package:special_equipment_flutter/utils/toast_utils.dart';
import 'package:special_equipment_flutter/widgets/custom_button.dart';
import 'package:special_equipment_flutter/widgets/custom_textfield.dart';
import 'package:special_equipment_flutter/widgets/first_refresh_widget.dart';
///监察人设置考核机构、考核题信息
class OverseerSettingsPage extends StatefulWidget {
const OverseerSettingsPage({super.key});
@override
State<OverseerSettingsPage> createState() => _OverseerSettingsState();
}
class _OverseerSettingsState extends State<OverseerSettingsPage> {
TextEditingController? unitText = TextEditingController();
FocusNode? unitFocusNode = FocusNode();
TextEditingController? equipmentText = TextEditingController();
FocusNode? equipmentFocusNode = FocusNode();
TextEditingController? singleZJText = TextEditingController();
FocusNode? singleZJFocusNode = FocusNode();
TextEditingController? judgmentZJText = TextEditingController();
FocusNode? judgmentZJFocusNode = FocusNode();
TextEditingController? singleAQYText = TextEditingController();
FocusNode? singleAQYFocusNode = FocusNode();
TextEditingController? judgmentAQYText = TextEditingController();
FocusNode? judgmentAQYFocusNode = FocusNode();
OfficeList? mOfficeList;
EquiList? mEquiList;
DataEq? mDataEq;
int allAQY = 0, allZJ = 0;
List<UserLists>? userSafetyDirectorList = [], userSafetyOfficerList = [];
UnitPersonListBo? mUnitPersonListBo;
var unitStatus = '';
@override
void initState() {
super.initState();
getFindQuestionNum();
unitStatus = StorageUtil.getInstance().getUnitStatus();
}
///获取设备类型
void getEquipmentList() {
HttpUtils.getEquipmentList(context, mOfficeList!.id).then((value) {
EquipmentListBo listBo = value;
if (mounted) {
setState(() {
mEquiList = listBo.list![0];
equipmentText!.text = mEquiList!.name!;
});
}
});
}
///获取题数
void getFindQuestionNum() {
HttpUtils.getFindQuestionNum(context).then((value) {
FindQuestionNum listBo = value;
if (mounted) {
setState(() {
DataNum dataNum = listBo.data!;
singleZJText!.text = dataNum.aqzjDx!.toString();
judgmentZJText!.text = dataNum.aqzjPd!.toString();
singleAQYText!.text = dataNum.aqyDx!.toString();
judgmentAQYText!.text = dataNum.aqyPd!.toString();
allAQY = dataNum.aqzjDx! + dataNum.aqzjPd!;
allZJ = dataNum.aqyDx! + dataNum.aqyPd!;
});
}
});
}
///获取人员
void getUnitPersonList(var roleId) {
HttpUtils.getUnitPerson(context, mOfficeList!.id, mEquiList!.id, roleId)
.then((value) {
mUnitPersonListBo = value;
if (mounted) {
setState(() {
///安全总监
if (roleId == 'f801011eb2c1481892dba5bc15023733') {
userSafetyDirectorList = mUnitPersonListBo!.userList;
///安全员
} else if (roleId == '77584ba03b4545fba9d23fd670b66c10') {
userSafetyOfficerList = mUnitPersonListBo!.userList;
}
});
}
});
}
///根据设备类型获取总题数
void getFindEqQuestionNum() {
HttpUtils.getFindEqQuestionNum(context, mEquiList!.id!).then((value) {
EqQuestionBo listBo = value;
if (mounted) {
setState(() {
mDataEq = listBo.data!;
if (int.parse(singleZJText!.text) > mDataEq!.dxNum!) {
singleZJText!.text = mDataEq!.dxNum!.toString();
allZJ = (singleZJText!.text.isNotEmpty
? int.parse(singleZJText!.text)
: 0) +
(judgmentZJText!.text.isNotEmpty
? int.parse(judgmentZJText!.text)
: 0);
}
if (int.parse(judgmentZJText!.text) > mDataEq!.pdNum!) {
judgmentZJText!.text = mDataEq!.pdNum!.toString();
allZJ = (singleZJText!.text.isNotEmpty
? int.parse(singleZJText!.text)
: 0) +
(judgmentZJText!.text.isNotEmpty
? int.parse(judgmentZJText!.text)
: 0);
}
if (int.parse(singleAQYText!.text) > mDataEq!.dxNum!) {
singleAQYText!.text = mDataEq!.dxNum!.toString();
allAQY = (singleAQYText!.text.isNotEmpty
? int.parse(singleAQYText!.text)
: 0) +
(judgmentAQYText!.text.isNotEmpty
? int.parse(judgmentAQYText!.text)
: 0);
}
if (int.parse(judgmentAQYText!.text) > mDataEq!.pdNum!) {
judgmentAQYText!.text = mDataEq!.pdNum!.toString();
allAQY = (singleAQYText!.text.isNotEmpty
? int.parse(singleAQYText!.text)
: 0) +
(judgmentAQYText!.text.isNotEmpty
? int.parse(judgmentAQYText!.text)
: 0);
}
});
}
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey[100],
body: Stack(
children: [
Image.asset('assets/home/rigister_bg.png'),
Container(
margin:
const EdgeInsets.only(left: 15, top: 110, right: 15, bottom: 0),
decoration: const BoxDecoration(
color: ColorConst.whiteColor,
borderRadius: BorderRadius.all(Radius.circular(10)),
),
child: CustomScrollView(
primary: false,
shrinkWrap: true,
slivers: <Widget>[
SliverToBoxAdapter(
child: Column(
children: [
buildUnitInformation(),
// buildSubmit(),
const SizedBox(height: 30)
],
),
),
],
),
),
buildTopTitle(context)
],
),
);
}
///单位信息
Container buildUnitInformation() {
return Container(
margin: const EdgeInsets.only(left: 10, top: 10, right: 10, bottom: 10),
child: Stack(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
const SizedBox(height: 10),
const Row(children: [
Icon(Icons.touch_app, color: ColorConst.orangeColor, size: 15),
Text('单位名称', style: TextStyle(fontSize: 14))
]),
const SizedBox(height: 5),
CustomTextField(
enabled: true,
readOnly: true,
hintText: '请选择单位名称',
controller: unitText,
focusNode: unitFocusNode,
onTop: () {
Get.toNamed(RouteString.UNIT_LIST_PAGE)?.then((map) {
if (map != null) {
mOfficeList = map;
setState(() {
unitText!.text = mOfficeList!.name!;
mEquiList = null;
equipmentText!.text = '';
userSafetyDirectorList = [];
userSafetyOfficerList = [];
});
}
});
}),
const SizedBox(height: 15),
const Row(children: [
Icon(Icons.touch_app, color: ColorConst.orangeColor, size: 15),
Text('设备类型', style: TextStyle(fontSize: 14))
]),
const SizedBox(height: 5),
CustomTextField(
enabled: true,
readOnly: true,
hintText: '请选择设备类型',
controller: equipmentText,
focusNode: equipmentFocusNode,
onTop: () {
if (mOfficeList != null && mOfficeList!.id!.isNotEmpty) {
Get.toNamed(RouteString.EQUIPMENT_LIST_PAGE,
arguments: {'officeId': mOfficeList!.id})
?.then((map) {
if (map != null) {
mEquiList = map;
setState(() {
equipmentText!.text = mEquiList!.name!;
getUnitPersonList(
'f801011eb2c1481892dba5bc15023733');
getUnitPersonList(
'77584ba03b4545fba9d23fd670b66c10');
getFindEqQuestionNum();
});
}
});
} else {
ToastUtils.showCenter('请先选择单位');
}
}),
const SizedBox(height: 15),
Container(
padding: const EdgeInsets.only(
left: 5, top: 10, right: 5, bottom: 10),
decoration: const BoxDecoration(
color: ColorConst.grayf5Color,
borderRadius: BorderRadius.all(Radius.circular(10)),
),
child: Column(
children: [
const Row(children: [
Icon(Icons.touch_app,
color: ColorConst.orangeColor, size: 15),
Text('安全总监', style: TextStyle(fontSize: 14))
]),
const SizedBox(height: 5),
if (mUnitPersonListBo != null &&
userSafetyDirectorList!.isEmpty) ...{
Container(
padding: const EdgeInsets.only(
left: 0, top: 15, right: 0, bottom: 15),
child: const Text(
"该单位暂无录入(质量)安全总监",
style: TextStyle(
color: ColorConst.blueColor,
fontWeight: FontWeight.bold),
),
)
},
buildSafetyDirectorListView(),
const SizedBox(height: 10),
Container(
padding: const EdgeInsets.only(
left: 5, top: 0, right: 5, bottom: 0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(children: [
const Text('单选题数', style: TextStyle(fontSize: 14)),
SizedBox(
width: 40,
height: 30,
child: TextFormField(
textAlign: TextAlign.center,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
LengthLimitingTextInputFormatter(3),
],
focusNode: singleZJFocusNode,
controller: singleZJText,
onChanged: (num) {
setState(() {
if (mDataEq != null &&
int.parse(num) > mDataEq!.dxNum!) {
ToastUtils.showCenter(
'题库只有${mDataEq!.dxNum}道单选题');
setState(() {
singleZJText!.text =
mDataEq!.dxNum.toString();
});
}
allZJ = (singleZJText!.text.isNotEmpty
? int.parse(singleZJText!.text)
: 0) +
(judgmentZJText!.text.isNotEmpty
? int.parse(judgmentZJText!.text)
: 0);
});
},
),
)
]),
Row(children: [
const Text('判断题数', style: TextStyle(fontSize: 14)),
SizedBox(
width: 40,
height: 30,
child: TextFormField(
textAlign: TextAlign.center,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
LengthLimitingTextInputFormatter(3),
],
focusNode: judgmentZJFocusNode,
controller: judgmentZJText,
onChanged: (num) {
setState(() {
if (mDataEq != null &&
int.parse(num) > mDataEq!.pdNum!) {
ToastUtils.showCenter(
'题库只有${mDataEq!.pdNum}道判断题');
setState(() {
judgmentZJText!.text =
mDataEq!.pdNum.toString();
});
}
allZJ = (judgmentZJText!.text.isNotEmpty
? int.parse(judgmentZJText!.text)
: 0) +
(singleZJText!.text.isNotEmpty
? int.parse(singleZJText!.text)
: 0);
});
},
),
)
]),
Text('总题数: ${allZJ.toString()}',
style: const TextStyle(
color: Colors.grey, fontSize: 14)),
],
),
),
],
),
),
const SizedBox(height: 10),
Container(
padding: const EdgeInsets.only(
left: 5, top: 10, right: 5, bottom: 10),
decoration: const BoxDecoration(
color: ColorConst.grayf5Color,
borderRadius: BorderRadius.all(Radius.circular(10)),
),
child: Column(
children: [
const Row(children: [
Icon(Icons.touch_app,
color: ColorConst.orangeColor, size: 15),
Text('安全员', style: TextStyle(fontSize: 14))
]),
const SizedBox(height: 5),
if (mUnitPersonListBo != null &&
userSafetyOfficerList!.isEmpty) ...{
Container(
padding: const EdgeInsets.only(
left: 0, top: 15, right: 0, bottom: 15),
child: const Text(
"该单位暂无录入(质量)安全员",
style: TextStyle(
color: ColorConst.blueColor,
fontWeight: FontWeight.bold),
),
)
},
buildSafetyOfficerListView(),
const SizedBox(height: 10),
Container(
padding: const EdgeInsets.only(
left: 5, top: 0, right: 5, bottom: 0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(children: [
const Text('单选题数', style: TextStyle(fontSize: 14)),
SizedBox(
width: 40,
height: 30,
child: TextFormField(
textAlign: TextAlign.center,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
LengthLimitingTextInputFormatter(3),
],
focusNode: singleAQYFocusNode,
controller: singleAQYText,
onChanged: (num) {
setState(() {
if (mDataEq != null &&
int.parse(num) > mDataEq!.dxNum!) {
ToastUtils.showCenter(
'题库只有${mDataEq!.dxNum}道单选题');
setState(() {
singleAQYText!.text =
mDataEq!.dxNum.toString();
});
}
allAQY = (singleAQYText!.text.isNotEmpty
? int.parse(singleAQYText!.text)
: 0) +
(judgmentAQYText!.text.isNotEmpty
? int.parse(judgmentAQYText!.text)
: 0);
});
},
),
)
]),
Row(children: [
const Text('判断题数', style: TextStyle(fontSize: 14)),
SizedBox(
width: 40,
height: 30,
child: TextFormField(
textAlign: TextAlign.center,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
LengthLimitingTextInputFormatter(3)
],
focusNode: judgmentAQYFocusNode,
controller: judgmentAQYText,
onChanged: (num) {
setState(() {
if (mDataEq != null &&
int.parse(num) > mDataEq!.pdNum!) {
ToastUtils.showCenter(
'题库只有${mDataEq!.pdNum}道判断题');
setState(() {
judgmentAQYText!.text =
mDataEq!.pdNum.toString();
});
}
allAQY = (judgmentAQYText!.text.isNotEmpty
? int.parse(judgmentAQYText!.text)
: 0) +
(singleAQYText!.text.isNotEmpty
? int.parse(singleAQYText!.text)
: 0);
});
},
),
)
]),
Text('总题数: ${allAQY.toString()}',
style: const TextStyle(
color: Colors.grey, fontSize: 14)),
],
),
),
],
),
),
buildSubmit()
],
)
],
),
);
}
ListView buildSafetyDirectorListView() {
return ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
padding: const EdgeInsets.only(top: 0, left: 0, bottom: 0, right: 0),
itemCount: userSafetyDirectorList!.length,
// 列表项数量
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {
setState(() {
if (userSafetyDirectorList![index].isChecked!) {
userSafetyDirectorList![index].isChecked = false;
} else {
userSafetyDirectorList![index].isChecked = true;
}
});
},
child: Container(
height: 40,
decoration: BoxDecoration(
color: userSafetyDirectorList![index].isChecked!
? Colors.grey.withOpacity(0.1)
: Colors.transparent,
borderRadius: const BorderRadius.all(Radius.circular(5)),
),
child: Row(
children: [
Checkbox(
value: userSafetyDirectorList![index].isChecked,
onChanged: (value) {
setState(() {
// selectedSafetyDirectorIndex = value!;
});
},
),
Text(userSafetyDirectorList![index].name!)
],
),
),
);
},
);
}
ListView buildSafetyOfficerListView() {
return ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
padding: const EdgeInsets.only(top: 0, left: 0, bottom: 0, right: 0),
itemCount: userSafetyOfficerList!.length,
// 列表项数量
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {
setState(() {
if (userSafetyOfficerList![index].isChecked!) {
userSafetyOfficerList![index].isChecked = false;
} else {
userSafetyOfficerList![index].isChecked = true;
}
});
},
child: Container(
height: 40,
// color: _selectedIndex == index
// ? Colors.grey.withOpacity(0.3)
// : Colors.transparent, // 选中时高亮背景色
decoration: BoxDecoration(
color: userSafetyOfficerList![index].isChecked!
? Colors.grey.withOpacity(0.3)
: Colors.transparent,
borderRadius: const BorderRadius.all(Radius.circular(5)),
),
child: Row(
children: [
Checkbox(
value: userSafetyOfficerList![index].isChecked,
onChanged: (value) {
setState(() {
// selectedSafetyDirectorIndex = value!;
});
},
),
Text(userSafetyOfficerList![index].name!)
],
),
),
);
},
);
}
Container buildTopTitle(BuildContext context) {
return Container(
margin: const EdgeInsets.only(top: 50),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
IconButton(
onPressed: () {
Navigator.of(context).pop();
},
icon: const Icon(Icons.arrow_back, color: Colors.white),
iconSize: 30,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Container(
margin: const EdgeInsets.only(top: 5),
child: const Text(
'考核设置',
style: TextStyle(
fontSize: 23,
color: Colors.white,
fontWeight: FontWeight.bold),
)),
Container(
height: 3,
width: 50,
alignment: Alignment.topLeft,
margin: const EdgeInsets.only(top: 3, bottom: 3),
decoration: const BoxDecoration(
color: Colors.white54,
borderRadius: BorderRadius.all(Radius.circular(5)),
)),
const Text(
'',
style: TextStyle(fontSize: 12, color: Colors.white),
),
],
),
],
),
);
}
///交卷
Container buildSubmit() {
return Container(
margin: const EdgeInsets.only(top: 30, bottom: 0),
padding: const EdgeInsets.only(left: 20, right: 20, top: 15, bottom: 0),
width: double.infinity,
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(5)),
),
child: GradientButton(
tapCallback: () {
if (unitText!.text.isEmpty) {
ToastUtils.showCenter('选择单位名称');
return;
}
if (equipmentText!.text.isEmpty) {
ToastUtils.showCenter('选择设备类型');
return;
}
if (userSafetyDirectorList!.isEmpty &&
userSafetyOfficerList!.isEmpty) {
ToastUtils.showCenter('没有可选的\n【安全总监】\n【安全员】\n无法提交');
return;
}
bool isSafety = false;
for (var i = 0; i < userSafetyDirectorList!.length; i++) {
if (userSafetyDirectorList![i].isChecked!) {
isSafety = true;
}
}
for (var i = 0; i < userSafetyOfficerList!.length; i++) {
if (userSafetyOfficerList![i].isChecked!) {
isSafety = true;
}
}
if (!isSafety) {
ToastUtils.showCenter('至少选择一个\n【安全总监】\n【安全员】');
return;
}
if (allZJ == 0 && allAQY == 0) {
ToastUtils.showCenter('总题数不能为 0');
return;
}
Get.dialog(AlertDialog(
title: const Text("温馨提示"),
content: const Text("您确定要提交考核吗?"),
actionsPadding: const EdgeInsets.only(
left: 0, top: 0, bottom: 10, right: 20),
contentPadding: const EdgeInsets.only(
left: 20, top: 0, bottom: 10, right: 20),
titlePadding: const EdgeInsets.only(
left: 20, top: 20, bottom: 10, right: 20),
shape: const RoundedRectangleBorder(
// 这里设置shape属性
borderRadius: BorderRadius.all(Radius.circular(10.0))),
actions: <Widget>[
TextButton(
child: const Text("取消", style: TextStyle(fontSize: 16)),
onPressed: () {
Get.back();
},
),
TextButton(
child: const Text("确定", style: TextStyle(fontSize: 16)),
onPressed: () {
//关闭弹窗
Get.back();
// printLog(
// "《考核-交卷》提交json数据----->${json.encode(examineQuestionsBo)}");
ExamSettingSubmitBo mExamSettingSubmitBo =
ExamSettingSubmitBo();
// 安全主管判断题数
mExamSettingSubmitBo.aqzgPdNum =
judgmentZJText!.text.isNotEmpty
? int.parse(judgmentZJText!.text)
: 0;
// 安全主管选择题数
mExamSettingSubmitBo.aqzgXzNum =
singleZJText!.text.isNotEmpty
? int.parse(singleZJText!.text)
: 0;
// 安全员判断题数
mExamSettingSubmitBo.aqyPdNum =
judgmentAQYText!.text.isNotEmpty
? int.parse(judgmentAQYText!.text)
: 0;
// 安全员选择题数
mExamSettingSubmitBo.aqyXzNum =
singleAQYText!.text.isNotEmpty
? int.parse(singleAQYText!.text)
: 0;
mExamSettingSubmitBo.type = mEquiList!.id;
List<String>? aqzgIds = [];
for (var i = 0; i < userSafetyDirectorList!.length; i++) {
if (userSafetyDirectorList![i].isChecked!) {
aqzgIds.add(userSafetyDirectorList![i].id.toString());
}
}
mExamSettingSubmitBo.aqzgIds = aqzgIds;
List<String>? aqyIds = [];
for (var i = 0; i < userSafetyOfficerList!.length; i++) {
if (userSafetyOfficerList![i].isChecked!) {
aqyIds.add(userSafetyOfficerList![i].id.toString());
}
}
mExamSettingSubmitBo.aqyIds = aqyIds;
HttpUtils.getExamSettingSubmit(
context, mExamSettingSubmitBo)
.then((value) {
BaseModel bo = value;
if (mounted) {
setState(() {
ToastUtils.showCenter(bo.msg);
Get.back();
});
}
});
},
),
],
));
},
width: 300,
height: 40,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(10),
topRight: Radius.circular(20),
bottomLeft: Radius.circular(20),
bottomRight: Radius.circular(10)),
disable: false,
colors: const [ColorConst.blueColor, ColorConst.blue1Color],
child: const Text(
"提交",
style: TextStyle(fontSize: 14, color: ColorConst.whiteColor),
)));
}
}
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:special_equipment_flutter/dio/http_utils.dart';
import 'package:special_equipment_flutter/model/exam/exam_unit_list.dart';
import 'package:special_equipment_flutter/utils/storage_util.dart';
import 'package:special_equipment_flutter/widgets/app_bar/custom_app_bar.dart';
///单位选择
class UnitListPage extends StatefulWidget {
const UnitListPage({super.key});
@override
State<UnitListPage> createState() => _UnitListPageState();
}
class _UnitListPageState extends State<UnitListPage> {
List<OfficeList>? officeLists = [];
List<OfficeList>? filterOfficeLists = [];
@override
void initState() {
super.initState();
getUnitList();
}
///获取单位列表
void getUnitList() {
HttpUtils.getUnitList(context, StorageUtil.getInstance().getOfficeId())
.then((value) {
ExamUnitList listBo = value;
if (mounted) {
setState(() {
officeLists = listBo.officeList;
filterOfficeLists = officeLists;
});
}
});
}
void _filterData(String query) {
setState(() {
filterOfficeLists = officeLists!.where((OfficeList item) {
return item.name!.toLowerCase().contains(query.toLowerCase());
}).toList();
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBarCustom(text: '选择单位', height: 50),
body: Column(
children: [
const SizedBox(height: 10),
Container(
margin: const EdgeInsets.only(left: 10, right: 10),
decoration: BoxDecoration(
color: Colors.grey[200],
borderRadius: BorderRadius.circular(10),
),
child: Row(
children: [
IconButton(
icon: const Icon(Icons.search),
onPressed: () {
// 处理搜索逻辑
},
),
Expanded(
child: TextField(
onChanged: (value) {
_filterData(value);
},
decoration: const InputDecoration(
hintText: '请输入搜索关键字',
border: InputBorder.none,
),
),
),
],
),
),
const SizedBox(height: 10),
Flexible(
child: ListView.builder(
shrinkWrap: true,
padding:
const EdgeInsets.only(top: 0, left: 0, bottom: 0, right: 0),
itemCount: filterOfficeLists!.length,
// 列表项数量
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {
setState(() {
Get.back(result: filterOfficeLists![index]);
});
},
child: Container(
padding: const EdgeInsets.only(
left: 30, right: 15, top: 10, bottom: 10),
child: Text(
filterOfficeLists![index].name!,
style: const TextStyle(fontSize: 18),
),
),
);
},
),
),
],
),
);
}
}
...@@ -344,7 +344,11 @@ class _UserSettingsPageState extends State<UserSettingsPage> { ...@@ -344,7 +344,11 @@ class _UserSettingsPageState extends State<UserSettingsPage> {
GestureDetector( GestureDetector(
onTap: () { onTap: () {
setState(() { setState(() {
if (newList[index].name == '公司账户') {
newList[index].check = !newList[index].check!; newList[index].check = !newList[index].check!;
} else {
newList[index].check = !newList[index].check!;
}
///如果取消身份勾选,将当前身份下的已选中设备全部取消勾选 ///如果取消身份勾选,将当前身份下的已选中设备全部取消勾选
if (!newList[index].check!) { if (!newList[index].check!) {
...@@ -641,10 +645,14 @@ class _UserSettingsPageState extends State<UserSettingsPage> { ...@@ -641,10 +645,14 @@ class _UserSettingsPageState extends State<UserSettingsPage> {
children: [ children: [
GestureDetector( GestureDetector(
onTap: () { onTap: () {
if (!roleNames().contains('公司账户')) {
setState(() { setState(() {
if (!roleNames().contains('公司账户')) {
if (editList!.roleDtoList![index].name == '公司账户') {
editList!.roleDtoList![index].check = false;
} else {
editList!.roleDtoList![index].check = editList!.roleDtoList![index].check =
!editList!.roleDtoList![index].check!; !editList!.roleDtoList![index].check!;
}
///如果取消身份勾选,将当前身份下的已选中设备全部取消勾选 ///如果取消身份勾选,将当前身份下的已选中设备全部取消勾选
if (!editList!.roleDtoList![index].check!) { if (!editList!.roleDtoList![index].check!) {
...@@ -653,8 +661,8 @@ class _UserSettingsPageState extends State<UserSettingsPage> { ...@@ -653,8 +661,8 @@ class _UserSettingsPageState extends State<UserSettingsPage> {
item.check = false; item.check = false;
} }
} }
});
} }
});
}, },
child: Padding( child: Padding(
padding: const EdgeInsets.only( padding: const EdgeInsets.only(
......
import 'package:event_bus/event_bus.dart';
///event bus
class EventBusUtils {
static EventBus? _eventBus;
static EventBus? getInstance() {
_eventBus ??= EventBus();
return _eventBus;
}
}
...@@ -12,7 +12,7 @@ class AppBarCustom extends StatelessWidget implements PreferredSizeWidget { ...@@ -12,7 +12,7 @@ class AppBarCustom extends StatelessWidget implements PreferredSizeWidget {
///标题颜色 ///标题颜色
var textColor; var textColor;
///背景色 ///背景色
var bgColor; var bgColor;
///icon颜色 ///icon颜色
......
// ignore_for_file: prefer_typing_uninitialized_variables, must_be_immutable
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:special_equipment_flutter/common/color_const.dart';
///全局统一appbar
class AppBarCustom extends StatelessWidget implements PreferredSizeWidget {
Widget? leading;
///标题内容
var text;
///标题颜色
var textColor;
///背景色
var bgColor;
///icon颜色
var iconColor;
double height;
List<Widget>? actions = [];
PreferredSizeWidget? bottom;
AppBarCustom(
{super.key,
this.leading,
this.text,
this.textColor,
this.bgColor,
this.iconColor,
required this.height,
this.bottom,
this.actions});
@override
Widget build(BuildContext context) {
return buildAppBar(context);
}
AppBar buildAppBar(BuildContext context) {
return AppBar(
backgroundColor: bgColor ?? ColorConst.blueColor,
leading: leading,
elevation: 0,
shadowColor: ColorConst.greyF8Color,
actions: actions,
/// 这里设置标题的左边距为零
titleSpacing: 0.0,
title: Container(
alignment: Alignment.centerLeft,
child: Text(
text,
style: TextStyle(
color: textColor ?? ColorConst.whiteColor, fontSize: 18),
),
),
bottom: bottom,
);
}
@override
Size get preferredSize => Size(100, height); //写啥没差,自动采用子视图尺寸
}
...@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev ...@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts # In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix. # of the product and file versions while build-number is used as the build suffix.
version: 1.0.4+4 version: 1.0.5+5
environment: environment:
sdk: '>=3.1.3 <4.0.0' sdk: '>=3.1.3 <4.0.0'
...@@ -55,6 +55,8 @@ dependencies: ...@@ -55,6 +55,8 @@ dependencies:
flutter_treeview: ^1.0.7+1 flutter_treeview: ^1.0.7+1
flutter_image_compress: ^2.1.0 flutter_image_compress: ^2.1.0
flutter_bmflocation: ^3.5.0 flutter_bmflocation: ^3.5.0
sliding_up_panel: ^2.0.0+1
event_bus: ^2.0.0
# geolocator: ^7.1.0 # geolocator: ^7.1.0
...@@ -123,6 +125,17 @@ flutter: ...@@ -123,6 +125,17 @@ flutter:
- assets/home/select_check_blue.png - assets/home/select_check_blue.png
- assets/home/select_check_orange.png - assets/home/select_check_orange.png
- assets/spalsh.jpeg - assets/spalsh.jpeg
- assets/examine/examine_history_icon.png
- assets/examine/examine_icon.png
- assets/examine/examine_test_icon.png
- assets/examine/exam_title_icon.png
- assets/examine/check_title_icon.png
- assets/examine/answer_sheet_icon.png
- assets/examine/answer_sheet_black_icon.png
- assets/examine/pass_icon.png
- assets/examine/no_pass_icon.png
- assets/examine/examine_gary_icon.png
# An image asset can refer to one or more resolution-specific "variants", see # An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware # https://flutter.dev/assets-and-images/#resolution-aware
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment