zhaoy 11 mesi fa
parent
commit
a967e0cd0d
14 ha cambiato i file con 416 aggiunte e 357 eliminazioni
  1. +2
    -2
      config/routes.js
  2. +2
    -2
      src/app.jsx
  3. +48
    -45
      src/pages/database/goods/goodsattribute/index.jsx
  4. +3
    -3
      src/pages/device/deviceInfo/components/CreateForm.jsx
  5. +30
    -29
      src/pages/device/deviceInfo/index.jsx
  6. +3
    -3
      src/pages/device/deviceInfo/services.js
  7. +0
    -203
      src/pages/device/deviceType/index.jsx
  8. +0
    -43
      src/pages/device/deviceType/services.js
  9. +2
    -2
      src/pages/device/deviceVesion/components/CreateForm.jsx
  10. +18
    -17
      src/pages/device/deviceVesion/index.jsx
  11. +6
    -6
      src/pages/device/deviceVesion/services.js
  12. +4
    -2
      src/pages/device/product/components/CreateForm.jsx
  13. +254
    -0
      src/pages/device/product/index.jsx
  14. +44
    -0
      src/pages/device/product/services.js

+ 2
- 2
config/routes.js Vedi File

@@ -165,8 +165,8 @@ export default [
{
name: '产品管理',
icon: 'smile',
path: '/device/deviceType',
component: './device/deviceType',
path: '/device/product',
component: './device/product',
access: 'k12',
},
{


+ 2
- 2
src/app.jsx Vedi File

@@ -152,8 +152,8 @@ export async function getInitialState() {
code: 'deviceType',
name: '产品管理',
icon: 'smile',
path: '/device/deviceType',
component: './device/deviceType',
path: '/device/product',
component: './device/product',
access: 'k12',
},
{


+ 48
- 45
src/pages/database/goods/goodsattribute/index.jsx Vedi File

@@ -16,7 +16,52 @@ import {
} from './service';

/**


const goodsattribute = () => {
/** 新建/更新窗口的弹窗 */
const [createModalVisible, handleModalVisible] = useState(false);
const [createattrModalVisible, handleMattrodalVisible] = useState(false);
/** 分布更新窗口的弹窗 */

const [goodstypeData, setGoodstypeData] = useState([]);
const [attributeid, setAttributeid] = useState('');
const actionRef = useRef();
const [currentRow, setCurrentRow] = useState();
const [selectedRowsState, setSelectedRows] = useState([]);
const [treeData, setTreeData] = useState();
/** 国际化修改 */
useEffect(() => {

intDicData();
}, []);
function intDicData() {
gettree().then((r) => {
setTreeData(r.data);
});
}

/**
* 批量删除
*
* @param selectedRows
*/

const handleRemove = async (selectedRows) => {
const hide = message.loading('正在删除');
if (!selectedRows) return true;
await deletegoodsattribute(selectedRows.map((row) => row.id)).then((r) => {
if (r.succeeded) {
message.success('删除成功');
actionRef.current.reload();
} else {
message.error(r.errors);
}
});
hide();
return true;
};
/**
* 添加节点
*
* @param fields
@@ -28,6 +73,7 @@ const handleAdd = async (fields) => {
await addgoodsattribute(JSON.stringify(fields)).then((r) => {
if (r.succeeded) {
message.success('添加成功');
actionRef.current.reload();
} else {
message.error(r.errors);
}
@@ -57,6 +103,7 @@ const handleUpdate = async (fields) => {
}).then((r) => {
if (r.succeeded) {
message.success('修改成功');
actionRef.current.reload();
} else {
message.error(r.errors);
}
@@ -69,50 +116,6 @@ const handleUpdate = async (fields) => {
return false;
}
};

const goodsattribute = () => {
/** 新建/更新窗口的弹窗 */
const [createModalVisible, handleModalVisible] = useState(false);
const [createattrModalVisible, handleMattrodalVisible] = useState(false);
/** 分布更新窗口的弹窗 */

const [goodstypeData, setGoodstypeData] = useState([]);
const [attributeid, setAttributeid] = useState('');
const actionRef = useRef();
const [currentRow, setCurrentRow] = useState();
const [selectedRowsState, setSelectedRows] = useState([]);
const [treeData, setTreeData] = useState();
/** 国际化修改 */
useEffect(() => {

intDicData();
}, []);
function intDicData() {
gettree().then((r) => {
setTreeData(r.data);
});
}

/**
* 批量删除
*
* @param selectedRows
*/

const handleRemove = async (selectedRows) => {
const hide = message.loading('正在删除');
if (!selectedRows) return true;
await deletegoodsattribute(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: '主键',


+ 3
- 3
src/pages/device/deviceInfo/components/CreateForm.jsx Vedi File

@@ -74,8 +74,8 @@ const CreateForm = (props) => {
<Select onChange={handleChange}>
{props.dicData.map((item, index) => {
return (
<Select.Option index={index} value={item.code} key={item.code}>
{item.value}
<Select.Option index={index} value={item.label} key={item.id}>
{item.label}
</Select.Option>
);
})}
@@ -101,7 +101,7 @@ const CreateForm = (props) => {
treeDefaultExpandAll
/>
</Form.Item> */}
<Form.Item label={'设备标签'} name="deviceTypeId" rules={[{ required: true }]}>
<Form.Item label={'设备标签'} name="deviceTypeId" rules={[{ required: false }]}>
{/* <Select>
{props.storeType.map((item, index) => {
return (


+ 30
- 29
src/pages/device/deviceInfo/index.jsx Vedi File

@@ -6,7 +6,7 @@ import ProTable from '@ant-design/pro-table';
import CreateForm from './components/CreateForm';
import {
GetDeviceInfoPage,
GetDicList,
GetProductList,
AddDeviceInfo,
UpdateDeviceInfo,
DelDeviceInfo,
@@ -136,22 +136,23 @@ const GoodsTypeManage = () => {
initOrgList();
initDeviceType();
function intDicData() {
// GetDicList('DeviceClientType').then((r) => {
// var arr = r.data;
// let data = {};
// if (r.succeeded) {
// var list = [];
// arr.forEach((item) => {
// data[item.code] = { text: item.code };
// list.push({
// code: item.code,
// value: item.code,
// });
// });
// setDicDataAny(data);
// setDicData(list);
// }
// });
GetProductList().then((r) => {
var arr = r.data;
let data = {};
if (r.succeeded) {
var list = [];
arr.forEach((item) => {
data[item.code] = { text: item.code };
list.push({
id: item.id,
label: item.name,
text:item.name,
});
});
setDicDataAny(data);
setDicData(list);
}
});
}
intDicData();
initDeviceVersion();
@@ -163,7 +164,7 @@ const GoodsTypeManage = () => {
data.data.forEach((item) => {
list2.push({
label: item.name,
text:item,
text:item.name,
id: item.id,
});
list[item.id] = { text: item.name };
@@ -213,12 +214,12 @@ const GoodsTypeManage = () => {
dataIndex: 'deviceVersionName',
search: false,
},
{
title: '归属门店',
dataIndex: 'orgId',
search: false,
valueEnum: OrgListArray,
},
// {
// title: '归属门店',
// dataIndex: 'orgId',
// search: false,
// valueEnum: OrgListArray,
// },
{
title: '设备标签',
dataIndex: 'deviceTypeId',
@@ -239,11 +240,11 @@ const GoodsTypeManage = () => {
dataIndex: 'autoKey',
search: false,
},
{
title: '归属门店唯一key',
dataIndex: 'orgKey',
search: false,
},
// {
// title: '归属门店唯一key',
// dataIndex: 'orgKey',
// search: false,
// },
{
title: '操作',
dataIndex: 'option',


+ 3
- 3
src/pages/device/deviceInfo/services.js Vedi File

@@ -7,9 +7,9 @@ export async function GetDeviceInfoPage(data) {
data: data,
});
}
/**获取设备类型 */
export async function GetDicList(TypeCode) {
return request(`/saasbase/api/dict-data/dic-list/${TypeCode}`, {
/**获取产品 */
export async function GetProductList() {
return request(`/saasbase/api/product/list`, {
method: 'Get',
});
}


+ 0
- 203
src/pages/device/deviceType/index.jsx Vedi File

@@ -1,203 +0,0 @@

import { Modal,Button, message, } from 'antd';
import React, { useState, useRef } from 'react';
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout';
import { PlusOutlined } from '@ant-design/icons';
import ProTable from '@ant-design/pro-table';
import CreateForm from './components/CreateForm';
import { GetDeviceTypePage, AddDeviceType, DelDeviceType, UpdateDeviceType, } from "./services"

const key = 'message';

//添加
const handleAdd = async (fields) => {
try {
message.loading('正在添加', key);
await AddDeviceType(JSON.stringify(fields)).then((r) => {
message.destroy(key);
if (r.data) {
message.success('添加成功');
return true;
} else {
message.error('添加失败');
return false;
}
});
} catch (error) {
message.error('添加失败请重试!');
return false;
}
};


//修改
const handleUpdate = async (fields) => {
try {
message.loading('正在修改', key);
message.destroy(key);
await UpdateDeviceType(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 DelDeviceType(ids).then((r) => {
if (r.data) {
message.success('删除成功');
return true;
} else {
message.error(r.errors);
return false;
}
});
} catch (error) {
message.error('删除失败请重试!');
return false;
}
};

const GoodsTypeManage = () => {
const [createModalVisible, handleModalVisible] = useState(false);
const actionRef = useRef();
const [currentRow, setCurrentRow] = useState();
const [selectedRowsState, setSelectedRows] = useState([]);
const columns = [
{
title: '主键',
dataIndex: 'id',
hideInSearch: true,
hideInTable: true,
tip: '规则名称是唯一的 key'
},
{
title: '类型名称',
dataIndex: 'name',
valueType: 'textarea',
},
{
title: '操作',
dataIndex: 'option',
valueType: 'option',
render: (_, record) => [
<a
key="config"
onClick={() => {
handleModalVisible(true);
setCurrentRow(record);
}} > 更新</a>
],
},
];

return (
<PageContainer>
<ProTable
headerTitle="设备分类"
actionRef={actionRef}
rowKey="id"
search={{
labelWidth: 120,
}}
toolBarRender={() => [
<Button
type="primary"
key="primary"
onClick={() => {
handleModalVisible(true);
}} >
<PlusOutlined /> 新建
</Button>,
]}
request={async (params) => {
var data = [];
var total = 0;
await GetDeviceTypePage(params).then((r) => {
data = r.data.data;
total = r.data.total;
});
return {
data: data,
success: true,
total: total,
};
}}
columns={columns}
rowSelection={{
onChange: (_, selectedRows) => {
setSelectedRows(selectedRows);
},
}}
/>
{selectedRowsState?.length > 0 && (
<FooterToolbar
extra={
<div>
已选择{' '}
<a
style={{
fontWeight: 600,
}}
>
{selectedRowsState.length}
</a>{' '}
项 &nbsp;&nbsp;
</div>
}
>
<Button
onClick={async () => {
await handleRemove(selectedRowsState);
setSelectedRows([]);
actionRef.current?.reloadAndRest?.();
}}
>
删除
</Button>
</FooterToolbar>
)}

<CreateForm
onFinish={async (value) => {
var success = false;
if (value.id) {
success = handleUpdate(value);
} else {
success = handleAdd(value);
}
if (success) {
handleModalVisible(false);
setCurrentRow(undefined);
}
actionRef.current.reload();
}}
onCancel={() => {
handleModalVisible(false);
setCurrentRow(undefined);
}}
createModalVisible={createModalVisible}
values={currentRow || {}}
/>
</PageContainer>
);
};

export default GoodsTypeManage;

+ 0
- 43
src/pages/device/deviceType/services.js Vedi File

@@ -1,43 +0,0 @@
import { request } from 'umi';

/** 设备类型列表 */
export async function GetDeviceTypePage(data) {
return request(`/saasbase/api/Device/GetDeviceTypePage`, {
method: 'POST',
data: data,
});
}

/** 添加设备类型 */
export async function AddDeviceType(data) {
return request(`/saasbase/api/Device/AddDeviceType`, {
method: 'POST',
data: data,
// params: { ...params },
// ...(options || {}),
});
}

/** 删除设备类型 */
export async function DelDeviceType(data) {
return request(`​/saasbase/api/Device/DelDeviceType`, {
method: 'POST',
data: data,
});
}

/** 修改设备类型 */
export async function UpdateDeviceType(data) {
return request(`​/saasbase/api/Device/UpdateDeviceType`, {
method: 'POST',
data: data,
});
}

/** 获取所有设备类型 */
export async function GetDeviceType(data) {
return request(`​/saasbase/api/Device/GetDeviceType`, {
method: 'GET',
});
}


+ 2
- 2
src/pages/device/deviceVesion/components/CreateForm.jsx Vedi File

@@ -97,8 +97,8 @@ const CreateForm = (props) => {
<Select>
{props.dicData.map((item, index) => {
return (
<Select.Option index={index} value={item.code} key={item.code}>
{item.value}
<Select.Option index={index} value={item.label} key={item.label}>
{item.label}
</Select.Option>
);
})}


+ 18
- 17
src/pages/device/deviceVesion/index.jsx Vedi File

@@ -5,7 +5,7 @@ import { PageContainer, FooterToolbar } from '@ant-design/pro-layout';
import { PlusOutlined } from '@ant-design/icons';
import ProTable from '@ant-design/pro-table';
import CreateForm from './components/CreateForm';
import { GetDeviceVesionPage, AddDeviceVesion, DelDeviceVesion, UpdateDeviceVesion, GetDicList,UpdateStatus } from "./services"
import { GetDeviceVesionPage, AddDeviceVesion, DelDeviceVesion, UpdateDeviceVesion, GetProductList,UpdateStatus } from "./services"

const key = 'message';

@@ -199,22 +199,23 @@ const GoodsTypeManage = () => {
},
];
useEffect(() => {
// GetDicList('DeviceClientType').then((r) => {
// var arr = r.data;
// let data = {};
// if (r.succeeded) {
// var list = [];
// arr.forEach((item) => {
// data[item.code] = { text: item.code };
// list.push({
// code: item.code,
// value: item.code,
// });
// });
// //setDicDataAny(data);
// setDictData(list);
// }
// });
GetProductList().then((r) => {
var arr = r.data;
let data = {};
if (r.succeeded) {
var list = [];
arr.forEach((item) => {
data[item.code] = { text: item.code };
list.push({
label: item.name,
text:item,
id: item.id,
});
});
//setDicDataAny(data);
setDictData(list);
}
});
}, [])
return (
<PageContainer host header={{


+ 6
- 6
src/pages/device/deviceVesion/services.js Vedi File

@@ -38,12 +38,12 @@ export async function UpdateDeviceVesion(data) {
data: data,
});
}
/**获取设备类型 */
export async function GetDicList(TypeCode) {
return request(`/saasbase/api/dict-data/dic-list/${TypeCode}`, {
method: 'Get',
});
}
/**获取产品 */
export async function GetProductList() {
return request(`/saasbase/api/product/list`, {
method: 'Get',
});
}

export async function GetCosRequestURL(data) {
return request(`/saasbase/api/systemconfig/GetCosRequestSignURL`, {


src/pages/device/deviceType/components/CreateForm.jsx → src/pages/device/product/components/CreateForm.jsx Vedi File

@@ -23,10 +23,12 @@ const CreateForm = (props) => {
<Form.Item name="id" hidden={true}>
<Input />
</Form.Item>
<Form.Item label={"类型名称"} name="name" rules={[{ required: true,max:50}]} >
<Form.Item label={"产品名称"} name="name" rules={[{ required: true,max:50}]} >
<Input />
</Form.Item>
<Form.Item label={"备注"} name="remark" rules={[{ required: true,max:50}]} >
<Input />
</Form.Item>

<Form.Item>
<Button type="primary" htmlType="submit">
保存

+ 254
- 0
src/pages/device/product/index.jsx Vedi File

@@ -0,0 +1,254 @@

import { Modal,Button, message,Popconfirm } from 'antd';
import React, { useState, useRef } from 'react';
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout';
import { PlusOutlined } from '@ant-design/icons';
import ProTable from '@ant-design/pro-table';
import CreateForm from './components/CreateForm';
import { GetProductPage, AddProduct, DelProduct, UpdateProduct,UpdateStatus } from "./services"

const key = 'message';
const GoodsTypeManage = () => {
const [createModalVisible, handleModalVisible] = useState(false);
const actionRef = useRef();
const [currentRow, setCurrentRow] = useState();
const [selectedRowsState, setSelectedRows] = useState([]);
const columns = [
{
title: '主键',
dataIndex: 'id',
hideInSearch: true,
hideInTable: true,
tip: '规则名称是唯一的 key'
},
{
title: '产品名称',
dataIndex: 'name',
valueType: 'textarea',
},
{
title: '产品key',
dataIndex: 'key',
valueType: 'textarea',
},
{
title: '备注',
dataIndex: 'remark',
valueType: 'textarea',
width: 450,
},
{
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 450,
render: (_, record) => [
<a
key="config"
onClick={() => {
handleModalVisible(true);
setCurrentRow(record);
}} > 更新</a>,
<a
key="status"
onClick={async () => {
actionRef.current.reload();
record.status = record.status ? 0 : 1;

await UpdateStatus(record).then((r) => {
if (r.succeeded) {
message.success('配置成功');
} else {
message.error('配置失败请重试!');
}
});
}}
>
{record.status == 0 ? '停用' : '启用'}
</a>,
<Popconfirm
type="primary"
key="primary"
title="确认删除吗?"
okText="是"
cancelText="否"
onConfirm={() => {
DelProduct([record.id]).then((r) => {
message.success('删除成功,即将刷新');
actionRef.current.reload();
});
}}
onCancel={() => { }}
>
<a href="#">删除</a>
</Popconfirm>,
],
},
];
//添加
const handleAdd = async (fields) => {
try {
message.loading('正在添加', key);
await AddProduct(JSON.stringify(fields)).then((r) => {
message.destroy(key);
if (r.succeeded) {
message.success('添加成功');
actionRef.current.reload();
return true;
} else {
message.error(r.errors);
return false;
}
});
} catch (error) {
message.error('添加失败请重试!');
return false;
}
};
//修改
const handleUpdate = async (fields) => {
try {
message.loading('正在修改', key);
message.destroy(key);
await UpdateProduct(JSON.stringify(fields)).then((r) => {
message.destroy(key);
if (r.succeeded) {
message.success('修改成功',);
actionRef.current.reload();
return true;
} else {
message.error(r.errors);
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 DelProduct(ids).then((r) => {
if (r.data) {
message.success('删除成功');
actionRef.current.reload();
return true;
} else {
message.error(r.errors);
return false;
}
});
} catch (error) {
message.error('删除失败请重试!');
return false;
}
};
return (
<PageContainer host header={{
title: '',
breadcrumb: {},
}}>
<ProTable
headerTitle="设备分类"
actionRef={actionRef}
rowKey="id"
pagination={{ defaultPageSize: 10 }}
search={{
labelWidth: 120,
}}
toolBarRender={() => [
<Button
type="primary"
key="primary"
onClick={() => {
handleModalVisible(true);
}} >
<PlusOutlined /> 新建
</Button>,
]}
request={async (params) => {
var data = [];
var total = 0;
await GetProductPage(params).then((r) => {
data = r.data.data;
total = r.data.total;
});
return {
data: data,
success: true,
total: total,
};
}}
columns={columns}
rowSelection={{
onChange: (_, selectedRows) => {
setSelectedRows(selectedRows);
},
}}
/>
{selectedRowsState?.length > 0 && (
<FooterToolbar
extra={
<div>
已选择{' '}
<a
style={{
fontWeight: 600,
}}
>
{selectedRowsState.length}
</a>{' '}
项 &nbsp;&nbsp;
</div>
}
>
<Button
onClick={async () => {
await handleRemove(selectedRowsState);
setSelectedRows([]);
actionRef.current?.reloadAndRest?.();
}}
>
删除
</Button>
</FooterToolbar>
)}

<CreateForm
onFinish={async (value) => {
var success = false;
if (value.id) {
success = handleUpdate(value);
} else {
success = handleAdd(value);
}
if (success) {
handleModalVisible(false);
setCurrentRow(undefined);
}
actionRef.current.reload();
}}
onCancel={() => {
handleModalVisible(false);
setCurrentRow(undefined);
}}
createModalVisible={createModalVisible}
values={currentRow || {}}
/>
</PageContainer>
);
};

export default GoodsTypeManage;

+ 44
- 0
src/pages/device/product/services.js Vedi File

@@ -0,0 +1,44 @@
import { request } from 'umi';

/** 产品列表 */
export async function GetProductPage(data) {
return request(`/saasbase/api/product/page`, {
method: 'POST',
data: data,
});
}

/** 添加产品 */
export async function AddProduct(data) {
return request(`/saasbase/api/product/add`, {
method: 'POST',
data: data,
// params: { ...params },
// ...(options || {}),
});
}

/** 删除产品 */
export async function DelProduct(data) {
return request(`​/saasbase/api/product/delete`, {
method: 'POST',
data: data,
});
}

/** 修改产品 */
export async function UpdateProduct(data) {
return request(`​/saasbase/api/product/update`, {
method: 'POST',
data: data,
});
}

/** 更新产品状态 */
export async function UpdateStatus(data) {
return request(`​/saasbase/api/product/updatestatus`, {
method: 'POST',
data: data,
});
}


Caricamento…
Annulla
Salva