Commit 82902dc9 authored by 陈万宝's avatar 陈万宝

Merge branch 'feature/20230327_public_takeaway' into feature/20230315_take_out_goods

parents 910a4dce 3158d3a5
......@@ -172,7 +172,6 @@ class goodsManage extends Component {
<FormItem label="商品类型" name="productType">
<Select style={selectW} placeholder="请选择商品类型" onChange={this.onChangeProductType}>
<Option value={1}>实体商品</Option>
<Option value={2}>虚拟商品</Option>
<Option value={4}>服务类商品</Option>
<Option value={5}>外卖商品</Option>
</Select>
......
import React, { useState, useEffect } from 'react';
import React, { useState, useEffect, forwardRef, useImperativeHandle } from 'react';
import { Button, Select, Tag } from 'antd';
import { DndProvider } from 'react-dnd';
import HTML5Backend from 'react-dnd-html5-backend';
......@@ -8,7 +8,7 @@ import InsertTag from './InsertTag';
import GroupInfo from './GroupInfo';
import { apiDelStorage, apiSortStorage, apiStorageList, apiSupplierShopList } from '../../service';
const GoodsGroup = options => {
const GoodsGroup = forwardRef((options, ref) => {
const [groupEdit, setGroupEdit] = useState(false);
const [selected, setSelected] = useState(0);
const [storageId, setStorageId] = useState(0);
......@@ -110,6 +110,10 @@ const GoodsGroup = options => {
options.changeGroup(selected);
}, [selected]);
useImperativeHandle(ref, () => ({
setSelected,
}));
return (
<div className={styles.groupBox}>
{(shops && shops.length && (
......@@ -182,6 +186,6 @@ const GoodsGroup = options => {
/>
</div>
);
};
});
export default GoodsGroup;
import React, { useState, useEffect, useCallback, useMemo } from 'react';
import React, { useState, useEffect, useRef } from 'react';
import { Spin, Table, Pagination, message, notification } from 'antd';
import { unstable_batchedUpdates } from 'react-dom';
import { SortableContainer, SortableElement, SortableHandle } from 'react-sortable-hoc';
......@@ -39,6 +39,8 @@ const Takeaway = options => {
const [visibleSwitchGroup, setVisibleSwitchGroup] = useState(false);
const [scribeToken, setScribeToken] = useState('');
const groupRef = useRef(null);
const rowSelection = {
selectedRowKeys,
onChange: setSelectedRowKeys,
......@@ -176,7 +178,8 @@ const Takeaway = options => {
useEffect(() => {
if (groupId) {
getDataList(0, pageSize);
setPageNo(1);
getDataList(1, pageSize);
} else {
setTableData([]);
}
......@@ -184,11 +187,16 @@ const Takeaway = options => {
useEffect(() => {
const stoken = PubSub.subscribe('refreshTakeAway', (_, data) => {
setShopId(data.shopId);
setGroupId(data.groupId);
getDataList(0, pageSize, data.groupId);
console.log('refreshTakeAway :>> ', data);
if (data.groupId && groupId !== data.groupId) {
setGroupId(data.groupId);
if (groupRef.current) {
groupRef.current.setSelected(`${data.groupId}`);
}
}
});
setScribeToken(stoken);
return () => {
PubSub.unsubscribe(scribeToken);
};
......@@ -208,7 +216,12 @@ const Takeaway = options => {
return (
<div className={styles.takeawayBox}>
<Spin spinning={loading}>
<GoodsGroup shopId={shopId} changeShop={setShopId} changeGroup={setGroupId} />
<GoodsGroup
ref={groupRef}
shopId={shopId}
changeShop={setShopId}
changeGroup={setGroupId}
/>
{(shopId && (
<ActionBar
selectedRowKeys={selectedRowKeys}
......
......@@ -8,6 +8,15 @@ import { apiChangeStateGoods, apiGoodsActionBatch } from './service';
const { confirm } = Modal;
export const NormalProduct = 1;
export const ServiceProduct = 4;
export const TakeawayProduct = 5;
export const GoodTypes = {
[NormalProduct]: '实体商品',
[ServiceProduct]: '服务类商品',
[TakeawayProduct]: '外卖商品',
};
export const productType = [
{
value: 1,
......
......@@ -139,7 +139,7 @@
.takeawayBox {
margin-top: 20px;
padding-bottom: 40px;
padding-bottom: 20px;
background-color: #fff;
&--page {
padding-top: 10px;
......
......@@ -149,7 +149,7 @@ const AddRepertoryModal = (props, ref) => {
name="maxStock"
label="最大库存"
rules={[
{ required: isRequired, message: '请填写最大库存' },
{ required: !isRequired, message: '请填写最大库存' },
{
validator: isIntegerNotZero,
type: 'number',
......
......@@ -7,7 +7,7 @@ export const formItemLayout = {
},
};
export const TaskList = (canAddService, canAddNormal) => [
export const TaskList = (canAddService, canAddNormal, canTakeawayService) => [
{
name: '实体商品',
type: 1,
......@@ -33,31 +33,31 @@ export const TaskList = (canAddService, canAddNormal) => [
},
},
},
{
name: '虚拟商品',
type: 2,
desc: '无需物流',
hide: !canAddNormal,
imgConfig: {
commonImageList: {
title: '公共滑动图',
rule: false,
limit: null,
renderExtra: () => '(图片最大上传2M)',
},
imageList: {
rule: false,
limit: null,
renderExtra: () => '(图片最大上传2M)',
},
detailImageList: {
title: '详情图',
rule: true,
limit: null,
renderExtra: () => '(图片最大上传2M)',
},
},
},
// {
// name: '虚拟商品',
// type: 2,
// desc: '无需物流',
// hide: !canAddNormal,
// imgConfig: {
// commonImageList: {
// title: '公共滑动图',
// rule: false,
// limit: null,
// renderExtra: () => '(图片最大上传2M)',
// },
// imageList: {
// rule: false,
// limit: null,
// renderExtra: () => '(图片最大上传2M)',
// },
// detailImageList: {
// title: '详情图',
// rule: true,
// limit: null,
// renderExtra: () => '(图片最大上传2M)',
// },
// },
// },
{
name: '服务类商品',
type: 4,
......@@ -94,7 +94,7 @@ export const TaskList = (canAddService, canAddNormal) => [
name: '外卖商品',
type: 5,
desc: '无需物流',
// hide: !canAddService,
hide: !canTakeawayService,
imgConfig: {
commonImageList: {
title: '封面图片',
......@@ -324,10 +324,7 @@ export const StaticColumns = customer => [
},
];
export const ENUM_REPERTORY = [{ label: '单规格', value: '1' }, { label: '多规格', value: '2' }];
export const ENUM_SET_REPERTORY = [
{ label: '清零', value: '0' },
{ label: '最大', value: '1' },
];
export const ENUM_SET_REPERTORY = [{ label: '清零', value: '0' }, { label: '最大', value: '1' }];
export const ENUM_WEEK = [
{ value: '1', label: '周一' },
{ value: '2', label: '周二' },
......
import React, { useState, useRef, useEffect, useCallback, useMemo } from 'react';
import { Spin, Button, Modal, message, notification } from 'antd';
import moment from 'moment';
import PubSub from 'pubsub-js';
import { Title, WrapperContainer } from './components/CommonTemplate';
import { TaskTypeSelect } from './components/TaskTypeSelect';
import FormInformationBasic from './components/FormInformationBasic';
......@@ -45,7 +46,7 @@ const ServiceGoods = options => {
} = options;
const canAddService = permissions[GOOD_MANAGE.ADD_SERVICE_GOODS];
const canAddNormal = permissions[GOOD_MANAGE.ADD_NORMAL_GOODS];
// const canTakeawayService = permissions[GOOD_MANAGE.ADD_TAKEAWAY_GOODS];
const canTakeawayService = permissions[GOOD_MANAGE.ADD_TAKEAWAY_GOODS];
// const canTakeawayService = true
const basicRef = useRef(null);
const stockRef = useRef(null);
......@@ -59,7 +60,9 @@ const ServiceGoods = options => {
const [categoryIds, setCategoryIds] = useState([]); // 商品品类ID
const [isEdit, setIsEdit] = useState(false); // 是否是编辑状态
const [isUseCache, setIsUseCache] = useState(false); // 是否使用缓存
const [productType, setProductType] = useState(canAddNormal ? 1 : 4); // 商品状态
let ptype = canTakeawayService ? 5 : 4;
ptype = canAddNormal ? 1 : ptype;
const [productType, setProductType] = useState(ptype); // 商品状态
const [pageLoading, setPageLoading] = useState(false); // 页面加载状态
const [afterAddressList, setAfterAddressList] = useState([]); // 售后地址
const [supplierIdList, setSupplierIdList] = useState([]); // 适用们店列表
......@@ -159,25 +162,41 @@ const ServiceGoods = options => {
const onResetData = refresh => {
setPageId(null);
setIsEdit(false);
setProductType(canAddNormal ? 1 : 4);
setProductType(ptype);
setEditData({});
setSpecKeyList([]);
resetForm();
options.onChange(false, refresh);
};
const handleCancel = refresh => {
const refreshPageList = (refresh, sendData) => {
onResetData(refresh);
// 新增外卖商品 关闭之后列表到跳转对应分组的下
if (
!isEdit &&
sendData &&
+sendData.type === 5 &&
sendData.storageRackIds &&
sendData.storageRackIds.length > 0
) {
PubSub.publish('refreshTakeAway', {
groupId: sendData.storageRackIds[0],
});
}
};
const handleCancel = (refresh, sendData) => {
const info = localStorage.get(localAutoSaveKey);
if (info && Object.keys(info).length > 1) {
Modal.confirm({
title: '确认提示',
content: '商品信息还未保存,确认关闭弹窗?',
onOk() {
onResetData(refresh);
refreshPageList(refresh, sendData);
},
});
} else {
onResetData(refresh);
refreshPageList(refresh, sendData);
}
};
......@@ -210,7 +229,7 @@ const ServiceGoods = options => {
if (addResponse.data) {
message.success(`${isEdit ? '修改' : '添加'}成功!`);
localStorage.remove(localAutoSaveKey);
handleCancel(true);
handleCancel(true, sendData);
}
setPageLoading(false);
} catch (error) {
......@@ -371,7 +390,7 @@ const ServiceGoods = options => {
}, [isEdit, options.visible]);
useEffect(() => {
setProductType(canAddNormal ? 1 : 4);
setProductType(ptype);
}, [canAddNormal]);
const onSpecCommonImgEvent = useCallback(
......@@ -478,7 +497,7 @@ const ServiceGoods = options => {
productType,
canAddService, // 是否可以添加服务商品(电子卡券)
canAddNormal, // 是否可以添加实物商品
// canTakeawayService, // 是否可以添加外卖商品
canTakeawayService, // 是否可以添加外卖商品
isCard: productType === 4,
isTakeawayService: productType === 5,
// 0, "商品删除" 1, "新建" 2, "提交审核" 3, "待审核" 4, "驳回" 5, "未上架" 6, "已上架" 7, "已下架"
......
......@@ -114,12 +114,12 @@ export const filterSendData = (type, params) => {
// 外卖商品
if (type === 5) {
const temp = Object.assign({}, takeawayItem?.intactData, infoMation);
const deepTemp = JSON.parse(JSON.stringify(temp))
const deepTemp = JSON.parse(JSON.stringify(temp));
deepTemp.categoryId =
Array.isArray(deepTemp.categoryId) &&
deepTemp.categoryId?.slice(deepTemp.categoryId?.length - 1)?.toString();
deepTemp.productRefShopId = deepTemp.productRefShopId.toString();
deepTemp.productRefShopId = deepTemp.productRefShopId.toString();
const tempWeightName = JSON.parse(sessionStorage.getItem('weightUnits'));
deepTemp.items.forEach(item => {
item.autoStock = item.autoStock ? 1 : 0;
......@@ -127,8 +127,8 @@ export const filterSendData = (type, params) => {
item.productStock = item?.serviceItem?.productStock;
item.list = deepTemp.list;
if (item?.specs?.length) {
item?.specs.forEach(itm => {
if (tempWeightName.includes(itm.unit)) {
item.specs.forEach(itm => {
if (itm?.unit && tempWeightName.includes(itm?.unit)) {
itm.quantity =
`${itm?.quantity}`.indexOf('约') > -1 ? itm?.quantity : `${itm?.quantity}`;
}
......@@ -136,15 +136,17 @@ export const filterSendData = (type, params) => {
}
});
deepTemp.specList &&
deepTemp.specList.forEach(item => {
deepTemp.specList.forEach(item => {
if (item?.specs?.length) {
item?.specs.forEach(itm => {
itm.unit =
(Array.isArray(itm.unit) &&
itm.unit?.length >= 2 &&
itm.unit?.splice(itm.unit?.length - 1)[0]) ||
itm.unit;
if (tempWeightName.includes(itm.unit)) {
item.specs.forEach(itm => {
if (itm?.unit) {
itm.unit =
(Array.isArray(itm?.unit) &&
itm?.unit?.length >= 2 &&
itm?.unit?.splice(itm?.unit?.length - 1)[0]) ||
itm?.unit;
}
if (itm?.unit && tempWeightName.includes(itm?.unit)) {
itm.quantity =
`${itm?.quantity}`.indexOf('约') > -1 ? itm?.quantity : `${itm?.quantity}`;
}
......
......@@ -53,7 +53,7 @@ export async function getInfo() {
res.customList = res.facilities.customList || [];
res.selfList = res.facilities.selfList || [];
}
res.signDateType = [res.signDateType] || [];
res.signDateType = res.signDateType ? [res.signDateType] : [];
res.accountOpenPermitImage = res.accountOpenPermitImage
? [{ uid: 0, url: res.accountOpenPermitImage }]
: [];
......@@ -77,8 +77,11 @@ export async function getInfo() {
: [];
// 工商局
res.icbProofImage = res.icbProofImage ? [{ uid: 0, url: res.icbProofImage }] : [];
if (res.categoryQualificateImage) {
res.categoryQualificateImage = [{ uid: 0, url: res.categoryQualificateImage }];
if (res.categoryQualificateImage && res.categoryQualificateImage.length) {
res.categoryQualificateImage = res.categoryQualificateImage.map((item, index) => ({
uid: index,
url: item,
}));
}
if (res.otherImage && res.otherImage.length) {
res.otherImage = res.otherImage.map((item, index) => ({
......@@ -126,7 +129,15 @@ export async function getInfo() {
// 删除图片
function delImg(keyName, e) {
this.setState(state => {
state.businessInfo[keyName].splice(e.uid, 1);
if (keyName === 'categoryQualificateImage') {
state.businessInfo.categoryQualificateImage.forEach((item, index) => {
if (item.uid === e.uid) {
state.businessInfo.categoryQualificateImage.splice(index, 1);
}
});
} else {
state.businessInfo[keyName].splice(e.uid, 1);
}
return {
businessInfo: state.businessInfo,
};
......@@ -319,7 +330,6 @@ export async function getAreaAddr() {
label: item.addrName,
value: item.addrId,
}));
console.log(this.state.businessInfo, '......');
// 编辑时 回显 市、区、街道
if (this.state.businessInfo.provinceId) {
const pros = res.filter(item => +item.value === +this.state.businessInfo.provinceId);
......
......@@ -259,7 +259,6 @@ class BusinessInfo extends Component {
}
});
}
obj.businessLicenseImage =
(imgs?.businessLicenseImage?.length && imgs?.businessLicenseImage[0].url) || '';
obj.idCardEmblemImage =
......@@ -287,7 +286,11 @@ class BusinessInfo extends Component {
delete obj.otherImage;
}
if (imgs.categoryQualificateImage && imgs.categoryQualificateImage.length) {
obj.categoryQualificateImage = imgs.categoryQualificateImage[0].url;
const list = [];
imgs.categoryQualificateImage.forEach(item => {
list.push(item.url);
});
obj.categoryQualificateImage = list;
} else {
delete obj.categoryQualificateImage;
}
......@@ -449,9 +452,12 @@ class BusinessInfo extends Component {
<Col span={12}>
<FormItem label="联系人姓名" labelCol={{ span: 8 }}>
{getFieldDecorator('contactName', {
rules: [{ required: true, message: '请输入联系人姓名!' }],
rules: [
{ required: true, message: '请输入联系人姓名!' },
{ pattern: /^[A-Za-z\u4e00-\u9fa5]+$/, message: '请输入汉字或字母!' },
],
initialValue: businessInfo.contactName,
})(<Input maxLength={8} />)}
})(<Input />)}
</FormItem>
</Col>
<Col span={12}>
......@@ -604,9 +610,12 @@ class BusinessInfo extends Component {
<Col span={12}>
<FormItem label="统一社会信用代码" labelCol={{ span: 8 }}>
{getFieldDecorator('socialCode', {
rules: [{ required: true, message: '请输入统一社会信用代码!' }],
rules: [
{ required: true, message: '请输入统一社会信用代码!' },
{ pattern: /^[A-Za-z0-9]*$/, message: '仅支持输入数字和字母' },
],
initialValue: businessInfo.socialCode,
})(<Input maxLength={32} />)}
})(<Input maxLength={18} />)}
</FormItem>
</Col>
{(!companyNamedis &&
......@@ -680,6 +689,7 @@ class BusinessInfo extends Component {
{...uploadPropsFn.call(this, {
keyName: 'categoryQualificateImage',
type: 6,
limit: 9,
})}
fileList={businessInfo.categoryQualificateImage}
>
......@@ -808,7 +818,10 @@ class BusinessInfo extends Component {
<Col span={12}>
<FormItem label="身份证号码" labelCol={{ span: 8 }}>
{getFieldDecorator('legalPersonIdCard', {
rules: [{ required: true, message: '请输入身份证号码!' }],
rules: [
{ required: true, message: '请输入身份证号码!' },
{ pattern: /^[A-Za-z0-9]*$/, message: '请输入数字或字母' },
],
initialValue: businessInfo.legalPersonIdCard,
})(<Input maxLength={18} />)}
</FormItem>
......@@ -926,9 +939,12 @@ class BusinessInfo extends Component {
<Col span={12}>
<FormItem label="开户许可证编号" labelCol={{ span: 8 }}>
{getFieldDecorator('bankAccountLicenseNum', {
rules: [{ required: true, message: '请输入开户许可证编号!' }],
rules: [
{ required: true, message: '请输入开户许可证编号!' },
{ pattern: /^[A-Za-z0-9]*$/, message: '请输入数字或字母' },
],
initialValue: businessInfo.bankAccountLicenseNum,
})(<Input maxLength={32} />)}
})(<Input />)}
</FormItem>
</Col>
<Col span={12}>
......@@ -963,14 +979,18 @@ class BusinessInfo extends Component {
<Col span={12}>
<FormItem label="银行帐号" labelCol={{ span: 8 }}>
{getFieldDecorator('bankAccount', {
rules: [{ required: true, message: '请输入银行帐号!' }],
rules: [
{ required: true, message: '请输入银行帐号!' },
{ pattern: /^[0-9]*$/, message: '请输入数字' },
],
initialValue: businessInfo.bankAccount,
})(<Input maxLength={20} />)}
})(<Input />)}
</FormItem>
</Col>
<Col span={12}>
<FormItem label="联行号" labelCol={{ span: 8 }}>
{getFieldDecorator('interbankNum', {
rules: [{ pattern: /^[0-9]*$/, message: '请输入数字' }],
initialValue: businessInfo.interbankNum,
})(<Input maxLength={50} />)}
</FormItem>
......@@ -1046,9 +1066,12 @@ class BusinessInfo extends Component {
<Col span={12}>
<FormItem label="银行帐号" labelCol={{ span: 8 }}>
{getFieldDecorator('bankAccount', {
rules: [{ required: true, message: '请输入银行帐号!' }],
rules: [
{ required: true, message: '请输入银行帐号!' },
{ pattern: /^[0-9]*$/, message: '请输入数字' },
],
initialValue: businessInfo.bankAccount,
})(<Input maxLength={20} />)}
})(<Input />)}
</FormItem>
</Col>
</Row>
......@@ -1107,9 +1130,12 @@ class BusinessInfo extends Component {
<Col span={12}>
<FormItem label="银行帐号" labelCol={{ span: 8 }}>
{getFieldDecorator('bankAccount', {
rules: [{ required: true, message: '请输入银行帐号!' }],
rules: [
{ required: true, message: '请输入银行帐号!' },
{ pattern: /^[0-9]*$/, message: '请输入数字' },
],
initialValue: businessInfo.bankAccount,
})(<Input maxLength={20} />)}
})(<Input />)}
</FormItem>
</Col>
</Row>
......
......@@ -4,7 +4,7 @@ import moment from 'moment';
import { PlusSquareFilled, MinusSquareFilled } from '@ant-design/icons';
import { Modal, Input, TimePicker, Checkbox, Cascader, Radio, notification, Button } from 'antd';
import { apiAddrArea, apiCreatStore, apiEditStore } from '../services';
import { weekOptions, weekDefault, layout, businessModel } from '../data';
import { weekOptions, weekDefault, layout } from '../data';
import MapModal from '@/components/GaoDeMap';
import style from './style.less';
import { isCheckNumberLine } from '@/utils/validator';
......@@ -20,6 +20,7 @@ const StoreModal = props => {
formInfo,
status,
productBusiness,
existTakewayShop,
} = props;
const [areaAddr, setAreaAddr] = useState([]);
const [visibleMap, setVisibleMap] = useState(false);
......@@ -30,25 +31,19 @@ const StoreModal = props => {
address: '',
});
const [disabled, setDisabled] = useState(false);
const [isDisabled, setIsDisabled] = useState(true);
const [isDisabled, setIsDisabled] = useState(false);
const [businessModel, setBusinessModel] = useState([
{ label: '到家外卖业务(外卖配送业务)', value: 1 },
{ label: '实物商品业务员', value: 2 },
{ label: '到店业务(服务类业务)', value: 3 },
]);
const divDom = useRef();
useEffect(() => {
setDisabled(props.status);
}, [props.status]);
useEffect(() => {
if (props.productBusiness.length) {
const val = props.productBusiness.includes(2) || props.productBusiness.includes(3);
setIsDisabled(val);
}
}, [props.productBusiness]);
const handleCancel = isSuccess => {
resetFields();
onCancel(isSuccess);
};
const onSubmit = () => {
validateFields(async (error, fieldsValue) => {
if (!error) {
......@@ -59,7 +54,7 @@ const StoreModal = props => {
params[areaArr[i]] = item;
});
}
if (params.shopHeadImage.length) {
if (params?.shopHeadImage?.length) {
// eslint-disable-next-line prefer-destructuring
params.shopHeadImage = params.shopHeadImage[0];
}
......@@ -219,10 +214,42 @@ const StoreModal = props => {
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();
}
};
const onBusiness = e => {
const val = e.includes(1);
setIsDisabled(val);
};
useEffect(() => {
if (visible) {
resetFields();
const info = Object.assign({}, formInfo);
const val = info?.productBusiness?.includes(1);
setIsDisabled(val);
if (status === 'look') {
setDisabled(true);
} else {
setDisabled(false);
}
const data = [...businessModel];
data.forEach(item => {
item.disabled = !productBusiness.includes(item.value);
if (existTakewayShop && item.value === 1 && !val) {
item.disabled = true;
}
});
console.log(data, '.........');
setBusinessModel(data);
if (info && info.id) {
info.week = info.businessHours.weeks;
const hours = info.businessHours.hoursItems;
......@@ -235,13 +262,13 @@ const StoreModal = props => {
});
});
}
info.lnglat = `${info.longitude},${info.latitude}`;
info.addr = [info.provinceId, info.cityId, info.countyId];
info.shopHeadImage = [info.shopHeadImage] || [];
info.shopHeadImage = (info.shopHeadImage && [info.shopHeadImage]) || [];
if (info.townId) {
info.addr.push(info.townId);
}
console.log(info);
setTimes(harr);
setFormData(info);
getLazyAddr(info);
......@@ -278,8 +305,9 @@ const StoreModal = props => {
<Form {...layout} name="formData">
<FormItem label="业务模式">
{getFieldDecorator('productBusiness', {
initialValue: productBusiness,
})(<Checkbox.Group disabled options={businessModel} />)}
rules: [{ required: true, message: '请选择业务模式' }],
initialValue: formData.productBusiness,
})(<Checkbox.Group disabled={disabled} options={businessModel} onChange={onBusiness} />)}
</FormItem>
{isDisabled && (
<FormItem label="门店头像">
......@@ -317,18 +345,12 @@ const StoreModal = props => {
<div>
<FormItem name={item.name}>
{getFieldDecorator(item.name, {
rules: [{ required: true, message: '请选择营业时间!' }],
rules: [
{ required: true, message: '请选择营业时间!' },
{ validator: timerWrapper, message: '选择开始时间结束时间不能一样' },
],
initialValue: formData[item.name],
})(
<TimePicker.RangePicker
format="HH:mm"
showTime={{
hideDisabledOptions: true,
defaultValue: [moment('00:00', 'HH:mm'), moment('23:59', 'HH:mm')],
}}
disabled={disabled}
/>,
)}
})(<TimePicker.RangePicker format="HH:mm" disabled={disabled} />)}
</FormItem>
</div>
{!disabled &&
......
......@@ -18,13 +18,6 @@ export const layout = {
wrapperCol: { span: 16 },
};
// 业务模式
export const businessModel = [
{ label: '到家外卖业务(外卖配送业务)', value: 1 },
{ label: '实物商品业务员', value: 2 },
{ label: '到店业务(服务类业务)', value: 3 },
];
export const businessList = [
{ label: '外卖', value: 1 },
{ label: '实物类', value: 2 },
......
......@@ -25,30 +25,33 @@ export default () => {
const [visible, setVisible] = useState(false);
const [storeInfo, setStoreInfo] = useState({});
const [areaAddr, setAreaAddr] = useState([]);
const [status, setStatus] = useState();
const [status, setStatus] = useState(false);
const [dataList, setDataList] = useState([]);
const [pageNo, setPageNo] = useState(1);
const [totalNum, setTotalNum] = useState(0);
const [pageSize, setPageSize] = useState(20);
const [productBusiness, setProductBusiness] = useState([]);
const [existTakewayShop, setExistTakewayShop] = useState(false);
const refSearch = useRef();
const divDom = useRef();
// 获取业务模式
const getBusiness = async () => {
const res = await apiproductBusiness();
setProductBusiness(res);
if (res) {
setProductBusiness(res.productBusiness || []);
setExistTakewayShop(res.existTakewayShop);
}
setVisible(true);
};
const onCreate = () => {
setStatus('add');
setStoreInfo({});
setVisible(true);
getBusiness();
};
const onShowInfo = (info, val) => {
setStoreInfo(info);
const value = val !== 'edit';
setStatus(value);
setVisible(true);
setStatus(val);
getBusiness();
};
......@@ -122,6 +125,9 @@ export default () => {
if (val.businessStatus) {
params.businessStatus = val.businessStatus;
}
if (val.productBusiness) {
params.productBusiness = val.productBusiness;
}
getList(params);
};
......@@ -215,8 +221,8 @@ export default () => {
dataIndex: 'productBusiness',
width: 120,
align: 'center',
render: v =>
v && (
render: (v, value) =>
value?.productBusiness?.length && (
<div>
{v.map(it => (
<span>{businessList.find(item => +it === +item.value).label}&nbsp;</span>
......@@ -265,7 +271,7 @@ export default () => {
fixed: 'right',
render: (val, r) => (
<div className={style.actionBtn}>
<Button key="look" onClick={() => onShowInfo(r)}>
<Button key="look" onClick={() => onShowInfo(r, 'look')}>
查看
</Button>
<Button key="seek" onClick={() => onShowInfo(r, 'edit')}>
......@@ -309,6 +315,17 @@ export default () => {
</Select>
</Form.Item>
</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>
<div className={style.search}>
<Button type="primary" htmlType="submit" size="middle">
......@@ -351,6 +368,7 @@ export default () => {
formInfo={storeInfo}
status={status}
productBusiness={productBusiness}
existTakewayShop={existTakewayShop}
/>
</div>
);
......
......@@ -154,20 +154,20 @@ export const getObjectType = v => Object.prototype.toString.call(v).replace(/\[o
export const getErrorMessage = err => {
const message = '请检查表单数据!';
// eslint-disable-next-line wrap-iife
// (function getMsg(v) {
// if (Array.isArray(v)) {
// getMsg(v[0]);
// } else {
// const keys = Object.keys(v);
// if (Array.isArray(v[keys[0]])) {
// getMsg(v[keys[0]][0]);
// } else if (v[keys[0]].errors && v[keys[0]].errors.length) {
// // eslint-disable-next-line no-const-assign
// message = v[keys[0]].errors[0].message;
// } else {
// getMsg(v);
// }
// }
// })(err);
(function getMsg(v) {
if (Array.isArray(v)) {
getMsg(v[0]);
} else {
const keys = Object.keys(v);
if (Array.isArray(v[keys[0]])) {
getMsg(v[keys[0]][0]);
} else if (v[keys[0]].errors && v[keys[0]].errors.length) {
// eslint-disable-next-line no-const-assign
message = v[keys[0]].errors[0].message;
} else {
getMsg(v);
}
}
})(err);
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