diff --git a/config/routes.js b/config/routes.js index 1368f6f..a29767f 100644 --- a/config/routes.js +++ b/config/routes.js @@ -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', diff --git a/src/app.jsx b/src/app.jsx index 52e3948..b2e16a8 100644 --- a/src/app.jsx +++ b/src/app.jsx @@ -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', + }, ] }, ] diff --git a/src/pages/authorization/platformAuthorization/index.jsx b/src/pages/authorization/platformAuthorization/index.jsx new file mode 100644 index 0000000..2656bb5 --- /dev/null +++ b/src/pages/authorization/platformAuthorization/index.jsx @@ -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) => {text}, + }, + { + title: '有效日期', + dataIndex: 'periodValidity', + valueType: 'textarea', + width:200, + search: false, + render: (_, record) => { + var time=dayjs(record.periodValidity, dateFormat).format('YYYY-MM-DD'); + return {record.periodValidity == null ? "长期有效" : time} + } + }, + { + title: '修改时间', + dataIndex: 'updateAt', + valueType: 'textarea', + width:200, + search: false + }, + { + title: '操作', + dataIndex: 'option', + valueType: 'option', + fixed: 'right', + width: 300, + render: (_, record) => [ + { + UpdateAuthorization(record.id).then((r) => { + if (r.statusCode == 200 && r.data) { + actionRef.current.reload(); + message.success("修改成功"); + } else { + message.error(r.errors || "修改失败"); + } + }); + }} + onCancel={() => { }} + > + 更新授权码 + , + { + 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); + }}>更新授权时间, + { + DelAuthorization(record.id).then((r) => { + if (r.statusCode == 200 && r.data) { + actionRef.current.reload(); + message.success("删除成功"); + } else { + message.error(r.errors || "删除失败"); + } + }); + }} + onCancel={() => { }} + > + 删除 + + + + ], + }, + ]; + + return ( + + [ + , + ]} + 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} + /> + + { + form.submit(); + + }} + onCancel={() => { + handleModalVisible(false); + }}> + +
{ + 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, + }}> + + + + 长期有效 + 固定时间 + + + + prevValues.autho !== currentValues.autho} > + {({ getFieldValue }) => + getFieldValue('autho') == 'gdsj' ? ( + + + + ) : null + } + +
+
+ + +
+ ); +}; + +export default App; diff --git a/src/pages/authorization/platformAuthorization/services.js b/src/pages/authorization/platformAuthorization/services.js new file mode 100644 index 0000000..548f347 --- /dev/null +++ b/src/pages/authorization/platformAuthorization/services.js @@ -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, + }); +} + + diff --git a/src/pages/authorization/storeAuthorization/index.jsx b/src/pages/authorization/storeAuthorization/index.jsx new file mode 100644 index 0000000..b11532e --- /dev/null +++ b/src/pages/authorization/storeAuthorization/index.jsx @@ -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) => {text}, + }, + + { + title: '有效日期', + dataIndex: 'periodValidity', + valueType: 'date', + width:150, + search: false, + render: (_, record) => { + var time=dayjs(record.periodValidity, dateFormat).format('YYYY-MM-DD'); + return {record.periodValidity == null ? "长期有效" : time} + } + }, + { + title: '修改时间', + dataIndex: 'updateAt', + valueType: 'textarea', + width: 150, + search: false + }, + { + title: '操作', + dataIndex: 'option', + valueType: 'option', + fixed: 'right', + width: 250, + render: (_, record) => [ + { + await UpdateStoreAuthorization(record.id).then((r) => { + if (r.statusCode == 200 && r.data) { + message.success("修改成功"); + actionRef.current.reload(); + + } else { + message.error(r.errors || "修改失败"); + } + }); + }} + onCancel={() => { }} + > + 更新授权码 + , + { + 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); + }}>更新授权时间, + { + await DelStoreAuthTime(record.id).then((r) => { + if (r.statusCode == 200 && r.data) { + message.success("删除成功"); + actionRef.current.reload(); + + } else { + message.error(r.errors || "删除失败"); + } + }); + }} + onCancel={() => { }} + > + 删除 + , + + ], + }, + ]; + + return ( + + [ + + ]} + 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} + /> + + { + form.submit(); + + }} + onCancel={() => { + handleModalVisible(false); + }}> + +
{ + 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, + }}> + + + - + + (option?.label ?? '').includes(input)} filterSort={(optionA, optionB) => (optionA?.label ?? '').toLowerCase().localeCompare((optionB?.label ?? '').toLowerCase()) } options={options}/> + + 事件类型} rules={[{ required: false }]}> + + 信息 + 告警 + 故障 + +