476 lines
17 KiB
Dart
476 lines
17 KiB
Dart
|
|
import 'dart:convert';
|
|||
|
|
import 'package:flutter/material.dart';
|
|||
|
|
import 'package:qhd_prevention/constants/app_enums.dart';
|
|||
|
|
import 'package:qhd_prevention/customWidget/ItemWidgetFactory.dart';
|
|||
|
|
import 'package:qhd_prevention/customWidget/bottom_picker.dart';
|
|||
|
|
import 'package:qhd_prevention/customWidget/custom_button.dart';
|
|||
|
|
import 'package:qhd_prevention/customWidget/item_list_widget.dart';
|
|||
|
|
import 'package:qhd_prevention/customWidget/photo_picker_row.dart';
|
|||
|
|
import 'package:qhd_prevention/customWidget/toast_util.dart';
|
|||
|
|
import 'package:qhd_prevention/http/ApiService.dart';
|
|||
|
|
import 'package:qhd_prevention/pages/main_tab.dart';
|
|||
|
|
import 'package:qhd_prevention/pages/my_appbar.dart';
|
|||
|
|
import 'package:qhd_prevention/services/SessionService.dart';
|
|||
|
|
import 'package:qhd_prevention/tools/tools.dart';
|
|||
|
|
|
|||
|
|
class UnitJoinDetailPage extends StatefulWidget {
|
|||
|
|
const UnitJoinDetailPage({super.key, required this.firmId});
|
|||
|
|
final String firmId;
|
|||
|
|
@override
|
|||
|
|
State<UnitJoinDetailPage> createState() => _UnitJoinDetailPageState();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
class _UnitJoinDetailPageState extends State<UnitJoinDetailPage> {
|
|||
|
|
Map<String, dynamic> pd = {
|
|||
|
|
};
|
|||
|
|
late bool _isEdit;
|
|||
|
|
|
|||
|
|
String _genderText = '';
|
|||
|
|
String _birthText = '';
|
|||
|
|
List<String> _idCardImgList = [];
|
|||
|
|
List<String> _idCartImgIds = [];
|
|||
|
|
List<String> _idCardImgRemoveList = [];
|
|||
|
|
|
|||
|
|
List<dynamic> _wenhuachengduList = [];
|
|||
|
|
List<dynamic> _zhengzhimianmaoList = [];
|
|||
|
|
List<dynamic> _hunyinList = [
|
|||
|
|
{"name": "已婚", "value": 1},
|
|||
|
|
{"name": "未婚", "value": 0},
|
|||
|
|
];
|
|||
|
|
List<String> idPhotos = [];
|
|||
|
|
|
|||
|
|
@override
|
|||
|
|
void initState() {
|
|||
|
|
super.initState();
|
|||
|
|
_isEdit = false;
|
|||
|
|
_getUserDetail();
|
|||
|
|
|
|||
|
|
_getKeyValues();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Future<void> _getUserDetail() async {
|
|||
|
|
final res = await BasicInfoApi.getFirmInfo(
|
|||
|
|
widget.firmId,
|
|||
|
|
);
|
|||
|
|
if (res['success']) {
|
|||
|
|
final data = res['data'];
|
|||
|
|
_genderText = data['sex'] ?? '';
|
|||
|
|
_birthText = data['birthday'] ?? '';
|
|||
|
|
final eqForeignKey = data['userId'];
|
|||
|
|
await FileApi.getImagePathWithType(
|
|||
|
|
eqForeignKey,
|
|||
|
|
'',
|
|||
|
|
UploadFileType.idCardPhoto,
|
|||
|
|
).then((result) {
|
|||
|
|
if (result['success']) {
|
|||
|
|
List files = result['data'] ?? [];
|
|||
|
|
_idCardImgList =
|
|||
|
|
files.map((item) => item['filePath'].toString()).toList();
|
|||
|
|
_idCartImgIds = files.map((item) => item['id'].toString()).toList();
|
|||
|
|
// final filePath = fileData.first['filePath'] ?? '';
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
setState(() {
|
|||
|
|
pd = data;
|
|||
|
|
try{
|
|||
|
|
final idCardBase64 = utf8.decode(base64.decode(pd['userIdCard']));
|
|||
|
|
if (idCardBase64.isNotEmpty) {
|
|||
|
|
pd['userIdCard'] =idCardBase64;
|
|||
|
|
}
|
|||
|
|
}catch(e){
|
|||
|
|
print(e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Future<void> _getKeyValues() async {
|
|||
|
|
await BasicInfoApi.getDictValues('wenhuachengdu').then((res) {
|
|||
|
|
_wenhuachengduList = res['data'];
|
|||
|
|
});
|
|||
|
|
await BasicInfoApi.getDictValues('zhengzhimianmao').then((res) {
|
|||
|
|
_zhengzhimianmaoList = res['data'];
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Future<void> _saveSuccess() async {
|
|||
|
|
|
|||
|
|
pd['userIdCard'] = base64.encode(utf8.encode(pd['userIdCard']));
|
|||
|
|
await BasicInfoApi.updateUserInfo(pd).then((res) {
|
|||
|
|
LoadingDialogHelper.hide();
|
|||
|
|
if (res['success']) {
|
|||
|
|
ToastUtil.showNormal(context, '保存成功');
|
|||
|
|
Navigator.pushReplacement(
|
|||
|
|
context,
|
|||
|
|
MaterialPageRoute(builder: (_) => const MainPage(isChooseFirm: false)),
|
|||
|
|
);
|
|||
|
|
} else {
|
|||
|
|
ToastUtil.showNormal(context, '保存失败');
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
@override
|
|||
|
|
Widget build(BuildContext context) {
|
|||
|
|
bool isShow = _isEdit;
|
|||
|
|
if (!_isEdit && FormUtils.hasValue(pd, 'id')) {
|
|||
|
|
isShow = true;
|
|||
|
|
}
|
|||
|
|
return Scaffold(
|
|||
|
|
appBar: MyAppbar(
|
|||
|
|
title: '查看信息',
|
|||
|
|
),
|
|||
|
|
|
|||
|
|
body: SafeArea(
|
|||
|
|
child: ItemListWidget.itemContainer(
|
|||
|
|
horizontal: 5,
|
|||
|
|
isShow ? ListView(
|
|||
|
|
children: [
|
|||
|
|
RepairedPhotoSection(
|
|||
|
|
title: '照片',
|
|||
|
|
inlineSingle: true,
|
|||
|
|
isRequired: _isEdit,
|
|||
|
|
initialMediaPaths:
|
|||
|
|
FormUtils.hasValue(pd, 'userAvatarUrl')
|
|||
|
|
? [
|
|||
|
|
'${ApiService.baseImgPath}${pd['userAvatarUrl'] ?? ''}',
|
|||
|
|
]
|
|||
|
|
: [],
|
|||
|
|
horizontalPadding: _isEdit ? 12 : 0,
|
|||
|
|
inlineImageWidth: 60,
|
|||
|
|
isFaceImage: true,
|
|||
|
|
isEdit: _isEdit,
|
|||
|
|
onChanged: (files) {
|
|||
|
|
if (files.isEmpty) {
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
pd['faceFiles'] = files.first.path;
|
|||
|
|
},
|
|||
|
|
onAiIdentify: () {},
|
|||
|
|
// onMediaRemovedForIndex: (index) async {
|
|||
|
|
// final deleFile = pd['userAvatarUrl'] ?? '';
|
|||
|
|
// if (deleFile.contains(UploadFileType.idCardPhoto.path)) {
|
|||
|
|
// _idCardImgRemoveList.add(deleFile);
|
|||
|
|
// }
|
|||
|
|
// },
|
|||
|
|
),
|
|||
|
|
if (_isEdit)
|
|||
|
|
ItemListWidget.itemContainer(
|
|||
|
|
const Text(
|
|||
|
|
'温馨提示:该照片为进入项目施工场所口门人脸识别使用',
|
|||
|
|
style: TextStyle(color: Colors.red, fontSize: 10),
|
|||
|
|
),
|
|||
|
|
),
|
|||
|
|
const Divider(),
|
|||
|
|
ItemListWidget.singleLineTitleText(
|
|||
|
|
label: '姓名:',
|
|||
|
|
isRequired: true,
|
|||
|
|
hintText: '请输入姓名',
|
|||
|
|
text: pd['name'] ?? '',
|
|||
|
|
isEditable: _isEdit,
|
|||
|
|
onChanged: (value) {
|
|||
|
|
pd['name'] = value;
|
|||
|
|
},
|
|||
|
|
),
|
|||
|
|
const Divider(),
|
|||
|
|
ItemListWidget.singleLineTitleText(
|
|||
|
|
label: '手机号:',
|
|||
|
|
isRequired: true,
|
|||
|
|
text: pd['username'] ?? '',
|
|||
|
|
isNumericInput: true,
|
|||
|
|
hintText: '请输入手机号',
|
|||
|
|
strongRequired: _isEdit,
|
|||
|
|
isEditable: false,
|
|||
|
|
),
|
|||
|
|
const Divider(),
|
|||
|
|
// 身份证输入:只使用 onChanged 回调(value 是实时输入框的值)
|
|||
|
|
ItemListWidget.singleLineTitleText(
|
|||
|
|
label: '身份证:',
|
|||
|
|
isRequired: true,
|
|||
|
|
hintText: '请输入身份证号',
|
|||
|
|
text: pd['userIdCard'] ?? '',
|
|||
|
|
isEditable: _isEdit,
|
|||
|
|
onChanged: (value) {
|
|||
|
|
},
|
|||
|
|
),
|
|||
|
|
const Divider(),
|
|||
|
|
ItemListWidget.selectableLineTitleTextRightButton(
|
|||
|
|
label: '民族:',
|
|||
|
|
isEditable: _isEdit,
|
|||
|
|
text: pd['nationName'] ?? '请选择',
|
|||
|
|
isRequired: _isEdit,
|
|||
|
|
onTap: () async {
|
|||
|
|
final found = await BottomPicker.show(
|
|||
|
|
context,
|
|||
|
|
items: nationMapList,
|
|||
|
|
itemBuilder:
|
|||
|
|
(i) =>
|
|||
|
|
Text(i['name']!, textAlign: TextAlign.center),
|
|||
|
|
initialIndex: 0,
|
|||
|
|
);
|
|||
|
|
//FocusHelper.clearFocus(context);
|
|||
|
|
|
|||
|
|
if (found != null) {
|
|||
|
|
setState(() {
|
|||
|
|
pd['nationName'] = found['name'];
|
|||
|
|
pd['nation'] = found['code'];
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
),
|
|||
|
|
const Divider(),
|
|||
|
|
// 性别:不可编辑,显示解析结果(也允许手动覆盖)
|
|||
|
|
ItemListWidget.selectableLineTitleTextRightButton(
|
|||
|
|
label: '性别:',
|
|||
|
|
isEditable: false,
|
|||
|
|
text: _genderText,
|
|||
|
|
|
|||
|
|
strongRequired: _isEdit,
|
|||
|
|
isRequired: true,
|
|||
|
|
onTap: () {
|
|||
|
|
// 允许手动选择覆盖解析结果
|
|||
|
|
showModalBottomSheet(
|
|||
|
|
context: context,
|
|||
|
|
builder: (_) {
|
|||
|
|
return Column(
|
|||
|
|
mainAxisSize: MainAxisSize.min,
|
|||
|
|
children: [
|
|||
|
|
ListTile(
|
|||
|
|
title: const Text('男'),
|
|||
|
|
onTap: () {
|
|||
|
|
setState(() {
|
|||
|
|
pd['gender'] = '男';
|
|||
|
|
_genderText = '男';
|
|||
|
|
});
|
|||
|
|
Navigator.pop(context);
|
|||
|
|
},
|
|||
|
|
),
|
|||
|
|
ListTile(
|
|||
|
|
title: const Text('女'),
|
|||
|
|
onTap: () {
|
|||
|
|
setState(() {
|
|||
|
|
pd['gender'] = '女';
|
|||
|
|
_genderText = '女';
|
|||
|
|
});
|
|||
|
|
Navigator.pop(context);
|
|||
|
|
},
|
|||
|
|
),
|
|||
|
|
],
|
|||
|
|
);
|
|||
|
|
},
|
|||
|
|
);
|
|||
|
|
},
|
|||
|
|
),
|
|||
|
|
const Divider(),
|
|||
|
|
// 出生年月:显示解析结果,但仍然可以手动修改
|
|||
|
|
ItemListWidget.selectableLineTitleTextRightButton(
|
|||
|
|
label: '出生年月:',
|
|||
|
|
isEditable: false,
|
|||
|
|
text: _birthText,
|
|||
|
|
strongRequired: _isEdit,
|
|||
|
|
isRequired: true,
|
|||
|
|
onTap: () async {
|
|||
|
|
},
|
|||
|
|
),
|
|||
|
|
const Divider(),
|
|||
|
|
|
|||
|
|
ItemListWidget.singleLineTitleText(
|
|||
|
|
label: '户口所在地:',
|
|||
|
|
isRequired: _isEdit,
|
|||
|
|
hintText: '请输入户口所在地',
|
|||
|
|
text: pd['locationAddress'] ?? '',
|
|||
|
|
isEditable: _isEdit,
|
|||
|
|
onChanged: (value) {
|
|||
|
|
pd['locationAddress'] = value;
|
|||
|
|
},
|
|||
|
|
),
|
|||
|
|
const Divider(),
|
|||
|
|
ItemListWidget.singleLineTitleText(
|
|||
|
|
label: '现住址:',
|
|||
|
|
isRequired: true,
|
|||
|
|
text: pd['currentAddress'] ?? '',
|
|||
|
|
hintText: '请输入现住址',
|
|||
|
|
isEditable: _isEdit,
|
|||
|
|
onChanged: (value) {
|
|||
|
|
pd['currentAddress'] = value;
|
|||
|
|
},
|
|||
|
|
),
|
|||
|
|
const Divider(),
|
|||
|
|
if (_isEdit || _idCardImgList.isNotEmpty)
|
|||
|
|
RepairedPhotoSection(
|
|||
|
|
title: '身份证照片',
|
|||
|
|
isRequired: _isEdit,
|
|||
|
|
maxCount: 2,
|
|||
|
|
initialMediaPaths:
|
|||
|
|
_idCardImgList
|
|||
|
|
.map(
|
|||
|
|
(item) =>
|
|||
|
|
ApiService.baseImgPath + item,
|
|||
|
|
)
|
|||
|
|
.toList(),
|
|||
|
|
isEdit: _isEdit,
|
|||
|
|
horizontalPadding: _isEdit ? 12 : 0,
|
|||
|
|
inlineImageWidth: 60,
|
|||
|
|
onChanged: (files) {
|
|||
|
|
idPhotos = files.map((file) => file.path).toList();
|
|||
|
|
},
|
|||
|
|
onMediaRemovedForIndex: (index) async {
|
|||
|
|
final deleFile = _idCardImgList[index];
|
|||
|
|
final deleId = _idCartImgIds[index];
|
|||
|
|
if (deleFile.contains(UploadFileType.idCardPhoto.path)) {
|
|||
|
|
_idCardImgList.removeAt(index);
|
|||
|
|
_idCartImgIds.removeAt(index);
|
|||
|
|
_idCardImgRemoveList.add(deleId);
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
onAiIdentify: () {
|
|||
|
|
/* ... */
|
|||
|
|
},
|
|||
|
|
),
|
|||
|
|
if (_isEdit)
|
|||
|
|
ItemListWidget.itemContainer(
|
|||
|
|
const Text(
|
|||
|
|
'温馨提示:用户要上传身份证正反面(身份证照片数量是2张才能进行人员培训)',
|
|||
|
|
style: TextStyle(color: Colors.red, fontSize: 10),
|
|||
|
|
),
|
|||
|
|
),
|
|||
|
|
const Divider(),
|
|||
|
|
ItemListWidget.selectableLineTitleTextRightButton(
|
|||
|
|
label: '文化程度:',
|
|||
|
|
isEditable: _isEdit,
|
|||
|
|
text: pd['culturalLevelName'] ?? '请选择',
|
|||
|
|
isRequired: _isEdit,
|
|||
|
|
onTap: () async {
|
|||
|
|
final found = await BottomPicker.show(
|
|||
|
|
context,
|
|||
|
|
items: _wenhuachengduList,
|
|||
|
|
itemBuilder:
|
|||
|
|
(i) => Text(
|
|||
|
|
i['dictLabel']!,
|
|||
|
|
textAlign: TextAlign.center,
|
|||
|
|
),
|
|||
|
|
initialIndex: 0,
|
|||
|
|
);
|
|||
|
|
//FocusHelper.clearFocus(context);
|
|||
|
|
|
|||
|
|
if (found != null) {
|
|||
|
|
setState(() {
|
|||
|
|
pd['culturalLevelName'] = found['dictLabel'];
|
|||
|
|
pd['culturalLevel'] = found['dictValue'];
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
),
|
|||
|
|
const Divider(),
|
|||
|
|
ItemListWidget.selectableLineTitleTextRightButton(
|
|||
|
|
label: '政治面貌:',
|
|||
|
|
isEditable: _isEdit,
|
|||
|
|
text: pd['politicalAffiliationName'] ?? '请选择',
|
|||
|
|
isRequired: _isEdit,
|
|||
|
|
onTap: () async {
|
|||
|
|
final found = await BottomPicker.show(
|
|||
|
|
context,
|
|||
|
|
items: _zhengzhimianmaoList,
|
|||
|
|
itemBuilder:
|
|||
|
|
(i) => Text(
|
|||
|
|
i['dictLabel']!,
|
|||
|
|
textAlign: TextAlign.center,
|
|||
|
|
),
|
|||
|
|
initialIndex: 0,
|
|||
|
|
);
|
|||
|
|
//FocusHelper.clearFocus(context);
|
|||
|
|
|
|||
|
|
if (found != null) {
|
|||
|
|
setState(() {
|
|||
|
|
pd['politicalAffiliationName'] = found['dictLabel'];
|
|||
|
|
pd['politicalAffiliation'] = found['dictValue'];
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
),
|
|||
|
|
const Divider(),
|
|||
|
|
ItemListWidget.selectableLineTitleTextRightButton(
|
|||
|
|
label: '婚姻状态:',
|
|||
|
|
isEditable: _isEdit,
|
|||
|
|
text: pd['maritalStatusName'] ?? '请选择',
|
|||
|
|
isRequired: _isEdit,
|
|||
|
|
onTap: () async {
|
|||
|
|
final found = await BottomPicker.show(
|
|||
|
|
context,
|
|||
|
|
items: _hunyinList,
|
|||
|
|
itemBuilder:
|
|||
|
|
(i) =>
|
|||
|
|
Text(i['name']!, textAlign: TextAlign.center),
|
|||
|
|
initialIndex: 0,
|
|||
|
|
);
|
|||
|
|
//FocusHelper.clearFocus(context);
|
|||
|
|
|
|||
|
|
if (found != null) {
|
|||
|
|
setState(() {
|
|||
|
|
pd['maritalStatusName'] = found['name'];
|
|||
|
|
pd['maritalStatus'] = found['value'];
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
),
|
|||
|
|
const Divider(),
|
|||
|
|
ListItemFactory.createYesNoSection(
|
|||
|
|
title: "是否流动人员:",
|
|||
|
|
horizontalPadding: 2,
|
|||
|
|
verticalPadding: 0,
|
|||
|
|
yesLabel: "是",
|
|||
|
|
noLabel: "否",
|
|||
|
|
text: pd['flowFlag'] == 1 ? '是' : '否',
|
|||
|
|
isRequired: true,
|
|||
|
|
isEdit: _isEdit,
|
|||
|
|
groupValue: (pd['flowFlag'] ?? 0) == 1,
|
|||
|
|
onChanged: (val) {
|
|||
|
|
setState(() {
|
|||
|
|
pd['flowFlag'] = val ? 1 : 0;
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
),
|
|||
|
|
const Divider(),
|
|||
|
|
ItemListWidget.singleLineTitleText(
|
|||
|
|
label: '电子邮箱:',
|
|||
|
|
isRequired: false,
|
|||
|
|
isNumericInput: false,
|
|||
|
|
hintText: '请输入电子邮箱',
|
|||
|
|
text: pd['email'] ?? '',
|
|||
|
|
isEditable: _isEdit,
|
|||
|
|
onChanged: (value) {
|
|||
|
|
pd['email'] = value;
|
|||
|
|
},
|
|||
|
|
),
|
|||
|
|
const Divider(),
|
|||
|
|
ItemListWidget.singleLineTitleText(
|
|||
|
|
label: '部门:',
|
|||
|
|
isRequired: false,
|
|||
|
|
isNumericInput: false,
|
|||
|
|
hintText: '',
|
|||
|
|
text: pd['departmentName'] ?? '',
|
|||
|
|
isEditable: _isEdit,
|
|||
|
|
|
|||
|
|
),
|
|||
|
|
const Divider(),
|
|||
|
|
ItemListWidget.singleLineTitleText(
|
|||
|
|
label: '岗位(工种):',
|
|||
|
|
isRequired: false,
|
|||
|
|
isNumericInput: false,
|
|||
|
|
hintText: '',
|
|||
|
|
text: pd['postName'] ?? '',
|
|||
|
|
isEditable: _isEdit,
|
|||
|
|
),
|
|||
|
|
const Divider(),
|
|||
|
|
],
|
|||
|
|
) : NoDataWidget.show(),
|
|||
|
|
),
|
|||
|
|
),
|
|||
|
|
);
|
|||
|
|
}
|
|||
|
|
}
|