Commit ab2785d4 authored by tjy's avatar tjy
parents 0476aee6 f7b8ad5c
......@@ -9,6 +9,7 @@
"start": "yarn api && yarn scripts:build && umi dev",
"build": "yarn api && yarn scripts:build && umi build",
"build:analyze": "ANALYZE=1 umi build",
"build:dev": "pm2 start scripts/devServer.js",
"postinstall": "umi generate tmp",
"prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'",
"test": "umi-test",
......@@ -56,6 +57,9 @@
"axios": "^0.19.2",
"chalk": "^4.1.0",
"clone": "^2.1.2",
"connect-history-api-fallback": "^1.6.0",
"express": "^4.17.1",
"express-http-proxy": "^1.6.2",
"fs-extra": "^9.0.1",
"god-yapi2ts": "^1.6.0",
"gulp": "^4.0.2",
......
/**
* 用于build后在10.0.0.25环境下,作为本地调试
*
*/
//express模块
var express =require("express");
var app =express();
const path = require('path')
const httpProxy = require('express-http-proxy')
const port = 4396
const proxyConfig = {
url: 'http://10.0.0.25',
port: '8100'
}
// 用于解决刷新后404问题
var history = require('connect-history-api-fallback');
app.use(history());
app.use(express.static('dist'))
app.use('/api',proxy(`${proxyConfig.url}:${proxyConfig.proxy}`))
app.get('/',(req,res)=>{
res.sendFile(path.resolve(__dirname, "../dist/", "index.html")) //设置/ 下访问文件位置
});
var server =app.listen(port,()=>{
var port =server.address().port
console.log("【】访问地址http://localhost:%s",port)
})
\ No newline at end of file
......@@ -13,10 +13,10 @@ import { StandardTable } from 'god'
import ReutrnEle from '@/components/ReturnEle';
import './index.less'
import NiceForm, {FlexBox} from '@/components/NiceForm'
import { repositDetailSchema, repositMoreSchema, repositSchema, repositTabOneSchema, repositInSchema } from './schema'
import { repositDetailSchema, repositMoreSchema, repositSchema, repositTabOneSchema, repositInSchema, repositOutSchema } from './schema'
import { createFormActions, ISchema, FormButtonGroup, Submit, FormEffectHooks, FormProvider, FormSpy, createAsyncFormActions } from '@formily/antd'
import EyePreview from '@/components/EyePreview'
import { findItemAndDelete, omit } from '@/utils'
import { findItemAndDelete, omit, getStepNumber } from '@/utils'
import { PublicApi } from '@/services/api'
import { useRowSelectionTable } from '@/hooks/useRowSelectionTable'
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect'
......@@ -49,7 +49,8 @@ const fetchDepositAllList = async () => {
}
const addSchemaAction = createFormActions()
const repositSchemaAction = createAsyncFormActions()
const repositInAction = createAsyncFormActions()
const repositOutAction = createAsyncFormActions()
const AddRepository:React.FC<{}> = (props) => {
const ref = useRef<any>({})
......@@ -133,9 +134,8 @@ const AddRepository:React.FC<{}> = (props) => {
key: 'unitName',
},
]
useEffect(() => {
PublicApi.getWarehouseWarehouseAll().then(({data}) => {
PublicApi.getWarehouseFreightSpaceAll().then(({data}) => {
setReposits(data)
})
}, [])
......@@ -243,6 +243,9 @@ const AddRepository:React.FC<{}> = (props) => {
}
}
}
const reloadRepot = () => {
}
// 商品选择
......@@ -271,13 +274,27 @@ const AddRepository:React.FC<{}> = (props) => {
await PublicApi.postWarehouseFreightSpaceAllotFold(params)
}
// 库存调出表单提交
const handleRespotOut = async (values) => {
const params = {}
Object.entries(values).forEach(([key, value]) => {
if (!key.includes('NO_SUBMIT')) {
params[key] = value
}
})
await PublicApi.postWarehouseFreightSpaceAllotFold(params)
}
const transforInBtn = <Row justify='center'>
<Button type='primary' htmlType='submit'>调入</Button>
</Row>
const transforOutBtn = <Row justify='center'>
<Button type='primary' htmlType='submit'>调出</Button>
</Row>
const topTableChange = (tabs) => {
if (tabs === 'tab2') {
repositSchemaAction.getFieldValue('NO_SUBMIT1').then(data => {
repositInAction.getFieldValue('NO_SUBMIT1').then(data => {
console.log(data)
}) // 调入的数值
......@@ -326,21 +343,24 @@ const AddRepository:React.FC<{}> = (props) => {
return (
<NiceForm
schema={repositInSchema}
actions={repositSchemaAction}
actions={repositInAction}
onSubmit={handleRespotIn}
effects={async ($, {setFieldState}) => {
const utils = useLinkageUtils()
FormEffectHooks.onFormMount$().subscribe(() => {
const name = spyForm.getFieldValue('name')
console.log(reposits)
const asyncEnums = reposits.map(v => ({
label: v.name,
value: v.id
}))
utils.enum('freightSpaceId', asyncEnums)
$('onFieldInputChange', 'freightSpaceId').subscribe(state => {
const numberValue = reposits.find(v => v.id === state.value).principal || 0
const numberValue = reposits.find(v => v.id === state.value).inventory || 0
utils.value('NO_SUBMIT1', numberValue)
setFieldState('foldInventory', state => {
state.props["x-component-props"].max = numberValue
state.props["x-component-props"].marks = getStepNumber(numberValue)
})
})
// 调入仓位信息
utils.enum('foldFreightSpaceId', [
......@@ -360,7 +380,49 @@ const AddRepository:React.FC<{}> = (props) => {
</FormSpy>
</Tabs.TabPane>
<Tabs.TabPane tab='库存调出' key="tab2-2" forceRender>2</Tabs.TabPane>
<Tabs.TabPane tab='库存调出' key="tab2-2" forceRender>
<FormSpy>
{({ form: spyForm }) => {
return (
<NiceForm
schema={repositOutSchema}
actions={repositOutAction}
onSubmit={handleRespotOut}
effects={async ($, {setFieldState}) => {
const utils = useLinkageUtils()
FormEffectHooks.onFormMount$().subscribe(() => {
const name = spyForm.getFieldValue('name')
const asyncEnums = reposits.map(v => ({
label: v.name,
value: v.id
}))
utils.enum('foldFreightSpaceId', asyncEnums)
$('onFieldInputChange', 'foldFreightSpaceId').subscribe(state => {
const numberValue = reposits.find(v => v.id === state.value).inventory || 0
utils.value('NO_SUBMIT2', numberValue)
setFieldState('foldInventory', state => {
state.props["x-component-props"].max = numberValue
state.props["x-component-props"].marks = getStepNumber(numberValue)
})
})
// 调入仓位信息
utils.enum('freightSpaceId', [
{label: name, value: id}
])
utils.value('freightSpaceId', id)
utils.value('NO_SUBMIT1', spyForm.getFieldValue('inventory'))
})
}}
expressionScope={{
transforOutBtn
}}
>
</NiceForm>
)
}}
</FormSpy>
</Tabs.TabPane>
<Tabs.TabPane tab='调拨记录' key="tab2-3">3</Tabs.TabPane>
</Tabs>
</Tabs.TabPane>
......
......@@ -731,3 +731,83 @@ export const repositInSchema: ISchema = {
}
}
}
// 库存调出
export const repositOutSchema: ISchema = {
type: 'object',
properties: {
repos_layout: {
type: 'object',
"x-component": 'mega-layout',
"x-component-props": {
grid: true,
autoRow: true,
labelCol: 8,
labelAlign: 'left',
columns: 2
},
properties: {
'freightSpaceId': {
type: 'string',
title: '调出仓位名称',
enum: [],
required: true,
"x-component-props": {
disabled: true
},
"x-mega-props": {
span: 1
}
},
'foldFreightSpaceId': {
type: 'string',
title: '调入仓位名称',
enum: [],
"x-mega-props": {
span: 1
},
required: true
},
'NO_SUBMIT1': {
type: 'object',
readOnly: true,
title: '当前仓位库存(尺)',
"x-component": 'CircleBox',
default: 0
},
'NO_SUBMIT2': {
type: 'object',
title: '当前仓位库存(尺)',
"x-component": 'CircleBox',
default: 0
},
"foldInventory": {
type: 'number',
"x-component": "CustomSlider",
"x-component-props": {
width: '80%',
isNumber: true,
max: 0,
min: 0,
layout: {
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center'
}
},
"x-mega-props": {
span: 2
}
},
}
},
submit: {
type: 'object',
"x-component": 'Children',
"x-component-props": {
children: "{{transforOutBtn}}"
}
}
}
}
......@@ -13,6 +13,6 @@ export const useLinkageUtils = () => {
enum: linkage('props.enum', []),
loading: linkage('loading', true),
loaded: linkage('loading', false),
value: linkage('value')
value: linkage('value'),
}
}
......@@ -106,6 +106,50 @@ export function timeRange(val: number) {
return { st, et }
}
// 判断是否是素数
export function isPrimeNum(num){
if (!isNum(num)){
return false;
}
if (!isInteger(num)){
return false;
}
if (num==2||num==3||num==5) {
return true;
}
if (!isDual(num)){
return false;
}
if (!isThree(num)){
return false;
}
for (var i = 2; i < num/5+1; i++) {
if (num%i==0){
return false;
}
};
return true;
}
function isInteger(num){
return num == ~~num ? true : false;
}
function isNum(num){
return num == +num ? true : false;
}
function isDual(num){
var num = num.toString();
var lastNum = num.substring(num.length-1,num.length);
return lastNum%2 == 0 || lastNum%5 == 0 ? false : true;
}
function isThree(num){
var str = num.toString();
var sum = 0;
for (var i = 0; i < str.length; i++) {
sum += +str.substring(i,i+1);
};
return sum%3 == 0 ? false : true;
}
export function omit(obj: any, arr: string[]) {
const tempObj = { ...obj }
for (let i = 0; i < arr.length; i++) {
......@@ -150,6 +194,34 @@ export const dupliArr = (arr: any[]) => {
return Array.from(new Set(arr))
}
// 获取最小的差距值
export const getDistanceNumber = (target, step, min) => {
const value = target / step
if (value >= min) {
let num = 0
const result = {}
while (num < target) {
result[num] = num
num += Math.ceil(value)
}
result[target] = target
return result
} else {
return getDistanceNumber(target, step--, min)
}
}
// 将数字拆分成指定区间
export const getStepNumber = (target: number, step?: number) => {
// 最小相差10
const minDistance = 10
step = step || 4
const marks = getDistanceNumber(target, step, minDistance)
return marks
}
// 遍历树拿到所有key的集合
export const findTreeKeys = (arr: any[], keyword?: ReactText) => {
const copyArr: any[] = deepClone(arr)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment