@@ -303,7 +303,7 @@ export async function getInitialState() { | |||
var tempMenu = await queryMenuData(); | |||
//创建菜单 | |||
//await syncMenus(tempMenu); | |||
if (!isDev) { | |||
if (isDev) { | |||
var data = await dymicMenus(currentUser.data.id); | |||
tempMenu = data.data; | |||
} | |||
@@ -134,17 +134,17 @@ const Advanced = (props) => { | |||
tabActiveKey: props.location.query.tabStatus ? props.location.query.tabStatus : 'basis', | |||
}); | |||
useEffect(() => { | |||
if(!props.location.query.values.id){ | |||
history.push({ | |||
pathname: '/database/goods/newgoods', | |||
}); | |||
}else{ | |||
// if(!props.location?.query?.values){ | |||
// history.push({ | |||
// pathname: '/database/goods/newgoods', | |||
// }); | |||
// }else{ | |||
SetCurrTabKey(tabStatus.tabActiveKey); | |||
initGoodsUnit(); | |||
initGoodsType(); | |||
initGetbomType(); | |||
intBatching(); | |||
} | |||
//} | |||
}, [tabStatus]) | |||
const onTabChange = (key) => { | |||
@@ -22,68 +22,6 @@ import StockMaterial from './components/StockMaterial'; | |||
import { values } from 'lodash'; | |||
const key = 'message'; | |||
//添加 | |||
const handleAdd = async (fields) => { | |||
try { | |||
message.loading('正在添加', key); | |||
await AddDeviceInfo(JSON.stringify(fields)).then((r) => { | |||
message.destroy(key); | |||
if (r.data) { | |||
message.success('添加成功'); | |||
return true; | |||
} else { | |||
//message.error('添加失败'); | |||
message.success('添加成功'); | |||
return false; | |||
} | |||
}); | |||
} catch (error) { | |||
message.error('添加失败请重试!'); | |||
return false; | |||
} | |||
}; | |||
//修改 | |||
const handleUpdate = async (fields) => { | |||
try { | |||
message.loading('正在修改', key); | |||
await UpdateDeviceInfo(JSON.stringify(fields)).then((r) => { | |||
message.destroy(key); | |||
if (r.data) { | |||
message.success('修改成功'); | |||
return true; | |||
} else { | |||
message.success('修改失败'); | |||
return false; | |||
} | |||
}); | |||
} catch (error) { | |||
message.error('修改失败请重试!'); | |||
return false; | |||
} | |||
}; | |||
//删除 | |||
const handleRemove = async (selectedRows) => { | |||
try { | |||
message.loading('正在删除'); | |||
let ids = []; | |||
selectedRows.forEach((item) => { | |||
ids.push(item.id); | |||
}); | |||
await DelDeviceInfo(ids).then((r) => { | |||
if (r.data) { | |||
message.success('删除成功'); | |||
return true; | |||
} else { | |||
message.success('删除失败'); | |||
return false; | |||
} | |||
}); | |||
} catch (error) { | |||
message.error('删除失败请重试!'); | |||
return false; | |||
} | |||
}; | |||
const GoodsTypeManage = () => { | |||
const [storeType, setStoreType] = useState(); | |||
@@ -99,6 +37,12 @@ const GoodsTypeManage = () => { | |||
const [deviceFoodModal, setDeviceFoodModal] = useState(); | |||
// 是否显示 库存物料弹窗 | |||
const [stockModal, setStockModal] = useState(false); | |||
/** 新建/更新窗口的弹窗 */ | |||
const [createModalVisible, handleModalVisible] = useState(false); | |||
/** 分布更新窗口的弹窗 */ | |||
const actionRef = useRef(); | |||
const [currentRow, setCurrentRow] = useState(); | |||
const [selectedRowsState, setSelectedRows] = useState([]); | |||
//初始化数据 | |||
useEffect(() => { | |||
@@ -182,12 +126,6 @@ const GoodsTypeManage = () => { | |||
} | |||
}; | |||
/** 新建/更新窗口的弹窗 */ | |||
const [createModalVisible, handleModalVisible] = useState(false); | |||
/** 分布更新窗口的弹窗 */ | |||
const actionRef = useRef(); | |||
const [currentRow, setCurrentRow] = useState(); | |||
const [selectedRowsState, setSelectedRows] = useState([]); | |||
/** 国际化配置 */ | |||
const columns = [ | |||
@@ -343,6 +281,59 @@ const GoodsTypeManage = () => { | |||
}, | |||
]; | |||
//添加 | |||
const handleAdd = async (fields) => { | |||
await AddDeviceInfo(JSON.stringify(fields)).then((r) => { | |||
if (r.succeeded) { | |||
message.success('添加成功'); | |||
handleModalVisible(false); | |||
actionRef.current.reload(); | |||
} else { | |||
message.error(r.errors) | |||
return false; | |||
} | |||
}); | |||
}; | |||
//修改 | |||
const handleUpdate = async (fields) => { | |||
await UpdateDeviceInfo(JSON.stringify(fields)).then((r) => { | |||
if (r.succeeded) { | |||
message.success('添加成功'); | |||
handleModalVisible(false); | |||
actionRef.current.reload(); | |||
} else { | |||
message.error(r.errors) | |||
return false; | |||
} | |||
}); | |||
}; | |||
//删除 | |||
const handleRemove = async (selectedRows) => { | |||
try { | |||
message.loading('正在删除'); | |||
let ids = []; | |||
selectedRows.forEach((item) => { | |||
ids.push(item.id); | |||
}); | |||
await DelDeviceInfo(ids).then((r) => { | |||
if (r.data) { | |||
message.success('删除成功'); | |||
return true; | |||
} else { | |||
message.success('删除失败'); | |||
return false; | |||
} | |||
}); | |||
} catch (error) { | |||
message.error('删除失败请重试!'); | |||
return false; | |||
} | |||
}; | |||
return ( | |||
<PageContainer host header={{ | |||
title: '', | |||
@@ -426,16 +417,10 @@ const GoodsTypeManage = () => { | |||
dicData={dicData} | |||
initDeviceType={initDeviceType} | |||
onFinish={async (value) => { | |||
var success = false; | |||
if (value.id) { | |||
success = handleUpdate(value); | |||
handleUpdate(value); | |||
} else { | |||
success = handleAdd(value); | |||
} | |||
if (success) { | |||
handleModalVisible(false); | |||
setCurrentRow(undefined); | |||
actionRef.current.reload(); | |||
handleAdd(value); | |||
} | |||
}} | |||
onCancel={() => { | |||
@@ -28,23 +28,17 @@ const menuManager = () => { | |||
*/ | |||
const handleAdd = async (fields) => { | |||
const hide = message.loading('正在添加'); | |||
try { | |||
fields.type=3 | |||
await api.add({ ...fields }).then((r) => { | |||
if (r.succeeded) { | |||
hide(); | |||
message.success('添加成功'); | |||
actionRef.current.reload(); | |||
handleModalVisible(false); | |||
}else{ | |||
message.error(r.errors); | |||
} | |||
}); | |||
} catch (error) { | |||
hide(); | |||
message.error('添加失败请重试!'); | |||
return false; | |||
} | |||
}; | |||
/** | |||
* 更新节点 | |||
@@ -53,43 +47,15 @@ const menuManager = () => { | |||
*/ | |||
const handleUpdate = async (fields) => { | |||
const hide = message.loading('正在配置'); | |||
try { | |||
api.update(fields).then((r) => { | |||
if (r.succeeded) { | |||
hide(); | |||
message.success('更新成功'); | |||
actionRef.current.reload(); | |||
handleModalVisible(false); | |||
}else{ | |||
message.error(r.errors); | |||
} | |||
}); | |||
} catch (error) { | |||
hide(); | |||
message.error('更新失败请重试!'); | |||
return false; | |||
} | |||
}; | |||
/** | |||
* 删除节点 | |||
* | |||
* @param selectedRows | |||
*/ | |||
const handleRemove = async (selectedRows) => { | |||
const hide = message.loading('正在删除'); | |||
if (!selectedRows) return true; | |||
try { | |||
await api.remove(selectedRows.map((row) => row.id)); | |||
hide(); | |||
message.success('删除成功,即将刷新'); | |||
return true; | |||
} catch (error) { | |||
hide(); | |||
message.error('删除失败,请重试'); | |||
return false; | |||
} | |||
}; | |||
const InitTree = async () => { | |||
await api.trees().then((r) => { | |||
@@ -115,7 +81,12 @@ const handleRemove = async (selectedRows) => { | |||
arr.push(<a | |||
onClick={() => { | |||
api.enable(record.id).then((r) => { | |||
actionRef.current.reload(); | |||
if (r.succeeded) { | |||
message.success('操作成功'); | |||
actionRef.current.reload(); | |||
}else{ | |||
message.error(r.errors); | |||
} | |||
}); | |||
}} | |||
> | |||
@@ -126,7 +97,12 @@ const handleRemove = async (selectedRows) => { | |||
arr.push(<a | |||
onClick={() => { | |||
api.disable(record.id).then((r) => { | |||
actionRef.current.reload(); | |||
if (r.succeeded) { | |||
message.success('操作成功'); | |||
actionRef.current.reload(); | |||
}else{ | |||
message.error(r.errors); | |||
} | |||
}); | |||
}} | |||
> | |||
@@ -151,7 +127,12 @@ const handleRemove = async (selectedRows) => { | |||
cancelText="否" | |||
onConfirm={() => { | |||
api.remove([record.id]).then((r) => { | |||
actionRef.current.reload(); | |||
if (r.succeeded) { | |||
message.success('操作成功'); | |||
actionRef.current.reload(); | |||
}else{ | |||
message.error(r.errors); | |||
} | |||
}); | |||
}} | |||
onCancel={() => { }} | |||
@@ -181,6 +162,11 @@ const handleRemove = async (selectedRows) => { | |||
dataIndex: 'code', | |||
ellipsis:true, | |||
}, | |||
{ | |||
title: '排序', | |||
dataIndex: 'sort', | |||
ellipsis:true, | |||
}, | |||
{ | |||
title: '菜单图标', | |||
dataIndex: 'icon', | |||
@@ -284,15 +270,10 @@ const handleRemove = async (selectedRows) => { | |||
treeDatas={treeData} | |||
dictData={handlData} | |||
onFinish={async (value) => { | |||
var success = false; | |||
if (value.id) { | |||
success = await handleUpdate(value); | |||
await handleUpdate(value); | |||
} else { | |||
success = await handleAdd(value); | |||
} | |||
if (success) { | |||
handleModalVisible(false); | |||
actionRef.current.reload(); | |||
await handleAdd(value); | |||
} | |||
}} | |||
onCancel={() => { | |||