@@ -173,6 +173,13 @@ export default [ | |||
component: './database/goods/goodstechnology', | |||
access: 'k7', | |||
}, | |||
{ | |||
name: '商品属性配置', | |||
icon: 'smile', | |||
path: '/database/goods/goodsattributeprice', | |||
component: './database/goods/goodsattributeprice', | |||
access: 'k7', | |||
}, | |||
] | |||
}, | |||
], | |||
@@ -453,6 +460,27 @@ export default [ | |||
}, | |||
], | |||
}, | |||
{ | |||
name: '授权管理', | |||
icon: 'BankFilled', | |||
path: '/authorization', | |||
routes: [ | |||
{ | |||
name: '平台授权', | |||
icon: 'smile', | |||
path: '/authorization/platformAuthorization', | |||
component: './authorization/platformAuthorization', | |||
access: 'k12', | |||
}, | |||
{ | |||
name: '店铺授权', | |||
icon: 'smile', | |||
path: '/authorization/storeAuthorization', | |||
component: './authorization/storeAuthorization', | |||
access: 'k12', | |||
} | |||
], | |||
}, | |||
{ | |||
path: '/', | |||
redirect: '/welcome', | |||
@@ -244,6 +244,14 @@ export async function getInitialState() { | |||
component: './database/goods/newgoods', | |||
access: 'k10', | |||
}, | |||
{ | |||
code: 'newgoods', | |||
name: '商品属性配置', | |||
icon: 'smile', | |||
path: '/database/goods/goodsattributeprice', | |||
component: './database/goods/goodsattributeprice', | |||
access: 'k10', | |||
}, | |||
] | |||
}, | |||
] | |||
@@ -0,0 +1,219 @@ | |||
import React, { useState, useRef } from 'react'; | |||
import { Modal, Button, message, Popconfirm, Typography, Form, Input, DatePicker, Select, Radio } from 'antd'; | |||
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'; | |||
import { PlusOutlined } from '@ant-design/icons'; | |||
import ProTable from '@ant-design/pro-table'; | |||
import dayjs from 'dayjs'; | |||
import weekday from "dayjs/plugin/weekday"; | |||
import localeData from "dayjs/plugin/localeData"; | |||
dayjs.extend(weekday); | |||
dayjs.extend(localeData); | |||
const dateFormat = 'YYYY/MM/DD'; | |||
const { Paragraph, Text } = Typography; | |||
import { PageAuthorization, AddAuthorization, UpdateAuthorization, UpdateAuthTime,DelAuthorization } from "./services" | |||
const App = () => { | |||
const actionRef = useRef(); | |||
const [ModalVisible, handleModalVisible] = useState(false); | |||
const [currentRow, setCurrentRow] = useState(); | |||
const [form] = Form.useForm(); | |||
const columns = [ | |||
{ | |||
title: '主键', | |||
dataIndex: 'id', | |||
hideInSearch: true, | |||
hideInTable: true, | |||
tip: '规则名称是唯一的 key' | |||
}, | |||
{ | |||
title: '授权码', | |||
dataIndex: 'key', | |||
valueType: 'textarea', | |||
search: false, | |||
render: (text) => <Paragraph style={{ display: 'inline' }} copyable>{text}</Paragraph>, | |||
}, | |||
{ | |||
title: '有效日期', | |||
dataIndex: 'periodValidity', | |||
valueType: 'textarea', | |||
width:200, | |||
search: false, | |||
render: (_, record) => { | |||
var time=dayjs(record.periodValidity, dateFormat).format('YYYY-MM-DD'); | |||
return <span>{record.periodValidity == null ? "长期有效" : time}</span> | |||
} | |||
}, | |||
{ | |||
title: '修改时间', | |||
dataIndex: 'updateAt', | |||
valueType: 'textarea', | |||
width:200, | |||
search: false | |||
}, | |||
{ | |||
title: '操作', | |||
dataIndex: 'option', | |||
valueType: 'option', | |||
fixed: 'right', | |||
width: 300, | |||
render: (_, record) => [ | |||
<Popconfirm | |||
type="primary" | |||
key="primary" | |||
title="确认更新吗?" | |||
okText="是" | |||
cancelText="否" | |||
onConfirm={() => { | |||
UpdateAuthorization(record.id).then((r) => { | |||
if (r.statusCode == 200 && r.data) { | |||
actionRef.current.reload(); | |||
message.success("修改成功"); | |||
} else { | |||
message.error(r.errors || "修改失败"); | |||
} | |||
}); | |||
}} | |||
onCancel={() => { }} | |||
> | |||
<a href="#">更新授权码</a> | |||
</Popconfirm>, | |||
<a href="#" onClick={() => { | |||
setCurrentRow(record); | |||
var aa = record.periodValidity == null ? "cqyx" : "gdsj"; | |||
var time=record.periodValidity == null ?null:dayjs(record.periodValidity, dateFormat); | |||
form.setFieldsValue({ id: record.id, autho:aa, periodValidity: time }); | |||
handleModalVisible(true); | |||
}}>更新授权时间</a>, | |||
<Popconfirm | |||
type="primary" | |||
key="primary" | |||
title="确认删除吗?" | |||
okText="是" | |||
cancelText="否" | |||
onConfirm={() => { | |||
DelAuthorization(record.id).then((r) => { | |||
if (r.statusCode == 200 && r.data) { | |||
actionRef.current.reload(); | |||
message.success("删除成功"); | |||
} else { | |||
message.error(r.errors || "删除失败"); | |||
} | |||
}); | |||
}} | |||
onCancel={() => { }} | |||
> | |||
<a href="#">删除</a> | |||
</Popconfirm> | |||
], | |||
}, | |||
]; | |||
return ( | |||
<PageContainer host header={{ title: '', breadcrumb: {}, }}> | |||
<ProTable | |||
actionRef={actionRef} | |||
rowKey="id" | |||
pagination={{ defaultPageSize: 10 }} | |||
search={{ | |||
labelWidth: 120, | |||
}} | |||
toolBarRender={() => [ | |||
<Button | |||
type="primary" | |||
key="primary" | |||
onClick={() => { | |||
handleModalVisible(true); | |||
form.setFieldsValue({ id: null, autho: "cqyx", periodValidity: null }); | |||
}} > | |||
<PlusOutlined /> 添加授权码 | |||
</Button>, | |||
]} | |||
request={async (params) => { | |||
var data = []; | |||
var total = 0; | |||
await PageAuthorization(params).then((r) => { | |||
total = r.data.total; | |||
data = r.data.data; | |||
}); | |||
return { | |||
data: data, | |||
success: true, | |||
total: total, | |||
}; | |||
}} | |||
columns={columns} | |||
/> | |||
<Modal title="授权操作" open={ModalVisible} | |||
onOk={() => { | |||
form.submit(); | |||
}} | |||
onCancel={() => { | |||
handleModalVisible(false); | |||
}}> | |||
<Form form={form} onFinish={(values) => { | |||
if (values.id) { | |||
UpdateAuthTime(values).then((r) => { | |||
if (r.statusCode == 200 && r.data) { | |||
message.success("修改成功"); | |||
actionRef.current.reload(); | |||
handleModalVisible(false); | |||
} else { | |||
message.error(r.errors || "修改失败"); | |||
} | |||
}); | |||
} else { | |||
AddAuthorization(values).then((r) => { | |||
if (r.statusCode == 200 && r.data) { | |||
message.success("添加成功"); | |||
actionRef.current.reload(); | |||
handleModalVisible(false); | |||
} else { | |||
message.error(r.errors || "添加失败"); | |||
} | |||
}); | |||
} | |||
}} | |||
style={{ | |||
maxWidth: 600, | |||
}}> | |||
<Form.Item name="id" hidden={true}> | |||
<Input /> | |||
</Form.Item> | |||
<Form.Item name="autho" label="授权时间" rules={[{ required: true, }]} > | |||
<Radio.Group > | |||
<Radio value="cqyx"> 长期有效 </Radio> | |||
<Radio value="gdsj"> 固定时间 </Radio> | |||
</Radio.Group> | |||
</Form.Item> | |||
<Form.Item noStyle shouldUpdate={(prevValues, currentValues) => prevValues.autho !== currentValues.autho} > | |||
{({ getFieldValue }) => | |||
getFieldValue('autho') == 'gdsj' ? ( | |||
<Form.Item name="periodValidity" label="固定时间" rules={[{ required: true, }]}> | |||
<DatePicker style={{ width: "300px" }} /> | |||
</Form.Item> | |||
) : null | |||
} | |||
</Form.Item> | |||
</Form> | |||
</Modal> | |||
</PageContainer> | |||
); | |||
}; | |||
export default App; |
@@ -0,0 +1,45 @@ | |||
import { request } from 'umi'; | |||
import { getDataBaseUrl,GetkitchbaseUrl } from '@/global_data'; | |||
/** 获取平台授权码 */ | |||
export async function PageAuthorization(data) { | |||
return request(getDataBaseUrl()+`/api/authorization/pageauthorization`, { | |||
method: 'POST', | |||
data: data, | |||
}); | |||
} | |||
/** 添加平台授权码 */ | |||
export async function AddAuthorization(data) { | |||
return request(getDataBaseUrl()+`/api/authorization/addauthorization`, { | |||
method: 'POST', | |||
data: data, | |||
}); | |||
} | |||
/** 修改平台授权码 */ | |||
export async function UpdateAuthorization(data) { | |||
return request(getDataBaseUrl()+`/api/authorization/updateauthorization?id=`+data, { | |||
method: 'POST', | |||
data: data, | |||
}); | |||
} | |||
/** 修改平台授权码时间 */ | |||
export async function UpdateAuthTime(data) { | |||
return request(getDataBaseUrl()+`/api/authorization/updateauthtime`, { | |||
method: 'POST', | |||
data: data, | |||
}); | |||
} | |||
/** 删除授权码 */ | |||
export async function DelAuthorization(data) { | |||
return request(getDataBaseUrl()+`/api/authorization/delauthorization?id=`+data, { | |||
method: 'POST', | |||
data: data, | |||
}); | |||
} | |||
@@ -0,0 +1,247 @@ | |||
import React, { useState, useRef, useEffect } from 'react'; | |||
import { Modal, Button, message, Popconfirm, Typography, Select,Form,Input,Radio,DatePicker} from 'antd'; | |||
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'; | |||
import { PlusOutlined } from '@ant-design/icons'; | |||
import ProTable from '@ant-design/pro-table'; | |||
import { QuestionCircleOutlined } from '@ant-design/icons'; | |||
import dayjs from 'dayjs'; | |||
import weekday from "dayjs/plugin/weekday"; | |||
import localeData from "dayjs/plugin/localeData"; | |||
dayjs.extend(weekday); | |||
dayjs.extend(localeData); | |||
const dateFormat = 'YYYY/MM/DD'; | |||
const { Paragraph, Text } = Typography; | |||
import { PageStoreAuthorization, AddStoreAuthorization, UpdateStoreAuthorization, UpdateStoreAuthTime, GetStoreList,DelStoreAuthTime } from "./services" | |||
const App = () => { | |||
const actionRef = useRef(); | |||
const [ModalVisible, handleModalVisible] = useState(false); | |||
const [currentRow, setCurrentRow] = useState(); | |||
const [storeList, setStoreList] = useState([]); | |||
const [form] = Form.useForm(); | |||
//初始化数据 | |||
useEffect(() => { | |||
function initData() { | |||
GetStoreList({ "current": 1, "pageSize": 9999 }).then((r) => { | |||
let data = []; | |||
if (r.statusCode == 200) { | |||
r.data.data.forEach((item) => { | |||
data.push({ | |||
id: item.id, | |||
label: item.name, | |||
value: item.id, | |||
}); | |||
}); | |||
setStoreList(data); | |||
} | |||
}); | |||
} | |||
initData(); | |||
}, []); | |||
const columns = [ | |||
{ | |||
title: '主键', | |||
dataIndex: 'id', | |||
hideInSearch: true, | |||
hideInTable: true, | |||
tip: '规则名称是唯一的 key' | |||
}, | |||
{ | |||
title: '场景', | |||
dataIndex: 'storeName', | |||
valueType: 'textarea', | |||
width:200, | |||
}, | |||
{ | |||
title: '授权码', | |||
dataIndex: 'key', | |||
valueType: 'textarea', | |||
search: false, | |||
render: (text) => <Paragraph style={{ display: 'inline' }} copyable>{text}</Paragraph>, | |||
}, | |||
{ | |||
title: '有效日期', | |||
dataIndex: 'periodValidity', | |||
valueType: 'date', | |||
width:150, | |||
search: false, | |||
render: (_, record) => { | |||
var time=dayjs(record.periodValidity, dateFormat).format('YYYY-MM-DD'); | |||
return <span>{record.periodValidity == null ? "长期有效" : time}</span> | |||
} | |||
}, | |||
{ | |||
title: '修改时间', | |||
dataIndex: 'updateAt', | |||
valueType: 'textarea', | |||
width: 150, | |||
search: false | |||
}, | |||
{ | |||
title: '操作', | |||
dataIndex: 'option', | |||
valueType: 'option', | |||
fixed: 'right', | |||
width: 250, | |||
render: (_, record) => [ | |||
<Popconfirm | |||
type="primary" | |||
key="primary" | |||
title="确认更新吗?" | |||
okText="是" | |||
cancelText="否" | |||
onConfirm={async () => { | |||
await UpdateStoreAuthorization(record.id).then((r) => { | |||
if (r.statusCode == 200 && r.data) { | |||
message.success("修改成功"); | |||
actionRef.current.reload(); | |||
} else { | |||
message.error(r.errors || "修改失败"); | |||
} | |||
}); | |||
}} | |||
onCancel={() => { }} | |||
> | |||
<a href="#">更新授权码</a> | |||
</Popconfirm>, | |||
<a href="#" onClick={() => { | |||
setCurrentRow(record); | |||
var aa = record.periodValidity == null ? "cqyx" : "gdsj"; | |||
var time=record.periodValidity == null ?null:dayjs(record.periodValidity, dateFormat); | |||
form.setFieldsValue({ id: record.id, autho:aa, periodValidity: time,storeId:record.storeId }); | |||
handleModalVisible(true); | |||
}}>更新授权时间</a>, | |||
<Popconfirm | |||
type="primary" | |||
key="primary" | |||
title="确认删除吗?" | |||
okText="是" | |||
cancelText="否" | |||
onConfirm={async () => { | |||
await DelStoreAuthTime(record.id).then((r) => { | |||
if (r.statusCode == 200 && r.data) { | |||
message.success("删除成功"); | |||
actionRef.current.reload(); | |||
} else { | |||
message.error(r.errors || "删除失败"); | |||
} | |||
}); | |||
}} | |||
onCancel={() => { }} | |||
> | |||
<a href="#">删除</a> | |||
</Popconfirm>, | |||
], | |||
}, | |||
]; | |||
return ( | |||
<PageContainer host header={{ title: '', breadcrumb: {}, }}> | |||
<ProTable | |||
actionRef={actionRef} | |||
rowKey="id" | |||
pagination={{ defaultPageSize: 10 }} | |||
search={{ | |||
labelWidth: 120, | |||
}} | |||
toolBarRender={() => [ | |||
<Button type="primary" key="primary" onClick={() => { | |||
handleModalVisible(true); | |||
}} > | |||
添加授权码 | |||
</Button> | |||
]} | |||
request={async (params) => { | |||
var data = []; | |||
var total = 0; | |||
await PageStoreAuthorization(params).then((r) => { | |||
total = r.data.total; | |||
data = r.data.data; | |||
}); | |||
return { | |||
data: data, | |||
success: true, | |||
total: total, | |||
}; | |||
}} | |||
columns={columns} | |||
/> | |||
<Modal title="授权操作" open={ModalVisible} | |||
onOk={() => { | |||
form.submit(); | |||
}} | |||
onCancel={() => { | |||
handleModalVisible(false); | |||
}}> | |||
<Form form={form} onFinish={(values) => { | |||
if (values.id) { | |||
UpdateStoreAuthTime(values).then((r) => { | |||
if (r.statusCode == 200 && r.data) { | |||
message.success("修改成功"); | |||
actionRef.current.reload(); | |||
handleModalVisible(false); | |||
} else { | |||
message.error(r.errors || "修改失败"); | |||
} | |||
}); | |||
} else { | |||
AddStoreAuthorization(values).then((r) => { | |||
if (r.statusCode == 200 && r.data) { | |||
message.success("添加成功"); | |||
actionRef.current.reload(); | |||
handleModalVisible(false); | |||
} else { | |||
message.error(r.errors || "添加失败"); | |||
} | |||
}); | |||
} | |||
}} | |||
style={{ | |||
maxWidth: 600, | |||
}}> | |||
<Form.Item name="id" hidden={true}> | |||
<Input /> | |||
</Form.Item> | |||
<Form.Item name="storeId" label="场景" rules={[{ required: true, }]}> | |||
<Select style={{ width: 330, }} onChange={(value) => { setCurrentRow(value); }} options={storeList} /> | |||
</Form.Item> | |||
<Form.Item name="autho" label="授权时间" rules={[{ required: true, }]} > | |||
<Radio.Group > | |||
<Radio value="cqyx"> 长期有效 </Radio> | |||
<Radio value="gdsj"> 固定时间 </Radio> | |||
</Radio.Group> | |||
</Form.Item> | |||
<Form.Item noStyle shouldUpdate={(prevValues, currentValues) => prevValues.autho !== currentValues.autho} > | |||
{({ getFieldValue }) => | |||
getFieldValue('autho') == 'gdsj' ? ( | |||
<Form.Item name="periodValidity" label="固定时间" rules={[{ required: true, }]}> | |||
<DatePicker style={{ width: "300px" }} /> | |||
</Form.Item> | |||
) : null | |||
} | |||
</Form.Item> | |||
</Form> | |||
</Modal> | |||
</PageContainer> | |||
); | |||
}; | |||
export default App; |
@@ -0,0 +1,55 @@ | |||
import { request } from 'umi'; | |||
import { getDataBaseUrl,GetkitchbaseUrl } from '@/global_data'; | |||
/** 获取平台授权码 */ | |||
export async function PageStoreAuthorization(data) { | |||
return request(GetkitchbaseUrl()+`/api/authorization/pagestoreauthorization`, { | |||
method: 'POST', | |||
data: data, | |||
}); | |||
} | |||
/** 添加平台授权码 */ | |||
export async function AddStoreAuthorization(data) { | |||
return request(GetkitchbaseUrl()+`/api/authorization/addstoreauthorization?storeId=`+data, { | |||
method: 'POST', | |||
data: data, | |||
}); | |||
} | |||
/** 修改平台授权码 */ | |||
export async function UpdateStoreAuthorization(data) { | |||
return request(GetkitchbaseUrl()+`/api/authorization/updatestoreauthorization?id=`+data, { | |||
method: 'POST', | |||
data: data, | |||
}); | |||
} | |||
/** 修改平台授权码时间 */ | |||
export async function UpdateStoreAuthTime(data) { | |||
return request(GetkitchbaseUrl()+`/api/authorization/updatestoreauthtime`, { | |||
method: 'POST', | |||
data: data, | |||
}); | |||
} | |||
/** 删除店铺授权码 */ | |||
export async function DelStoreAuthTime(data) { | |||
return request(GetkitchbaseUrl()+`/api/authorization/delstoreauthorization?id=`+data, { | |||
method: 'POST', | |||
data: data, | |||
}); | |||
} | |||
/** 获取店铺列表 */ | |||
export async function GetStoreList(data) { | |||
return request(GetkitchbaseUrl()+`/api/store/page`, { | |||
method: 'POST', | |||
data: data, | |||
}); | |||
} |
@@ -174,6 +174,7 @@ const CreateForm = (props) => { | |||
formRef={formRef} | |||
initialValues={props.values} | |||
onFinish={props.onFinish} | |||
submitter={false} | |||
> | |||
<Row gutter={16}> | |||
<Col lg={12} md={12} sm={24}> | |||
@@ -207,67 +208,8 @@ const CreateForm = (props) => { | |||
placeholder="请输入原料名称" | |||
/> | |||
</Col> | |||
{/* <Col lg={8} md={12} sm={24}> | |||
<ProFormText | |||
label={fieldLabels.specs} | |||
name="specs" | |||
rules={[ | |||
{ | |||
required: true, | |||
max: 500, | |||
}, | |||
]} | |||
placeholder="请输入规格型号" | |||
/> | |||
</Col> */} | |||
</Row> | |||
{/* <Row gutter={16}> | |||
<Col lg={8} md={12} sm={24}> | |||
<ProFormSelect | |||
label={fieldLabels.aittribute} | |||
name="aittribute" | |||
rules={[ | |||
{ | |||
required: true, | |||
message: '请选择物料属性', | |||
}, | |||
]} | |||
options={[ | |||
{ | |||
value: '0', | |||
label: '成品', | |||
}, | |||
{ | |||
value: '1', | |||
label: '半成品', | |||
}, | |||
{ | |||
value: '2', | |||
label: '易耗品', | |||
}, | |||
]} | |||
placeholder="请选择物料属性" | |||
/> | |||
</Col> | |||
<Col lg={8} md={12} sm={24}> | |||
<ProFormDigit | |||
label={fieldLabels.price} | |||
name="price" | |||
placeholder="请输入成本价" | |||
min={1} | |||
/> | |||
</Col> | |||
<Col lg={8} md={12} sm={24}> | |||
<ProFormDigit | |||
label={fieldLabels.netrecovery} | |||
name="netrecovery" | |||
min={1} | |||
max={100} | |||
placeholder="请输入净料率" | |||
/> | |||
</Col> | |||
</Row> */} | |||
<Row gutter={16}> | |||
<Col lg={12} md={12} sm={24}> | |||
@@ -359,85 +301,14 @@ const CreateForm = (props) => { | |||
options={itemsuity} | |||
/> | |||
</Col> | |||
{/* <Col lg={8} md={12} sm={24}> | |||
<ProFormSelect | |||
label={fieldLabels.OutstockUint} | |||
name="outstockUint" | |||
rules={[ | |||
{ | |||
required: true, | |||
message: '请选择出库单位', | |||
}, | |||
]} | |||
request={async () => itemsuity} | |||
placeholder="请选择出库单位" | |||
/> | |||
</Col> */} | |||
{/* <Col lg={8} md={12} sm={24}> | |||
<ProFormDigit | |||
label={fieldLabels.proportion} | |||
name="proportion" | |||
rules={[ | |||
{ | |||
required: true, | |||
message: '请输入出入库换算比例', | |||
}, | |||
]} | |||
placeholder="请输入换算比例" | |||
/> | |||
</Col> */} | |||
{/* <Col lg={8} md={12} sm={24}> | |||
<ProFormSelect | |||
label={fieldLabels.status} | |||
name="status" | |||
rules={[ | |||
{ | |||
required: true, | |||
message: '请选择状态', | |||
}, | |||
]} | |||
options={[ | |||
{ | |||
value: '0', | |||
label: '正常', | |||
}, | |||
{ | |||
value: '1', | |||
label: '停用', | |||
}, | |||
]} | |||
placeholder="请选择状态" | |||
/> | |||
</Col> */} | |||
{/* <Col lg={8} md={12} sm={24}> | |||
<ProFormText | |||
label={fieldLabels.foreignKeyRe} | |||
name="foreignKeyRe" | |||
placeholder="请输入关联外键" | |||
/> | |||
</Col> */} | |||
</Row> | |||
{/* <ProForm.Item name="membersList" trigger="onValuesChange"> | |||
<EditableProTable | |||
rowKey="id" | |||
toolBarRender={false} | |||
columns={columns} | |||
recordCreatorProps={{ | |||
newRecordType: 'dataSource', | |||
record: () => ({ | |||
id: Date.now(), | |||
}), | |||
}} | |||
editable={{ | |||
type: 'multiple', | |||
editableKeys, | |||
onChange: setEditableRowKeys, | |||
actionRender: (row, _, dom) => { | |||
return [dom.delete]; | |||
}, | |||
}} | |||
/> | |||
</ProForm.Item> */} | |||
</Row> | |||
<Row gutter={4}> | |||
<Col span={12}></Col> | |||
<Col span={12}> | |||
<Button htmlType="button" style={{float:'right',left:10}} onClick={onCancel} >取消</Button> | |||
<Button type="primary" htmlType="submit" style={{float:'right'}} >保存</Button> | |||
</Col> | |||
</Row> | |||
</ProForm> | |||
</Modal> | |||
); | |||
@@ -0,0 +1,370 @@ | |||
import { PlusOutlined,ArrowLeftOutlined } from '@ant-design/icons'; | |||
import { Button, message, Input, Form, Popconfirm,Radio,InputNumber,Card,Tag } from 'antd'; | |||
import React, { useState, useRef, useEffect } from 'react'; | |||
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'; | |||
import ProTable from '@ant-design/pro-table'; | |||
import EditableProTable from '@ant-design/pro-table'; | |||
import { history } from 'umi'; | |||
import ProDescriptions from '@ant-design/pro-descriptions'; | |||
import { | |||
getpage, | |||
add, | |||
update, | |||
del, | |||
getbygoodsidattribute | |||
} from './service'; | |||
const goodsattribute = (props) => { | |||
/** 新建/更新窗口的弹窗 */ | |||
const [createModalVisible, handleModalVisible] = useState(false); | |||
const [editableKeys, setEditableRowKeys] = useState([]); | |||
/** 分布更新窗口的弹窗 */ | |||
const [arttuename,setarttuename]=useState(""); | |||
const [checkvalue, setCheckvalue] = useState([]); | |||
const actionRef = useRef(); | |||
const [currentRow, setCurrentRow] = useState(); | |||
const [selectedRowsState, setSelectedRows] = useState([]); | |||
const [price, setprice] = useState(0); | |||
const [goodsAttriburteData, setGoodsAttriburteData] = useState([]); | |||
const [dataSource, setDataSource] = useState([]); | |||
/** 国际化修改 */ | |||
useEffect(() => { | |||
intDicData(); | |||
}, []); | |||
function intDicData() { | |||
getbygoodsidattribute(props.location.query.values.id).then((r)=>{ | |||
if(r.data && r.data.length>0){ | |||
setGoodsAttriburteData(r.data); | |||
} | |||
}) | |||
} | |||
/** | |||
* 批量删除 | |||
* | |||
* @param selectedRows | |||
*/ | |||
const handleRemove = async (selectedRows) => { | |||
const hide = message.loading('正在删除'); | |||
if (!selectedRows) return true; | |||
await del(selectedRows.map((row) => row.id)).then((r) => { | |||
if (r.succeeded) { | |||
message.success('删除成功'); | |||
actionRef.current.reload(); | |||
} else { | |||
message.error(r.errors); | |||
} | |||
}); | |||
hide(); | |||
return true; | |||
}; | |||
const columns = [ | |||
{ | |||
title: '主键', | |||
dataIndex: 'id', | |||
hideInSearch: true, | |||
hideInTable: true, | |||
tip: '规则名称是唯一的 key', | |||
render: (dom, entity) => { | |||
return ( | |||
<a | |||
onClick={() => { | |||
setCurrentRow(entity); | |||
setShowDetail(true); | |||
}} | |||
> | |||
{dom} | |||
</a> | |||
); | |||
}, | |||
}, | |||
{ | |||
title: '属性', | |||
dataIndex: 'goodsattributeValue', | |||
valueType: 'textarea', | |||
ellipsis: true, | |||
readonly: true, | |||
}, | |||
{ | |||
title: '价格', | |||
dataIndex: 'price', | |||
hideInSearch: true, | |||
}, | |||
{ | |||
title: '操作', | |||
dataIndex: 'option', | |||
valueType: 'option', | |||
render: (text, record, _, action) => [ | |||
<a | |||
key="config" | |||
onClick={() => { | |||
action?.startEditable?.(record.id); | |||
}} | |||
> | |||
更新 | |||
</a>, | |||
<Popconfirm | |||
type="primary" | |||
key="primary" | |||
title="确认删除吗?" | |||
okText="是" | |||
cancelText="否" | |||
onConfirm={async () => { | |||
await del([record.id]).then((r) => { | |||
if (r.succeeded) { | |||
message.success('删除成功'); | |||
actionRef.current.reload(); | |||
} else { | |||
message.error(r.errors); | |||
} | |||
}); | |||
}} | |||
onCancel={() => {}} | |||
> | |||
<a href="#">删除</a> | |||
</Popconfirm>, | |||
], | |||
}, | |||
]; | |||
const onChangevalue =(data)=>{ | |||
const { name, value } = data.target; | |||
let names=""; | |||
let updatedValues = [...checkvalue]; | |||
for (let index = 0; index <goodsAttriburteData.length; index++) { | |||
if (name === 'radiogroup'+index) { | |||
// 将第一组的值累加到数组中 | |||
updatedValues[index] = value; | |||
} | |||
} | |||
goodsAttriburteData.forEach(item=>{ | |||
for (let index = 0; index < updatedValues.length; index++) { | |||
var bs=item.goodsAttributeValueList.find(x=>x.goodsAttributeValuId==updatedValues[index])?.attributeValue | |||
if(bs){ | |||
names=names+bs; | |||
if(index< updatedValues.length-1){ | |||
names=names+"-" | |||
} | |||
} | |||
} | |||
item.goodsAttributeValueList.forEach(x=>{ | |||
if(value==x.goodsAttributeValuId){ | |||
x.check=true; | |||
item.defalutvalue=value | |||
} | |||
}) | |||
}) | |||
setarttuename(names) | |||
setCheckvalue(updatedValues) | |||
} | |||
const onpriceChange=(value)=>{ | |||
setprice(value) | |||
} | |||
const onsubmit=()=>{ | |||
var check=true; | |||
if(checkvalue.length==0){ | |||
check=false; | |||
message.error("请选择属性"); | |||
} | |||
else if(price<=0){ | |||
check=false; | |||
message.error("价格不能小于0"); | |||
} | |||
if(check){ | |||
var parm={goodsId:props.location.query.values.id,goodsattributeValueId:checkvalue.join(','),Price:price,goodsattributeValue:arttuename} | |||
add(parm).then((r)=>{ | |||
if (r.succeeded) { | |||
message.success('保存成功'); | |||
actionRef.current.reload(); | |||
setCheckvalue([]); | |||
setarttuename(""); | |||
setprice(0) | |||
var gg=goodsAttriburteData.map(x => { | |||
x.goodsAttributeValueList.forEach(t=>{ | |||
t.check=false; | |||
x.defalutvalue="" | |||
}) | |||
return x | |||
}) | |||
setGoodsAttriburteData(gg) | |||
} else { | |||
message.error(r.errors); | |||
} | |||
}) | |||
} | |||
} | |||
const onresetsubmit=()=>{ | |||
setCheckvalue([]); | |||
setarttuename(""); | |||
setprice(0) | |||
var gg=goodsAttriburteData.map(x => { | |||
x.goodsAttributeValueList.forEach(t=>{ | |||
t.check=false; | |||
x.defalutvalue="" | |||
}) | |||
return x | |||
}) | |||
setGoodsAttriburteData(gg) | |||
} | |||
return ( | |||
<> | |||
<PageContainer host header={{ | |||
title: [<a key="back" | |||
onClick={() => { | |||
history.push({ | |||
pathname: '/database/goods/newgoods', | |||
}); | |||
}}><ArrowLeftOutlined />返回</a>], | |||
breadcrumb: {}, | |||
}}> | |||
<Card> | |||
<span><span style={{color:'red',marginRight: 3}}>*</span>商品属性</span> | |||
{ | |||
goodsAttriburteData==undefined || goodsAttriburteData.length ==0 ? ( <div style={{fontSize: '12px',marginLeft:10}}>当前商品分类还未配置属性点击跳转 <a | |||
key="primary" | |||
type="primary" | |||
onClick={() => { | |||
history.push({ | |||
pathname: '/database/goods/goodstypemanage', | |||
}); | |||
// handleModalVisible(true); | |||
// setCurrentRow(record); | |||
}} | |||
> | |||
添加属性 | |||
</a></div>) :( | |||
goodsAttriburteData.map((item, index) => { | |||
return ( | |||
<div style={{marginLeft: 80,marginBottom:10}}> | |||
<div> | |||
<span style={{marginRight: 10}}> <Tag color="blue">{item.attributeName}</Tag>:</span> | |||
<span> | |||
<Radio.Group name={"radiogroup"+index} buttonStyle="solid" size="small" value={item.defalutvalue} onChange={onChangevalue}> | |||
{ | |||
item.goodsAttributeValueList.map((item, index)=>{ | |||
return ( | |||
<Radio.Button name={index} defaultChecked={item.check} checked={item.check} value={item.goodsAttributeValuId} style={{marginRight: 22, marginTop: 16}}>{item.attributeValue}</Radio.Button> | |||
) | |||
}) | |||
} | |||
</Radio.Group> | |||
</span> | |||
</div> | |||
</div> | |||
); | |||
}) | |||
) | |||
} | |||
<div style={{marginTop:10}}> | |||
<span style={{marginRight:'3%'}}><span style={{color:'red',marginRight: 3}}>*</span>价格:</span><InputNumber value={price} style={{width:'20%'}} onChange={onpriceChange} placeholder="请输入价格"/> | |||
</div> | |||
<div style={{float:'right',position: 'absolute', top: '70%',left: '88%',width: '200px'}}> | |||
<Button htmlType="submit" style={{marginRight:'2%'}} onClick={onresetsubmit}> 重置</Button> | |||
<Button type="primary" htmlType="submit" onClick={onsubmit}> | |||
保存 | |||
</Button> | |||
</div> | |||
</Card> | |||
<EditableProTable | |||
headerTitle="属性价格列表" | |||
actionRef={actionRef} | |||
rowKey="id" | |||
pagination={{ defaultPageSize: 10 }} | |||
search={false} | |||
// toolBarRender={false} | |||
recordCreatorProps={false} | |||
request={async (params) => { | |||
var data = []; | |||
params.goodsId=props.location.query.values.id | |||
var total = 0; | |||
await getpage(params).then((r) => { | |||
data = r.data.data; | |||
total = r.data.total; | |||
}); | |||
return { | |||
data: data, | |||
success: true, | |||
total: total, | |||
}; | |||
}} | |||
columns={columns} | |||
onChange={setDataSource} | |||
editable={{ | |||
type: 'multiple', | |||
editableKeys, | |||
actionRender: (row, config, dom) => [dom.save, dom.cancel], | |||
onSave: async (rowKey, data, row) => { | |||
console.log(rowKey, data, row); | |||
update(data).then((res)=>{ | |||
if (res.succeeded) { | |||
message.success('保存成功'); | |||
actionRef.current.reload(); | |||
} else { | |||
message.error(r.errors); | |||
} | |||
}) | |||
//onsubmit() | |||
}, | |||
onChange: setEditableRowKeys, | |||
}} | |||
rowSelection={{ | |||
onChange: (_, selectedRows) => { | |||
setSelectedRows(selectedRows); | |||
}, | |||
}} | |||
/> | |||
{selectedRowsState?.length > 0 && ( | |||
<FooterToolbar | |||
extra={ | |||
<div> | |||
已选择{' '} | |||
<a | |||
style={{ | |||
fontWeight: 600, | |||
}} | |||
> | |||
{selectedRowsState.length} | |||
</a>{' '} | |||
项 | |||
{/* <span> | |||
服务调用次数总计 {selectedRowsState.reduce((pre, item) => pre + item.id, 0)} 万 | |||
</span> */} | |||
</div> | |||
} | |||
> | |||
<Button | |||
onClick={async () => { | |||
await handleRemove(selectedRowsState); | |||
setSelectedRows([]); | |||
actionRef.current?.reloadAndRest?.(); | |||
}} | |||
> | |||
删除 | |||
</Button> | |||
{/* <Button type="primary">批量审批</Button> */} | |||
</FooterToolbar> | |||
)} | |||
</PageContainer> | |||
</> | |||
); | |||
}; | |||
export default goodsattribute; |
@@ -0,0 +1,41 @@ | |||
import { request } from 'umi'; | |||
import { getDataBaseUrl } from '@/global_data'; | |||
/** 获取商品属性列表 sdsa GET /kitchen/api/rule */ | |||
export async function getpage(data) { | |||
return request(getDataBaseUrl()+`/api/goodsattributeprice/getpage`, { | |||
method: 'POST', | |||
data: data, | |||
// params: { ...params }, | |||
// ...(options || {}), | |||
}); | |||
} | |||
export async function add(data) { | |||
return request(getDataBaseUrl()+`/api/goodsattributeprice/add`, { | |||
method: 'POST', | |||
data: data, | |||
// params: { ...params }, | |||
// ...(options || {}), | |||
}); | |||
} | |||
export async function update(data) { | |||
return request(getDataBaseUrl()+`/api/goodsattributeprice/update`, { | |||
method: 'POST', | |||
data: data, | |||
// params: { ...params }, | |||
// ...(options || {}), | |||
}); | |||
} | |||
export async function del(data) { | |||
return request(getDataBaseUrl()+`/api/goodsattributeprice/delete?id=`+data, { | |||
method: 'GET', | |||
// params: { ...params }, | |||
// ...(options || {}), | |||
}); | |||
} | |||
export async function getbygoodsidattribute (data) { | |||
return request(getDataBaseUrl()+`/api/goodsattribute/getbygoodsidattribute?id=`+data, { | |||
method: 'Get', | |||
// params: { ...params }, | |||
// ...(options || {}), | |||
}); | |||
} |
@@ -2,6 +2,7 @@ import React, { useState,useRef,useEffect } from 'react'; | |||
import { PlusOutlined,CheckOutlined} from '@ant-design/icons'; | |||
import { Modal, Form, Input, Button, Select,Radio,message,Tag,Divider,Space } from 'antd'; | |||
import { AddBomType,getbyidbomlist } from '../service'; | |||
import { history } from 'umi'; | |||
import { | |||
EditableProTable, | |||
ProTable | |||
@@ -243,7 +244,20 @@ const GoodsbomFrom = (props) => { | |||
> | |||
<span><span style={{color:'red',marginRight: 3}}>*</span>商品属性</span> | |||
{ | |||
props.goodsAttriburteData == undefined ? '' :( | |||
props.goodsAttriburteData == undefined || props.goodsAttriburteData.length==0 ? ( <div style={{fontSize: '12px',marginLeft:10}}>当前商品分类还未配置属性点击跳转 <a | |||
key="primary" | |||
type="primary" | |||
onClick={() => { | |||
history.push({ | |||
pathname: '/database/goods/goodstypemanage', | |||
}); | |||
// handleModalVisible(true); | |||
// setCurrentRow(record); | |||
}} | |||
> | |||
添加属性 | |||
</a></div>) :( | |||
props.goodsAttriburteData.map((item, index) => { | |||
return ( | |||
<div style={{marginLeft: 80,marginBottom:10}}> | |||
@@ -3,6 +3,7 @@ import React, { useState, useRef, useEffect } from 'react'; | |||
import { CloseOutlined, DeleteOutlined, FormOutlined } from '@ant-design/icons'; | |||
import { ProCard } from '@ant-design/pro-Card'; | |||
import { BetaSchemaForm } from '@ant-design/pro-form'; | |||
import { history } from 'umi'; | |||
import { | |||
getbyidgoods, | |||
GetGoodsTechnology, | |||
@@ -50,7 +51,6 @@ const goodstechnologymaken = (props) => { | |||
interdata() | |||
}, []) | |||
const interdata = () => { | |||
console.log("props.goodsid",props.goodsid) | |||
if(props.goodsid!=undefined){ | |||
getbyidgoods(props.goodsid).then((res) => { | |||
if (res.succeeded) { | |||
@@ -125,8 +125,6 @@ const goodstechnologymaken = (props) => { | |||
}) | |||
} | |||
const onChangevalue = (e) => { | |||
console.log(checkvalue) | |||
const { name, value } = e.target; | |||
let names = ""; | |||
let updatedValues = [...checkvalue]; | |||
@@ -169,21 +167,27 @@ const goodstechnologymaken = (props) => { | |||
setdefaultValue(item.deviceId) | |||
setddevideId(item.deviceId) | |||
GetGoodsTechnologyvalue(item.deviceId,"edit",item) | |||
var atrid=[] | |||
var gg=goodsinfo.goodsAttributeList.map(x => { | |||
x.goodsAttributeValueList.forEach(t=>{ | |||
var da=item.goodsAttributeId.split(',') | |||
var df=da.find(g=>g==t.goodsAttributeValuId) | |||
if(df){ | |||
t.check=true; | |||
x.defalutvalue=t.goodsAttributeValuId | |||
atrid.push(t.goodsAttributeValuId) | |||
} | |||
}) | |||
return x | |||
}) | |||
const nextItems = {...goodsinfo,goodsAttributeList:gg}; | |||
var goodsinfos=nextItems | |||
console.log("goods",goodsinfos) | |||
setCheckvalue(atrid) | |||
console.log("checkvalue",atrid) | |||
setCheckvalue(atrid) | |||
setGoodsinfo(goodsinfos) | |||
//console.log("attr", attr) | |||
@@ -229,20 +233,11 @@ const goodstechnologymaken = (props) => { | |||
} | |||
const GetGoodsTechnologyvalue=(value,va,item)=>{ | |||
let godata=[] | |||
console.log("va",va) | |||
console.log("value",value) | |||
console.log("item",item) | |||
console.log("goodsinfo.goodsAttributeList",goodsinfo.goodsAttributeList) | |||
if(item){ | |||
GetwarehousetemplateData(item.deviceId) | |||
setWarehousrTemplateId(item.warehousrTemplateId) | |||
setdefaulttemplateValue(item.warehousrTemplateId) | |||
} | |||
GetGoodsTechnology(value).then((r)=>{ | |||
if (r.data.length > 0) { | |||
var Technologyacton=[]; | |||
@@ -255,7 +250,6 @@ const goodstechnologymaken = (props) => { | |||
} | |||
return { value: x.id, label: x.name } | |||
}) | |||
console.log("godata",godata) | |||
setTechnologyattralldata(Technologyacton) | |||
setgoodstechnologydata(godata) | |||
}else{ | |||
@@ -274,8 +268,6 @@ const goodstechnologymaken = (props) => { | |||
DeleteGoodsTechnologyAction(item.id).then((res) => { | |||
if (res.data) { | |||
message.success("删除成功") | |||
console.log(fromdata) | |||
//formRef?.current?.resetFields(...props.technologyattrdata) | |||
updadata() | |||
} else { | |||
message.error("删除失败") | |||
@@ -283,12 +275,37 @@ const goodstechnologymaken = (props) => { | |||
}) | |||
} | |||
//删除设备工艺 | |||
const onClickDevicedele = (e, devideId, action) => { | |||
deletebydevidegoodstechnologyaction({ devideId: devideId, goodsId: props.goodsid }).then((res) => { | |||
const onClickDevicedele = (e, devideId,goodsAttributeId, action) => { | |||
if(goodstechnologydata.length>0){ | |||
setgoodstechnologydata([]) | |||
} | |||
if(fromdata.length>0){ | |||
setfromdata([]) | |||
} | |||
if(defaultValue==devideId){ | |||
setdefaultValue('') | |||
setcwdis("none") | |||
setdefaulttemplateValue() | |||
} | |||
if(checkvalue.find(x=>goodsAttributeId.includes(x))){ | |||
var gg=goodsinfo.goodsAttributeList.map(x => { | |||
x.goodsAttributeValueList.forEach(t=>{ | |||
t.check=false; | |||
x.defalutvalue="" | |||
setCheckvalue([]) | |||
}) | |||
return x | |||
}) | |||
const nextItems = {...goodsinfo,goodsAttributeList:gg}; | |||
var goodsinfos=nextItems | |||
setGoodsinfo(goodsinfos) | |||
setCheckvalue([]) | |||
} | |||
//console.log(goodstechnologydata) | |||
deletebydevidegoodstechnologyaction({ devideId: devideId, goodsId: props.goodsid,goodsAttributeId:goodsAttributeId }).then((res) => { | |||
if (res.data) { | |||
message.success("删除成功") | |||
setgoodstechnolog([]) | |||
//formRef?.current?.resetFields(...props.technologyattrdata) | |||
updadata() | |||
} else { | |||
message.error("删除失败") | |||
@@ -316,14 +333,10 @@ const goodstechnologymaken = (props) => { | |||
const GetwarehousetemplateData=(deviceId)=>{ | |||
setcwdis('block') | |||
GetwarehousetemplateList(deviceId).then((r)=>{ | |||
// var data= r.data.map(x=>{ | |||
// return {id:x.id,label:x.templateName} | |||
// }) | |||
setwarehousetemplatedata(r.data) | |||
}) | |||
} | |||
const handleChange = (value) => { | |||
console.log("进来了", value) | |||
setdefaulttemplateValue("") | |||
if(value){ | |||
setdefaultValue(value) | |||
@@ -335,30 +348,14 @@ const goodstechnologymaken = (props) => { | |||
setdefaultValue("") | |||
setddevideId('') | |||
} | |||
// let sd = DeviceTechnologydata.find(x => x.id == value); | |||
// if (sd) { | |||
// if (sd.goodsTechnologyInfo.length > 0) { | |||
// godata = sd.goodsTechnologyInfo.map(x => { | |||
// return { value: x.deviceTechnologyId, label: x.name } | |||
// }) | |||
// setgoodstechnologydata(godata) | |||
// } | |||
// setfromdata([]) | |||
// } | |||
// console.log("godata", godata) | |||
// setgoodstechnologydata(godata) | |||
} | |||
const onUpdataStatus = (val) => { | |||
setUpdataStatus(val) | |||
} | |||
const onSaveClick = (val) => { | |||
console.log("222",val) | |||
setfromdata(val) | |||
} | |||
const onSubmitSaveClick = () => { | |||
console.log("保存的数据", fromdata) | |||
let check = true; | |||
var data = [] | |||
var msg="没有要保存的数据或数据格式不正确"; | |||
@@ -393,22 +390,22 @@ const goodstechnologymaken = (props) => { | |||
} | |||
}) | |||
// var vacheck=x.optiondata.find(x=>x.actionValue=='') | |||
item.goodsId = props.goodsid | |||
item.warehousrTemplateId=WarehousrTemplateId; | |||
item.goodsAttributeId = checkvalue.join(',') | |||
if (x.chnologyId == "") { | |||
check = false; | |||
} | |||
if(item.warehousrTemplateId==undefined || item.warehousrTemplateId==""){ | |||
check = false; | |||
msg="请选择仓位模板" | |||
} | |||
if(item.goodsAttributeId==undefined || item.goodsAttributeId==""){ | |||
check = false; | |||
msg="请选择商品属性" | |||
} | |||
data.push(item) | |||
}) | |||
if(WarehousrTemplateId==""){ | |||
check = false; | |||
msg="请选择仓位模板" | |||
} | |||
if (data.length > 0 && check) { | |||
if (UpdataStatus == "add") { | |||
AddGoodsTechnologyAction(data).then((res) => { | |||
@@ -433,6 +430,17 @@ const goodstechnologymaken = (props) => { | |||
}) | |||
} | |||
var gg=goodsinfo.goodsAttributeList.map(x => { | |||
x.goodsAttributeValueList.forEach(t=>{ | |||
t.check=false; | |||
x.defalutvalue="" | |||
}) | |||
return x | |||
}) | |||
const nextItems = {...goodsinfo,goodsAttributeList:gg}; | |||
var goodsinfos=nextItems | |||
setGoodsinfo(goodsinfos) | |||
setCheckvalue([]) | |||
setUpdataStatus("view") | |||
setdisabled(false) | |||
setopreaction("add") | |||
@@ -466,10 +474,23 @@ const goodstechnologymaken = (props) => { | |||
</Descriptions> | |||
</Card> | |||
<Card bodyStyle={{ padding: 15 }} style={{ display: display }} > | |||
<Card bodyStyle={{ padding: 15 }} > | |||
<div style={{ fontSize: 16, marginBottom: 5, color: '#1890ff', fontWeight: 600 }}>商品属性</div> | |||
{ | |||
goodsinfo.goodsAttributeList == undefined ? '' : ( | |||
goodsinfo.goodsAttributeList == undefined || goodsinfo.goodsAttributeList == "" ? ( <div style={{fontSize: '12px',marginLeft:10}}>当前商品分类还未配置属性点击跳转 <a | |||
key="primary" | |||
type="primary" | |||
onClick={() => { | |||
history.push({ | |||
pathname: '/database/goods/goodstypemanage', | |||
}); | |||
// handleModalVisible(true); | |||
// setCurrentRow(record); | |||
}} | |||
> | |||
添加属性 | |||
</a></div>) : ( | |||
goodsinfo.goodsAttributeList.map((item, index) => { | |||
return ( | |||
<div style={{ marginLeft: 10 }}> | |||
@@ -557,7 +578,7 @@ const goodstechnologymaken = (props) => { | |||
<Popconfirm | |||
title="确认删除吗?" | |||
description="确认删除吗" | |||
onConfirm={(e) => { onClickDevicedele(e, x.deviceId) }} | |||
onConfirm={(e) => { onClickDevicedele(e, x.deviceId,x.goodsAttributeId) }} | |||
onCancel={cancel} | |||
okText="确定" | |||
cancelText="取消" | |||
@@ -164,7 +164,7 @@ const GoodsManage = () => { | |||
// setCurrentRow(record); | |||
}} | |||
> | |||
商品配方设置 | |||
配方配置 | |||
</a>, | |||
<a | |||
key="primary" | |||
@@ -182,9 +182,25 @@ const GoodsManage = () => { | |||
// setCurrentRow(record); | |||
}} | |||
> | |||
商品工艺设置 | |||
工艺配置 | |||
</a>, | |||
<a | |||
key="primary" | |||
type="primary" | |||
onClick={() => { | |||
history.push({ | |||
pathname: '/database/goods/goodsattributeprice', | |||
query: { | |||
isAdd: false, | |||
values: record, | |||
}, | |||
}); | |||
// handleModalVisible(true); | |||
// setCurrentRow(record); | |||
}} | |||
> | |||
价格配置 | |||
</a>, | |||
<Popconfirm | |||
type="primary" | |||
key="primary" | |||
@@ -10,6 +10,7 @@ const CreateForm = (props) => { | |||
const [value, setValue] = useState(0); | |||
const [deviceTypename,setdeviceTypename]=useState(""); | |||
const [options,setoptions]=useState([]); | |||
const [stopoptions,setstopoptions]=useState([]); | |||
const inputRef = useRef(null); | |||
useEffect(() => { | |||
console.log(props.values) | |||
@@ -22,6 +23,10 @@ const CreateForm = (props) => { | |||
return {value:item.id,label:item.label} | |||
}) | |||
setoptions(optdata); | |||
var stopData=props.StopData?.map((item, index) => { | |||
return {value:item.id,label:item.name} | |||
}) | |||
setstopoptions(stopData) | |||
},[props]) | |||
const handleChange=(value)=>{ | |||
GetDeviceVesion(value).then((res)=>{ | |||
@@ -75,13 +80,20 @@ const CreateForm = (props) => { | |||
<Form.Item name="id" hidden={true}> | |||
<Input /> | |||
</Form.Item> | |||
<Form.Item label={'选择场景'} name="stopId" rules={[{ required: true }]}> | |||
<Select allowClear showSearch optionFilterProp="children" filterOption={(input, option) => (option?.label ?? '').includes(input)} | |||
filterSort={(optionA, optionB) => | |||
(optionA?.label ?? '').toLowerCase().localeCompare((optionB?.label ?? '').toLowerCase()) } options={stopoptions}/> | |||
</Form.Item> | |||
<Form.Item label={'所属产品'} name="productId" rules={[{ required: true }]}> | |||
<Select onChange={handleChange} allowClear showSearch optionFilterProp="children" filterOption={(input, option) => (option?.label ?? '').includes(input)} | |||
filterSort={(optionA, optionB) => | |||
(optionA?.label ?? '').toLowerCase().localeCompare((optionB?.label ?? '').toLowerCase()) | |||
} options={options}/> | |||
</Form.Item> | |||
<Form.Item label={'产品版本'} name="productVersionId" rules={[{ required: true }]}> | |||
<Select> | |||
{DeviceVesionData.map((item, index) => { | |||
@@ -12,7 +12,7 @@ import { | |||
DelDeviceInfo, | |||
GetDeviceType, | |||
GetDeviceVersions, | |||
CopyDevice, | |||
GetStop, | |||
TechnologyTemplateExport, | |||
GoodsTemplateExport, | |||
} from './services'; | |||
@@ -37,9 +37,12 @@ const GoodsTypeManage = () => { | |||
const actionRef = useRef(); | |||
const [currentRow, setCurrentRow] = useState(); | |||
const [selectedRowsState, setSelectedRows] = useState([]); | |||
const [StopData, setStopData] = useState([]); | |||
//初始化数据 | |||
useEffect(() => { | |||
GetStop().then((t)=>{ | |||
setStopData(t.data) | |||
}) | |||
function initOrgList() { | |||
gettree().then((r) => { | |||
inittree(r.data); | |||
@@ -147,13 +150,10 @@ const GoodsTypeManage = () => { | |||
search: false, | |||
}, | |||
{ | |||
title: '支持功能', | |||
dataIndex: 'technologyOrBom', | |||
title: '所属场景', | |||
dataIndex: 'stopName', | |||
search: false, | |||
valueEnum: { | |||
0: { text: '工艺', }, | |||
1: { text: '配方',}, | |||
}, | |||
}, | |||
// { | |||
// title: '归属门店', | |||
@@ -300,28 +300,6 @@ const handleUpdate = async (fields) => { | |||
}; | |||
//删除 | |||
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: '', | |||
@@ -360,6 +338,14 @@ const handleRemove = async (selectedRows) => { | |||
var data = []; | |||
var total = 0; | |||
await GetDeviceInfoPage(params).then((r) => { | |||
console.log("StopData",StopData) | |||
// r.data.data.forEach(x=>{ | |||
// var stop=StopData.find(f=>f.id==x.stopId); | |||
// if(stop){ | |||
// x.stopName=stop.name | |||
// } | |||
// }) | |||
data = r.data.data; | |||
total = r.data.total; | |||
}); | |||
@@ -418,6 +404,7 @@ const handleRemove = async (selectedRows) => { | |||
createModalVisible={createModalVisible} | |||
deviceVersions={deviceVersion} | |||
values={currentRow || {}} | |||
StopData={StopData} | |||
/> | |||
</PageContainer> | |||
@@ -213,5 +213,9 @@ export async function TechnologyTemplateExport(data) { | |||
// responseType: 'blob' | |||
}); | |||
} | |||
export async function GetStop() { | |||
return request(GetkitchbaseUrl()+`/api/store/getstorelist`, { | |||
method: 'Get', | |||
}); | |||
} | |||
@@ -136,14 +136,16 @@ const GoodsTypeManage = () => { | |||
setCurrentRow(record); | |||
const tempUploadImage = JSON.parse(JSON.stringify([ | |||
{ | |||
uid: '-1', | |||
name: 'image.png', | |||
status: 'done', | |||
url: '', | |||
}, | |||
])); | |||
tempUploadImage[0].url=record.productUrl; | |||
setFileList(tempUploadImage); | |||
if(record.productUrl){ | |||
tempUploadImage[0].url=record.productUrl; | |||
setFileList(tempUploadImage); | |||
}else{ | |||
setFileList([]) | |||
} | |||
// form.setFielsValue(record) | |||
}} > 更新</a>, | |||
<Popconfirm | |||
@@ -1,7 +1,8 @@ | |||
import React, { useState,useEffect } from 'react'; | |||
import { CloseOutlined} from '@ant-design/icons'; | |||
import { Modal, Form, Input, Button, Select,Radio,InputNumber, message,Space } from 'antd'; | |||
import { CloseOutlined,QuestionCircleOutlined} from '@ant-design/icons'; | |||
import { Modal, Form, Input, Button, Select,Radio,InputNumber, message,Space,Tooltip } from 'antd'; | |||
import unitoption from '../unit' | |||
import useFetchData from '@ant-design/pro-descriptions/lib/useFetchData'; | |||
const CreateForm = (props) => { | |||
const { Option, OptGroup } = Select; | |||
@@ -14,6 +15,7 @@ const CreateForm = (props) => { | |||
const [displaylength,setdisplaylength]=useState('none'); | |||
const [displaytxtjson,setdisplaytxtjson]=useState('none'); | |||
const [disabledname,setdisabledname]=useState('false'); | |||
const [displayleventType,setdisplayleventType]=useState('none'); | |||
const [minnumber, setminnumber] = useState(0); | |||
const [maxnumber, setmaxnumber] = useState(1); | |||
const [ReadWrite, setReadWrite] = useState(0); | |||
@@ -106,7 +108,6 @@ const CreateForm = (props) => { | |||
} | |||
},[props?.values]) | |||
const onchagetype=(e)=>{ | |||
console.log(e) | |||
setarttue(e.target.value) | |||
form.setFieldsValue({ | |||
type: e.target.value | |||
@@ -117,12 +118,23 @@ const onchagetype=(e)=>{ | |||
setdisplaybool('none') | |||
setdisaenumbled('none') | |||
setdisanumbled('none') | |||
setdisplayleventType("none") | |||
}else if(e.target.value==0){ | |||
setdisplay("block") | |||
setdisplayleventType("none") | |||
form.setFieldsValue({ | |||
dataType: "digit" | |||
}); | |||
setdisanumbled("block") | |||
}else if(e.target.value==2){ | |||
setdisplayleventType("block") | |||
setdisplay("none") | |||
setdisanumbled('none') | |||
setdisplaylength('none') | |||
setdisplaybool('none') | |||
form.setFieldsValue({ | |||
eventType: 0 | |||
}); | |||
} | |||
} | |||
const onChangemix=(value)=>{ | |||
@@ -187,6 +199,11 @@ const onChangeboolLabel0=(e)=>{ | |||
const onChangeboolLabel1=(e)=>{ | |||
setboolLabel1(e.target.value) | |||
} | |||
const onChangeeventType=(e)=>{ | |||
form.setFieldsValue({ | |||
eventType: e.target.value | |||
}); | |||
} | |||
return ( | |||
<Modal | |||
@@ -212,8 +229,7 @@ const onChangeboolLabel1=(e)=>{ | |||
boolLabel: boolLabel0+":"+boolLabel1 | |||
}); | |||
} | |||
console.log(form.getFieldsValue()) | |||
console.log("form.getFieldsValue()",form.getFieldsValue()) | |||
props?.onFinish(form.getFieldsValue()) | |||
}} | |||
> | |||
@@ -235,6 +251,7 @@ const onChangeboolLabel1=(e)=>{ | |||
<Radio.Group name="type" defaultValue={0} value={arttue} onChange={onchagetype} disabled={disabled}> | |||
<Radio.Button value={0}>属性</Radio.Button> | |||
<Radio.Button value={1}>服务</Radio.Button> | |||
<Radio.Button value={2}>事件</Radio.Button> | |||
</Radio.Group> | |||
</Form.Item> | |||
@@ -303,6 +320,13 @@ const onChangeboolLabel1=(e)=>{ | |||
<Input placeholder="10240" defaultValue="10240" addonAfter="字节" /> | |||
</Form.Item> | |||
<Form.Item style={{display:displayleventType}} name="eventType" label={<span>事件类型<Tooltip placement="top" title="“信息”是设备上报的一般性通知,如完成某项任务等。“告警”和“故障”是设备运行过程中主动上报的突发或异常情况,优先级高。不同的事件类型将用于统计分析。"><QuestionCircleOutlined /></Tooltip></span>} rules={[{ required: false }]}> | |||
<Radio.Group defaultValue={0} onChange={onChangeeventType} value={0}> | |||
<Radio value={0}>信息</Radio> | |||
<Radio value={1}>告警</Radio> | |||
<Radio value={2}>故障</Radio> | |||
</Radio.Group> | |||
</Form.Item> | |||
<Form.Item style={{display:displaytxtjson}} name="dataJson" label="数组字符串" rules={[{ required: false }]}> | |||
<TextArea | |||
placeholder="数据格式:[data1:{value1:'1'},{value2:'2'},data2:{value1:'1'},{value2:'2'}]" | |||
@@ -91,7 +91,6 @@ const bomtechnology = (props) => { | |||
tabActiveKey: props.location.query.tabStatus ? props.location.query.tabStatus : 'basis', | |||
}); | |||
useEffect(() => { | |||
console.log("props.location",props.location) | |||
SetCurrTabKey(tabStatus.tabActiveKey); | |||
if(!props.location.query.values.id){ | |||
history.push({ | |||
@@ -118,7 +117,7 @@ const bomtechnology = (props) => { | |||
}, [tabStatus]) | |||
const Btn = (record) => { | |||
var arr = []; | |||
if (record.type == 1) { | |||
if (record.type == 1 || record.type == 2) { | |||
arr.push(<a | |||
key="config" | |||
onClick={() => { | |||
@@ -136,7 +135,6 @@ const bomtechnology = (props) => { | |||
onClick={() => { | |||
handleModalVisible(true); | |||
setCurrentRow(record); | |||
actionRef.current?.reloadAndRest?.(); | |||
}} | |||
> | |||
更新 | |||
@@ -152,7 +150,7 @@ const bomtechnology = (props) => { | |||
cancelText="否" | |||
onConfirm={() => { | |||
handleRemove([record.id]); | |||
actionRef.current?.reloadAndRest(); | |||
}} | |||
onCancel={() => {}} | |||
> | |||
@@ -201,8 +199,12 @@ const bomtechnology = (props) => { | |||
1: { | |||
text: '服务', | |||
}, | |||
2: { | |||
text: '事件', | |||
}, | |||
}, | |||
}, | |||
// { | |||
// title: '版本', | |||
// dataIndex: 'vesion', | |||
@@ -323,29 +325,19 @@ const bomtechnology = (props) => { | |||
] | |||
const topicsmrcolumns=[ | |||
{ | |||
title: '主键', | |||
dataIndex: 'id', | |||
tip: '规则名称是唯一的 key', | |||
hideInSearch: true, | |||
hideInTable: true, | |||
render: (dom, entity) => { | |||
return ( | |||
<a | |||
onClick={() => { | |||
setCurrentRow(entity); | |||
setShowDetail(true); | |||
}} | |||
> | |||
{dom} | |||
</a> | |||
); | |||
}, | |||
title: '功能', | |||
dataIndex: 'name', | |||
with:'10%', | |||
onCell: (_, index) => { | |||
return {rowSpan: index % 2==0?2:0} | |||
} | |||
}, | |||
{ | |||
title: 'Topics类', | |||
dataIndex: 'topics', | |||
valueType: 'textarea', | |||
with:500, | |||
with:'40%', | |||
render: (text) => <Paragraph style={{display:'inline'}} copyable>{text}</Paragraph>, | |||
}, | |||
{ | |||
@@ -354,6 +346,7 @@ const bomtechnology = (props) => { | |||
valueType: 'select', | |||
ellipsis: true, | |||
search: true, | |||
with:'10%', | |||
valueEnum: { | |||
0: { | |||
text: '发布', | |||
@@ -372,7 +365,7 @@ const bomtechnology = (props) => { | |||
valueType: 'textarea', | |||
ellipsis: true, | |||
search: false, | |||
with:350, | |||
with:'40%', | |||
}, | |||
] | |||
const operationTabList = [ | |||
@@ -415,7 +408,7 @@ const handleAdd = async (fields) => { | |||
await addgoodstechnology(JSON.stringify(fields)).then((r) => { | |||
if (r.data) { | |||
message.success('添加成功'); | |||
var params={productId:props.location.query.values.productId,deviceTypeKey:props.location.query.values.productId,current:1,pageSize:10} | |||
var params={productId:props.location.query.values.productId,productVesionId:props.location.query.values.productId,current:1,pageSize:10} | |||
LoadfunData(params) | |||
handleModalVisible(false); | |||
if (actionRef.current) { | |||
@@ -440,8 +433,10 @@ const handleRemove = async (ids) => { | |||
deletegoodstechnology(ids).then((r) => { | |||
if (r.data) { | |||
message.success('删除成功'); | |||
var params={productId:props.location.query.values.productId,deviceTypeKey:props.location.query.values.productId,current:1,pageSize:10} | |||
LoadfunData(params) | |||
// var params={productId:props.location.query.values.productId,productVesionId:props.location.query.values.productId,current:1,pageSize:10} | |||
// LoadfunData(params) | |||
actionRef.current.reload(); | |||
} else { | |||
message.error(r.errors); | |||
} | |||
@@ -463,15 +458,18 @@ const handleRemove = async (ids) => { | |||
} | |||
} | |||
if(check){ | |||
console.log("actionRef.current",actionRef.current.current) | |||
updategoodstechnology(fields).then((r) => { | |||
if (r.data) { | |||
message.success('修改成功'); | |||
var params={productId:props.location.query.values.productId,deviceTypeKey:props.location.query.values.productId,current:1,pageSize:10} | |||
LoadfunData(params) | |||
handleModalVisible(false); | |||
if (actionRef.current) { | |||
actionRef.current.reloadAndRest(); | |||
} | |||
actionRef.current.reload(); | |||
// var params={productId:props.location.query.values.productId,productVesionId:props.location.query.values.productId,current:actionRef.current.current,pageSize:10} | |||
// LoadfunData(params) | |||
// handleModalVisible(false); | |||
// if (actionRef.current) { | |||
// actionRef.current.reloadAndRest(); | |||
// } | |||
} else { | |||
message.error(r.errors); | |||
} | |||
@@ -483,7 +481,12 @@ const handleRemove = async (ids) => { | |||
}; | |||
const LoadtopisData= async(params)=>{ | |||
await getproducttopicspage(params).then((r) => { | |||
// var datasoure = r.data.data.groupBy(x => { | |||
// return x.name; | |||
// }); | |||
// console.log("datasoure",datasoure) | |||
setdataSource( r.data.data) | |||
settotal( r.data.total) | |||
}); | |||
} | |||
@@ -585,6 +588,7 @@ const handleRemove = async (ids) => { | |||
pagination={{ defaultPageSize: 10}} | |||
columns={topicsmrcolumns} | |||
toolBarRender={false} | |||
scroll={{x:'100%'}} | |||
//数据绑定 | |||
// dataSource={dataSource} | |||
request={async (params) => { | |||
@@ -594,7 +598,11 @@ const handleRemove = async (ids) => { | |||
params.productVesionId=props.location.query.values.id | |||
params.isDefault=true; | |||
await getproducttopicspage(params).then((r) => { | |||
setdataSource( r.data.data) | |||
// var datasoure = r.data.data.groupBy(x => { | |||
// return x.name; | |||
// }); | |||
// console.log("datasoure",datasoure) | |||
setdataSource(r.data.data) | |||
data = r.data.data; | |||
total = r.data.total; | |||
}); | |||
@@ -639,20 +647,6 @@ const handleRemove = async (ids) => { | |||
> | |||
<PlusOutlined /> 新建 | |||
</Button>, | |||
// <Button | |||
// key="primary" | |||
// onClick={async () => { | |||
// const link = document.createElement('a'); | |||
// link.href = "https://hbl-test-1305371387.cos.ap-chengdu.myqcloud.com//Franchisee/gzaxn@163.com/goods/133458884696092845.xlsx"; | |||
// link.click(); | |||
// }} | |||
// > | |||
// <UploadOutlined /> 下载设备版本工艺模板 | |||
// </Button>, | |||
// <Upload {...props}> | |||
// <Button icon={<UploadOutlined />}>导入工艺模版</Button> | |||
// </Upload> | |||
]} | |||
dataSource={datafunctionSource} | |||
//数据绑定 | |||
@@ -62,14 +62,14 @@ const CreateForm = (props) => { | |||
// valueType:'digit', | |||
// width: '15%', | |||
// }, | |||
{ | |||
title: '操作', | |||
valueType: 'option', | |||
width: '15%', | |||
render: () => { | |||
return null; | |||
}, | |||
}, | |||
// { | |||
// title: '操作', | |||
// valueType: 'option', | |||
// width: '15%', | |||
// render: () => { | |||
// return null; | |||
// }, | |||
// }, | |||
] | |||
const handleChange=(value)=>{ | |||
var device=props.devicedata.find(x=>x.id==value); | |||
@@ -77,7 +77,7 @@ const CreateForm = (props) => { | |||
if(device){ | |||
var ary=[] | |||
for (let index = 0; index < device.productNumber; index++) { | |||
ary.push({id: index,code:'',batchingId:''}) | |||
ary.push({id: index,code:'LC000'+(index+1),batchingId:''}) | |||
} | |||
console.log("ary",ary) | |||
setEditableRowKeys(ary.map((item) => item.id)) | |||
@@ -162,7 +162,7 @@ const CreateForm = (props) => { | |||
type: 'multiple', | |||
editableKeys, | |||
actionRender: (row, config, defaultDoms) => { | |||
return [defaultDoms.delete,defaultDoms.Button]; | |||
return []; | |||
}, | |||
onValuesChange: (record, recordList) => { | |||
setDataSource(recordList); | |||
@@ -79,7 +79,7 @@ const GoodsTypeManage = () => { | |||
WarehousetemplateDel([record.id]).then((r) => { | |||
message.success('删除成功,即将刷新'); | |||
actionRef.current.reload(); | |||
actionRef.current.reloadAndRest(); | |||
}); | |||
}} | |||
onCancel={() => { }} | |||