From a967e0cd0d6f284629f10594dd30526c221b98f5 Mon Sep 17 00:00:00 2001 From: zhaoy <137053305@qq.com> Date: Thu, 11 Jan 2024 18:43:26 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/routes.js | 4 +- src/app.jsx | 4 +- .../database/goods/goodsattribute/index.jsx | 93 +++---- .../deviceInfo/components/CreateForm.jsx | 6 +- src/pages/device/deviceInfo/index.jsx | 59 ++-- src/pages/device/deviceInfo/services.js | 6 +- src/pages/device/deviceType/index.jsx | 203 -------------- src/pages/device/deviceType/services.js | 43 --- .../deviceVesion/components/CreateForm.jsx | 4 +- src/pages/device/deviceVesion/index.jsx | 35 +-- src/pages/device/deviceVesion/services.js | 12 +- .../components/CreateForm.jsx | 6 +- src/pages/device/product/index.jsx | 254 ++++++++++++++++++ src/pages/device/product/services.js | 44 +++ 14 files changed, 416 insertions(+), 357 deletions(-) delete mode 100644 src/pages/device/deviceType/index.jsx delete mode 100644 src/pages/device/deviceType/services.js rename src/pages/device/{deviceType => product}/components/CreateForm.jsx (82%) create mode 100644 src/pages/device/product/index.jsx create mode 100644 src/pages/device/product/services.js diff --git a/config/routes.js b/config/routes.js index 8754d40..ee270aa 100644 --- a/config/routes.js +++ b/config/routes.js @@ -165,8 +165,8 @@ export default [ { name: '产品管理', icon: 'smile', - path: '/device/deviceType', - component: './device/deviceType', + path: '/device/product', + component: './device/product', access: 'k12', }, { diff --git a/src/app.jsx b/src/app.jsx index 3b564cd..015d852 100644 --- a/src/app.jsx +++ b/src/app.jsx @@ -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', }, { diff --git a/src/pages/database/goods/goodsattribute/index.jsx b/src/pages/database/goods/goodsattribute/index.jsx index 6577e81..e89aa7c 100644 --- a/src/pages/database/goods/goodsattribute/index.jsx +++ b/src/pages/database/goods/goodsattribute/index.jsx @@ -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: '主键', diff --git a/src/pages/device/deviceInfo/components/CreateForm.jsx b/src/pages/device/deviceInfo/components/CreateForm.jsx index 6ea1ffa..e958d6b 100644 --- a/src/pages/device/deviceInfo/components/CreateForm.jsx +++ b/src/pages/device/deviceInfo/components/CreateForm.jsx @@ -74,8 +74,8 @@ const CreateForm = (props) => { {props.storeType.map((item, index) => { return ( diff --git a/src/pages/device/deviceInfo/index.jsx b/src/pages/device/deviceInfo/index.jsx index e6cf590..36f1b4d 100644 --- a/src/pages/device/deviceInfo/index.jsx +++ b/src/pages/device/deviceInfo/index.jsx @@ -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', diff --git a/src/pages/device/deviceInfo/services.js b/src/pages/device/deviceInfo/services.js index ebb9bf7..f5e38bf 100644 --- a/src/pages/device/deviceInfo/services.js +++ b/src/pages/device/deviceInfo/services.js @@ -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', }); } diff --git a/src/pages/device/deviceType/index.jsx b/src/pages/device/deviceType/index.jsx deleted file mode 100644 index f316995..0000000 --- a/src/pages/device/deviceType/index.jsx +++ /dev/null @@ -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) => [ - { - handleModalVisible(true); - setCurrentRow(record); - }} > 更新 - ], - }, - ]; - - return ( - - [ - , - ]} - 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 && ( - - 已选择{' '} - - {selectedRowsState.length} - {' '} - 项    - - } - > - - - )} - - { - 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 || {}} - /> - - ); -}; - -export default GoodsTypeManage; diff --git a/src/pages/device/deviceType/services.js b/src/pages/device/deviceType/services.js deleted file mode 100644 index cd0c313..0000000 --- a/src/pages/device/deviceType/services.js +++ /dev/null @@ -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', - }); -} - diff --git a/src/pages/device/deviceVesion/components/CreateForm.jsx b/src/pages/device/deviceVesion/components/CreateForm.jsx index 5de52f0..66de4b3 100644 --- a/src/pages/device/deviceVesion/components/CreateForm.jsx +++ b/src/pages/device/deviceVesion/components/CreateForm.jsx @@ -97,8 +97,8 @@ const CreateForm = (props) => { - + + + + - , + ]} + 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 && ( + + 已选择{' '} + + {selectedRowsState.length} + {' '} + 项    + + } + > + + + )} + + { + 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 || {}} + /> + + ); +}; + +export default GoodsTypeManage; diff --git a/src/pages/device/product/services.js b/src/pages/device/product/services.js new file mode 100644 index 0000000..ef6b298 --- /dev/null +++ b/src/pages/device/product/services.js @@ -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, + }); +} +