Commit 2d3be144 authored by 张子雨's avatar 张子雨

Merge branch 'feat/constructionOne' into feature/20230327_public_takeaway

* feat/constructionOne:
  feat: 增加校验规则
parents 1c772b85 c692257b
...@@ -232,6 +232,18 @@ const StoreModal = props => { ...@@ -232,6 +232,18 @@ const StoreModal = props => {
const normFile = fileList => fileList; const normFile = fileList => fileList;
const timerWrapper = async (time, timeString, callback) => {
if (timeString && timeString.length) {
const begin = moment(timeString[0]).format('HH:mm');
const end = moment(timeString[1]).format('HH:mm');
if (begin === end) {
callback(new Error('选择开始时间结束时间不能一样'));
}
} else {
callback();
}
};
useEffect(() => { useEffect(() => {
if (visible) { if (visible) {
resetFields(); resetFields();
...@@ -254,7 +266,6 @@ const StoreModal = props => { ...@@ -254,7 +266,6 @@ const StoreModal = props => {
if (info.townId) { if (info.townId) {
info.addr.push(info.townId); info.addr.push(info.townId);
} }
console.log(info);
setTimes(harr); setTimes(harr);
setFormData(info); setFormData(info);
getLazyAddr(info); getLazyAddr(info);
...@@ -331,18 +342,12 @@ const StoreModal = props => { ...@@ -331,18 +342,12 @@ const StoreModal = props => {
<div> <div>
<FormItem name={item.name}> <FormItem name={item.name}>
{getFieldDecorator(item.name, { {getFieldDecorator(item.name, {
rules: [{ required: true, message: '请选择营业时间!' }], rules: [
{ required: true, message: '请选择营业时间!' },
{ validator: timerWrapper, message: '选择开始时间结束时间不能一样' },
],
initialValue: formData[item.name], initialValue: formData[item.name],
})( })(<TimePicker.RangePicker format="HH:mm" disabled={disabled} />)}
<TimePicker.RangePicker
format="HH:mm"
showTime={{
hideDisabledOptions: true,
defaultValue: [moment('00:00', 'HH:mm'), moment('23:59', 'HH:mm')],
}}
disabled={disabled}
/>,
)}
</FormItem> </FormItem>
</div> </div>
{!disabled && {!disabled &&
......
...@@ -37,7 +37,6 @@ export default () => { ...@@ -37,7 +37,6 @@ export default () => {
// 获取业务模式 // 获取业务模式
const getBusiness = async () => { const getBusiness = async () => {
const res = await apiproductBusiness(); const res = await apiproductBusiness();
console.log(res);
if (res) { if (res) {
setProductBusiness(res.productBusiness || []); setProductBusiness(res.productBusiness || []);
setExistTakewayShop(res.existTakewayShop); setExistTakewayShop(res.existTakewayShop);
...@@ -127,6 +126,9 @@ export default () => { ...@@ -127,6 +126,9 @@ export default () => {
if (val.businessStatus) { if (val.businessStatus) {
params.businessStatus = val.businessStatus; params.businessStatus = val.businessStatus;
} }
if (val.productBusiness) {
params.productBusiness = val.productBusiness;
}
getList(params); getList(params);
}; };
...@@ -220,8 +222,8 @@ export default () => { ...@@ -220,8 +222,8 @@ export default () => {
dataIndex: 'productBusiness', dataIndex: 'productBusiness',
width: 120, width: 120,
align: 'center', align: 'center',
render: v => render: (v, value) =>
v && ( value?.productBusiness?.length && (
<div> <div>
{v.map(it => ( {v.map(it => (
<span>{businessList.find(item => +it === +item.value).label}&nbsp;</span> <span>{businessList.find(item => +it === +item.value).label}&nbsp;</span>
...@@ -314,6 +316,17 @@ export default () => { ...@@ -314,6 +316,17 @@ export default () => {
</Select> </Select>
</Form.Item> </Form.Item>
</Col> </Col>
<Col span={8}>
<Form.Item label="业务模式" name="productBusiness">
<Select>
{businessList.map(item => (
<Option label={item.label} value={item.value} key={item.value}>
{item.label}
</Option>
))}
</Select>
</Form.Item>
</Col>
</Row> </Row>
<div className={style.search}> <div className={style.search}>
<Button type="primary" htmlType="submit" size="middle"> <Button type="primary" htmlType="submit" size="middle">
......
...@@ -154,20 +154,20 @@ export const getObjectType = v => Object.prototype.toString.call(v).replace(/\[o ...@@ -154,20 +154,20 @@ export const getObjectType = v => Object.prototype.toString.call(v).replace(/\[o
export const getErrorMessage = err => { export const getErrorMessage = err => {
const message = '请检查表单数据!'; const message = '请检查表单数据!';
// eslint-disable-next-line wrap-iife // eslint-disable-next-line wrap-iife
// (function getMsg(v) { (function getMsg(v) {
// if (Array.isArray(v)) { if (Array.isArray(v)) {
// getMsg(v[0]); getMsg(v[0]);
// } else { } else {
// const keys = Object.keys(v); const keys = Object.keys(v);
// if (Array.isArray(v[keys[0]])) { if (Array.isArray(v[keys[0]])) {
// getMsg(v[keys[0]][0]); getMsg(v[keys[0]][0]);
// } else if (v[keys[0]].errors && v[keys[0]].errors.length) { } else if (v[keys[0]].errors && v[keys[0]].errors.length) {
// // eslint-disable-next-line no-const-assign // eslint-disable-next-line no-const-assign
// message = v[keys[0]].errors[0].message; message = v[keys[0]].errors[0].message;
// } else { } else {
// getMsg(v); getMsg(v);
// } }
// } }
// })(err); })(err);
return message; return message;
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment