zhaoy před 10 měsíci
rodič
revize
7f90083ed6
9 změnil soubory, kde provedl 544 přidání a 23 odebrání
  1. +7
    -0
      config/routes.js
  2. +0
    -7
      src/pages/database/goods/goodsbom/components/CreateBom.jsx
  3. +1
    -1
      src/pages/database/goods/goodstechnology/components/EditFrom.jsx
  4. +5
    -5
      src/pages/database/goods/goodstechnology/components/From.jsx
  5. +60
    -10
      src/pages/database/goods/goodstechnology/components/goodstechnologymaken.jsx
  6. +7
    -0
      src/pages/database/goods/goodstechnology/service.js
  7. +178
    -0
      src/pages/device/warehousepostion/components/CreateForm.jsx
  8. +249
    -0
      src/pages/device/warehousepostion/index.jsx
  9. +37
    -0
      src/pages/device/warehousepostion/services.js

+ 7
- 0
config/routes.js Zobrazit soubor

@@ -196,6 +196,13 @@ export default [
component: './device/deviceInfo',
access: 'k14',
},
{
name: '设备仓位模板',
icon: 'smile',
path: '/device/warehousepostion',
component: './device/warehousepostion',
access: 'k14',
},
{
name: '版本管理',
icon: 'smile',


+ 0
- 7
src/pages/database/goods/goodsbom/components/CreateBom.jsx Zobrazit soubor

@@ -48,8 +48,6 @@ const GoodsbomFrom = (props) => {
}
useEffect(() => {
var ty=form.getFieldValue("type");
console.log("props.Bomdata",form.getFieldValue("type"))
console.log(props.goodsname)
if(ty!=0){
setdisaenumbled('block')
setdisnewd("none");
@@ -57,11 +55,6 @@ const GoodsbomFrom = (props) => {
setbomNameRules( [{ required: false}])
setbomTypeListRules([{ required: false}])
}
// form.setFieldsValue({
// bomName: props.goodsname,
// // bomType:1
// });
if(props.defaultmatedata){
let soredata=[];
props.defaultmatedata.forEach((item,index)=>{


+ 1
- 1
src/pages/database/goods/goodstechnology/components/EditFrom.jsx Zobrazit soubor

@@ -128,7 +128,7 @@ const EditFrom = (props) => {
<div style={{ float: 'left', width: '20%' }}>
<Select name="chnologyId" key={x.sort} style={{ width: '108px' }} value={x.chnologyId} disabled={x.disabled} options={props.goodstechnologydata} onChange={async (value, option) => { onHandleChange(value, option, x.index) }}></Select>
</div>
<div style={{ float: 'left',width: '360px'}}>
<div style={{ float: 'left',width: '75%'}}>
{
// x.isBatch ?
<From propsdata={x.propsdata} fromdata={fromdata} batchingdata={props.batchingdata} onSaveClick={onSaveClick} optiondata={x.optiondata} index={x.index} />


+ 5
- 5
src/pages/database/goods/goodstechnology/components/From.jsx Zobrazit soubor

@@ -85,25 +85,25 @@ const From = (props) => {
if (x.actionType == "text") {
return <>
<div className={style['formlable']} style={{ display: 'block', float: 'left', backgroundColor: '#dcf4ff',marginBottom:5 }}>{x.actionName}</div>
<div style={{ display: 'block', float: 'left',marginBottom:5 }}><Input key={x.id} defaultValue={value} style={{ width: 240 }} onChange={(value) => { handleChange(value, x.id, x.goddteid) }} /></div>
<div style={{ display: 'block', float: 'left',marginBottom:5,width: '66%' }}><Input key={x.id} defaultValue={value} style={{ width: '100%' }} onChange={(value) => { handleChange(value, x.id, x.goddteid) }} /></div>
</>
}
if (x.actionType == "digit") {
return <>
<div className={style['formlable']} style={{ display: 'block', float: 'left', backgroundColor: '#dcf4ff',marginBottom:5 }}>{x.actionName}</div>
<div style={{ display: 'block', float: 'left',marginBottom:5 }}><InputNumber key={x.id} defaultValue={value} style={{ width: 240 }} onChange={(value) => { handlenumChange(value, x.id, x.goddteid) }} /></div>
<div style={{ display: 'block', float: 'left',marginBottom:5,width: '66%' }}><InputNumber key={x.id} defaultValue={value} style={{ width: '100%' }} onChange={(value) => { handlenumChange(value, x.id, x.goddteid) }} /></div>
</>
}
if (x.actionType == "textarea") {
return <>
<div className={style['formlable']} style={{ display: 'block', float: 'left', backgroundColor: '#dcf4ff',marginBottom:5 }}>{x.actionName}</div>
<div style={{ display: 'block', float: 'left',marginBottom:5 }}><TextArea key={x.id} defaultValue={value} style={{ width: 240}} onChange={(value) => { handleChange(value, x.id, x.goddteid) }} /></div>
<div style={{ display: 'block', float: 'left',marginBottom:5,width: '66%' }}><TextArea key={x.id} defaultValue={value} style={{ width: '100%'}} onChange={(value) => { handleChange(value, x.id, x.goddteid) }} /></div>
</>
}
if (x.actionType == "switch") {
return <>
<div className={style['formlable']} style={{ display: 'block', float: 'left', backgroundColor: '#dcf4ff',marginBottom:5 }}>{x.actionName}</div>
<div style={{ display: 'block', float: 'left',marginBottom:5 }}><Switch key={x.id} defaultValue={value} onChange={(value) => { handleChange(value, x.id, x.goddteid) }} /></div>
<div style={{ display: 'block', float: 'left',marginBottom:5,width: '66%' }}><Switch key={x.id} defaultValue={value} onChange={(value) => { handleChange(value, x.id, x.goddteid) }} /></div>
</>
}
if (x.actionType == "select") {
@@ -123,7 +123,7 @@ const From = (props) => {
}
return <>
<div className={style['formlable']} style={{ display: 'block', float: 'left', backgroundColor: '#dcf4ff',marginBottom:5 }}>{x.actionName}</div>
<div style={{ display: 'block', float: 'left',marginBottom:5 }}><Select key={x.id} defaultValue={value} labelInValue options={op} style={{ width: 240 }} onChange={(value) => { handleselectChange(value, x.id, x.goddteid) }} /></div>
<div style={{ display: 'block', float: 'left',marginBottom:5,width: '66%' }}><Select key={x.id} defaultValue={value} labelInValue options={op} style={{ width: '100%' }} onChange={(value) => { handleselectChange(value, x.id, x.goddteid) }} /></div>
</>
}


+ 60
- 10
src/pages/database/goods/goodstechnology/components/goodstechnologymaken.jsx Zobrazit soubor

@@ -16,6 +16,7 @@ import {
UpdateGoodsTechnologyAction,
deletebydevidegoodstechnologyaction
} from '../../goodsInfo/service';
import {GetwarehousetemplateList} from '../service'
import style from '../style.less'
import EditFrom from '../components/EditFrom'
import useFetchData from '@ant-design/pro-descriptions/lib/useFetchData';
@@ -41,6 +42,10 @@ const goodstechnologymaken = (props) => {
const [defaultValue, setdefaultValue] = useState('')
const [defaultattrValue, setdefaultattrValue] = useState('')
const [opreaction, setopreaction] = useState('add')
const [warehousetemplatedata, setwarehousetemplatedata] = useState([])
const [cwdis,setcwdis]=useState('none')
const [WarehousrTemplateId,setWarehousrTemplateId]= useState('')
const [defaulttemplateValue,setdefaulttemplateValue]=useState('')
useEffect(() => {
interdata()
}, [])
@@ -206,6 +211,11 @@ const goodstechnologymaken = (props) => {
const GetGoodsTechnologyvalue=(value,va,item)=>{
let godata=[]
console.log("va",va)
console.log("value",value)
console.log("item",item)
GetwarehousetemplateData(item.deviceId)
setWarehousrTemplateId(item.warehousrTemplateId)
setdefaulttemplateValue(item.warehousrTemplateId)
GetGoodsTechnology(value).then((r)=>{
if (r.data.length > 0) {
var Technologyacton=[];
@@ -276,11 +286,28 @@ const goodstechnologymaken = (props) => {
}
})
}
const GetwarehousetemplateData=(deviceId)=>{
setcwdis('block')
GetwarehousetemplateList(deviceId).then((r)=>{
// var data= r.data.map(x=>{
// return {id:x.id,label:x.templateName}
// })
setwarehousetemplatedata(r.data)
})
}
const handleChange = (value) => {
console.log("进来了", value)
setdefaultValue(value)
setddevideId(value)
GetGoodsTechnologyvalue(value,"",null)
if(value){
setdefaultValue(value)
setddevideId(value)
GetGoodsTechnologyvalue(value,"",null)
GetwarehousetemplateData(value)//查询设备仓位
}else{
setcwdis('none')
setdefaultValue("")
setddevideId('')
}
// let sd = DeviceTechnologydata.find(x => x.id == value);
// if (sd) {
// if (sd.goodsTechnologyInfo.length > 0) {
@@ -306,6 +333,7 @@ const goodstechnologymaken = (props) => {
console.log("保存的数据", fromdata)
let check = true;
var data = []
var msg="没有要保存的数据或数据格式不正确";
fromdata.forEach(x => {
let item = {};
item.deviceId = devideId
@@ -340,18 +368,19 @@ const goodstechnologymaken = (props) => {
// var vacheck=x.optiondata.find(x=>x.actionValue=='')
// if(vacheck){
// check = false;
// }
item.goodsId = props.goodsid
item.warehousrTemplateId=WarehousrTemplateId;
item.goodsAttributeId = checkvalue.join(',')
if (x.chnologyId == "") {
check = false;
}
data.push(item)
})
console.log("转化后要保存的数据", data)
console.log("更新添加状态", UpdataStatus)
if(WarehousrTemplateId==""){
check = false;
msg="请选择仓位模板"
}
if (data.length > 0 && check) {
if (UpdataStatus == "add") {
AddGoodsTechnologyAction(data).then((res) => {
@@ -380,7 +409,7 @@ const goodstechnologymaken = (props) => {
setdisabled(false)
setopreaction("add")
} else {
message.error("没有要保存的数据或数据格式不正确")
message.error(msg)
}
}
@@ -388,6 +417,9 @@ const goodstechnologymaken = (props) => {
console.log(e);
message.error('取消删除');
};
const handleChangewarehousetemplate=(value)=>{
setWarehousrTemplateId(value)
}
return <>

<Card bodyStyle={{ padding: 15 }}>
@@ -433,7 +465,8 @@ const goodstechnologymaken = (props) => {
}
</Card>
<Card bodyStyle={{ padding: 15 }} >
<div style={{ fontSize: 16, marginBottom: 5, color: '#1890ff', fontWeight: 600 }}>选择设备:
<div style={{ fontSize: 16, marginBottom: 5, color: '#1890ff', fontWeight: 600 }}>
<span style={{float: 'left'}}>选择设备:
<Select
showSearch
allowClear
@@ -451,6 +484,23 @@ const goodstechnologymaken = (props) => {
onChange={handleChange}
options={DeviceTechnologyoption}
/>
</span>
<span style={{float: 'left',width: '30%',display:cwdis,}}>选择仓位模板:
<Select style={{width: '50%'}} value={defaulttemplateValue} allowClear showSearch filterOption={(input, option) => (option?.label ?? '').includes(input)}
filterSort={(optionA, optionB) =>
(optionA?.label ?? '').toLowerCase().localeCompare((optionB?.label ?? '').toLowerCase())
} onChange={handleChangewarehousetemplate}>
{warehousetemplatedata?.map((item, index) => {
return (
<Select.Option index={index} value={item.id} key={item.id}>
{item.templateName}
</Select.Option>
);
})}
</Select>
</span>
</div>
</Card>


+ 7
- 0
src/pages/database/goods/goodstechnology/service.js Zobrazit soubor

@@ -0,0 +1,7 @@
import { request } from 'umi';
import { getDataBaseUrl } from '@/global_data';
export async function GetwarehousetemplateList(data) {
return request(getDataBaseUrl()+'/api/warehousetemplate/list?deviceId='+data, {
method: 'Get',
});
}

+ 178
- 0
src/pages/device/warehousepostion/components/CreateForm.jsx Zobrazit soubor

@@ -0,0 +1,178 @@
import React, {useState,useEffect } from 'react';
import { Modal, Form, Input, Button, Select } from 'antd';
import {
EditableProTable
} from '@ant-design/pro-table';
import { useFetchData } from '@ant-design/pro-utils';
const CreateForm = (props) => {
const [form] = Form.useForm();
const [dataSource, setDataSource] = useState([]);
const [editableKeys, setEditableRowKeys] = useState([]);
useEffect(() => {
console.log("props.values",props.values)
if(props.values.id){
form.setFieldsValue({
id: props.values.id,
templateName:props.values.templateName,
deviceId:props.values.deviceId,
});
var data=props.values.warehousePostion.map(x=>{
return {id: x.id,code:x.code,batchingId:x.batchingId}
})
setEditableRowKeys(data.map((item) => item.id))
setDataSource(data)
}
},[props])
const columns=[
{
title: '主键',
dataIndex: 'id',
hideInSearch: true,
hideInTable: true,
tip: '规则名称是唯一的 key'
},
{
title: '仓位编码',
dataIndex: 'code',
},
{
title: '物料',
dataIndex: 'batchingId',
formItemProps: (form, { rowIndex }) => {
return {
rules:
rowIndex > 1 ? [{ required: true, message: '此项为必填项' }] : [],
};
},
valueType: 'select',
fieldProps: {
showSearch:true,
options: props.matedata.map((item, index) => {return {label:item.name,value:item.id}})
},
width: '45%',
},
// {
// title: '用量',
// dataIndex: 'dosage',
// valueType:'digit',
// width: '15%',
// },
{
title: '操作',
valueType: 'option',
width: '15%',
render: () => {
return null;
},
},
]
const handleChange=(value)=>{
var device=props.devicedata.find(x=>x.id==value);
console.log("device",device)
if(device){
var ary=[]
for (let index = 0; index < device.productNumber; index++) {
ary.push({id: index,code:'',batchingId:''})
}
console.log("ary",ary)
setEditableRowKeys(ary.map((item) => item.id))
setDataSource(ary);
}
}
const headleOk=()=>{
form
.validateFields()
.then((data) => {
var check=true
if(dataSource.length==0){
check=false;
message.error("请选择物料")
}
if(check){
data.warehousePostionData=dataSource
props.handleAdd(data)
}
})
}
return (
<Modal
title={props.values.id ? '编辑' : '新建'}
width={640}
visible={props.createModalVisible}
bodyStyle={{ padding: '32px 40px 48px' }}
okText="确认"
cancelText="取消"
onOk={headleOk}
onCancel={() => {
props.onCancel();
setDataSource([])
setEditableRowKeys([])
}}
maskClosable={false}
destroyOnClose
>
<Form
layout="vertical"
preserve={false}
form={form}>
<Form.Item name="id" hidden={true}>
<Input />
</Form.Item>
<Form.Item label={"模板名称"} name="templateName" rules={[{ required: true,max:50}]} >
<Input />
</Form.Item>
<Form.Item label={"选择设备"} name="deviceId" rules={[{ required: true,max:50}]} >
<Select style={{width: '100%'}} onChange={handleChange}>
{props.devicedata?.map((item, index) => {
return (
<Select.Option index={index} value={item.id} key={item.id}>
{item.name}
</Select.Option>
);
})}
</Select>
</Form.Item>
{/* <Form.Item>
<Button type="primary" htmlType="submit">
保存
</Button>
</Form.Item> */}
</Form>
<EditableProTable
headerTitle={ <span><span style={{color:'red',marginRight: 3}}>*</span>仓位详情</span>}
columns={columns}
rowKey="id"
value={dataSource}
onChange={setDataSource}
recordCreatorProps={false}
// recordCreatorProps={{
// newRecordType: 'dataSource',
// record: () => ({
// id: Date.now(),
// code:'',
// batchingId:''
// }),
// }}
editable={{
type: 'multiple',
editableKeys,
actionRender: (row, config, defaultDoms) => {
return [defaultDoms.delete,defaultDoms.Button];
},
onValuesChange: (record, recordList) => {
setDataSource(recordList);
},
onDelete:async (key, row) =>{
console.log(key)
console.log(row)
},
onChange: setEditableRowKeys,
}}/>
</Modal>
);
};

export default CreateForm;

+ 249
- 0
src/pages/device/warehousepostion/index.jsx Zobrazit soubor

@@ -0,0 +1,249 @@

import { Modal,Button, message,Popconfirm,Typography } from 'antd';
import React, { useState, useRef,useEffect } 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 { GetWarehousetemplatePage, WarehousetemplateAdd, WarehousetemplateDel, WarehousetemplateUpdate,Getdevice,GetBatching } from "./services"

const key = 'message';
const { Paragraph, Text } = Typography;
const GoodsTypeManage = () => {
const [createModalVisible, handleModalVisible] = useState(false);
const actionRef = useRef();
const [currentRow, setCurrentRow] = useState();
const [selectedRowsState, setSelectedRows] = useState([]);
const [devicedata, setdevicedata] = useState([]);
const [devicevalueEnumdata, setdevicevalueEnumdata] = useState([]);
const [matedata, setMatedata] = useState([]);
useEffect(() => {
Getdevice().then((r)=>{
let list = {};
r.data.forEach((item) => {
list[item.id] = { text: item.name };
})
setdevicevalueEnumdata(list)
setdevicedata(r.data)
})
GetBatching().then((r) => {
setMatedata(r.data);
});
},[])
const columns = [
{
title: '主键',
dataIndex: 'id',
hideInSearch: true,
hideInTable: true,
tip: '规则名称是唯一的 key'
},
{
title: '模板名称',
dataIndex: 'templateName',
valueType: 'textarea',
},
{
title: '设备名称',
dataIndex: 'deviceName',
valueEnum:devicevalueEnumdata
},
{
title: '仓位数',
dataIndex: 'productNumber',
valueType: 'textarea',
hideInSearch: true,
},
{
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 450,
render: (_, record) => [
<a
key="config"
onClick={() => {
handleModalVisible(true);
setCurrentRow(record);
}} > 更新</a>,
<Popconfirm
type="primary"
key="primary"
title="确认删除吗?"
okText="是"
cancelText="否"
onConfirm={() => {
WarehousetemplateDel([record.id]).then((r) => {
message.success('删除成功,即将刷新');
actionRef.current.reload();
});
}}
onCancel={() => { }}
>
<a href="#">删除</a>
</Popconfirm>,
],
},
];
//添加
const handleAdd = async (fields) => {
try {
await WarehousetemplateAdd(JSON.stringify(fields)).then((r) => {
if (r.succeeded) {
message.success('添加成功');
actionRef.current.reload();
handleModalVisible(false);
} else {
message.error(r.errors);
}
});
} catch (error) {
message.error('添加失败请重试!');
}
};
//修改
const handleUpdate = async (fields) => {
try {
message.loading('正在修改', key);
message.destroy(key);
await WarehousetemplateUpdate(JSON.stringify(fields)).then((r) => {
message.destroy(key);
if (r.succeeded) {
message.success('修改成功',);
actionRef.current.reload();
handleModalVisible(false);
} else {
message.error(r.errors);
}
});
} catch (error) {
message.error('修改失败请重试!');
}
};
//删除
const handleRemove = async (selectedRows) => {
try {
message.loading('正在删除');
let ids = [];
selectedRows.forEach((item) => {
ids.push(item.id);
});
await WarehousetemplateDel(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
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 GetWarehousetemplatePage(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
handleAdd={async (value) => {
var success = false;
if (value.id) {
handleUpdate(value);
} else {
handleAdd(value);
}
}}
onCancel={() => {
handleModalVisible(false);
setCurrentRow(undefined);
}}
createModalVisible={createModalVisible}
values={currentRow || {}}
devicedata={devicedata}
matedata={matedata}
/>
</PageContainer>
);
};

export default GoodsTypeManage;

+ 37
- 0
src/pages/device/warehousepostion/services.js Zobrazit soubor

@@ -0,0 +1,37 @@
import { request } from 'umi';
import { getDataBaseUrl } from '@/global_data';
/** 获取列表 */
export async function GetWarehousetemplatePage(data) {
return request(getDataBaseUrl()+`/api/warehousetemplate/page`, {
method: 'POST',
data: data,
});
}
export async function WarehousetemplateAdd(data) {
return request(getDataBaseUrl()+`/api/warehousetemplate/add`, {
method: 'POST',
data: data,
});
}
export async function WarehousetemplateUpdate(data) {
return request(getDataBaseUrl()+`/api/warehousetemplate/update`, {
method: 'POST',
data: data,
});
}
export async function WarehousetemplateDel(data) {
return request(getDataBaseUrl()+`/api/warehousetemplate/del`, {
method: 'POST',
data: data,
});
}
export async function Getdevice() {
return request(getDataBaseUrl()+`/api/device/list`, {
method: 'Get'
});
}
export async function GetBatching() {
return request(getDataBaseUrl()+'/api/batching/getbatchingselectlist', {
method: 'Get',
});
}

Načítá se…
Zrušit
Uložit