Skip to content

Commit

Permalink
feat(logistics): 更新 box 组件为 chakra-ui,文字对齐
Browse files Browse the repository at this point in the history
  • Loading branch information
twinh committed Jan 24, 2024
1 parent 8937809 commit b02750f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 33 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@mxjs/a-input": "^1.3.3",
"@mxjs/actions": "^0.2.16",
"@mxjs/app": "^0.6.5",
"@mxjs/box": "^0.3.12",
"@mxjs/a-box": "^1.0.0",
"@mxjs/test": "^1.0.10",
"@testing-library/react": "^11.2.6",
"antd": "~5.1.6",
Expand All @@ -36,7 +36,7 @@
},
"ciDependencies": {
"miaoxing": "miaoxing/miaoxing-js",
"@mxjs/box": "miaoxing/mxjs-box",
"@mxjs/a-box": "miaoxing/mxjs-a-box",
"babel-preset-miaoxing": "miaoxing/babel-preset-miaoxing",
"@miaoxing/dev": "miaoxing/dev",
"jest-preset-miaoxing": "miaoxing/jest-preset-miaoxing",
Expand Down
71 changes: 40 additions & 31 deletions pages/admin/shipping-tpls/new.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,54 @@
/**
* @share [id]/edit
*/
import {useEffect, useRef, useState} from 'react';
import {CListBtn} from '@mxjs/a-clink';
import {Page, PageActions} from '@mxjs/a-page';
import {Form, FormItem, FormAction, FormList} from '@mxjs/a-form';
import { useEffect, useRef, useState } from 'react';
import { CListBtn } from '@mxjs/a-clink';
import { Page, PageActions } from '@mxjs/a-page';
import { Form, FormItem, FormAction, FormList } from '@mxjs/a-form';
import {
Divider,
Radio,
Switch,
Table,
InputNumber,
TreeSelect,
Typography,
Typography, theme,
} from 'antd';
import $ from 'miaoxing';
import {DeleteOutlined, PlusOutlined} from '@ant-design/icons';
import {Box} from '@mxjs/box';
import {FormItemSort, InputPrice} from '@miaoxing/admin';
import {css} from '@emotion/css';
import { DeleteOutlined, PlusOutlined } from '@ant-design/icons';
import { Box } from '@mxjs/a-box';
import { FormItemSort, InputPrice } from '@miaoxing/admin';
import { css } from '@emotion/css';
import PropTypes from "prop-types";

Check failure on line 21 in pages/admin/shipping-tpls/new.js

View workflow job for this annotation

GitHub Actions / eslint (20)

Strings must use singlequote

// 默认的物流服务编号,即"快递"
const DEFAULT_SERVICE_ID = 1;

const FeeFormItem = (props) => {
return <FormItem required className={css({'&&':{marginBottom: 0}})} {...props}>
return <FormItem required className={css({'&&': {marginBottom: 0}})} {...props}>
<InputPrice className={css({'&&': {width: 70}})}/>
</FormItem>;
};

const NumberFormItem = (props) => {
return <FormItem required className={css({'&&':{marginBottom: 0}})} {...props}>
return <FormItem required className={css({'&&': {marginBottom: 0}})} {...props}>
<InputNumber min={1} max={1000} precision={0} controls={false} className={css({'&&': {width: 70}})}/>
</FormItem>;
};

const verticalAlignBaseline = css({verticalAlign: 'baseline'});
const {useToken} = theme;
const FormText = ({children, ...rest}) => {

Check failure on line 39 in pages/admin/shipping-tpls/new.js

View workflow job for this annotation

GitHub Actions / eslint (20)

'children' is missing in props validation
const {token} = useToken();

return (
<Box h={token.controlHeight + 'px'} display="flex" alignItems="center" {...rest}>{children}</Box>
);
};

FormText.propType = {
children: PropTypes.node,
};

const verticalAlignTop = css({verticalAlign: 'top'});

const New = () => {
const form = useRef();
Expand Down Expand Up @@ -145,11 +158,7 @@ const New = () => {
</FormItem>

<FormItem label="运费规则" wrapperCol={{span: 18}}>
<Box mt1 gray500>
请设置地区对应的运费,未设置的地区使用默认运费。
</Box>

<Divider/>
<FormText color="gray.500" mb={2}>请设置地区对应的运费,未设置的地区使用默认运费。</FormText>

<FormList
name="services">
Expand Down Expand Up @@ -189,10 +198,10 @@ const New = () => {
{
title: '地区',
dataIndex: 'regionIds',
className: verticalAlignBaseline,
className: verticalAlignTop,
render: (cell, row, ruleIndex) => {
if (row.isDefault) {
return '默认';
return <FormText>默认</FormText>;
}

// 找到其他规则已选中的地区
Expand Down Expand Up @@ -220,11 +229,11 @@ const New = () => {

return (
<FormItem name={[index, 'rules', ruleIndex, 'regionIds']} required
style={{marginBottom: 0}}
style={{marginBottom: 0}}
>
<TreeSelect treeData={treeData} treeCheckable
showCheckedStrategy={TreeSelect.SHOW_PARENT} placeholder="请选择"
treeNodeFilterProp="title"
showCheckedStrategy={TreeSelect.SHOW_PARENT} placeholder="请选择"
treeNodeFilterProp="title"
/>
</FormItem>
);
Expand All @@ -235,17 +244,17 @@ const New = () => {
dataIndex: 'startAmount',
align: 'center',
width: 460,
className: verticalAlignBaseline,
className: verticalAlignTop,
render: (value, row, ruleIndex) => {
return <Box alignItems="baseline" toBetween>
return <Box display="flex" alignItems="flex-start" justifyContent="space-between">
<NumberFormItem name={[index, 'rules', ruleIndex, 'startAmount']}/>
{' '}{unit}{' '}
<FormText>{unit}</FormText>
<FeeFormItem name={[index, 'rules', ruleIndex, 'startFee']}/>
{' '}元,每增加{' '}
<FormText>元,每增加</FormText>
<NumberFormItem name={[index, 'rules', ruleIndex, 'addAmount']}/>
{' '}{unit}{' '}
<FormText>{unit}</FormText>
<FeeFormItem name={[index, 'rules', ruleIndex, 'addFee']}/>
{' '}
<FormText></FormText>
</Box>;
},
},
Expand All @@ -254,11 +263,11 @@ const New = () => {
dataIndex: 'id',
align: 'center',
width: 100,
className: verticalAlignBaseline,
className: verticalAlignTop,
render: (value, row, ruleIndex) => {
return row.isDefault ? <span title="默认地区不能删除">-</span> : (
<Typography.Link type="danger" onClick={deleteRule.bind(this, ruleIndex)} href="#"
title="删除">
title="删除">
<DeleteOutlined/>
</Typography.Link>
);
Expand Down

0 comments on commit b02750f

Please sign in to comment.