From 50950c11b5c0fab87e422b44b2f7a92aeb7efa32 Mon Sep 17 00:00:00 2001 From: zhaoy <137053305@qq.com> Date: Sat, 13 Jan 2024 17:55:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=A7=E5=93=81=E7=89=A9=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/routes.js | 7 + .../goodstechnology/components/CreateForm.jsx | 57 -- .../database/goods/goodstechnology/index.jsx | 292 ---------- .../deviceInfo/components/CreateForm.jsx | 30 +- src/pages/device/deviceInfo/index.jsx | 67 ++- src/pages/device/deviceInfo/services.js | 4 +- .../deviceVesion/components/CreateForm.jsx | 4 +- src/pages/device/deviceVesion/index.jsx | 17 +- .../components/ActionForm.jsx | 239 -------- .../components/CreateAction.jsx | 245 -------- .../components/CreateForm.jsx | 89 --- src/pages/device/devicetechnology/services.js | 61 -- .../device/product/components/CreateForm.jsx | 5 +- src/pages/device/product/index.jsx | 40 +- .../productmanage}/components/ActionForm.jsx | 20 +- .../components/CreateAction.jsx | 20 +- .../productmanage/components/CreateForm.jsx | 232 ++++++++ .../index.jsx | 293 ++++++---- .../productmanage}/services.js | 22 +- src/pages/device/productmanage/unit.js | 531 ++++++++++++++++++ 20 files changed, 1100 insertions(+), 1175 deletions(-) delete mode 100644 src/pages/database/goods/goodstechnology/components/CreateForm.jsx delete mode 100644 src/pages/database/goods/goodstechnology/index.jsx delete mode 100644 src/pages/device/devicetechnology/components/ActionForm.jsx delete mode 100644 src/pages/device/devicetechnology/components/CreateAction.jsx delete mode 100644 src/pages/device/devicetechnology/components/CreateForm.jsx delete mode 100644 src/pages/device/devicetechnology/services.js rename src/pages/{database/goods/goodstechnology => device/productmanage}/components/ActionForm.jsx (92%) rename src/pages/{database/goods/goodstechnology => device/productmanage}/components/CreateAction.jsx (93%) create mode 100644 src/pages/device/productmanage/components/CreateForm.jsx rename src/pages/device/{devicetechnology => productmanage}/index.jsx (65%) rename src/pages/{database/goods/goodstechnology => device/productmanage}/services.js (53%) create mode 100644 src/pages/device/productmanage/unit.js diff --git a/config/routes.js b/config/routes.js index ee270aa..69d52e5 100644 --- a/config/routes.js +++ b/config/routes.js @@ -183,6 +183,13 @@ export default [ component: './device/deviceVesion', access: 'k14', }, + { + name: '产品功能', + icon: 'smile', + path: '/device/productmanage', + component: './device/productmanage', + access: 'k14', + }, // { // name: '设备工艺信息', // icon: 'smile', diff --git a/src/pages/database/goods/goodstechnology/components/CreateForm.jsx b/src/pages/database/goods/goodstechnology/components/CreateForm.jsx deleted file mode 100644 index 03c2829..0000000 --- a/src/pages/database/goods/goodstechnology/components/CreateForm.jsx +++ /dev/null @@ -1,57 +0,0 @@ -import React, { useState } from 'react'; -import { Modal, Form, Input, Button, Select } from 'antd'; -const CreateForm = (props) => { - const { Option, OptGroup } = Select; - return ( - { - props?.onCancel(); - }} - destroyOnClose - maskClosable={false} - > -
- - - - - - - - - - - - - - -
-
- ); -}; - -export default CreateForm; diff --git a/src/pages/database/goods/goodstechnology/index.jsx b/src/pages/database/goods/goodstechnology/index.jsx deleted file mode 100644 index 8c2419c..0000000 --- a/src/pages/database/goods/goodstechnology/index.jsx +++ /dev/null @@ -1,292 +0,0 @@ -import { DropboxOutlined, PlusOutlined } from '@ant-design/icons'; -import { Button, message, Input, Drawer, Modal, Popconfirm } from 'antd'; -import React, { useState, useRef, useEffect } from 'react'; -import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'; -import ProTable from '@ant-design/pro-table'; -import ProDescriptions from '@ant-design/pro-descriptions'; -import CreateForm from './components/CreateForm'; -import ActionForm from './components/ActionForm'; -import { - getGoodstechnologypage, - addgoodstechnology, - updategoodstechnology, - deletegoodstechnology, -} from './services'; - -//页面 相当于 class -/** - * 添加节点 - * - * @param fields - */ -const handleAdd = async (fields) => { - try { - await addgoodstechnology(JSON.stringify(fields)).then((r) => { - if (r.data) { - message.success('添加成功'); - } else { - message.error(r.errors); - } - }); - return true; - } catch (error) { - message.error('添加失败请重试!'); - return false; - } -}; -/** - * 批量删除节点 - * - * @param selectedRows - */ -const handleRemove = async (ids) => { - try { - deletegoodstechnology(ids).then((r) => { - if (r.data) { - message.success('删除成功'); - } else { - message.error(r.errors); - } - }); - return true; - } catch (error) { - message.error('删除失败,请重试'); - } -}; - -/** - * 更新节点 - * - * @param fields - */ - -const handleUpdate = async (fields) => { - try { - updategoodstechnology(fields).then((r) => { - if (r.data) { - message.success('修改成功'); - } else { - message.error(r.errors); - } - }); - return true; - } catch (error) { - message.error('修改失败请重试!'); - return false; - } -}; -//页面 相当于 class -const bomtechnology = () => { - /** 新建/更新窗口的弹窗 */ - const [createModalVisible, handleModalVisible] = useState(false); - /** 分布更新窗口的弹窗 */ - - const [actionFormModalVisible, setactionFormModalVisible] = useState(false); - const [showDetail, setShowDetail] = useState(false); - //绑定 - const actionRef = useRef(); - const [currentRow, setCurrentRow] = useState(); - //选中的行 - const [selectedRowsState, setSelectedRows] = useState([]); - - /** 国际化配置 */ - - const columns = [ - { - title: '主键', - dataIndex: 'id', - tip: '规则名称是唯一的 key', - hideInSearch: true, - hideInTable: true, - render: (dom, entity) => { - return ( - { - setCurrentRow(entity); - setShowDetail(true); - }} - > - {dom} - - ); - }, - }, - { - title: '名称', - dataIndex: 'name', - valueType: 'textarea', - ellipsis: true, - search: true, - }, - { - title: '关联外键', - dataIndex: 'foreignKeyRe', - valueType: 'textarea', - ellipsis: true, - search: true, - }, - { - title: '状态', - dataIndex: 'status', - hideInForm: true, - search: true, - valueEnum: { - 0: { - text: '正常', - status: 'Processing', - }, - 1: { - text: '停用', - status: 'Success', - }, - }, - }, - { - title: '创建时间', - dataIndex: 'createAt', - valueType: 'date', - hideInSearch: true, - }, - { - title: '操作', - dataIndex: 'option', - valueType: 'option', - render: (_, record) => [ - { - let a = 0; - if (record.status == 0) { - a = 1; - } - setCurrentRow((record.status = a)); - - await handleUpdate(record).then((r) => { - if (r) { - actionRef.current.reload(); - } else { - message.error('配置失败请重试!'); - } - }); - }} - > - {record.status == 0 ? '停用' : '使用'} - , - { - handleModalVisible(true); - setCurrentRow(record); - actionRef.current?.reloadAndRest?.(); - }} - > - 更新 - , - { - setactionFormModalVisible(true); - setCurrentRow(record); - actionRef.current?.reloadAndRest?.(); - }} - > - 模型配置 - , - { - handleRemove([record.id]); - actionRef.current?.reloadAndRest(); - }} - onCancel={() => {}} - > - 删除 - , - ], - }, - ]; - - return ( - - [ - , - ]} - //数据绑定 - request={async (params) => { - var data = []; - var total = 0; - await getGoodstechnologypage(params).then((r) => { - data = r.data.data; - data.forEach((x) => { - x.status = x.status.toString(); - }); - total = r.data.total; - }); - return { - data: data, - success: true, - total: total, - }; - }} - // 每行选择点击事件 - rowSelection={{ - onChange: (_, selectedRows) => { - setSelectedRows(selectedRows); - }, - }} - > - { - var success = false; - if (value.id) { - success = await handleUpdate(value); - } else { - success = await handleAdd(value); - } - if (success) { - handleModalVisible(false); - if (actionRef.current) { - actionRef.current.reload(); - } - } - }} - onCancel={() => { - setCurrentRow(undefined); - handleModalVisible(false); - }} - createModalVisible={createModalVisible} - values={currentRow || {}} - /> - { - setCurrentRow(undefined); - setactionFormModalVisible(false); - }} - /> - - ); -}; - -export default bomtechnology; diff --git a/src/pages/device/deviceInfo/components/CreateForm.jsx b/src/pages/device/deviceInfo/components/CreateForm.jsx index e958d6b..56c2790 100644 --- a/src/pages/device/deviceInfo/components/CreateForm.jsx +++ b/src/pages/device/deviceInfo/components/CreateForm.jsx @@ -13,7 +13,7 @@ const CreateForm = (props) => { useEffect(() => { console.log(props.values) if(Object.keys(props.values).length>0){ - GetDeviceVesion(props.values.deviceTypeKey).then((res)=>{ + GetDeviceVesion(props.values.productId).then((res)=>{ setDeviceVesionData(res.data) }) } @@ -70,18 +70,18 @@ const CreateForm = (props) => { - - {props.dicData.map((item, index) => { return ( - + {item.label} ); })} - + - {/* - - */} - {/* */} - + - }, - ]; - default: - return [{ - dataIndex: 'actionValue', - valueType: valueType, - fieldProps:{ - disabled:true - } - }]; - } - } - }, - ] - - // const handleChange=(value)=>{ - - // } - // const onNameChange = (event) => { - // settypename(event.target.value); - // }; - // const addItem = async (e) => { - // e.preventDefault(); - // setItems([...items, {label:typename,value:index++} || `New item ${index++}`]); - // settypename(''); - // setTimeout(() => { - // inputRef.current?.focus(); - // }, 0); - // console.log(items) - // } - return ( - <> - { - props?.onCancel(); - }} - destroyOnClose - maskClosable={false} - > -
- - - - - - - - { - if(e=='select'){ - setLayoutType('ModalForm'); - }else{ - setLayoutType('Form') - - } - setValueType(e); - }, - }}/> - - - setModalVisit(true)}>添加选项} - columns={columns} - layoutType={layoutType} - visible={modalVisit} - modalProps={{ - forceRender: true,//切换显示模式后强制渲染其他模式表单 - onCancel:()=>setModalVisit(false) - }} - onVisibleChange={(vis)=>{ - setshuUpdate(vis) - }} - width={420} - shouldUpdate={shuUpdate} - submitter={false} - style={{padding:'40px 10px 1px 10px;' }} - /> - - - {/* - - - - - */} - - - - - - -
-
- - ) -} -export default CreateAction; \ No newline at end of file diff --git a/src/pages/device/devicetechnology/components/CreateForm.jsx b/src/pages/device/devicetechnology/components/CreateForm.jsx deleted file mode 100644 index a2086d8..0000000 --- a/src/pages/device/devicetechnology/components/CreateForm.jsx +++ /dev/null @@ -1,89 +0,0 @@ -import React, { useState } from 'react'; -import { Modal, Form, Input, Button, Select } from 'antd'; -import { - GetDeviceVesion -} from '../services'; -const CreateForm = (props) => { - const { Option, OptGroup } = Select; - const [DeviceVesionData, setDeviceVesionData] = useState([]); - const handleChange=(value)=>{ - GetDeviceVesion(value).then((res)=>{ - setDeviceVesionData(res.data) - }) - } - return ( - { - props?.onCancel(); - }} - destroyOnClose - maskClosable={false} - > -
- - - - - - - - - - - - - - - - - - - - - -
-
- ); -}; - -export default CreateForm; diff --git a/src/pages/device/devicetechnology/services.js b/src/pages/device/devicetechnology/services.js deleted file mode 100644 index d18a61b..0000000 --- a/src/pages/device/devicetechnology/services.js +++ /dev/null @@ -1,61 +0,0 @@ -import { request } from 'umi'; - -//获取分页数据 -export async function getGoodstechnologypage(data) { - return request(`/saasbase/api/goodstechnology/getGoodstechnologypage`, { - method: 'Post', - data: data, - }); -} -export async function addgoodstechnology(data) { - return request(`/saasbase/api/goodstechnology/addgoodstechnology`, { - method: 'Post', - data: data, - }); - } - export async function updategoodstechnology(data) { - return request(`/saasbase/api/goodstechnology/updategoodstechnology`, { - method: 'Post', - data: data, - }); - } - export async function deletegoodstechnology(data) { - return request(`/saasbase/api/goodstechnology/deletegoodstechnology`, { - method: 'Post', - data: data, - }); - } - export async function gettechnologyactionList(data) { - return request(`/saasbase/api/goodstechnology/gettechnologyactionList?GoodstechnologyId=`+data, { - method: 'Get', - }); - } - export async function addtechnologyaction(data) { - return request(`/saasbase/api/goodstechnology/addtechnologyaction`, { - method: 'Post', - data: data, - }); - } - export async function updatetechnologyaction(data) { - return request(`/saasbase/api/goodstechnology/updatetechnologyaction`, { - method: 'Post', - data: data, - }); - } - export async function deletetechnologyaction(data) { - return request(`/saasbase/api/goodstechnology/deletetechnologyaction`, { - method: 'Post', - data: data, - }); - } - /**获取设备类型 */ -export async function GetDicList(TypeCode) { - return request(`/saasbase/api/dict-data/dic-list/${TypeCode}`, { - method: 'Get', - }); -} - export async function GetDeviceVesion(TypeCode) { - return request(`/saasbase/api/DeviceVesion/GetDeviceVesion?Code=${TypeCode}`, { - method: 'Get', - }); - } \ No newline at end of file diff --git a/src/pages/device/product/components/CreateForm.jsx b/src/pages/device/product/components/CreateForm.jsx index c9efe2d..640b05f 100644 --- a/src/pages/device/product/components/CreateForm.jsx +++ b/src/pages/device/product/components/CreateForm.jsx @@ -26,7 +26,10 @@ const CreateForm = (props) => { - + + + + diff --git a/src/pages/device/product/index.jsx b/src/pages/device/product/index.jsx index bde1b31..cfc0399 100644 --- a/src/pages/device/product/index.jsx +++ b/src/pages/device/product/index.jsx @@ -6,7 +6,7 @@ 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" - +import { history } from 'umi'; const key = 'message'; const GoodsTypeManage = () => { const [createModalVisible, handleModalVisible] = useState(false); @@ -26,6 +26,11 @@ const GoodsTypeManage = () => { dataIndex: 'name', valueType: 'textarea', }, + { + title: '产品标签', + dataIndex: 'code', + valueType: 'textarea', + }, { title: '产品key', dataIndex: 'key', @@ -37,6 +42,22 @@ const GoodsTypeManage = () => { valueType: 'textarea', width: 450, }, + { + title: '状态', + dataIndex: 'status', + hideInForm: true, + search: true, + valueEnum: { + 0: { + text: '启用', + status: 'Processing', + }, + 1: { + text: '禁用', + status: 'Success', + }, + }, + }, { title: '操作', dataIndex: 'option', @@ -65,7 +86,7 @@ const GoodsTypeManage = () => { }); }} > - {record.status == 0 ? '停用' : '启用'} + {record.status == 0 ? '禁用' : '启用'} , { > 删除 , + { + history.push({ + pathname: '/device/productmanage', + query: { + isAdd: false, + values: record, + tabStatus: 'basis' + }, + }); + }} > 管理, ], }, ]; @@ -161,8 +194,7 @@ const GoodsTypeManage = () => { breadcrumb: {}, }}> { const [actionValueName,setactionValueName]=useState(); const [createModalVisible, handleModalVisible] = useState(false); const options = { - text:{value:'text',text: `文本框`}, - select:{ value: `select`, text: `下拉框`}, + text:{value:'text',text: `text(字符串)`}, + select:{ value: `select`, text: `enum(枚举)`}, // money:{ value: `money`, text: `金额输入`}, - textarea:{ value: `textarea`, text: `文本域`}, + textarea:{ value: `textarea`, text: `text(文本域)`}, // date:{ value: `date`, text: `日期`}, // dateTime:{ value: `dateTime`, text: `日期时间`}, // radio:{ value: `radio`, text: `单选框`}, // radioButton:{ value: `radioButton`, text: `按钮单选框`}, - digit:{ value: `digit`, text: `数字输入框`}, - switch:{ value: `switch`, text: `开关`}, + digit:{ value: `digit`, text: `int32(整型)`}, + switch:{ value: `switch`, text: `bool(布尔型)`}, } const columns= [ { - title: '模型名称', + title: '参数名称', dataIndex: 'actionName', width: '15%', }, { - title: '输入类型', + title: '数据类型', key: 'actionType', dataIndex: 'actionType', valueType: 'select', @@ -162,7 +162,7 @@ const ActionForm = (props) => { return ( <> { maskClosable={false} > { var success = false; console.log(value) console.log(value.actionValue) - value.goodstechnologyId=props.values.id; + value.productFunctionId=props.values.id; if (value.id) { success = await handleUpdate(value); diff --git a/src/pages/database/goods/goodstechnology/components/CreateAction.jsx b/src/pages/device/productmanage/components/CreateAction.jsx similarity index 93% rename from src/pages/database/goods/goodstechnology/components/CreateAction.jsx rename to src/pages/device/productmanage/components/CreateAction.jsx index e1bbf27..5423663 100644 --- a/src/pages/database/goods/goodstechnology/components/CreateAction.jsx +++ b/src/pages/device/productmanage/components/CreateAction.jsx @@ -54,16 +54,16 @@ const handleChange=(value)=>{ message.success("保存成功") } const options = [ - {value:'text',label: `文本框`}, - { value: `select`, label: `下拉框`}, + {value:'text',label: `text(字符串)`}, + { value: `select`, label: `enum(枚举)`}, // { value: `money`, label: `金额输入`}, - { value: `textarea`, label: `文本域`}, + { value: `textarea`, label: `text(文本域)`}, // { value: `date`, label: `日期`}, // { value: `dateTime`, label: `日期时间`}, // { value: `radio`, label: `单选框`}, // { value: `radioButton`, label: `按钮单选框`}, - { value: `digit`, label: `数字输入框`}, - { value: `switch`, label: `开关`}, + { value: `digit`, label: `int32(整型)`}, + { value: `switch`, label: `bool(布尔型)`}, ] const columns=[ { @@ -85,7 +85,7 @@ const handleChange=(value)=>{ valueType: 'group', columns: [ { - title: '选项名称', + title: '枚举名称', dataIndex: 'actionValueName', width: 'md', formItemProps: { @@ -159,7 +159,7 @@ const handleChange=(value)=>{ return ( <> { - + - + { @@ -203,7 +203,7 @@ const handleChange=(value)=>{ setModalVisit(true)}>添加选项} + trigger={setModalVisit(true)}>添加枚举} columns={columns} layoutType={layoutType} visible={modalVisit} diff --git a/src/pages/device/productmanage/components/CreateForm.jsx b/src/pages/device/productmanage/components/CreateForm.jsx new file mode 100644 index 0000000..157c71d --- /dev/null +++ b/src/pages/device/productmanage/components/CreateForm.jsx @@ -0,0 +1,232 @@ +import React, { useState,useEffect } from 'react'; +import { CloseOutlined} from '@ant-design/icons'; +import { Modal, Form, Input, Button, Select,Radio,InputNumber, message,Space } from 'antd'; +import unitoption from '../unit' +const CreateForm = (props) => { + const { Option, OptGroup } = Select; + const [display,setdisplay]=useState('block'); + const [arttue,setarttue]=useState(0); + const [disabled, setDisabled] = useState(false); + const [disanumbled, setdisanumbled] = useState('block'); + const [disaenumbled, setdisaenumbled] = useState('none'); + const [minnumber, setminnumber] = useState(0); + const [maxnumber, setmaxnumber] = useState(1); + const [form] = Form.useForm(); + const options = [ + { value: `digit`, label: `int32(整型)`}, + {value:'text',label: `text(字符串)`}, + { value: `select`, label: `enum(枚举)`}, + // { value: `money`, label: `金额输入`}, + { value: `textarea`, label: `text(文本域)`}, + // { value: `date`, label: `日期`}, + // { value: `dateTime`, label: `日期时间`}, + // { value: `radio`, label: `单选框`}, + // { value: `radioButton`, label: `按钮单选框`}, + + { value: `switch`, label: `bool(布尔型)`}, + ] + useEffect(() => { + + if(props?.values?.id){ + console.log(JSON.parse(props?.values?.enumValue)) + setDisabled(true); + setarttue(props?.values?.type) + if(props?.values?.type==1){ + setdisplay("none") + }else if(props?.values?.type==0){ + setdisplay("block") + } + if(props?.values?.dataType=="select"){ + setdisaenumbled('block') + setdisanumbled('none') + }else if(props?.values?.dataType=="digit"){ + setdisaenumbled('none') + setdisanumbled('block') + } + var enumvaluelist=[]; + enumvaluelist=JSON.parse(props?.values?.enumValue); + form.setFieldsValue({ + id: props?.values?.id, + type: props?.values?.type, + deviceVersionKey: props?.values?.deviceVersionKey, + name: props?.values?.name, + dataType: props?.values?.dataType, + dataRange: props?.values?.dataRange, + stepSize: props?.values?.stepSize, + unit: props?.values?.unit, + foreignKeyRe: props?.values?.foreignKeyRe, + enumvaluelist:enumvaluelist + }); + if(props?.values?.dataRange){ + var num=props?.values?.dataRange.split('-') + setminnumber(num[0]); + setmaxnumber(num[1]) + } + + }else{ + + console.log("xinjian") + setDisabled(false); + setdisplay("block") + setminnumber(0); + setmaxnumber(1) + form.resetFields(); + setarttue(0) + + form.setFieldsValue({ + type: 0 + }); + } + },[props?.values]) +const onchagetype=(e)=>{ + console.log(e) + setarttue(e.target.value) + form.setFieldsValue({ + type: e.target.value + }); + if(e.target.value==1){ + setdisplay("none") + }else if(e.target.value==0){ + setdisplay("block") + } +} +const onChangemix=(value)=>{ + setminnumber(value) +} +const onChangemax=(value)=>{ + if(minnumber>value){ + message.error("最大值不能小于最小值") + }else{ + setmaxnumber(value) + form.setFieldsValue({ + dataRange: minnumber+"-"+value + }); + } +} +const onChangedataType=(value)=>{ + console.log(value) + if(value=="digit"){ + setdisanumbled('block') + setdisaenumbled('none') + }else if(value=="select"){ + setdisaenumbled('block') + setdisanumbled('none') + }else{ + setdisaenumbled('none') + setdisanumbled('none') + } +} + return ( + { + props?.onCancel(); + }} + destroyOnClose + maskClosable={false} + > +
+ + + + 属性 + 服务 + + + + + + + + + + + + + + {(subFields, subOpt) => ( +
+ {subFields.map((subField) => ( + + + + + + + + { + subOpt.remove(subField.name); + }} + /> + + ))} + +
+ )} +
+
+ + ~ + + + + + + + + + + + +
+
+ ); +}; + +export default CreateForm; diff --git a/src/pages/device/devicetechnology/index.jsx b/src/pages/device/productmanage/index.jsx similarity index 65% rename from src/pages/device/devicetechnology/index.jsx rename to src/pages/device/productmanage/index.jsx index 537c5dc..76bc04e 100644 --- a/src/pages/device/devicetechnology/index.jsx +++ b/src/pages/device/productmanage/index.jsx @@ -1,5 +1,5 @@ -import { DropboxOutlined, PlusOutlined,UploadOutlined } from '@ant-design/icons'; -import { Button, message, Input, Upload, Modal, Popconfirm } from 'antd'; +import { DropboxOutlined, PlusOutlined,ArrowLeftOutlined } from '@ant-design/icons'; +import { Button, message, Input, Upload, Modal, Popconfirm,Card } from 'antd'; import React, { useState, useRef, useEffect } from 'react'; import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'; import ProTable from '@ant-design/pro-table'; @@ -11,9 +11,9 @@ import { addgoodstechnology, updategoodstechnology, deletegoodstechnology, - GetDicList + GetDeviceVesion } from './services'; - +import { history } from 'umi'; //页面 相当于 class /** * 添加节点 @@ -22,6 +22,15 @@ import { */ const handleAdd = async (fields) => { try { + console.log(fields) + //var parm=JSON.stringify(fields) + if(fields.dataType=="select"){ + if(fields.enumvaluelist.length==0){ + message.error('请添加枚举值'); + }else{ + fields.enumValue=JSON.stringify(fields.enumvaluelist) + } + } await addgoodstechnology(JSON.stringify(fields)).then((r) => { if (r.data) { message.success('添加成功'); @@ -93,6 +102,13 @@ const props = { const handleUpdate = async (fields) => { try { + if(fields.dataType=="select"){ + if(fields.enumvaluelist.length==0){ + message.error('请添加枚举值'); + }else{ + fields.enumValue=JSON.stringify(fields.enumvaluelist) + } + } updategoodstechnology(fields).then((r) => { if (r.data) { message.success('修改成功'); @@ -107,11 +123,11 @@ const handleUpdate = async (fields) => { } }; //页面 相当于 class -const bomtechnology = () => { +const bomtechnology = (props) => { /** 新建/更新窗口的弹窗 */ const [createModalVisible, handleModalVisible] = useState(false); /** 分布更新窗口的弹窗 */ - + const [currTabKey, SetCurrTabKey] = useState("basis") const [actionFormModalVisible, setactionFormModalVisible] = useState(false); const [showDetail, setShowDetail] = useState(false); //绑定 @@ -119,9 +135,79 @@ const bomtechnology = () => { const [currentRow, setCurrentRow] = useState(); //选中的行 const [selectedRowsState, setSelectedRows] = useState([]); + const [DeviceVesionData, setDeviceVesionData] = useState([]); + const [DeviceVesionEnum, setDeviceVesionEnum] = useState({}); /** 国际化配置 */ const [DictData, setDictData] = useState([]); + const [tabStatus, seTabStatus] = useState({ + operationKey: props.location.query.tabStatus ? props.location.query.tabStatus : 'basis', + tabActiveKey: props.location.query.tabStatus ? props.location.query.tabStatus : 'basis', + }); + const Btn = (record) => { + var arr = []; + if (record.type == 1) { + arr.push( { + setactionFormModalVisible(true); + setCurrentRow(record); + actionRef.current?.reloadAndRest?.(); + }} + > + 参数配置 + ); + } + arr.push( + { + handleModalVisible(true); + setCurrentRow(record); + actionRef.current?.reloadAndRest?.(); + }} + > + 更新 + + ) + arr.push( + { + handleRemove([record.id]); + actionRef.current?.reloadAndRest(); + }} + onCancel={() => {}} + > + 删除 + ); + + arr.push( { + let a = 0; + if (record.status == 0) { + a = 1; + } + setCurrentRow((record.status = a)); + + await handleUpdate(record).then((r) => { + if (r) { + actionRef.current.reload(); + } else { + message.error('配置失败请重试!'); + } + }); + }} + > + {record.status == 0 ? '禁用' : '启用'} + ); + return arr; + } const columns = [ { title: '主键', @@ -143,32 +229,34 @@ const bomtechnology = () => { }, }, { - title: '名称', + title: '功能名称', dataIndex: 'name', valueType: 'textarea', ellipsis: true, search: true, }, { - title: '关联外键', - dataIndex: 'foreignKeyRe', - valueType: 'textarea', - ellipsis: true, - search: true, - }, - { - title: '设备类型', - dataIndex: 'deviceTypeKey', - valueType: 'textarea', + title: '功能类型', + dataIndex: 'type', + valueType: 'select', ellipsis: true, search: true, + valueEnum: { + 0: { + text: '属性', + }, + 1: { + text: '服务', + }, + }, }, { title: '版本', dataIndex: 'vesion', - valueType: 'textarea', + valueType: 'select', ellipsis: true, search: true, + valueEnum:DeviceVesionEnum }, { title: '状态', @@ -177,15 +265,22 @@ const bomtechnology = () => { search: true, valueEnum: { 0: { - text: '正常', + text: '启用', status: 'Processing', }, 1: { - text: '停用', + text: '禁用', status: 'Success', }, }, }, + { + title: '关联外键', + dataIndex: 'foreignKeyRe', + valueType: 'textarea', + ellipsis: true, + search: false, + }, { title: '创建时间', dataIndex: 'createAt', @@ -196,88 +291,34 @@ const bomtechnology = () => { title: '操作', dataIndex: 'option', valueType: 'option', - render: (_, record) => [ - { - let a = 0; - if (record.status == 0) { - a = 1; - } - setCurrentRow((record.status = a)); - - await handleUpdate(record).then((r) => { - if (r) { - actionRef.current.reload(); - } else { - message.error('配置失败请重试!'); - } - }); - }} - > - {record.status == 0 ? '停用' : '使用'} - , - { - handleModalVisible(true); - setCurrentRow(record); - actionRef.current?.reloadAndRest?.(); - }} - > - 更新 - , - { - setactionFormModalVisible(true); - setCurrentRow(record); - actionRef.current?.reloadAndRest?.(); - }} - > - 模型配置 - , - { - handleRemove([record.id]); - actionRef.current?.reloadAndRest(); - }} - onCancel={() => {}} - > - 删除 - , - ], + fixed: 'right', + width: 400, + render: (_, record) =>Btn(record), }, ]; - 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); - } - }); - }, []) - return ( - - + { request={async (params) => { var data = []; var total = 0; + params.deviceTypeKey=props.location.query.values.id + await getGoodstechnologypage(params).then((r) => { data = r.data.data; data.forEach((x) => { @@ -334,6 +377,7 @@ const bomtechnology = () => { > { + console.log("jnlaile ") var success = false; if (value.id) { success = await handleUpdate(value); @@ -353,7 +397,7 @@ const bomtechnology = () => { }} createModalVisible={createModalVisible} values={currentRow || {}} - dicData={DictData} + DeviceVesionData={DeviceVesionData} /> { setactionFormModalVisible(false); }} /> + + ), + topis: ( + + + + + ), + + }; + useEffect(() => { + console.log("props.location",props.location) + GetDeviceVesion(props.location.query.values.id).then((res)=>{ + let list = {}; + res.data.forEach((item) => { + list[item.id] = { text: item.vesion }; + }); + setDeviceVesionData(res.data) + setDeviceVesionEnum(list) + }) + }, []) + const onTabChange = (key) => { + // if (currentGoodsProp === 1) { + // message.info('套餐不能设置配方'); + // return; + // } + seTabStatus({ operationKey: key, tabActiveKey: key }); + //initGoodsType() + }; + return ( + { + history.push({ + pathname: '/device/product', + }); + }}>返回], + breadcrumb: {}, + }} + title={props.location.query.isAdd ? '商品新增' : '详情'} + tabActiveKey={currTabKey} + onTabChange={onTabChange} + tabList={operationTabList} + > + {contentList[tabStatus.operationKey]} ); }; diff --git a/src/pages/database/goods/goodstechnology/services.js b/src/pages/device/productmanage/services.js similarity index 53% rename from src/pages/database/goods/goodstechnology/services.js rename to src/pages/device/productmanage/services.js index f162faf..c96c54b 100644 --- a/src/pages/database/goods/goodstechnology/services.js +++ b/src/pages/device/productmanage/services.js @@ -2,49 +2,55 @@ import { request } from 'umi'; //获取分页数据 export async function getGoodstechnologypage(data) { - return request(`/saasbase/api/goodstechnology/getGoodstechnologypage`, { + return request(`/saasbase/api/productfunction/page`, { method: 'Post', data: data, }); } export async function addgoodstechnology(data) { - return request(`/saasbase/api/goodstechnology/addgoodstechnology`, { + return request(`/saasbase/api/productfunction/add`, { method: 'Post', data: data, }); } export async function updategoodstechnology(data) { - return request(`/saasbase/api/goodstechnology/updategoodstechnology`, { + return request(`/saasbase/api/productfunction/update`, { method: 'Post', data: data, }); } export async function deletegoodstechnology(data) { - return request(`/saasbase/api/goodstechnology/deletegoodstechnology`, { + return request(`/saasbase/api/productfunction/delete`, { method: 'Post', data: data, }); } export async function gettechnologyactionList(data) { - return request(`/saasbase/api/goodstechnology/gettechnologyactionList?GoodstechnologyId=`+data, { + return request(`/saasbase/api/productfunction/getproductfunctionaction?productFunctionId=`+data, { method: 'Get', }); } export async function addtechnologyaction(data) { - return request(`/saasbase/api/goodstechnology/addtechnologyaction`, { + return request(`/saasbase/api/productfunction/addproductfunctionaction`, { method: 'Post', data: data, }); } export async function updatetechnologyaction(data) { - return request(`/saasbase/api/goodstechnology/updatetechnologyaction`, { + return request(`/saasbase/api/productfunction/updateproductfunctionaction`, { method: 'Post', data: data, }); } export async function deletetechnologyaction(data) { - return request(`/saasbase/api/goodstechnology/deletetechnologyaction`, { + return request(`/saasbase/api/productfunction/delproductfunctionaction`, { method: 'Post', data: data, }); + } + + export async function GetDeviceVesion(TypeCode) { + return request(`/saasbase/api/devicevesion/getdevicevesion?productId=${TypeCode}`, { + method: 'Get', + }); } \ No newline at end of file diff --git a/src/pages/device/productmanage/unit.js b/src/pages/device/productmanage/unit.js new file mode 100644 index 0000000..67a4658 --- /dev/null +++ b/src/pages/device/productmanage/unit.js @@ -0,0 +1,531 @@ +export default +[ + { + value: "L/min", + label: "升/每分钟" + }, + { + value: "mg/kg", + label: "毫克/每千克" + }, + { + value: "NTU", + label: "浊度" + }, + { + value: "pH", + label: "PH值" + }, + { + value: "dS/m", + label: "土壤EC值" + }, + { + value: "W/㎡", + label: "太阳总辐射" + }, + { + value: "mm/hour", + label: "降雨量" + }, + { + value: "var", + label: "乏" + }, + { + value: "cP", + label: "厘泊" + }, + { + value: "aw", + label: "饱和度" + }, + { + value: "pcs", + label: "个" + }, + { + value: "cst", + label: "厘斯" + }, + { + value: "bar", + label: "巴" + }, + { + value: "ppt", + label: "纳克/每升" + }, + { + value: "ppb", + label: "微克/每升" + }, + { + value: "uS/cm", + label: "微西/每厘米" + }, + { + value: "N/C", + label: "牛顿/每库仑" + }, + { + value: "V/m", + label: "伏特/每米" + }, + { + value: "ml/min", + label: "滴速" + }, + { + value: "mmHg", + label: "毫米汞柱" + }, + { + value: "mmol/L", + label: "血糖" + }, + { + value: "mm/s", + label: "毫米/每秒" + }, + { + value: "turn/m", + label: "转每/分钟" + }, + { + value: "count", + label: "次" + }, + { + value: "gear", + label: "档" + }, + { + value: "stepCount", + label: "步" + }, + { + value: "Nm3/h", + label: "标准立方米/每小时" + }, + { + value: "kV", + label: "千伏" + }, + { + value: "kVA", + label: "千伏安" + }, + { + value: "kVar", + label: "千乏" + }, + { + value: "uw/cm2", + label: "微瓦/每平方厘米" + }, + { + value: "只", + label: "只" + }, + { + value: "%RH", + label: "相对湿度" + }, + { + value: "m³/s", + label: "立方米每秒" + }, + { + value: "kg/s", + label: "公斤/每秒" + }, + { + value: "r/min", + label: "转/每分钟" + }, + { + value: "t/h", + label: "吨/每小时" + }, + { + value: "KCL/h", + label: "千卡/每小时" + }, + { + value: "L/s", + label: "升每秒" + }, + { + value: "Mpa", + label: "兆帕" + }, + { + value: "m³/h", + label: "立方米/每小时" + }, + { + value: "kvarh", + label: "千乏时" + }, + { + value: "μg/L", + label: "微克/每升" + }, + { + value: "kcal", + label: "千卡路里" + }, + { + value: "GB", + label: "吉字节" + }, + { + value: "MB", + label: "兆字节" + }, + { + value: "KB", + label: "千字节" + }, + { + value: "B", + label: "字节" + }, + { + value: "μg/(d㎡·d)", + label: "微克/每平方分米/每天" + }, + { + value: "", + label: "无" + }, + { + value: "ppm", + label: "百万分率" + }, + { + value: "pixel", + label: "像素" + }, + { + value: "Lux", + label: "照度" + }, + { + value: "grav", + label: "重力加速度" + }, + { + value: "dB", + label: "分贝" + }, + { + value: "%", + label: "百分比" + }, + { + value: "lm", + label: "流明" + }, + { + value: "bit", + label: "比特" + }, + { + value: "g/mL", + label: "克/每毫升" + }, + { + value: "g/L", + label: "克/每升" + }, + { + value: "mg/L", + label: "毫克/每升" + }, + { + value: "μg/m³", + label: "微克/每立方米" + }, + { + value: "mg/m³", + label: "毫克/每立方米" + }, + { + value: "g/m³", + label: "克/每立方米" + }, + { + value: "kg/m³", + label: "千克/每立方米" + }, + { + value: "nF", + label: "纳法" + }, + { + value: "pF", + label: "皮法" + }, + { + value: "μF", + label: "微法" + }, + { + value: "F", + label: "法拉" + }, + { + value: "Ω", + label: "欧姆" + }, + { + value: "μA", + label: "微安" + }, + { + value: "mA", + label: "毫安" + }, + { + value: "kA", + label: "千安" + }, + { + value: "A", + label: "安培" + }, + { + value: "mV", + label: "毫伏" + }, + { + value: "V", + label: "伏特" + }, + { + value: "ms", + label: "毫秒" + }, + { + value: "s", + label: "秒" + }, + { + value: "min", + label: "分钟" + }, + { + value: "h", + label: "小时" + }, + { + value: "day", + label: "日" + }, + { + value: "week", + label: "周" + }, + { + value: "month", + label: "月" + }, + { + value: "year", + label: "年" + }, + { + value: "kn", + label: "节" + }, + { + value: "km/h", + label: "千米/每小时" + }, + { + value: "m/s", + label: "米/每秒" + }, + { + value: "″", + label: "秒" + }, + { + value: "′", + label: "分" + }, + { + value: "°", + label: "度" + }, + { + value: "rad", + label: "弧度" + }, + { + value: "Hz", + label: "赫兹" + }, + { + value: "μW", + label: "微瓦" + }, + { + value: "mW", + label: "毫瓦" + }, + { + value: "kW", + label: "千瓦特" + }, + { + value: "W", + label: "瓦特" + }, + { + value: "cal", + label: "卡路里" + }, + { + value: "kW·h", + label: "千瓦时" + }, + { + value: "Wh", + label: "瓦时" + }, + { + value: "eV", + label: "电子伏" + }, + { + value: "kJ", + label: "千焦" + }, + { + value: "J", + label: "焦耳" + }, + { + value: "℉", + label: "华氏度" + }, + { + value: "K", + label: "开尔文" + }, + { + value: "t", + label: "吨" + }, + { + value: "°C", + label: "摄氏度" + }, + { + value: "mPa", + label: "毫帕" + }, + { + value: "hPa", + label: "百帕" + }, + { + value: "kPa", + label: "千帕" + }, + { + value: "Pa", + label: "帕斯卡" + }, + { + value: "mg", + label: "毫克" + }, + { + value: "g", + label: "克" + }, + { + value: "kg", + label: "千克" + }, + { + value: "N", + label: "牛" + }, + { + value: "mL", + label: "毫升" + }, + { + value: "L", + label: "升" + }, + { + value: "mm³", + label: "立方毫米" + }, + { + value: "cm³", + label: "立方厘米" + }, + { + value: "km³", + label: "立方千米" + }, + { + value: "m³", + label: "立方米" + }, + { + value: "h㎡", + label: "公顷" + }, + { + value: "c㎡", + label: "平方厘米" + }, + { + value: "m㎡", + label: "平方毫米" + }, + { + value: "k㎡", + label: "平方千米" + }, + { + value: "㎡", + label: "平方米" + }, + { + value: "nm", + label: "纳米" + }, + { + value: "μm", + label: "微米" + }, + { + value: "mm", + label: "毫米" + }, + { + value: "cm", + label: "厘米" + }, + { + value: "dm", + label: "分米" + }, + { + value: "km", + label: "千米" + }, + { + value: "m", + label: "米" + } +] \ No newline at end of file