Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修改列表排序问题 #303

Merged
merged 3 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 128 additions & 30 deletions tdesign-component/example/lib/page/td_cascader_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';
import '../../annotation/demo.dart';
import '../../base/example_widget.dart';
Expand Down Expand Up @@ -144,64 +147,132 @@ class _TDCascaderPageState extends State<TDCascaderPage> {

String? _initData_3;
String _selected_3 = '';
List<Map> _data_3 = [
final List<Map> _data_3 = [
{
"label": '技术部门',
"value": '110000',
"segmentValue": 'J',
"children": [
{
"value": '110100',
"label": '部门一',
"segmentValue": 'B',
"children": [
{"value": '110101', "label": '洪磊', "segmentValue": 'H'},
{"value": '110102', "label": '洪磊2', "segmentValue": 'H'},
{"value": '1101022', "label": '洪磊3', "segmentValue": 'H'},
{"value": '110105', "label": '洪磊4', "segmentValue": 'H'},
{"value": '110106', "label": '郭天1', "segmentValue": 'G'},
{"value": '110107', "label": '郭天2', "segmentValue": 'G'},
{"value": '110108', "label": '郭天3', "segmentValue": 'G'},
{"value": '110109', "label": '冯笑1', "segmentValue": 'F'},
{"value": '110108', "label": '郭天3', "segmentValue": 'G'},
],
},
{
"value": '110200',
"label": '部门二',
"segmentValue": 'B',
"children": [
{"value": '110201', "label": '张雷1'},
{"value": '110202', "label": '张雷2'},
{"value": '1102022', "label": '张雷3'},
{"value": '110205', "label": '张雷4'},
{"value": '110206', "label": '张雷5'},
{"value": '110207', "label": '张雷6'},
{"value": '110208', "label": '张雷7'},
{"value": '110209', "label": '张雷8'},
{"value": '110201', "label": '洪磊', "segmentValue": 'H'},
{"value": '110205', "label": '洪磊4', "segmentValue": 'H'},
{"value": '110206', "label": '郭天1', "segmentValue": 'G'},
{"value": '110207', "label": '郭天2', "segmentValue": 'G'},
{"value": '110208', "label": '郭天3', "segmentValue": 'G'},
{"value": '110209', "label": '冯笑1', "segmentValue": 'F'},
{"value": '110202', "label": '洪磊2', "segmentValue": 'H'},
{"value": '1102022', "label": '洪磊3', "segmentValue": 'H'},
],
},
],
},
{
"label": '行政部门',
"value": '120000',
"segmentValue": 'X',
"children": [
{
"value": '120100',
"label": '部门一',
"segmentValue": 'B',
"children": [
{"value": '120201', "label": '洪磊', "segmentValue": 'H'},
{"value": '120205', "label": '洪磊4', "segmentValue": 'H'},
{"value": '120206', "label": '郭天1', "segmentValue": 'G'},
{"value": '120207', "label": '郭天2', "segmentValue": 'G'},
{"value": '120208', "label": '郭天3', "segmentValue": 'G'},
{"value": '120209', "label": '冯笑1', "segmentValue": 'F'},
{"value": '120202', "label": '洪磊2', "segmentValue": 'H'},
{"value": '1202022', "label": '洪磊3', "segmentValue": 'H'},
],
},
],
},
];

String? _initData_4;
String _selected_4 = '';
final List<Map> _data_4 = [
{
"label": '技术部门',
"value": '110000',
"children": [
{
"value": '110100',
"label": '部门一',
"children": [
{"value": '110201', "label": '后勤部门', "children":[
{
"value": '110301', "label": '后勤A组',"children":[
{
"value": '110401', "label": '一组',"children":[
{"value": '110501', "label": '洪磊',},
{"value": '110502', "label": '洪磊2'},
{"value": '110506', "label": '郭天1'},
{"value": '110507', "label": '郭天2'},
{"value": '110508', "label": '郭天3'},
{"value": '110509', "label": '冯笑1'},
{"value": '1105022', "label": '洪磊3'},
{"value": '110505', "label": '洪磊4'},
]
}
]
}
]},
],
},
{
"value": '120100',
"label": '部门二',
"children": [
{"value": '120101', "label": '张雷1'},
{"value": '120102', "label": '张雷2'},
{"value": '120103', "label": '张雷3'},
{"value": '120104', "label": '张雷4'},
{"value": '120105', "label": '张雷5'},
{"value": '120106', "label": '张雷6'},
{"value": '120110', "label": '张雷7'},
{"value": '120111', "label": '张雷8'},
{"value": '120112', "label": '张雷9'},
{"value": '120201', "label": '后勤部门', "children":[
{
"value": '120301', "label": '后勤A组',"children":[
{
"value": '120401', "label": '一组',"children":[
{"value": '120501', "label": '张雷1'},
{"value": '120502', "label": '张雷2'},
{"value": '1205022', "label": '张雷3'},
{"value": '120505', "label": '张雷4'},
{"value": '120506', "label": '张雷5'},
{"value": '120507', "label": '张雷6'},
{"value": '120508', "label": '张雷7'},
{"value": '120509', "label": '张雷8'},
]
}
]
}
]},
],
},
],
},
];
@override
void initState() {
// TODO: implement initState
super.initState();
}
@override
Widget build(BuildContext context) {
return Container(
color: TDTheme.of(context).whiteColor1,
Expand All @@ -211,18 +282,17 @@ class _TDCascaderPageState extends State<TDCascaderPage> {
desc: '用于多层级数据的逐级选择',
children: [
ExampleModule(title: '组件类型', children: [
ExampleItem(desc: '垂直级联选择器', builder: _buildVerticalCascader),
ExampleItem(desc: '垂直级联选择器-带字母定位', builder: _buildVerticalLetterCascader),
ExampleItem(desc: '垂直级联选择器', builder: _buildVerticalCascader),
ExampleItem(desc: '垂直级联选择器-带字母定位', builder: _buildVerticalLetterCascader),
ExampleItem(desc: '水平级联选择器', builder: _buildHorizontalCascader),
ExampleItem(desc: '水平级联选择器-带字母定位', builder: _buildHorizontalLetterCascader),
ExampleItem(desc: '水平级联选择器-带字母定位', builder: _buildHorizontalLetterCascader),
ExampleItem(desc: '水平级联选择器-部门', builder: _buildHorizontalCompanyCascader),
ExampleItem(desc: '垂直级联选择器-部门', builder: _buildVerticalCompanyCascader),
]),
],
test: [
ExampleItem(
desc: '测试使用次标题',
builder: _buildVerticalSubTitleCascader),
ExampleItem(desc: '测试使用次标题', builder: _buildVerticalSubTitleCascader),
ExampleItem(desc: '垂直级联选择器-部门', builder: _buildTestVerticalCompanyCascader),
],
),
);
Expand Down Expand Up @@ -305,8 +375,12 @@ class _TDCascaderPageState extends State<TDCascaderPage> {
Widget _buildHorizontalLetterCascader(BuildContext context) {
return GestureDetector(
onTap: () {
TDCascader.showMultiCascader(context, title: '选择地址', data: _data_2, initialData: _initData_2, theme: 'tab',
onChange: (List<MultiCascaderListModel> selectData) {
TDCascader.showMultiCascader(context,
title: '选择地址',
data: _data_2,
initialData: _initData_2,
isLetterSort: true,
theme: 'tab', onChange: (List<MultiCascaderListModel> selectData) {
setState(() {
List result = [];
int len = selectData.length;
Expand All @@ -328,7 +402,7 @@ class _TDCascaderPageState extends State<TDCascaderPage> {
Widget _buildHorizontalCompanyCascader(BuildContext context) {
return GestureDetector(
onTap: () {
TDCascader.showMultiCascader(context, title: '选择部门人员', data: _data_3, initialData: _initData_3, theme: 'tab',
TDCascader.showMultiCascader(context, title: '选择部门人员', data: _data_3,isLetterSort: true, initialData: _initData_3, theme: 'tab',
onChange: (List<MultiCascaderListModel> selectData) {
setState(() {
List result = [];
Expand All @@ -351,7 +425,7 @@ class _TDCascaderPageState extends State<TDCascaderPage> {
Widget _buildVerticalCompanyCascader(BuildContext context) {
return GestureDetector(
onTap: () {
TDCascader.showMultiCascader(context, title: '选择部门人员', data: _data_3, initialData: _initData_3, theme: 'step',
TDCascader.showMultiCascader(context, title: '选择部门人员', data: _data_3,isLetterSort: true, initialData: _initData_3, theme: 'step',
onChange: (List<MultiCascaderListModel> selectData) {
setState(() {
List result = [];
Expand Down Expand Up @@ -396,7 +470,31 @@ class _TDCascaderPageState extends State<TDCascaderPage> {
child: _buildSelectRow(context, _selected_1, '选择地区'),
);
}

@Demo(group: 'cascader')
Widget _buildTestVerticalCompanyCascader(BuildContext context) {
return GestureDetector(
onTap: () {
TDCascader.showMultiCascader(context,
title: '选择部门人员',
data: _data_4,
initialData: _initData,
theme: 'step', onChange: (List<MultiCascaderListModel> selectData) {
setState(() {
List result = [];
int len = selectData.length;
_initData = selectData[len - 1].value!;
selectData.forEach((element) {
result.add(element.label);
});
_selected_4 = result.join('/');
});
}, onClose: () {
Navigator.of(context).pop();
});
},
child: _buildSelectRow(context, _selected_4, '选择部门人员'),
);
}
Widget _buildSelectRow(BuildContext context, String output, String title) {
return Container(
color: TDTheme.of(context).whiteColor1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class TDCascader {
double cascaderHeight = 500,
String? initialData,
String? closeText,
bool isLetterSort=false,
List<String>? subTitles,
Function? onClose}) {
showModalBottomSheet(
Expand All @@ -32,6 +33,7 @@ class TDCascader {
onChange: onChange,
closeText: closeText,
theme: theme,
isLetterSort:isLetterSort,
subTitles: subTitles);
});
}
Expand Down
Loading