Browse Source

Merge branch 'master' into kitchenmanage

tmp
zhaoy 11 months ago
parent
commit
d675c6ae43
3 changed files with 199 additions and 57 deletions
  1. +11
    -11
      src/pages/device/deviceVesion/index.jsx
  2. +5
    -5
      src/pages/device/productmanage/components/CreateTopis.jsx
  3. +183
    -41
      src/pages/device/productmanage/index.jsx

+ 11
- 11
src/pages/device/deviceVesion/index.jsx View File

@@ -136,17 +136,17 @@ const GoodsTypeManage = () => {
dataIndex: 'productName', dataIndex: 'productName',
valueType: 'textarea', valueType: 'textarea',
}, },
{
title: '是否存在模板',
dataIndex: 'templatePath',
valueType: 'textarea',
hideInSearch: true,
render: (_, record) => [
<div>
<Tag color="#f50" style={{ textAlign: "center", display: (record.templatePath == null||record.templatePath == "") ? "none" : "block" }} >存在模板</Tag>
<Tag style={{ textAlign: "center", display: (record.templatePath == null||record.templatePath == "")? "block" : "none" }} color="#2db7f5">无模板</Tag>
</div>],
},
// {
// title: '是否存在模板',
// dataIndex: 'templatePath',
// valueType: 'textarea',
// hideInSearch: true,
// render: (_, record) => [
// <div>
// <Tag color="#f50" style={{ textAlign: "center", display: (record.templatePath == null||record.templatePath == "") ? "none" : "block" }} >存在模板</Tag>
// <Tag style={{ textAlign: "center", display: (record.templatePath == null||record.templatePath == "")? "block" : "none" }} color="#2db7f5">无模板</Tag>
// </div>],
// },
{ {
title: '操作', title: '操作',
dataIndex: 'option', dataIndex: 'option',


+ 5
- 5
src/pages/device/productmanage/components/CreateTopis.jsx View File

@@ -51,7 +51,7 @@ const onChange=(e)=>{
// initialValues={props?.values} // initialValues={props?.values}
onFinish={()=>{ onFinish={()=>{
form.setFieldsValue({ form.setFieldsValue({
topics:"/"+props.productCode+"/${deviceKey}/use/"+topics
topics:"/"+props.productCode+"/"+props.productVesion+"/${deviceKey}/use/"+topics
}) })
console.log(form.getFieldsValue()) console.log(form.getFieldsValue())
props?.onFinish(form.getFieldsValue()) props?.onFinish(form.getFieldsValue())
@@ -61,20 +61,20 @@ const onChange=(e)=>{
<Input /> <Input />
</Form.Item> </Form.Item>
<Form.Item name="topics" label="Topics类" rules={[{ required: true, max: 64, whitespace: true }]}> <Form.Item name="topics" label="Topics类" rules={[{ required: true, max: 64, whitespace: true }]}>
<Input addonBefore={props.productCode+"/${deviceKey}/use/"} onChange={onChange} placeholder="请输入Topics类" />
<Input addonBefore={props.productCode+"/"+props.productVesion+"/${deviceKey}/use/"} onChange={onChange} placeholder="请输入Topics类" />
</Form.Item> </Form.Item>
<Form.Item label={'类型'} name="topicsType" rules={[{ required: true }]}> <Form.Item label={'类型'} name="topicsType" rules={[{ required: true }]}>
<Select options={[ <Select options={[
{ {
value: '0',
value: 0,
label: '发布', label: '发布',
}, },
{ {
value: '1',
value: 1,
label: '订阅', label: '订阅',
}, },
{ {
value: '2',
value: 2,
label: '发布和订阅', label: '发布和订阅',
}, },
]}/> ]}/>


+ 183
- 41
src/pages/device/productmanage/index.jsx View File

@@ -1,5 +1,5 @@
import { DropboxOutlined, PlusOutlined,ArrowLeftOutlined } from '@ant-design/icons'; import { DropboxOutlined, PlusOutlined,ArrowLeftOutlined } from '@ant-design/icons';
import { Button, message, Input, Upload, Modal, Popconfirm,Card,Typography } from 'antd';
import { Button, message, Input, Upload, Modal, Popconfirm,Card,Typography,Tabs } from 'antd';
import React, { useState, useRef, useEffect } from 'react'; import React, { useState, useRef, useEffect } from 'react';
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'; import { PageContainer, FooterToolbar } from '@ant-design/pro-layout';
import ProTable from '@ant-design/pro-table'; import ProTable from '@ant-design/pro-table';
@@ -73,6 +73,7 @@ const bomtechnology = (props) => {
//绑定 //绑定
const actionRef = useRef(); const actionRef = useRef();
const actiontopisRef= useRef(); const actiontopisRef= useRef();
const actiontopismrRef= useRef();
const [currentRow, setCurrentRow] = useState(); const [currentRow, setCurrentRow] = useState();
const [currenttopsRow,setcurrenttopsRow] = useState(); const [currenttopsRow,setcurrenttopsRow] = useState();
//选中的行 //选中的行
@@ -108,7 +109,7 @@ const bomtechnology = (props) => {
// }) // })
GetProduct(props.location.query.values.productId).then((res)=>{ GetProduct(props.location.query.values.productId).then((res)=>{
setProduct(res.data) setProduct(res.data)
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.id,isDefault:true,current:1,pageSize:10}
LoadfunData(params) LoadfunData(params)
LoadtopisData(params); LoadtopisData(params);
}) })
@@ -248,6 +249,7 @@ const bomtechnology = (props) => {
title: 'Topics类', title: 'Topics类',
dataIndex: 'topics', dataIndex: 'topics',
valueType: 'textarea', valueType: 'textarea',
with:500,
render: (text) => <Paragraph style={{display:'inline'}} copyable>{text}</Paragraph>, render: (text) => <Paragraph style={{display:'inline'}} copyable>{text}</Paragraph>,
}, },
{ {
@@ -281,7 +283,7 @@ const bomtechnology = (props) => {
dataIndex: 'option', dataIndex: 'option',
valueType: 'option', valueType: 'option',
fixed: 'right', fixed: 'right',
width: 450,
width: 250,
render: (_, record) => [ render: (_, record) => [
<a <a
key="config" key="config"
@@ -311,6 +313,60 @@ 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: 'Topics类',
dataIndex: 'topics',
valueType: 'textarea',
with:500,
render: (text) => <Paragraph style={{display:'inline'}} copyable>{text}</Paragraph>,
},
{
title: '类型',
dataIndex: 'topicsType',
valueType: 'select',
ellipsis: true,
search: true,
valueEnum: {
0: {
text: '发布',
},
1: {
text: '订阅',
},
2: {
text: '发布和订阅',
},
},
},
{
title: '描述',
dataIndex: 'description',
valueType: 'textarea',
ellipsis: true,
search: false,
with:350,
},
]
const operationTabList = [ const operationTabList = [
{ {
key: 'basis', key: 'basis',
@@ -438,10 +494,123 @@ const handleRemove = async (ids) => {
// } // }
// //initGoodsType() // //initGoodsType()
}; };
const onTabsChange=(key)=> {
console.log(key)
var params={}
if(key=="1"){
params.productId=props.location.query.values.productId
params.productVesionId=props.location.query.values.id
params.isDefault=true;
params.current=1;
params.pageSize=10
LoadtopisData(params)
}else{
//actiontopisRef.current.reload();
params.productId=props.location.query.values.productId
params.productVesionId=props.location.query.values.id
params.isDefault=false;
params.current=1;
params.pageSize=10
LoadtopisData(params)
}
}
const zdytopicslist={
zdy: (
<ProTable
id="table1"
actionRef={actiontopisRef}
rowKey="id"
pagination={{ defaultPageSize: 10,total:total }}
search={{labelWidth: 120}}
columns={topicscolumns}
toolBarRender={() => [
<Button
type="primary"
key="primary"
onClick={() => {
setcreateTopisModalVisible(true);
setcurrenttopsRow({});
}}
>
<PlusOutlined /> 新建
</Button>,
]}
//数据绑定
dataSource={dataSource}
request={async (params) => {
var data = [];
var total = 0;
params.productId=props.location.query.values.productId
params.productVesionId=props.location.query.values.id
params.isDefault=false;
await getproducttopicspage(params).then((r) => {
setdataSource( r.data.data)
data = r.data.data;
total = r.data.total;
});
return {
data: data,
success: true,
total: total,
};
}}
// 每行选择点击事件
rowSelection={{
onChange: (_, selectedRows) => {
setSelectedRows(selectedRows);
},
}}
/>
),
mr:(
<ProTable
id="table3"
actionRef={actiontopismrRef}
rowKey="id"
search={false}
pagination={{ defaultPageSize: 10,total:total }}
columns={topicsmrcolumns}
toolBarRender={false}
//数据绑定
dataSource={dataSource}
request={async (params) => {
var data = [];
var total = 0;
params.productId=props.location.query.values.productId
params.productVesionId=props.location.query.values.id
params.isDefault=true;
await getproducttopicspage(params).then((r) => {
setdataSource( r.data.data)
data = r.data.data;
total = r.data.total;
});
return {
data: data,
success: true,
total: total,
};
}}
/>
)
};
const items=[{
key: '1',
label: '默认topics',
children: zdytopicslist.mr,
},
{
key: '2',
label: '自定义topics',
children: zdytopicslist.zdy
}]
const contentList = { const contentList = {
basis: ( basis: (
<Card style={{marginBottom: 24}} bordered={false}> <Card style={{marginBottom: 24}} bordered={false}>
<ProTable <ProTable
id="table2"
actionRef={actionRef} actionRef={actionRef}
rowKey="id" rowKey="id"
pagination={{ defaultPageSize: 10 }} pagination={{ defaultPageSize: 10 }}
@@ -478,8 +647,8 @@ const handleRemove = async (ids) => {
request={async (params) => { request={async (params) => {
var data = []; var data = [];
var total = 0; var total = 0;
params.deviceTypeKey=props.location.query.values.productId
params.productId=props.location.query.values.productId
params.productVesionId=props.location.query.values.id
await getGoodstechnologypage(params).then((r) => { await getGoodstechnologypage(params).then((r) => {
data = r.data.data; data = r.data.data;
setdatafunctionSource( r.data.data) setdatafunctionSource( r.data.data)
@@ -504,7 +673,6 @@ const handleRemove = async (ids) => {
console.log(value) console.log(value)
value.productId=props.location.query.values.productId value.productId=props.location.query.values.productId
value.deviceVersionKey=props.location.query.values.id; value.deviceVersionKey=props.location.query.values.id;
var success = false;
if (value.id) { if (value.id) {
await handleUpdate(value); await handleUpdate(value);
} else { } else {
@@ -530,46 +698,21 @@ const handleRemove = async (ids) => {
), ),
topis: ( topis: (
<Card style={{marginBottom: 24}} bordered={false}> <Card style={{marginBottom: 24}} bordered={false}>
<ProTable
id="table1"
actionRef={actiontopisRef}
rowKey="id"
pagination={{ defaultPageSize: 10,total:total }}
search={{labelWidth: 120}}
columns={topicscolumns}
toolBarRender={() => [
<Button
type="primary"
key="primary"
onClick={() => {
setcreateTopisModalVisible(true);
setcurrenttopsRow({});
}}
>
<PlusOutlined /> 新建
</Button>,
<Tabs tabPosition='left' items={items} onChange={onTabsChange}/>
]}
//数据绑定
dataSource={dataSource}
// 每行选择点击事件
rowSelection={{
onChange: (_, selectedRows) => {
setSelectedRows(selectedRows);
},
}}
></ProTable>
<CreateTopis createModalVisible={createTopisModalVisible} productCode={Product.key}
<CreateTopis createModalVisible={createTopisModalVisible} productCode={Product.key} productVesion={props.location.query.values?.vesion}
values={currenttopsRow || {}} values={currenttopsRow || {}}
onFinish={async (value) => { onFinish={async (value) => {
value.productId=props.location.query.values.productId value.productId=props.location.query.values.productId
value.productVesionId=props.location.query.values.id
if (value.id) { if (value.id) {
await updateproducttopics(value).then((r)=>{ await updateproducttopics(value).then((r)=>{
if (r.data) { if (r.data) {
message.success('修改成功'); message.success('修改成功');
actiontopisRef.current.reload();
setcreateTopisModalVisible(false) setcreateTopisModalVisible(false)
var params={productId:props.location.query.values.productId,current:1,pageSize:10}
LoadtopisData(params)
//var params={productId:props.location.query.values.productId,current:1,pageSize:10}
//LoadtopisData(params)
} else { } else {
message.error(r.errors); message.error(r.errors);
} }
@@ -578,8 +721,9 @@ const handleRemove = async (ids) => {
await addproducttopics(value).then((r)=>{ await addproducttopics(value).then((r)=>{
if (r.data) { if (r.data) {
message.success('添加成功'); message.success('添加成功');
var params={productId:props.location.query.values.productId,current:1,pageSize:10}
LoadtopisData(params)
actiontopisRef.current.reload();
// var params={productId:props.location.query.values.productId,current:1,pageSize:10}
// LoadtopisData(params)
setcreateTopisModalVisible(false) setcreateTopisModalVisible(false)
} else { } else {
message.error(r.errors); message.error(r.errors);
@@ -597,8 +741,6 @@ const handleRemove = async (ids) => {
), ),
}; };
return ( return (
<PageContainer host header={{ <PageContainer host header={{
title: [<a key="back" title: [<a key="back"


Loading…
Cancel
Save