提交 576e70c0 authored 作者: 钟是志's avatar 钟是志

增加移动端Cascader组件

上级 ad35a530
import React, {useMemo} from 'react';
import {List, Picker} from 'antd-mobile';
import styles from './styles.less';
const getItemChildren = (childrenList, parent) => {
if (!childrenList || !childrenList.length) {
return [];
}
for (let item of childrenList) {
if (item.label.indexOf(parent.label) > -1) {
item.label = item.label.replace(parent.label, '');
}
for (let proviceName of ['内蒙古', '广西', '新疆', '香港', '澳门', '西藏', '宁夏']) {
item.label = item.label.replace(proviceName, '');
}
if (item.children) {
item.children = getItemChildren(item.children, parent);
}
}
return childrenList;
}
export default function MobileCascader(props) { // 级联选择
const {onChange, options, label, disabled, value, json, otherProps} = props;
// console.log(props);
let opt = useMemo(() => {
return options &&
Array.isArray(options) &&
options.map((x) => {
return {
label: x.label,
value: x.value,
children: getItemChildren(x.children, x),
};
});
}, [options]);
return (
<div className={styles.mobileFormInput}>
<Picker
data={opt || []}
cascade={true}
// cols={1}
disabled={disabled}
value={value}
extra={disabled ? '' : json.placeholder || '点击选择'}
onChange={(val) => {
console.log(val);
onChange(val || undefined);
}}
{...otherProps?.props}
>
<List.Item arrow={disabled ? '' : 'horizontal'}>
{/*{label}*/}
</List.Item>
</Picker>
</div>
);
}
.mobileFormInput {
border-bottom: 1px solid #eee;
:global {
.am-input-label,
.am-textarea-label,
.am-list-content {
white-space: pre-line !important;
font-size: 14px !important;
}
.am-list-item.am-input-item {
height: auto;
}
//.am-list-item .am-list-line .am-list-content{
// padding-left: 15px;
//}
.am-list-item {
padding-left: 0;
}
.am-list-item .am-list-line {
padding-right: 0;
}
.am-list-extra {
flex-basis: 100% !important;
font-size: 14px !important;
}
.am-list-item .am-input-control input {
text-align: right;
}
.am-list-item
.am-input-control
.fake-input-container
.fake-input-placeholder {
font-size: 14px;
}
}
input,
textarea {
font-size: 14px !important;
}
}
.mobileFormItem {
margin-bottom: 0px !important;
:global {
.ant-form-item-label {
/*隐藏手机端 字段的label 使用 antd-mobile 替代*/
display: inline !important;
height: 1px !important;
}
}
}
.viewDetail {
display: grid;
justify-content: start;
align-items: center;
width: 100%;
grid-template-columns: 15% 35% 15% 35%;
.title {
padding: 15px;
margin: -1px;
background-color: #fafafa;
border: 1px solid #eee;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.name {
margin: -1px;
padding: 15px;
background-color: #fff;
border: 1px solid #eee;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
}
.viewDetailMobile {
display: grid;
justify-content: start;
align-items: center;
width: 100%;
grid-template-columns: 35% 65%;
border: 1px solid #eee;
margin-top: -1px;
.title {
padding: 15px;
margin-bottom: 0;
//margin: -1px;
background-color: #fafafa;
//overflow: hidden;
//white-space: nowrap;
//text-overflow: ellipsis;
}
.name {
//margin: -1px;
padding: 15px;
background-color: #fff;
//overflow: hidden;
//white-space: nowrap;
//text-overflow: ellipsis;
}
}
......@@ -58,6 +58,7 @@ import { formulaList } from '../excelInitFuc/functionList';
import FilePreview from '../filePreview';
import DraftEditorCom from '../App/DraftEditorCom';
import MobileItem from './MobileItem';
import MobileCascader from "./CascaderDiy/MobileCascader";
const Bs64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
const base64 = baseX(Bs64);
......@@ -905,7 +906,7 @@ export default class tableCom extends Component {
...options,
});
if (url.indexOf('localhost') > -1) {
url = url.replace(window.location.origin, window.specialImportantSystemConfig.gateWayPort);
url = url.replace(window.location.origin, window.specialImportantSystemConfig?.gateWayPort);
}
umiRequest(url, {
data: requestParams,
......@@ -2828,6 +2829,22 @@ export default class tableCom extends Component {
style={{ width: json.width }}
/>,
);
if(get === 'mobile') {
cm = getFieldDecorator(dataColumn.base52, {
initialValue: initValue,
rules:
json.vlds && json.vlds.length > 0
? json.vlds
: [{ required: required, message: '请选择' + dataColumn.title }],
})(
<MobileCascader options={options}
label={title}
disabled={disabled}
json={json}
/>);
}
if (
get === 'mobile' &&
((json.isMobileLabel != null && json.isMobileLabel) ||
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论