From 319b6c1a3d172b080a353f9ef41b888f5e060725 Mon Sep 17 00:00:00 2001 From: yinweiwen Date: Mon, 17 Oct 2022 21:55:56 +0800 Subject: [PATCH] products --- .gitignore | 1 + code/web/client/assets/color.less | 14 +- code/web/client/src/app.js | 4 +- .../src/layout/components/header/index.js | 3 + .../src/sections/factor/actions/index.js | 7 - .../src/sections/factor/containers/index.js | 5 - .../client/src/sections/meta/actions/index.js | 7 + .../factors.js => meta/actions/meta.js} | 12 ++ .../containers/ConfigModal.js | 0 .../containers/FactorProfile.js | 13 +- .../meta/containers/ProductsProfile.js | 161 ++++++++++++++++++ .../src/sections/meta/containers/index.js | 6 + .../{factor => meta}/containers/models.js | 0 .../src/sections/{factor => meta}/index.js | 4 +- .../src/sections/{factor => meta}/nav-item.js | 5 +- .../{factor => meta}/reducers/index.js | 0 .../src/sections/{factor => meta}/routes.js | 9 + .../src/sections/{factor => meta}/style.less | 0 code/web/client/src/utils/webapi.js | 2 + code/web/package.json | 2 +- 20 files changed, 221 insertions(+), 34 deletions(-) delete mode 100644 code/web/client/src/sections/factor/actions/index.js delete mode 100644 code/web/client/src/sections/factor/containers/index.js create mode 100644 code/web/client/src/sections/meta/actions/index.js rename code/web/client/src/sections/{factor/actions/factors.js => meta/actions/meta.js} (55%) rename code/web/client/src/sections/{factor => meta}/containers/ConfigModal.js (100%) rename code/web/client/src/sections/{factor => meta}/containers/FactorProfile.js (93%) create mode 100644 code/web/client/src/sections/meta/containers/ProductsProfile.js create mode 100644 code/web/client/src/sections/meta/containers/index.js rename code/web/client/src/sections/{factor => meta}/containers/models.js (100%) rename code/web/client/src/sections/{factor => meta}/index.js (84%) rename code/web/client/src/sections/{factor => meta}/nav-item.js (74%) rename code/web/client/src/sections/{factor => meta}/reducers/index.js (100%) rename code/web/client/src/sections/{factor => meta}/routes.js (52%) rename code/web/client/src/sections/{factor => meta}/style.less (100%) diff --git a/.gitignore b/.gitignore index e687ee9..49c12e2 100644 --- a/.gitignore +++ b/.gitignore @@ -121,3 +121,4 @@ dist *yarn.lock *package-lock.json *log/ +code/web/client/assets/color.less diff --git a/code/web/client/assets/color.less b/code/web/client/assets/color.less index 96c2350..c66ac4d 100644 --- a/code/web/client/assets/color.less +++ b/code/web/client/assets/color.less @@ -1147,10 +1147,10 @@ tr > .ant-picker-cell-in-view.ant-picker-cell-range-hover-start:last-child::afte .ant-mentions-dropdown-menu-item-active {background-color: @item-hover-bg;} .ant-menu-item-danger.ant-menu-item {color: #ff4d4f;} .ant-menu-item-danger.ant-menu-item:hover, .ant-menu-item-danger.ant-menu-item-active {color: #ff4d4f;} -.ant-menu-item-danger.ant-menu-item:active {background: color(~`colorPalette("@{skeleton-color}", 1)`);} +.ant-menu-item-danger.ant-menu-item:active {background: #fff1f0;} .ant-menu-item-danger.ant-menu-item-selected {color: #ff4d4f;} .ant-menu-item-danger.ant-menu-item-selected > a, .ant-menu-item-danger.ant-menu-item-selected > a:hover {color: #ff4d4f;} -.ant-menu:not(.ant-menu-horizontal) .ant-menu-item-danger.ant-menu-item-selected {background-color: color(~`colorPalette("@{skeleton-color}", 1)`);} +.ant-menu:not(.ant-menu-horizontal) .ant-menu-item-danger.ant-menu-item-selected {background-color: #fff1f0;} .ant-menu-inline .ant-menu-item-danger.ant-menu-item::after {border-right-color: #ff4d4f;} .ant-menu-dark .ant-menu-item-danger.ant-menu-item, .ant-menu-dark .ant-menu-item-danger.ant-menu-item:hover, .ant-menu-dark .ant-menu-item-danger.ant-menu-item > a {color: #ff4d4f;} .ant-menu-dark.ant-menu-dark:not(.ant-menu-horizontal) .ant-menu-item-danger.ant-menu-item-selected {color: #fff;background-color: #ff4d4f;} @@ -1727,15 +1727,15 @@ tr.ant-table-expanded-row:hover > td {background: @table-expanded-row-bg;} .ant-tag-checkable:active, .ant-tag-checkable-checked {color: #fff;} .ant-tag-checkable-checked {background-color: @primary-color;} .ant-tag-checkable:active {background-color: color(~`colorPalette("@{primary-color}", 7)`);} -.ant-tag-pink {color: #c41d7f;background: color(~`colorPalette("@{shadow-color}", 1)`);border-color: #ffadd2;} +.ant-tag-pink {color: #c41d7f;background: color(~`colorPalette("@{pagination-item-input-bg}", 2)`);border-color: #ffadd2;} .ant-tag-pink-inverse {color: #fff;background: #eb2f96;border-color: #eb2f96;} -.ant-tag-magenta {color: #c41d7f;background: color(~`colorPalette("@{shadow-color}", 1)`);border-color: #ffadd2;} +.ant-tag-magenta {color: #c41d7f;background: color(~`colorPalette("@{pagination-item-input-bg}", 2)`);border-color: #ffadd2;} .ant-tag-magenta-inverse {color: #fff;background: #eb2f96;border-color: #eb2f96;} -.ant-tag-red {color: #cf1322;background: color(~`colorPalette("@{skeleton-color}", 1)`);border-color: #ffa39e;} +.ant-tag-red {color: #cf1322;background: #fff1f0;border-color: #ffa39e;} .ant-tag-red-inverse {color: #fff;background: #f5222d;border-color: #f5222d;} .ant-tag-volcano {color: #d4380d;background: #fff2e8;border-color: #ffbb96;} .ant-tag-volcano-inverse {color: #fff;background: #fa541c;border-color: #fa541c;} -.ant-tag-orange {color: #d46b08;background: color(~`colorPalette("@{switch-bg}", 1)`);border-color: #ffd591;} +.ant-tag-orange {color: #d46b08;background: #fff7e6;border-color: #ffd591;} .ant-tag-orange-inverse {color: #fff;background: #fa8c16;border-color: #fa8c16;} .ant-tag-yellow {color: #d4b106;background: #feffe6;border-color: #fffb8f;} .ant-tag-yellow-inverse {color: #fff;background: #fadb14;border-color: #fadb14;} @@ -1749,7 +1749,7 @@ tr.ant-table-expanded-row:hover > td {background: @table-expanded-row-bg;} .ant-tag-green-inverse {color: #fff;background: #52c41a;border-color: #52c41a;} .ant-tag-blue {color: #096dd9;background: #e6f7ff;border-color: #91d5ff;} .ant-tag-blue-inverse {color: #fff;background: #1890ff;border-color: #1890ff;} -.ant-tag-geekblue {color: #1d39c4;background: color(~`colorPalette("@{disabled-color}", 1)`);border-color: #adc6ff;} +.ant-tag-geekblue {color: #1d39c4;background: color(~`colorPalette("@{calendar-bg}", 1)`);border-color: #adc6ff;} .ant-tag-geekblue-inverse {color: #fff;background: #2f54eb;border-color: #2f54eb;} .ant-tag-purple {color: #531dab;background: #f9f0ff;border-color: #d3adf7;} .ant-tag-purple-inverse {color: #fff;background: #722ed1;border-color: #722ed1;} diff --git a/code/web/client/src/app.js b/code/web/client/src/app.js index dde044d..30d760b 100644 --- a/code/web/client/src/app.js +++ b/code/web/client/src/app.js @@ -5,7 +5,7 @@ import Layout from './layout'; import Auth from './sections/auth'; import Gateway from './sections/gateway'; import Search from './sections/search'; -import Factor from './sections/factor'; +import Meta from './sections/meta'; const App = props => { const { projectName } = props @@ -17,7 +17,7 @@ const App = props => { return ( ) } diff --git a/code/web/client/src/layout/components/header/index.js b/code/web/client/src/layout/components/header/index.js index 7701c74..0bc21ef 100644 --- a/code/web/client/src/layout/components/header/index.js +++ b/code/web/client/src/layout/components/header/index.js @@ -79,6 +79,9 @@ const Header = props => { } > 监测因素 + } > + 监测因素 + 主题切换} > diff --git a/code/web/client/src/sections/factor/actions/index.js b/code/web/client/src/sections/factor/actions/index.js deleted file mode 100644 index 335a5b6..0000000 --- a/code/web/client/src/sections/factor/actions/index.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -import * as factor from './factors' - -export default { - ...factor -} \ No newline at end of file diff --git a/code/web/client/src/sections/factor/containers/index.js b/code/web/client/src/sections/factor/containers/index.js deleted file mode 100644 index a3e33d1..0000000 --- a/code/web/client/src/sections/factor/containers/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -import FactorProfile from './FactorProfile'; - -export { FactorProfile }; \ No newline at end of file diff --git a/code/web/client/src/sections/meta/actions/index.js b/code/web/client/src/sections/meta/actions/index.js new file mode 100644 index 0000000..b4b50e2 --- /dev/null +++ b/code/web/client/src/sections/meta/actions/index.js @@ -0,0 +1,7 @@ +'use strict'; + +import * as meta from './meta' + +export default { + ...meta +} \ No newline at end of file diff --git a/code/web/client/src/sections/factor/actions/factors.js b/code/web/client/src/sections/meta/actions/meta.js similarity index 55% rename from code/web/client/src/sections/factor/actions/factors.js rename to code/web/client/src/sections/meta/actions/meta.js index 792cd96..9e07ed5 100644 --- a/code/web/client/src/sections/factor/actions/factors.js +++ b/code/web/client/src/sections/meta/actions/meta.js @@ -13,4 +13,16 @@ export function list(query) { msg: { error: '获取监测原型列表失败' }, reducer: { name: 'factors' } }) +} + +export function listProducts(query) { + return dispatch => basicAction({ + type: 'get', + dispatch: dispatch, + query: query, + actionType: 'GET_PRODUCT_LIST', + url: ApiTable.getProducts, + msg: { error: '获取设备原型列表失败' }, + reducer: { name: 'products' } + }) } \ No newline at end of file diff --git a/code/web/client/src/sections/factor/containers/ConfigModal.js b/code/web/client/src/sections/meta/containers/ConfigModal.js similarity index 100% rename from code/web/client/src/sections/factor/containers/ConfigModal.js rename to code/web/client/src/sections/meta/containers/ConfigModal.js diff --git a/code/web/client/src/sections/factor/containers/FactorProfile.js b/code/web/client/src/sections/meta/containers/FactorProfile.js similarity index 93% rename from code/web/client/src/sections/factor/containers/FactorProfile.js rename to code/web/client/src/sections/meta/containers/FactorProfile.js index 4b57163..051493d 100644 --- a/code/web/client/src/sections/factor/containers/FactorProfile.js +++ b/code/web/client/src/sections/meta/containers/FactorProfile.js @@ -11,7 +11,7 @@ import { request } from 'superagent'; const FactorProfile = (props) => { const { dispatch, actions, user, loading, factors, total } = props - const { factor } = actions; + const { meta } = actions; const [configModalVis, setConfigModalVis] = useState(false) const [editData, setEditData] = useState(null) const [fdata, setFdata] = useState([]) @@ -19,7 +19,7 @@ const FactorProfile = (props) => { const pageSize = 10 useEffect(() => { - // dispatch(factor.list()) + // dispatch(meta.list()) }, []) const actionRef = useRef(); @@ -66,7 +66,7 @@ const FactorProfile = (props) => { ] const requestList = async (params) => { - const ret = await dispatch(factor.list()); + const ret = await dispatch(meta.list()); console.log(ret) let tmp = [] tmp = ret.payload.data.data; @@ -97,7 +97,7 @@ const FactorProfile = (props) => { limit: params.pageSize, offset: params.pageSize * (params.current - 1) } - const res = await dispatch(factor.list(query)); + const res = await dispatch(meta.list(query)); return { ...res, total: res.payload.data ? res.payload.data.total : 0 @@ -142,11 +142,6 @@ const FactorProfile = (props) => { request={requestList} manualRequest={false} options={false} - toolBarRender={() => [ - , - ]} pagination={{ pageSize: pageSize, onChange: (page) => console.log(page), diff --git a/code/web/client/src/sections/meta/containers/ProductsProfile.js b/code/web/client/src/sections/meta/containers/ProductsProfile.js new file mode 100644 index 0000000..e64c835 --- /dev/null +++ b/code/web/client/src/sections/meta/containers/ProductsProfile.js @@ -0,0 +1,161 @@ +import React, { useState, useRef, useEffect } from 'react'; +import { connect } from 'react-redux'; +import { Button, Space, Tag } from 'antd'; +import '../style.less'; +import ProTable from '@ant-design/pro-table'; +import ConfigModal from './ConfigModal'; + +const ProductsProfile = (props) => { + const { dispatch, actions, products } = props + + const { meta } = actions; + const [configModalVis, setConfigModalVis] = useState(false) + const [editData, setEditData] = useState(null) + // 过滤后数据,用于表格展示 + const [fdata, setFdata] = useState([]) + + useEffect(() => { + dispatch(meta.listProducts()) + }, []); + const pageSize = 10 + + const actionRef = useRef(); + const columns = [{ + title: 'ID', + dataIndex: 'Id', + copyable: true + }, { + title: '名称', + dataIndex: 'Name', + ellipsis: true + }, + { + title: '型号', + dataIndex: 'Model', + }, + { + title: '厂商', + dataIndex: 'Company', + ellipsis: true + }, + { + title: '创建时间', + dataIndex: 'CreatedAt', + valueType: 'dateTime', + hideInSearch: true, + sorter: (a, b) => a.CreatedAt - b.CreatedAt, + }, + { + title: '更新时间', + dataIndex: 'UpdatedAt', + valueType: 'dateTime', + hideInSearch: true, + sorter: (a, b) => a.UpdatedAt - b.UpdatedAt, + }, + { + title: '描述', + dataIndex: 'Desc', + ellipsis: true, + hideInSearch: true, + }, + { + title: '图片', + dataIndex: 'Image', + valueType: 'image', + hideInSearch: true, + }, + ] + + const requestList = async (params, sorter) => { + if (!products) { + return null + } + let tmp = products; + if (!!params.Name) { + tmp = tmp.filter(a => a.Name.includes(params.Name)) + } + if (!!params.Id) { + tmp = tmp.filter(a => a.Id.includes(params.Id)) + } + if (!!params.Company) { + tmp = tmp.filter(a => a.Company.includes(params.Company)) + } + if (!!params.Model) { + tmp = tmp.filter(a => a.Model.includes(params.Model)) + } + if (!!sorter.CreatedAt) { + console.log(sorter) + tmp = tmp.sort((a, b) => { + let aTime = new Date(a.CreatedAt).getTime() + let bTime = new Date(b.CreatedAt).getTime() + return sorter.CreatedAt === "ascend" ? aTime - bTime : bTime - aTime + }) + } + if (!!sorter.UpdatedAt) { + tmp = tmp.sort((a, b) => { + let aTime = new Date(a.UpdatedAt).getTime() + let bTime = new Date(b.UpdatedAt).getTime() + return sorter.UpdatedAt === "ascend" ? aTime - bTime : bTime - aTime + }) + } + let pageData = tmp.slice(params.pageSize * (params.current - 1), params.pageSize * params.current); + pageData = pageData.map(d => ({ + ...d, + key: d.Id + })) + setFdata(pageData) + return { + total: tmp.length, + data: pageData + } + } + + return ( +
+ + + + { + configModalVis ? + { + setConfigModalVis(false) + setEditData(null) + }} + editData={editData} + /> : '' + } +
+ ) +} + +function mapStateToProps(state) { + const { auth, global, products } = state; + return { + user: auth.user, + actions: global.actions, + loading: products.isRequesting, + products: products.data?.data ?? [], + }; +} + +export default connect(mapStateToProps)(ProductsProfile); diff --git a/code/web/client/src/sections/meta/containers/index.js b/code/web/client/src/sections/meta/containers/index.js new file mode 100644 index 0000000..d144d44 --- /dev/null +++ b/code/web/client/src/sections/meta/containers/index.js @@ -0,0 +1,6 @@ +'use strict'; + +import FactorProfile from './FactorProfile'; +import ProductsProfile from './ProductsProfile'; + +export { FactorProfile,ProductsProfile }; \ No newline at end of file diff --git a/code/web/client/src/sections/factor/containers/models.js b/code/web/client/src/sections/meta/containers/models.js similarity index 100% rename from code/web/client/src/sections/factor/containers/models.js rename to code/web/client/src/sections/meta/containers/models.js diff --git a/code/web/client/src/sections/factor/index.js b/code/web/client/src/sections/meta/index.js similarity index 84% rename from code/web/client/src/sections/factor/index.js rename to code/web/client/src/sections/meta/index.js index 3f4f724..6087745 100644 --- a/code/web/client/src/sections/factor/index.js +++ b/code/web/client/src/sections/meta/index.js @@ -6,8 +6,8 @@ import actions from './actions'; import { getNavItem } from './nav-item'; export default { - key: 'factor', - name: '监测因素', + key: 'meta', + name: '原型管理', reducers: reducers, routes: routes, actions: actions, diff --git a/code/web/client/src/sections/factor/nav-item.js b/code/web/client/src/sections/meta/nav-item.js similarity index 74% rename from code/web/client/src/sections/factor/nav-item.js rename to code/web/client/src/sections/meta/nav-item.js index 8eb5fa8..7a60a4f 100644 --- a/code/web/client/src/sections/factor/nav-item.js +++ b/code/web/client/src/sections/meta/nav-item.js @@ -7,10 +7,13 @@ const SubMenu = Menu.SubMenu; export function getNavItem(user, dispatch) { return ( - } title={'监测因素'}> + } title={'原型管理'}> 监测因素列表 + + 设备原型列表 + ); } \ No newline at end of file diff --git a/code/web/client/src/sections/factor/reducers/index.js b/code/web/client/src/sections/meta/reducers/index.js similarity index 100% rename from code/web/client/src/sections/factor/reducers/index.js rename to code/web/client/src/sections/meta/reducers/index.js diff --git a/code/web/client/src/sections/factor/routes.js b/code/web/client/src/sections/meta/routes.js similarity index 52% rename from code/web/client/src/sections/factor/routes.js rename to code/web/client/src/sections/meta/routes.js index 393f9ee..35f9dd9 100644 --- a/code/web/client/src/sections/factor/routes.js +++ b/code/web/client/src/sections/meta/routes.js @@ -1,5 +1,6 @@ 'use strict'; import { FactorProfile} from './containers'; +import { ProductsProfile} from './containers'; export default [{ type: 'inner', @@ -9,4 +10,12 @@ export default [{ breadcrumb: '监测因素管理', component: FactorProfile } +},{ + type: 'inner', + route: { + path: '/product_profile', + key: 'product', + breadcrumb: '设备原型管理', + component: ProductsProfile + } }]; \ No newline at end of file diff --git a/code/web/client/src/sections/factor/style.less b/code/web/client/src/sections/meta/style.less similarity index 100% rename from code/web/client/src/sections/factor/style.less rename to code/web/client/src/sections/meta/style.less diff --git a/code/web/client/src/utils/webapi.js b/code/web/client/src/utils/webapi.js index d9093ee..b75d376 100644 --- a/code/web/client/src/utils/webapi.js +++ b/code/web/client/src/utils/webapi.js @@ -19,6 +19,8 @@ export const ApiTable = { // 监测因素 getFactors: 'v1/searchFactor', + // 监测因素 + getProducts: 'v1/products', getEnterprisesMembers: 'enterprises/{enterpriseId}/members', }; diff --git a/code/web/package.json b/code/web/package.json index 8a18993..21112a0 100644 --- a/code/web/package.json +++ b/code/web/package.json @@ -6,7 +6,7 @@ "scripts": { "test": "mocha", "start": "cross-env NODE_ENV=development npm run start-params", - "start-params": "npm run color && node server -p 5000 -u http://127.0.0.1:4101", + "start-params": "npm run color && node server -p 5000 -u http://127.0.0.1:4100", "deploy": "export NODE_ENV=production&&npm run color && npm run build && node server", "build-dev": "export NODE_ENV=development&&webpack --config webpack.config.js", "build": "export NODE_ENV=production&&webpack --config webpack.config.prod.js",