Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-convertor-view
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
station
amos-convertor-view
Commits
4e4700cd
Commit
4e4700cd
authored
Apr 12, 2021
by
zhengjiawei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新功能和bug修复
parent
2cce6acc
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
179 additions
and
3 deletions
+179
-3
request.js
src/utils/request.js
+137
-0
EquipmentModel.js
src/view/bizview/equipmentLedger/Equipment/EquipmentModel.js
+41
-3
index.js
src/view/bizview/equipmentLedger/Equipment/index.js
+1
-0
No files found.
src/utils/request.js
View file @
4e4700cd
...
...
@@ -25,6 +25,8 @@ const compleHeaders = () => {
};
};
/**
* 获取 token
*/
...
...
@@ -194,4 +196,139 @@ export const fileDownload = ({ url, data, fileName, method = 'GET' }) => {
});
};
export
const
recursive
=
function
(
list
,
childName
=
'children'
)
{
class
recursiveClass
{
constructor
(
_list
,
_childName
)
{
this
.
list
=
_list
||
[];
this
.
childName
=
_childName
;
}
some
(
callback
)
{
const
func
=
arr
=>
{
return
arr
.
some
((
e
,
index
)
=>
{
const
flag
=
callback
(
e
,
index
);
if
(
flag
)
{
return
flag
;
}
else
{
if
(
e
[
this
.
childName
]
&&
e
[
this
.
childName
].
length
>
0
)
{
return
func
(
e
[
this
.
childName
]);
}
}
return
false
;
});
};
return
func
(
this
.
list
);
}
find
(
callback
)
{
let
obj
=
null
;
const
func
=
(
arr
,
parent
)
=>
{
return
arr
.
find
((
e
,
index
)
=>
{
const
flag
=
callback
(
e
,
index
,
parent
);
if
(
flag
)
{
obj
=
e
;
return
flag
;
}
else
{
if
(
e
[
this
.
childName
]
&&
e
[
this
.
childName
].
length
>
0
)
{
return
func
(
e
[
this
.
childName
],
e
);
}
}
return
false
;
});
};
func
(
this
.
list
,
{});
return
obj
;
}
findParent
(
callback
)
{
let
obj
=
null
;
const
func
=
(
arr
,
parent
)
=>
{
return
arr
.
find
((
e
,
index
)
=>
{
const
flag
=
callback
(
e
,
index
,
parent
);
if
(
flag
)
{
obj
=
parent
;
return
flag
;
}
else
{
if
(
e
[
this
.
childName
]
&&
e
[
this
.
childName
].
length
>
0
)
{
return
func
(
e
[
this
.
childName
],
e
);
}
}
return
false
;
});
};
func
(
this
.
list
,
{});
return
obj
;
}
findIndex
(
callback
)
{
let
resIndex
=
-
1
;
const
func
=
(
arr
,
parent
)
=>
{
return
arr
.
find
((
e
,
index
)
=>
{
const
flag
=
callback
(
e
,
index
,
parent
);
if
(
flag
)
{
resIndex
=
index
;
return
flag
;
}
else
{
if
(
e
[
this
.
childName
]
&&
e
[
this
.
childName
].
length
>
0
)
{
return
func
(
e
[
this
.
childName
],
e
);
}
}
return
false
;
});
};
func
(
this
.
list
,
{});
return
resIndex
;
}
filter
(
callback
)
{
const
func
=
(
arr
,
parent
)
=>
{
return
arr
.
filter
((
e
,
index
)
=>
{
const
flag
=
callback
(
e
,
index
,
parent
);
if
(
flag
)
{
if
(
e
[
this
.
childName
]
&&
e
[
this
.
childName
].
length
>
0
)
{
e
[
this
.
childName
]
=
func
(
e
[
this
.
childName
],
e
);
}
}
return
flag
;
});
};
return
func
(
this
.
list
,
{});
}
search
(
callback
)
{
const
func
=
(
arr
,
parent
)
=>
{
return
arr
.
filter
((
e
,
index
)
=>
{
let
flag
=
callback
(
e
,
index
,
parent
);
if
(
e
[
this
.
childName
]
&&
e
[
this
.
childName
].
length
>
0
)
{
e
[
this
.
childName
]
=
func
(
e
[
this
.
childName
],
e
);
if
(
e
[
this
.
childName
]
&&
e
[
this
.
childName
].
length
>
0
)
{
flag
=
true
;
}
}
return
flag
;
});
};
return
func
(
this
.
list
,
{});
}
map
(
callback
)
{
const
func
=
(
arr
,
parent
)
=>
{
return
arr
.
map
((
e
,
index
)
=>
{
const
node
=
callback
(
e
,
index
,
parent
);
if
(
node
)
{
e
=
node
;
}
if
(
e
[
this
.
childName
]
&&
e
[
this
.
childName
].
length
>
0
)
{
e
[
this
.
childName
]
=
func
(
e
[
this
.
childName
],
e
);
}
return
e
;
});
};
return
func
(
this
.
list
,
{});
}
}
return
new
recursiveClass
(
list
,
childName
);
};
export
{
amosRequest
,
singleFetch
,
convertDatalist
,
buildPageable
,
formatUrl
};
src/view/bizview/equipmentLedger/Equipment/EquipmentModel.js
View file @
4e4700cd
...
...
@@ -51,6 +51,7 @@ class EquipmentModel extends Component {
imageUrl2
:
[],
imageUrl3
:
[],
imageUrl4
:
[],
equipmentPic
:
[],
reservePlan
:
''
,
riskSourceId
:
0
},
...
...
@@ -60,7 +61,8 @@ class EquipmentModel extends Component {
rules
:
{
code
:
[{
required
:
true
,
message
:
'编码不能为空'
}],
name
:
[{
required
:
true
,
message
:
'名称不能为空'
}],
position3d
:
[{
validator
:
this
.
validPositon3d
}]
position3d
:
[{
validator
:
this
.
validPositon3d
}],
equipmentPic
:
[{
required
:
true
,
message
:
'重点设备照片不能为空'
}]
},
previewVisible
:
false
,
previewImage
:
''
,
...
...
@@ -175,7 +177,7 @@ class EquipmentModel extends Component {
console
.
log
(
data
);
data
.
forEach
(
ele
=>
{
let
type
=
ele
.
type
;
if
(
type
>=
1
&&
type
<=
4
)
{
if
(
type
>=
1
)
{
pMap
.
set
(
type
,
ele
.
picture
);
}
});
...
...
@@ -231,6 +233,9 @@ class EquipmentModel extends Component {
case 4:
_form.imageUrl4 = [file];
break;
case 5:
_form.equipmentPic = [file];
break;
}
this.setState({ form: _form });
};
...
...
@@ -255,7 +260,7 @@ class EquipmentModel extends Component {
changeData = async file => {
file.url = await getBase64(file);
let _form = this.state.form;
let { imageUrl1 = [], imageUrl2 = [], imageUrl3 = [], imageUrl4 = [] } = this.state.form;
let { imageUrl1 = [], imageUrl2 = [], imageUrl3 = [], imageUrl4 = []
,equipmentPic = []
} = this.state.form;
switch (file.mylist) {
case '
imageUrl1
':
_form.imageUrl1 = [...imageUrl1, file];
...
...
@@ -269,6 +274,10 @@ class EquipmentModel extends Component {
case '
imageUrl4
':
_form.imageUrl4 = [...imageUrl4, file];
break;
case '
equipmentPic
':
_form.equipmentPic = [...equipmentPic, file];
break;
}
this.setState({ form: _form });
};
...
...
@@ -315,6 +324,14 @@ class EquipmentModel extends Component {
this.setState({ form });
break;
}
case '
equipmentPic
': {
let index = form.equipmentPic.indexOf(file);
let newFileList = form.equipmentPic.slice();
newFileList.splice(index, 1);
form.equipmentPic = newFileList;
this.setState({ form });
break;
}
}
};
...
...
@@ -545,6 +562,27 @@ class EquipmentModel extends Component {
<FormItem label={<span>备注</span>} field="remark" {...formItemLayout}>
<TextArea rows={4} className="risk_factor_input" required value={form.remark} onChange={e => this.onInputChange('
remark
', e.target.value)} />
</FormItem>
<FormItem label={<span>重点设备照片</span>} field='
equipmentPic
' {...formItemLayout}>
<div>
<Upload
customRequest={this.handleUpload}
className="upload-img"
fileList={form.equipmentPic}
listType="picture-card"
beforeUpload={file => {
file.mylist = '
equipmentPic
';
this.beforeUpload(file);
}}
onPreview={this.handlePreview}
onRemove={file => {
file.mylist = '
equipmentPic
';
this.fileRemove(file);
}}
>
{form.equipmentPic ? form.equipmentPic.length >= 1 ? null : uploadButton : uploadButton}
</Upload>
</div>
</FormItem>
</div>
</Form>
</div>
...
...
src/view/bizview/equipmentLedger/Equipment/index.js
View file @
4e4700cd
...
...
@@ -305,6 +305,7 @@ class Equipment extends Component {
dataValues
.
imageUrl2
&&
formData
.
append
(
'img2'
,
dataValues
.
imageUrl2
[
0
]);
dataValues
.
imageUrl3
&&
formData
.
append
(
'img3'
,
dataValues
.
imageUrl3
[
0
]);
dataValues
.
imageUrl4
&&
formData
.
append
(
'img4'
,
dataValues
.
imageUrl4
[
0
]);
dataValues
.
equipmentPic
&&
formData
.
append
(
'equipmentPic'
,
dataValues
.
equipmentPic
[
0
]);
if
(
dataValues
)
{
for
(
var
key
in
dataValues
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment