infoList.js
5.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
import React, { Component, Fragment } from 'react'
import { connect } from 'dva'
import { routerRedux } from 'dva/router';
import { Toast } from 'antd-mobile';
import shareHide from "../../utils/shareHide";
import css from './databank.less';
class InfoList extends Component {
constructor(){
super()
this.state={
dataList: [],
filter: [],
chooseIdx: 0,
productId:''
}
}
componentDidMount() {
const { search } = this.props.location;
const _this = this;
let key = Number(sessionStorage.getItem('key'));
shareHide();
Toast.loading('loading...');
if (search) {
const matchs = decodeURI(search).match(/riskCode=(.*)&riskName=(.*)/i)
let riskCode = matchs[1]
let riskName = matchs[2]
document.title = riskName
this.props.dispatch({
type: 'addUser/Dictionaries',
payload: {
configType: 'dataConfig'
},
callback(data) {
if (data.length) {
_this.setState({
filter: data,
productId:riskCode
});
_this.props.dispatch({
type: 'databank/getDataInfoList',
payload: {
productId: riskCode,
dataType: data[key].configCode,
orgId: window.localStorage.getItem('orgId'),
proId: window.localStorage.getItem('project')
},
callback(res) {
if (res.status) {
Toast.hide();
_this.setState({
dataList: res.data
})
}
}
})
}
}
})
}
}
filterData(configCode) {
const _this = this;
Toast.loading('loading...');
_this.props.dispatch({
type: 'databank/getDataInfoList',
payload: {
productId:this.state.productId,
dataType: configCode,
orgId: window.localStorage.getItem('orgId'),
proId: window.localStorage.getItem('project')
},
callback(res) {
if (res.status) {
Toast.hide();
_this.setState({
dataList: res.data
})
}
}
})
}
render() {
let chooseIdx = 0;
if(sessionStorage.getItem("key")){
chooseIdx = Number(sessionStorage.getItem("key"))
}
const { dataList } = this.state;
return (
<Fragment>
<div className={css.pList}>
<div className={css.pTagList}>
<ul>
{
this.state.filter.length > 0 && this.state.filter.map((el, i) => <li key={i} className={chooseIdx === i ? 'on' : ''} onClick={() => {
this.filterData(el.configCode)
this.setState({
chooseIdx: i
})
sessionStorage.setItem( "key", i);
}}>{el.configName}</li>)
}
</ul>
</div>
<ul className={css.fileList}>
{
dataList && dataList.map((el, i) => {
let type = 'pdf';
switch (el.dataFormat.toLowerCase()) {
case 'pdf':
type = 'pdf';
break;
case 'mp4':
type = 'video';
break;
default:
type = '';
break;
}
if(/doc|docx/i.test(el.dataFormat)) type = 'word';
if(/ppt|pptx/i.test(el.dataFormat)) type = 'ppt';
if(/png|jpg|gif/i.test(el.dataFormat)) type = 'img';
if(/xls|xlsx/i.test(el.dataFormat)) type = 'excel';
return <li key={i} className={type} onClick={() => {
//记录点击数
this.props.dispatch({
type:"home/setClickRecord",
payload: {
"operCode": el.dataCode,
"operFunction": 100100,
"operTitle": el.dataName,
"operType": 201,
},
callback(data){
console.log('资料库点击一次')
}
});
if (type === 'pdf') {
window.location.href = el.dataPath
} else if (/doc|docx|xls|xlsx|ppt|pptx/i.test(el.dataFormat)) {
window.location.href = 'https://view.officeapps.live.com/op/view.aspx?src=' + el.dataPath
} else {
this.props.dispatch(routerRedux.push({
pathname: '/databank/preview',
state: {
url:el.dataPath
},
}));
}
}}>
<span>{el.dataName+'.'+el.dataFormat.toLowerCase()}</span>
</li>
})
}
</ul>
<div className={css.nomore}>没有更多啦</div>
</div>
</Fragment>
)
}
}
export default connect(({ databank }) => ({ databank }))(InfoList)