对接考勤相关接口

规程管理添加文件查看功能
hmxc
张萌 3 years ago
parent ecd0f7085f
commit 59581ad737

@ -9,6 +9,7 @@ class API {
static String get resource => '$host/static';
static String image(String path) => '$resource$path';
static String file(String path) => '$resource$path';
static const int networkTimeOut = 10000;
static _Auth auth = _Auth();
@ -230,6 +231,21 @@ class _Manage {
///app
String get submitFacilitiesCheckInfo => '/user/facilitiesCheck/submitCheck';
///app
String get todayClockRecord => '/user/attendance/todayClockRecord';
///app
String get clockInOut => '/user/attendance/clock';
///app
String get clockRecord => '/user/attendance/clockRecord';
///app /
String get clockApplyRecord => '/user/attendance/applyRecord';
///app /
String get clockApply => '/user/attendance/apply';
}
class _Upload {

@ -0,0 +1,104 @@
import 'package:aku_community_manager/style/app_style.dart';
import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
class ClockApplyRecordListModel {
int id;
String reason;
int status;
int type;
String startDate;
String endDate;
String createName;
String createTel;
String createDate;
String reviewerName;
String reviewerDate;
ClockApplyRecordListModel(
{this.id,
this.reason,
this.status,
this.type,
this.startDate,
this.endDate,
this.createName,
this.createTel,
this.createDate,
this.reviewerName,
this.reviewerDate});
ClockApplyRecordListModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
reason = json['reason'];
status = json['status'];
type = json['type'];
startDate = json['startDate'];
endDate = json['endDate'];
createName = json['createName'];
createTel = json['createTel'];
createDate = json['createDate'];
reviewerName = json['reviewerName'];
reviewerDate = json['reviewerDate'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['reason'] = this.reason;
data['status'] = this.status;
data['type'] = this.type;
data['startDate'] = this.startDate;
data['endDate'] = this.endDate;
data['createName'] = this.createName;
data['createTel'] = this.createTel;
data['createDate'] = this.createDate;
data['reviewerName'] = this.reviewerName;
data['reviewerDate'] = this.reviewerDate;
return data;
}
String get typeString {
switch (this.type) {
case 1:
return '请假';
case 2:
return '加班';
default:
return '未知';
}
}
String get statusString {
switch (this.status) {
case 1:
return '待审核';
case 2:
return '审核通过';
case 3:
return '审核驳回';
default:
return '未知';
}
}
Color get statusColor {
switch (this.status) {
case 1:
return kPrimaryColor;
case 2:
return Colors.green;
case 3:
return Colors.red;
default:
return Colors.black;
}
}
String get startTimeString =>
DateUtil.formatDateStr(this.startDate, format: 'yyyy-MM-dd HH:mm');
String get endTimeString =>
DateUtil.formatDateStr(this.endDate, format: 'yyyy-MM-dd HH:mm');
String get applyTimeString =>
DateUtil.formatDateStr(this.createDate, format: 'yyyy-MM-dd HH:mm:ss');
}

@ -0,0 +1,58 @@
import 'package:aku_community_manager/utils/weekdays_to_chinese.dart';
import 'package:common_utils/common_utils.dart';
class ClockRecordListModel {
int id;
String startClockDate;
String endClockDate;
String cardReplacementDate;
String operatorName;
String clockName;
String clockTel;
String createDate;
ClockRecordListModel(
{this.id,
this.startClockDate,
this.endClockDate,
this.cardReplacementDate,
this.operatorName,
this.clockName,
this.clockTel,
this.createDate});
ClockRecordListModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
startClockDate = json['startClockDate'];
endClockDate = json['endClockDate'];
cardReplacementDate = json['cardReplacementDate'];
operatorName = json['operatorName'];
clockName = json['clockName'];
clockTel = json['clockTel'];
createDate = json['createDate'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['startClockDate'] = this.startClockDate;
data['endClockDate'] = this.endClockDate;
data['cardReplacementDate'] = this.cardReplacementDate;
data['operatorName'] = this.operatorName;
data['clockName'] = this.clockName;
data['clockTel'] = this.clockTel;
data['createDate'] = this.createDate;
return data;
}
String get startClockString =>
DateUtil.formatDateStr(this.startClockDate, format: 'HH:mm:ss');
String get endClockString =>
DateUtil.formatDateStr(this.endClockDate, format: 'HH:mm:ss');
String get clockDateString =>
DateUtil.formatDateStr(this.startClockDate, format: 'yyyy.MM.dd');
String get weekDay => WeekDaysToChinese.fromInt(
DateUtil.getDateTime(this.startClockDate).weekday);
}

@ -0,0 +1,49 @@
import 'package:common_utils/common_utils.dart';
class TodayClockRecordModel {
int id;
String startClockDate;
String endClockDate;
String cardReplacementDate;
String operatorName;
String clockName;
String clockTel;
String createDate;
TodayClockRecordModel(
{this.id,
this.startClockDate,
this.endClockDate,
this.cardReplacementDate,
this.operatorName,
this.clockName,
this.clockTel,
this.createDate});
TodayClockRecordModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
startClockDate = json['startClockDate'];
endClockDate = json['endClockDate'];
cardReplacementDate = json['cardReplacementDate'];
operatorName = json['operatorName'];
clockName = json['clockName'];
clockTel = json['clockTel'];
createDate = json['createDate'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['startClockDate'] = this.startClockDate;
data['endClockDate'] = this.endClockDate;
data['cardReplacementDate'] = this.cardReplacementDate;
data['operatorName'] = this.operatorName;
data['clockName'] = this.clockName;
data['clockTel'] = this.clockTel;
data['createDate'] = this.createDate;
return data;
}
DateTime get clockInTime => DateUtil.getDateTime(this.startClockDate);
DateTime get clockOutTime => DateUtil.getDateTime(this.endClockDate);
}

@ -4,14 +4,24 @@ class RulesManageListModel {
int id;
String title;
String content;
String fileDocUrl;
String fileDocName;
String releaseDate;
RulesManageListModel({this.id, this.title, this.content, this.releaseDate});
RulesManageListModel(
{this.id,
this.title,
this.content,
this.fileDocUrl,
this.fileDocName,
this.releaseDate});
RulesManageListModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
title = json['title'];
content = json['content'];
fileDocUrl = json['fileDocUrl'];
fileDocName = json['fileDocName'];
releaseDate = json['releaseDate'];
}
@ -20,6 +30,8 @@ class RulesManageListModel {
data['id'] = this.id;
data['title'] = this.title;
data['content'] = this.content;
data['fileDocUrl'] = this.fileDocUrl;
data['fileDocName'] = this.fileDocName;
data['releaseDate'] = this.releaseDate;
return data;
}

@ -0,0 +1,53 @@
import 'package:aku_community_manager/const/api.dart';
import 'package:aku_community_manager/models/manager/clock_in_out/today_clock_record_model.dart';
import 'package:aku_community_manager/utils/network/base_model.dart';
import 'package:aku_community_manager/utils/network/net_util.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:common_utils/common_utils.dart';
class ClockFunc {
static Future initClockInfo() async {
BaseModel baseModel = await NetUtil().get(API.manage.todayClockRecord);
if (baseModel.status && baseModel.data != null) {
return TodayClockRecordModel.fromJson(baseModel.data);
} else {
BotToast.showText(text: baseModel.message);
}
}
static Future clockIn(int id, DateTime dateTime) async {
BaseModel baseModel = await NetUtil().post(
API.manage.clockInOut,
params: {
"id": id,
"startClockDate":
DateUtil.formatDate(dateTime, format: 'yyyy-MM-dd HH:mm:ss'),
},
showMessage: true,
);
}
static Future clockOut(int id, DateTime dateTime) async {
BaseModel baseModel = await NetUtil().post(API.manage.clockInOut,
params: {
"id": id,
"endClockDate":
DateUtil.formatDate(dateTime, format: 'yyyy-MM-dd HH:mm:ss'),
},
showMessage: true);
}
static Future clockApply(
String reason, int type, DateTime start, DateTime end) async {
BaseModel baseModel = await NetUtil().post(API.manage.clockApply,
params: {
"reason": reason,
'type': type,
"startDate":
DateUtil.formatDate(start, format: 'yyyy-MM-dd HH:mm:ss'),
"endDate": DateUtil.formatDate(end, format: 'yyyy-MM-dd HH:mm:ss')
},
showMessage: true);
return baseModel.status;
}
}

@ -1,3 +1,4 @@
import 'package:aku_community_manager/models/manager/clock_in_out/clock_apply_record_list_model.dart';
import 'package:aku_community_manager/style/app_style.dart';
import 'package:aku_community_manager/tools/aku_divider.dart';
import 'package:flutter/material.dart';
@ -6,7 +7,8 @@ import 'package:velocity_x/velocity_x.dart';
import 'package:aku_community_manager/tools/extensions/list_extension_tool.dart';
class ClockInOutApplyCard extends StatefulWidget {
ClockInOutApplyCard({Key key}) : super(key: key);
final ClockApplyRecordListModel model;
ClockInOutApplyCard({Key key, this.model}) : super(key: key);
@override
_ClockInOutApplyCardState createState() => _ClockInOutApplyCardState();
@ -25,9 +27,17 @@ class _ClockInOutApplyCardState extends State<ClockInOutApplyCard> {
children: [
Row(
children: [
'Name'.text.size(32.sp).color(kTextPrimaryColor).bold.make(),
widget.model.typeString.text
.size(32.sp)
.color(kTextPrimaryColor)
.bold
.make(),
Spacer(),
'待审核'.text.size(28.sp).bold.color(kPrimaryColor).make()
widget.model.statusString.text
.size(28.sp)
.bold
.color(widget.model.statusColor)
.make()
],
),
16.w.heightBox,
@ -35,18 +45,16 @@ class _ClockInOutApplyCardState extends State<ClockInOutApplyCard> {
24.w.heightBox,
...<Widget>[
_rowTile(
R.ASSETS_MANAGE_IC_RENWU_PNG,
R.ASSETS_MANAGE_IC_TIME_PNG,
'开始时间',
'2021-05-19 10:00:00'
.text
widget.model.startTimeString.text
.size(24.sp)
.color(kTextSubColor)
.make()),
_rowTile(
R.ASSETS_MANAGE_LOCK_PNG,
R.ASSETS_MANAGE_IC_TIME_PNG,
'结束时间',
'2021-05-19 10:00:00'
.text
widget.model.endTimeString.text
.size(24.sp)
.color(kTextSubColor)
.make()),
@ -67,23 +75,22 @@ class _ClockInOutApplyCardState extends State<ClockInOutApplyCard> {
160.w.widthBox,
Row(
children: [
'弟弟结婚,需要回趟家帮忙张罗婚礼的筹备'
.text
widget.model.reason.text
.size(24.sp)
.maxLines(2)
.overflow(TextOverflow.ellipsis)
.align(TextAlign.end)
.color(kTextSubColor)
.make().expand()
.make()
.expand()
],
).expand()
],
),
_rowTile(
R.ASSETS_MANAGE_LOCK_PNG,
R.ASSETS_MANAGE_IC_TIME_PNG,
'申请时间',
'2021-05-19 10:00:00'
.text
widget.model.applyTimeString.text
.size(24.sp)
.color(kTextSubColor)
.make()),

@ -1,8 +1,10 @@
import 'dart:async';
import 'package:aku_community_manager/models/manager/clock_in_out/today_clock_record_model.dart';
import 'package:aku_community_manager/provider/app_provider.dart';
import 'package:aku_community_manager/style/app_style.dart';
import 'package:aku_community_manager/tools/user_tool.dart';
import 'package:aku_community_manager/ui/manage_pages/clock_in_out/clock_func.dart';
import 'package:aku_community_manager/utils/weekdays_to_chinese.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:common_utils/common_utils.dart';
@ -19,10 +21,11 @@ class ClockInOutMainPage extends StatefulWidget {
_ClockInOutMainPageState createState() => _ClockInOutMainPageState();
}
class _ClockInOutMainPageState extends State<ClockInOutMainPage> {
class _ClockInOutMainPageState extends State<ClockInOutMainPage> with AutomaticKeepAliveClientMixin {
EasyRefreshController _refreshController;
Timer _clockSetState;
DateTime _lastPressed;
TodayClockRecordModel _model;
bool get canTap {
if (_lastPressed == null ||
DateTime.now().difference(_lastPressed) > Duration(seconds: 15)) {
@ -42,7 +45,6 @@ class _ClockInOutMainPageState extends State<ClockInOutMainPage> {
_clockSetState = Timer.periodic(Duration(seconds: 1), (_timer) {
setState(() {});
});
UserTool.appProvider.initClock();
}
@override
@ -59,7 +61,24 @@ class _ClockInOutMainPageState extends State<ClockInOutMainPage> {
firstRefresh: true,
header: MaterialHeader(),
controller: _refreshController,
onRefresh: () async {},
onRefresh: () async {
UserTool.appProvider.initClock();
_model = await ClockFunc.initClockInfo();
if (_model != null) {
UserTool.appProvider.resetClock(); //
if (_model.startClockDate != null) {
//
UserTool.appProvider.setClockInTime(_model.clockInTime);
}
if (_model.endClockDate != null) {
//
UserTool.appProvider.setClockOutTime(_model.clockOutTime);
}
}
setState(() {});
},
child: Container(
margin: EdgeInsets.all(32.w),
padding: EdgeInsets.all(32.w),
@ -96,14 +115,18 @@ class _ClockInOutMainPageState extends State<ClockInOutMainPage> {
);
}
/// WORKCLOCK
clockInOut() {
DateTime _currentTime = DateTime.now();
switch (UserTool.appProvider.clockStatus) {
case WORKCLOCK.NOTIN:
UserTool.appProvider.setClockInTime(DateTime.now());
ClockFunc.clockIn(_model.id, _currentTime);
UserTool.appProvider.setClockInTime(_currentTime);
BotToast.showText(text: '上班打卡成功');
break;
case WORKCLOCK.IN:
UserTool.appProvider.setClockOutTime(DateTime.now());
ClockFunc.clockOut(_model.id, _currentTime);
UserTool.appProvider.setClockOutTime(_currentTime);
BotToast.showText(text: '下班打卡成功');
break;
case WORKCLOCK.OUT:
@ -227,4 +250,7 @@ class _ClockInOutMainPageState extends State<ClockInOutMainPage> {
}
return '$_hour小时$_min分钟';
}
@override
bool get wantKeepAlive => true;
}

@ -1,11 +1,12 @@
import 'package:aku_community_manager/models/manager/clock_in_out/clock_record_list_model.dart';
import 'package:aku_community_manager/style/app_style.dart';
import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:velocity_x/velocity_x.dart';
class ClockInOutRecordCard extends StatefulWidget {
ClockInOutRecordCard({Key key}) : super(key: key);
final ClockRecordListModel model;
ClockInOutRecordCard({Key key, this.model}) : super(key: key);
@override
_ClockInOutRecordCardState createState() => _ClockInOutRecordCardState();
@ -24,15 +25,18 @@ class _ClockInOutRecordCardState extends State<ClockInOutRecordCard> {
children: [
Row(
children: [
'2021.05.19'
.text
widget.model.clockDateString.text
.size(28.sp)
.bold
.color(kTextPrimaryColor)
.bold
.make(),
Spacer(),
'周三'.text.size(32.sp).bold.color(kTextPrimaryColor).make(),
widget.model.weekDay.text
.size(32.sp)
.bold
.color(kTextPrimaryColor)
.make(),
],
),
40.w.heightBox,
@ -48,12 +52,14 @@ class _ClockInOutRecordCardState extends State<ClockInOutRecordCard> {
width: 16.w,
height: 16.w,
decoration: BoxDecoration(
color: Color(0xFF3F8FFE),
color: widget.model.startClockDate == null
? Color(0xFFE60E0E)
: Color(0xFF3F8FFE),
borderRadius: BorderRadius.circular(8.w),
),
),
8.w.widthBox,
'上班打卡时间'
(widget.model.startClockDate == null ? '上班未打卡' : '上班打卡时间')
.text
.size(28.sp)
.color(kTextPrimaryColor)
@ -61,19 +67,22 @@ class _ClockInOutRecordCardState extends State<ClockInOutRecordCard> {
.make(),
],
),
16.w.heightBox,
Row(
children: [
24.w.widthBox,
(DateUtil.formatDateStr('2020-10-11 08:24:30',
format: 'HH:mm:ss'))
.text
.size(32.sp)
.color(kTextPrimaryColor)
.bold
.make(),
],
),
...widget.model.startClockDate == null
? []
: [
16.w.heightBox,
Row(
children: [
24.w.widthBox,
(widget.model.startClockString)
.text
.size(32.sp)
.color(kTextPrimaryColor)
.bold
.make(),
],
),
]
],
),
130.w.widthBox,
@ -86,12 +95,14 @@ class _ClockInOutRecordCardState extends State<ClockInOutRecordCard> {
width: 16.w,
height: 16.w,
decoration: BoxDecoration(
color: Color(0xFF3F8FFE),
color: widget.model.startClockDate == null
? Color(0xFFE60E0E)
: Color(0xFF3F8FFE),
borderRadius: BorderRadius.circular(8.w),
),
),
8.w.widthBox,
'下班打卡时间'
(widget.model.startClockDate == null ? '下班未打卡' : '下班打卡时间')
.text
.size(28.sp)
.color(kTextPrimaryColor)
@ -99,18 +110,21 @@ class _ClockInOutRecordCardState extends State<ClockInOutRecordCard> {
.make(),
],
),
16.w.heightBox,
Row(
children: [
24.w.widthBox,
DateUtil.formatDateStr('08:24:09', format: 'HH:mm:ss')
.text
.size(32.sp)
.color(kTextPrimaryColor)
.bold
.make(),
],
),
...widget.model.startClockDate == null
? []
: [
16.w.heightBox,
Row(
children: [
24.w.widthBox,
widget.model.endClockString.text
.size(32.sp)
.color(kTextPrimaryColor)
.bold
.make(),
],
),
]
],
),
],

@ -1,7 +1,13 @@
import 'package:aku_community_manager/const/api.dart';
import 'package:aku_community_manager/models/manager/clock_in_out/clock_apply_record_list_model.dart';
import 'package:aku_community_manager/models/manager/clock_in_out/clock_record_list_model.dart';
import 'package:aku_community_manager/ui/manage_pages/clock_in_out/clock_in_out_apply_card.dart';
import 'package:aku_community_manager/ui/manage_pages/clock_in_out/clock_in_out_record_card.dart';
import 'package:aku_community_manager/ui/widgets/common/bee_list_view.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:velocity_x/velocity_x.dart';
class ClockInOutView extends StatefulWidget {
final int index;
@ -12,20 +18,71 @@ class ClockInOutView extends StatefulWidget {
}
class _ClockInOutViewState extends State<ClockInOutView> {
EasyRefreshController _refreshController;
@override
void initState() {
super.initState();
_refreshController = EasyRefreshController();
}
@override
void dispose() {
_refreshController?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return widget.index == 1
? ListView(
padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 32.w),
children: [
ClockInOutRecordCard(),
],
)
: ListView(
padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 32.w),
children: [
ClockInOutApplyCard(),
],
);
return _getView();
}
_getView() {
switch (widget.index) {
case 1:
return BeeListView(
path: API.manage.clockRecord,
controller: _refreshController,
convert: (models) {
return models.tableList
.map((e) => ClockRecordListModel.fromJson(e))
.toList();
},
builder: (items) {
return ListView.separated(
padding: EdgeInsets.all(32.w),
itemBuilder: (context, index) {
return ClockInOutRecordCard(
model: items[index],
);
},
separatorBuilder: (_, __) {
return 24.w.heightBox;
},
itemCount: items.length);
});
case 2:
return BeeListView(
path: API.manage.clockApplyRecord,
controller: _refreshController,
convert: (models) {
return models.tableList
.map((e) => ClockApplyRecordListModel.fromJson(e))
.toList();
},
builder: (items) {
return ListView.separated(
padding: EdgeInsets.all(32.w),
itemBuilder: (context, index) {
return ClockInOutApplyCard(
model: items[index],
);
},
separatorBuilder: (_, __) {
return 24.w.heightBox;
},
itemCount: items.length);
});
default:
}
}
}

@ -1,5 +1,6 @@
import 'package:aku_community_manager/style/app_style.dart';
import 'package:aku_community_manager/tools/aku_divider.dart';
import 'package:aku_community_manager/ui/manage_pages/clock_in_out/clock_func.dart';
import 'package:aku_community_manager/ui/widgets/app_widgets/aku_single_check_button.dart';
import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart';
import 'package:aku_community_manager/ui/widgets/common/bee_date_picker.dart';
@ -9,6 +10,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:velocity_x/velocity_x.dart';
class WorkApplyPage extends StatefulWidget {
@ -21,25 +23,25 @@ class WorkApplyPage extends StatefulWidget {
class _WorkApplyPageState extends State<WorkApplyPage> {
int _type = 1; //1 2
TextEditingController _nameController;
TextEditingController _positionController;
TextEditingController _phoneController;
DateTime _beginTime ;
DateTime _endTime ;
// TextEditingController _nameController;
// TextEditingController _positionController;
TextEditingController _reasonController;
DateTime _beginTime;
DateTime _endTime;
@override
void initState() {
super.initState();
_nameController = TextEditingController();
_positionController = TextEditingController();
_phoneController = TextEditingController();
// _nameController = TextEditingController();
// _positionController = TextEditingController();
_reasonController = TextEditingController();
}
@override
void dispose() {
_nameController?.dispose();
_positionController?.dispose();
_phoneController?.dispose();
// _nameController?.dispose();
// _positionController?.dispose();
_reasonController?.dispose();
super.dispose();
}
@ -52,15 +54,19 @@ class _WorkApplyPageState extends State<WorkApplyPage> {
padding: EdgeInsets.all(32.w),
children: [
_headType(),
_inputRowTile('姓名', _nameController),
_inputRowTile('职位', _positionController),
_inputRowTile('联系方式', _phoneController),
_inputRowTile('理由', _reasonController),
_timePick(),
],
),
bottom: AkuBottomButton(
title: '确认提交',
onTap: () {},
onTap: () async {
bool _result = await ClockFunc.clockApply(
_reasonController.text, _type, _beginTime, _endTime);
if (_result) {
Get.back();
}
},
),
);
}
@ -151,7 +157,7 @@ class _WorkApplyPageState extends State<WorkApplyPage> {
: _beginTime,
max: _beginTime == null
? DateTime.now().add(Duration(days: 1))
: (_beginTime).add(Duration(days: 1)),
: (_beginTime).add(Duration(days: 7)),
mode: CupertinoDatePickerMode.dateAndTime,
);
if (date != null) {

@ -1,10 +1,15 @@
import 'package:aku_community_manager/models/manager/rules_manage/rules_manage_list_model.dart';
import 'package:aku_community_manager/style/app_style.dart';
import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart';
import 'package:aku_community_manager/ui/widgets/common/bee_download_view.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:open_file/open_file.dart';
import 'package:velocity_x/velocity_x.dart';
import 'package:aku_community_manager/const/resource.dart';
class RulesManageDetailPage extends StatefulWidget {
final RulesManageListModel model;
@ -21,57 +26,105 @@ class _RulesManageDetailPageState extends State<RulesManageDetailPage> {
return AkuScaffold(
backgroundColor: Colors.white,
title: '规程管理',
body: ListView(
padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 32.w),
children: [
_detailModel.title.text
.size(32.sp)
.color(kTextPrimaryColor)
.bold
.align(TextAlign.center)
.make(),
24.w.heightBox,
SizedBox(
width: double.infinity,
child: _detailModel.content.text
.size(28.sp)
body: Stack(
children:[ ListView(
padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 32.w),
children: [
_detailModel.title.text
.size(32.sp)
.color(kTextPrimaryColor)
.bold
.align(TextAlign.center)
.make(),
// child: RichText(
// text: TextSpan(
// children: List.generate(_parasedText.length, (index) {
// if (index.isEven) {
// return TextSpan(
// text: _parasedText[index],
// style: TextStyle(fontSize: 28.sp, color: ktextPrimary),
// );
// } else {
// return TextSpan(
// text: _parasedText[index],
// style: TextStyle(
// fontSize: 28.sp,
// color: Colors.lightBlue,
// ),
// recognizer: _tapLinkUrlLancher
// ..onTap = () {
// launch(_parasedText[index]);
// });
// }
// })),
// ),
),
40.w.heightBox,
Row(
children: [
Spacer(),
'发布于 ${DateUtil.formatDateStr(_detailModel.releaseDate, format: 'MM-dd HH:mm')}'
.text
.size(24.sp)
.color(kTextSubColor)
24.w.heightBox,
SizedBox(
width: double.infinity,
child: _detailModel.content.text
.size(28.sp)
.color(kTextPrimaryColor)
.make(),
],
)
],
// child: RichText(
// text: TextSpan(
// children: List.generate(_parasedText.length, (index) {
// if (index.isEven) {
// return TextSpan(
// text: _parasedText[index],
// style: TextStyle(fontSize: 28.sp, color: ktextPrimary),
// );
// } else {
// return TextSpan(
// text: _parasedText[index],
// style: TextStyle(
// fontSize: 28.sp,
// color: Colors.lightBlue,
// ),
// recognizer: _tapLinkUrlLancher
// ..onTap = () {
// launch(_parasedText[index]);
// });
// }
// })),
// ),
),
40.w.heightBox,
Row(
children: [
Spacer(),
'发布于 ${DateUtil.formatDateStr(_detailModel.releaseDate, format: 'MM-dd HH:mm')}'
.text
.size(24.sp)
.color(kTextSubColor)
.make(),
],
),
// docView(
// widget.model?.fileDocName ?? '', widget.model?.fileDocUrl ?? '')
],
),
Positioned(
bottom: MediaQuery.of(context).padding.bottom+88.w,
left: 32.w,
right: 32.w,
child: docView(
widget.model?.fileDocName ?? '', widget.model?.fileDocUrl ?? '') ),
]
),
);
}
Widget docView(String title, String path) {
// if (title?.isEmpty ?? true) return SizedBox();
return Container(
// margin: EdgeInsets.only(right: 113.w),
alignment: Alignment.centerLeft,
child: MaterialButton(
minWidth: 606.w,
height: 154.w,
padding: EdgeInsets.symmetric(horizontal: 32.w),
child: Row(
children: [
title.text.size(32.sp).make().expand(),
Image.asset(
R.ASSETS_MANAGE_IC_RENWU_PNG,
height: 52.w,
width: 52.w,
),
],
),
onPressed: path.isEmptyOrNull
? () {
BotToast.showText(text: '文件为空!');
}
: () async {
String result = await Get.dialog(BeeDownloadView(file: path));
if (result != null) OpenFile.open(result);
},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.w),
side: BorderSide(color: Color(0xFFD4CFBE)),
),
color: Colors.white,
),
);
}

@ -0,0 +1,63 @@
import 'dart:io';
import 'package:aku_community_manager/const/api.dart';
import 'package:flutter/material.dart';
import 'package:dio/dio.dart';
import 'package:get/get.dart';
import 'package:path_provider/path_provider.dart';
class BeeDownloadView extends StatefulWidget {
final String file;
BeeDownloadView({Key key, this.file}) : super(key: key);
@override
_BeeDownloadViewState createState() => _BeeDownloadViewState();
}
class _BeeDownloadViewState extends State<BeeDownloadView> {
Dio dio = Dio();
double progress;
Future download() async {
Directory dir = await getApplicationDocumentsDirectory();
Directory docPath = Directory('${dir.path}/docs');
if (!await (docPath.exists())) {
await docPath.create();
}
await Future.delayed(Duration(milliseconds: 500));
await dio.download(
API.file(widget.file),
'${docPath.path}/${widget.file.split('/').last}',
onReceiveProgress: (start, all) {
setState(() {
progress = start / all;
});
print('$start,$all');
},
);
Get.back(result: '${docPath.path}/${widget.file.split('/').last}');
}
@override
void initState() {
super.initState();
download();
}
@override
Widget build(BuildContext context) {
return Center(
child: Container(
width: 100,
height: 100,
alignment: Alignment.center,
child: CircularProgressIndicator(value: progress),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white,
),
),
);
}
}

@ -19,4 +19,25 @@ class WeekDaysToChinese {
return '未知';
}
}
static String fromInt(int weekday) {
switch (weekday) {
case 1:
return '周一';
case 2:
return '周二';
case 3:
return '周三';
case 4:
return '周四';
case 5:
return '周五';
case 6:
return '周六';
case 7:
return '周日';
default:
return '未知';
}
}
}

@ -655,6 +655,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.0"
open_file:
dependency: "direct main"
description:
name: open_file
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.2.1"
package_config:
dependency: transitive
description:

@ -71,6 +71,8 @@ dependencies:
shimmer: ^2.0.0-nullsafety.0
badges: ^2.0.0-nullsafety.1
equatable: ^2.0.0
#打开文件
open_file: ^3.2.1
dev_dependencies:
flutter_test:

Loading…
Cancel
Save