ww664853070
2 years ago
60 changed files with 2556 additions and 731 deletions
@ -0,0 +1,59 @@ |
|||||
|
'use strict'; |
||||
|
const moment = require('moment') |
||||
|
const request = require('superagent') |
||||
|
|
||||
|
function videoList (opts) { |
||||
|
return async function (ctx) { |
||||
|
try { |
||||
|
const { models, } = ctx.fs.dc; |
||||
|
const { app, yingshiTokenRes } = ctx |
||||
|
|
||||
|
let yingshiToken = '' |
||||
|
if (yingshiTokenRes && yingshiTokenRes.token && yingshiTokenRes.expire && moment().isBefore(moment(yingshiTokenRes.expire))) { |
||||
|
yingshiToken = yingshiTokenRes.token |
||||
|
} else { |
||||
|
const tokenRes = await app.fs.yingshiRequest.post(`lapp/token/get`, { |
||||
|
query: { |
||||
|
appKey: opts.yingshiKey, |
||||
|
appSecret: opts.yingshiSecret |
||||
|
} |
||||
|
}) |
||||
|
if (tokenRes.code == 200 && tokenRes.data) { |
||||
|
const { accessToken, expireTime } = tokenRes.data |
||||
|
|
||||
|
ctx.yingshiTokenRes = { |
||||
|
token: accessToken, |
||||
|
expire: expireTime |
||||
|
} |
||||
|
yingshiToken = accessToken |
||||
|
} else { |
||||
|
throw '未能获取进行萤石鉴权' |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
const deviceRes = await app.fs.yingshiRequest.post(`lapp/device/list`, { |
||||
|
query: { |
||||
|
accessToken: yingshiToken, |
||||
|
} |
||||
|
}) |
||||
|
|
||||
|
ctx.status = 200; |
||||
|
ctx.body = (deviceRes.data || []).map(item => { |
||||
|
return { |
||||
|
...item, |
||||
|
token: yingshiToken, |
||||
|
} |
||||
|
}) |
||||
|
} catch (error) { |
||||
|
ctx.fs.logger.error(`path: ${ctx.path}, error: error`); |
||||
|
ctx.status = 400; |
||||
|
ctx.body = { |
||||
|
message: typeof error == 'string' ? error : undefined |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
module.exports = { |
||||
|
videoList |
||||
|
}; |
@ -0,0 +1,65 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
async function getDepUsers(ctx) { |
||||
|
try { |
||||
|
const models = ctx.fs.dc.models; |
||||
|
//所有部门
|
||||
|
const departments = await models.Department.findAll({ |
||||
|
attributes: ['id', 'name', 'dependence'], |
||||
|
order: [['id', 'asc']], |
||||
|
where: { |
||||
|
delete: false, |
||||
|
}, |
||||
|
}) |
||||
|
//所有用户
|
||||
|
const allusers = await models.User.findAll({ |
||||
|
attributes: ['id', 'name', 'username', 'department_id'], |
||||
|
order: [['id', 'asc']], |
||||
|
where: { |
||||
|
delete: false, |
||||
|
}, |
||||
|
}) |
||||
|
const employees = [...new Set(allusers)] |
||||
|
function collectEmployees(departments, employees) { |
||||
|
const result = []; |
||||
|
const processDepartment = (department) => { |
||||
|
const departmentData = { |
||||
|
depId: department.id, |
||||
|
depName: department.name, |
||||
|
users: [], |
||||
|
expanded: false, // 初始状态折叠
|
||||
|
}; |
||||
|
const departmentEmployees = employees.filter(employee => |
||||
|
//console.log('employee.dataVaules.department_id', employee.department_id)
|
||||
|
employee.dataValues.department_id === department.id |
||||
|
); |
||||
|
departmentData.users.push(...departmentEmployees); |
||||
|
departments.forEach(subDepartment => { |
||||
|
if (subDepartment.dependence === department.id) { |
||||
|
const subDepartmentData = processDepartment(subDepartment); |
||||
|
departmentData.users.push(...subDepartmentData.users); |
||||
|
} |
||||
|
}); |
||||
|
return departmentData; |
||||
|
}; |
||||
|
departments.forEach(department => { |
||||
|
if (department.dependence === null) { |
||||
|
const departmentData = processDepartment(department); |
||||
|
result.push(departmentData); |
||||
|
} |
||||
|
}); |
||||
|
return result; |
||||
|
} |
||||
|
const result = collectEmployees(departments, employees); |
||||
|
ctx.status = 200; |
||||
|
ctx.body = result |
||||
|
} catch (error) { |
||||
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
||||
|
ctx.status = 400; |
||||
|
ctx.body = {} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
module.exports = { |
||||
|
getDepUsers |
||||
|
}; |
@ -1,50 +0,0 @@ |
|||||
'use strict'; |
|
||||
|
|
||||
const request = require('superagent'); |
|
||||
const buildUrl = (url,token) => { |
|
||||
let connector = url.indexOf('?') === -1 ? '?' : '&'; |
|
||||
return `${url}${connector}token=${token}`; |
|
||||
}; |
|
||||
|
|
||||
function factory(app, router, opts) { |
|
||||
return async function (ctx, next) { |
|
||||
|
|
||||
const token = ctx.fs.api.token; |
|
||||
|
|
||||
//console.log(username,password)
|
|
||||
const req = { |
|
||||
get: (url, query) => { |
|
||||
return request |
|
||||
.get(buildUrl(url,token)) |
|
||||
.query(query) |
|
||||
}, |
|
||||
post: (url, data, query) => { |
|
||||
return request |
|
||||
.post(buildUrl(url,token)) |
|
||||
.query(query) |
|
||||
//.set('Content-Type', 'application/json')
|
|
||||
.send(data); |
|
||||
}, |
|
||||
|
|
||||
put: (url, data) => { |
|
||||
return request |
|
||||
.put(buildUrl(url,token)) |
|
||||
//.set('Content-Type', 'application/json')
|
|
||||
.send(data); |
|
||||
}, |
|
||||
|
|
||||
delete: (url) => { |
|
||||
return request |
|
||||
.del(buildUrl(url,token)) |
|
||||
}, |
|
||||
}; |
|
||||
|
|
||||
app.business = app.business || {}; |
|
||||
app.business.request = req; |
|
||||
|
|
||||
await next(); |
|
||||
}; |
|
||||
} |
|
||||
|
|
||||
module.exports = factory; |
|
||||
|
|
@ -0,0 +1,67 @@ |
|||||
|
'use strict'; |
||||
|
const request = require('superagent') |
||||
|
|
||||
|
class paasRequest { |
||||
|
constructor(root, { query = {} } = {}, option) { |
||||
|
this.root = root; |
||||
|
this.query = query |
||||
|
this.option = option |
||||
|
} |
||||
|
|
||||
|
#buildUrl = (url) => { |
||||
|
return `${this.root}/${url}`; |
||||
|
} |
||||
|
|
||||
|
#resultHandler = (resolve, reject) => { |
||||
|
return (err, res) => { |
||||
|
if (err) { |
||||
|
reject(err); |
||||
|
} else { |
||||
|
resolve(res[this.option.dataWord]); |
||||
|
} |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
get = (url, { query = {}, header = {} } = {}) => { |
||||
|
return new Promise((resolve, reject) => { |
||||
|
request.get(this.#buildUrl(url)).set(header).query(Object.assign(query, this.query)).end(this.#resultHandler(resolve, reject)); |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
post = (url, { data = {}, query = {}, header = {} } = {}) => { |
||||
|
return new Promise((resolve, reject) => { |
||||
|
request.post(this.#buildUrl(url)).set(header).query(Object.assign(query, this.query)).send(data).end(this.#resultHandler(resolve, reject)); |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
put = (url, { data = {}, header = {}, query = {}, } = {}) => { |
||||
|
return new Promise((resolve, reject) => { |
||||
|
request.put(this.#buildUrl(url)).set(header).query(Object.assign(query, this.query)).send(data).end(this.#resultHandler(resolve, reject)); |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
delete = (url, { header = {}, query = {} } = {}) => { |
||||
|
return new Promise((resolve, reject) => { |
||||
|
request.delete(this.#buildUrl(url)).set(header).query(Object.assign(query, this.query)).end(this.#resultHandler(resolve, reject)); |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
function factory (app, opts) { |
||||
|
if (opts.pssaRequest) { |
||||
|
try { |
||||
|
for (let r of opts.pssaRequest) { |
||||
|
if (r.name && r.root) { |
||||
|
app.fs[r.name] = new paasRequest(r.root, { ...(r.params || {}) }, { dataWord: r.dataWord || 'body' }) |
||||
|
} else { |
||||
|
throw 'opts.pssaRequest 参数错误!' |
||||
|
} |
||||
|
} |
||||
|
} catch (error) { |
||||
|
console.error(error) |
||||
|
process.exit(-1); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
module.exports = factory; |
@ -0,0 +1,40 @@ |
|||||
|
create table if not exists assess |
||||
|
( |
||||
|
id serial not null |
||||
|
constraint assess_pk |
||||
|
primary key, |
||||
|
unit varchar(64), |
||||
|
month timestamp with time zone, |
||||
|
total_points double precision, |
||||
|
industry_points double precision, |
||||
|
industry_out_points double precision, |
||||
|
plus_or_subtract double precision, |
||||
|
"industry_deduction_reason " varchar(1024), |
||||
|
industry_out_deduction_reason varchar(1024), |
||||
|
remark varchar(1024) |
||||
|
); |
||||
|
|
||||
|
comment on table assess is '考核评分'; |
||||
|
|
||||
|
comment on column assess.unit is '考核单位'; |
||||
|
|
||||
|
comment on column assess.month is '考核月份'; |
||||
|
|
||||
|
comment on column assess.total_points is '总分'; |
||||
|
|
||||
|
comment on column assess.industry_points is '业内得分'; |
||||
|
|
||||
|
comment on column assess.industry_out_points is '业外得分'; |
||||
|
|
||||
|
comment on column assess.plus_or_subtract is '加减得分'; |
||||
|
|
||||
|
comment on column assess."industry_deduction_reason " is '业内扣分原因 |
||||
|
'; |
||||
|
|
||||
|
comment on column assess.industry_out_deduction_reason is '业外扣分原因'; |
||||
|
|
||||
|
comment on column assess.remark is '备注'; |
||||
|
|
||||
|
create unique index if not exists assess_id_uindex |
||||
|
on assess (id); |
||||
|
|
After Width: | Height: | Size: 1.4 MiB |
@ -0,0 +1,52 @@ |
|||||
|
/** |
||||
|
* 萤石视频直播(基于萤石云iframe模式,使用方式简单) |
||||
|
* 官方参考:https://open.ys7.com/console/ezopenIframe.html
|
||||
|
*/ |
||||
|
'use strict'; |
||||
|
|
||||
|
import React from 'react'; |
||||
|
import { connect } from 'react-redux'; |
||||
|
|
||||
|
const YSIframePlayer = props => { |
||||
|
|
||||
|
const { containerId, height, width, url, autoplay, audio, videoState, ysToken } = props; |
||||
|
const at = ysToken |
||||
|
if (!url || !at) return null; |
||||
|
const src = `https://open.ys7.com/ezopen/h5/iframe?audio=${audio ? '1' : '0'}&url=${url}&autoplay=${autoplay || 1}&accessToken=${at}` |
||||
|
// const src = `https://open.ys7.com/ezopen/h5/iframe?audio=1&url=${url}&autoplay=${autoplay || 1}&accessToken=${at}`
|
||||
|
return ( |
||||
|
<div |
||||
|
style={{ position: 'relative', height: '100%', width: '100%' }}> |
||||
|
<iframe |
||||
|
frameBorder="0" |
||||
|
id={containerId || 'myPlayer'} |
||||
|
src={src} |
||||
|
// https://open.ys7.com/doc/zh/book/index/live_proto.html 单个播放器的长宽比例限制最小为{width: 400px;height: 300px;}
|
||||
|
width={width || 400} |
||||
|
height={height || 300} |
||||
|
allowFullScreen |
||||
|
wmode="transparent" |
||||
|
> |
||||
|
</iframe> |
||||
|
{ |
||||
|
videoState && videoState.status == 0 ? |
||||
|
<div style={{ |
||||
|
height: width || 300, width: width || 400, position: 'absolute', top: 0, background: '#000', |
||||
|
display: 'flex', justifyContent: 'center', alignItems: 'center', color: '#fff' |
||||
|
}}> |
||||
|
设备中断,正在处理中... |
||||
|
</div> |
||||
|
: '' |
||||
|
} |
||||
|
</div> |
||||
|
) |
||||
|
} |
||||
|
|
||||
|
function mapStateToProps (state) { |
||||
|
const { auth, } = state; |
||||
|
return { |
||||
|
user: auth.user, |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
export default connect(mapStateToProps)(YSIframePlayer); |
@ -0,0 +1,14 @@ |
|||||
|
import { basicAction } from '@peace/utils' |
||||
|
import { ApiTable } from '$utils' |
||||
|
|
||||
|
export function getAllDepUsers(query) { |
||||
|
return dispatch => basicAction({ |
||||
|
type: 'get', |
||||
|
dispatch: dispatch, |
||||
|
query: query, |
||||
|
actionType: 'GET_AllDEPUSERS', |
||||
|
url: ApiTable.getAllDepUsers, |
||||
|
msg: { option: '获取部门下的所有员工' },//子部门算在第一级部门下面
|
||||
|
reducer: { name: 'allDepUsers' } |
||||
|
}); |
||||
|
} |
@ -0,0 +1,108 @@ |
|||||
|
import React, { useState, useEffect } from 'react'; |
||||
|
import { connect } from 'react-redux'; |
||||
|
import { Form, Input, Select, DatePicker, InputNumber, Button, Modal } from 'antd'; |
||||
|
import { unitList } from '../containers/assess' |
||||
|
import { getAssess, delAssess, editAssess } from '../actions/assess'; |
||||
|
import moment from 'moment'; |
||||
|
|
||||
|
const { Option } = Select; |
||||
|
|
||||
|
const AssessModal = ({ editData, check, visible, onCancel, dispatch }) => { |
||||
|
const [form] = Form.useForm(); |
||||
|
|
||||
|
return ( |
||||
|
<Modal |
||||
|
title="考核评分" |
||||
|
open={visible} |
||||
|
visible={visible} |
||||
|
cancelButtonProps={{ |
||||
|
disabled: check, |
||||
|
}} |
||||
|
onOk={() => { |
||||
|
if (check) { |
||||
|
return onCancel() |
||||
|
} |
||||
|
form.validateFields().then(values => { |
||||
|
dispatch(editAssess({ |
||||
|
...values, |
||||
|
month: moment(values.month).format('YYYY-MM-DD'), |
||||
|
assessId: editData ? editData.id : undefined |
||||
|
})).then(res => { |
||||
|
if (res.success) { |
||||
|
onCancel() |
||||
|
} |
||||
|
}) |
||||
|
}) |
||||
|
}} |
||||
|
onCancel={() => { |
||||
|
onCancel() |
||||
|
}} |
||||
|
> |
||||
|
<Form |
||||
|
form={form} |
||||
|
initialValues={editData ? { |
||||
|
...editData, |
||||
|
month: moment(editData.month), |
||||
|
} : {}} |
||||
|
disabled={check} |
||||
|
labelCol={{ |
||||
|
span: 6, |
||||
|
}} |
||||
|
wrapperCol={{ |
||||
|
span: 18, |
||||
|
}} |
||||
|
> |
||||
|
<Form.Item name="unit" label="管养责任单位" rules={[{ required: true, message: '请填写' }]}> |
||||
|
<Select> |
||||
|
{ |
||||
|
unitList.map(item => ( |
||||
|
<Option value={item} key={item} /> |
||||
|
)) |
||||
|
} |
||||
|
</Select> |
||||
|
</Form.Item> |
||||
|
|
||||
|
<Form.Item name="month" label="考核月份" rules={[{ required: true, message: '请填写' }]}> |
||||
|
<DatePicker picker="month" /> |
||||
|
</Form.Item> |
||||
|
|
||||
|
<Form.Item name="totalPoints" label="考核总分" rules={[{ required: true, message: '请填写' }]}> |
||||
|
<InputNumber step={0.1} precision={1} /> |
||||
|
</Form.Item> |
||||
|
|
||||
|
<Form.Item name="industryPoints" label="内业得分"> |
||||
|
<InputNumber step={0.1} precision={1} /> |
||||
|
</Form.Item> |
||||
|
|
||||
|
<Form.Item name="industryOutPoints" label="外业得分"> |
||||
|
<InputNumber step={0.1} precision={1} /> |
||||
|
</Form.Item> |
||||
|
|
||||
|
<Form.Item name="plusOrSubtract" label="加减分"> |
||||
|
<InputNumber step={0.1} precision={1} /> |
||||
|
</Form.Item> |
||||
|
|
||||
|
<Form.Item name="industryDeductionReason" label="内业扣分原因"> |
||||
|
<Input.TextArea rows={4} maxLength={1024} /> |
||||
|
</Form.Item> |
||||
|
|
||||
|
<Form.Item name="industryOutDeductionReason" label="外业扣分原因"> |
||||
|
<Input.TextArea rows={4} maxLength={1024} /> |
||||
|
</Form.Item> |
||||
|
|
||||
|
<Form.Item name="remark" label="备注"> |
||||
|
<Input.TextArea rows={4} maxLength={1024} /> |
||||
|
</Form.Item> |
||||
|
</Form> |
||||
|
</Modal> |
||||
|
); |
||||
|
}; |
||||
|
|
||||
|
function mapStateToProps (state) { |
||||
|
const { auth, assess } = state |
||||
|
return { |
||||
|
user: auth.user, |
||||
|
assess: assess.data || [] |
||||
|
} |
||||
|
} |
||||
|
export default connect(mapStateToProps)(AssessModal); |
@ -1,24 +1,167 @@ |
|||||
import React, { useState, useEffect } from 'react'; |
import React, { useState, useEffect } from 'react'; |
||||
import { connect } from 'react-redux'; |
import { connect } from 'react-redux'; |
||||
|
import { getAssess, delAssess, editAssess } from '../actions/assess'; |
||||
|
import ProTable from '@ant-design/pro-table'; |
||||
|
import AssessModal from '../components/assessModal'; |
||||
|
import { Form, Space, DatePicker, Button, Select, Popconfirm } from 'antd' |
||||
|
import moment from 'moment'; |
||||
|
|
||||
function Assess () { |
export const unitList = [ |
||||
|
'县道', |
||||
|
'蒋巷镇', |
||||
|
'三江镇', |
||||
|
'塔城乡', |
||||
|
'泾口乡', |
||||
|
'八一乡', |
||||
|
'冈上镇', |
||||
|
'南新乡', |
||||
|
'富山乡', |
||||
|
'莲塘镇', |
||||
|
'金湖管理处', |
||||
|
'武阳镇', |
||||
|
'向塘镇', |
||||
|
'幽兰镇', |
||||
|
'广福镇', |
||||
|
'塘南镇', |
||||
|
'银三角管委会', |
||||
|
'黄马乡', |
||||
|
] |
||||
|
function Assess (props) { |
||||
|
const { dispatch, assess } = props; |
||||
|
const [assessModalVisible, setAssessModalVisible] = useState(false); |
||||
|
const [editData, setEditData] = useState(null); |
||||
|
const [query, setQuery] = useState({ page: 1, pageSize: 10 }) |
||||
|
const [loading, setLoading] = useState(false); |
||||
|
const [isCheck, setIsCheck] = useState(false) |
||||
|
|
||||
useEffect(() => { |
useEffect(() => { |
||||
|
return () => { }; |
||||
return () => { |
|
||||
}; |
|
||||
}, []); |
}, []); |
||||
|
|
||||
|
useEffect(() => { |
||||
|
getData() |
||||
|
}, [query]) |
||||
|
|
||||
|
const getData = () => { |
||||
|
setLoading(true) |
||||
|
dispatch(getAssess(query)).then(res => { |
||||
|
setLoading(false) |
||||
|
}) |
||||
|
} |
||||
|
|
||||
return ( |
return ( |
||||
<div> |
<div> |
||||
|
<div style={{ marginBottom: '20px', display: 'flex', justifyContent: 'space-between' }}> |
||||
|
<Form layout="inline" onFinish={(v) => { |
||||
|
setQuery({ ...query, unit: v.unit, month: v.month ? moment(v.month).format() : undefined }) |
||||
|
}}> |
||||
|
<Form.Item name="unit" label="责任单位" > |
||||
|
<Select style={{ width: 200 }} placeholder="全部" allowClear> |
||||
|
{ |
||||
|
unitList.map(item => ( |
||||
|
<Option value={item} key={item} /> |
||||
|
)) |
||||
|
} |
||||
|
</Select> |
||||
|
</Form.Item> |
||||
|
|
||||
|
<Form.Item name="month" label="考核月份"> |
||||
|
<DatePicker picker="month" style={{ width: 200 }} /> |
||||
|
</Form.Item> |
||||
|
|
||||
|
<Form.Item> |
||||
|
<Button type="primary" htmlType="submit">搜索</Button> |
||||
|
</Form.Item> |
||||
|
</Form> |
||||
|
|
||||
|
<Button type="primary" onClick={() => { |
||||
|
setAssessModalVisible(true) |
||||
|
}}>新增</Button> |
||||
|
</div> |
||||
|
<ProTable |
||||
|
columns={[{ |
||||
|
title: '责任单位', |
||||
|
dataIndex: 'unit', |
||||
|
key: 'unit', |
||||
|
}, |
||||
|
{ |
||||
|
title: '考核月份', |
||||
|
dataIndex: 'month', |
||||
|
key: 'month', |
||||
|
render: (text, record) => ( |
||||
|
text ? moment(record.month).format('YYYY-MM') : '' |
||||
|
) |
||||
|
}, |
||||
|
{ |
||||
|
title: '考核得分', |
||||
|
dataIndex: 'totalPoints', |
||||
|
key: 'totalPoints', |
||||
|
}, |
||||
|
{ |
||||
|
title: '操作', |
||||
|
key: 'action', |
||||
|
render: (text, record) => ( |
||||
|
<span> |
||||
|
<Button type="link" onClick={() => { |
||||
|
setAssessModalVisible(true) |
||||
|
setEditData(record) |
||||
|
setIsCheck(true) |
||||
|
}}>详情</Button> |
||||
|
<Button type="link" onClick={() => { |
||||
|
setAssessModalVisible(true) |
||||
|
setEditData(record) |
||||
|
}}>编辑</Button> |
||||
|
<Popconfirm |
||||
|
title="确定删除此条数据吗?" |
||||
|
onConfirm={() => { |
||||
|
setLoading(true) |
||||
|
dispatch(delAssess({ id: record.id })).then(res => { |
||||
|
setLoading(false) |
||||
|
if (res.success) { |
||||
|
getData() |
||||
|
} |
||||
|
}) |
||||
|
}} |
||||
|
> |
||||
|
<Button type="link" danger>删除</Button> |
||||
|
</Popconfirm> |
||||
|
</span> |
||||
|
), |
||||
|
},]} |
||||
|
dataSource={assess.rows || []} |
||||
|
loading={loading} |
||||
|
pagination={{ |
||||
|
total: assess?.count || 0, |
||||
|
pageSize: 10, |
||||
|
defaultPageSize: 10, |
||||
|
showSizeChanger: false, |
||||
|
onChange: (page, pageSize) => { |
||||
|
setQuery({ |
||||
|
...query, |
||||
|
page, limit: pageSize |
||||
|
}) |
||||
|
} |
||||
|
}} |
||||
|
rowKey="key" |
||||
|
toolBarRender={false} |
||||
|
search={false} |
||||
|
/> |
||||
|
{ |
||||
|
assessModalVisible ? <AssessModal check={isCheck} visible={assessModalVisible} editData={editData} onCancel={() => { |
||||
|
getData() |
||||
|
setIsCheck(false) |
||||
|
setEditData(null) |
||||
|
setAssessModalVisible(false) |
||||
|
}} /> : '' |
||||
|
} |
||||
</div> |
</div> |
||||
); |
); |
||||
} |
} |
||||
function mapStateToProps (state) { |
function mapStateToProps (state) { |
||||
const { auth } = state |
const { auth, assess } = state |
||||
return { |
return { |
||||
user: auth.user, |
user: auth.user, |
||||
|
assess: assess.data || [], |
||||
} |
} |
||||
} |
} |
||||
export default connect(mapStateToProps)(Assess); |
export default connect(mapStateToProps)(Assess); |
@ -0,0 +1,41 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
import React, { useState, useEffect } from 'react'; |
||||
|
import { connect } from 'react-redux'; |
||||
|
// import { Spin, Button, Popconfirm } from 'antd';
|
||||
|
// import ProTable from '@ant-design/pro-table';
|
||||
|
// //import './protable.less'
|
||||
|
import moment from 'moment'; |
||||
|
// import { getRoadway, getProject, delRoadway, delProject } from "../actions/infor"
|
||||
|
// import UserModal from './infor/details';
|
||||
|
// import ProjectModal from './project/project';
|
||||
|
|
||||
|
const Building = (props) => { |
||||
|
|
||||
|
return ( |
||||
|
<div> |
||||
|
hha |
||||
|
</div> |
||||
|
) |
||||
|
} |
||||
|
function mapStateToProps(state) { |
||||
|
const { auth, depMessage } = state; |
||||
|
// const pakData = (dep) => {
|
||||
|
// return dep.map((d) => {
|
||||
|
// return {
|
||||
|
// title: d.name,
|
||||
|
// value: d.id,
|
||||
|
// // children: d.type >= 2 ? [] : pakData(d.subordinate)
|
||||
|
// children: pakData(d.subordinate)
|
||||
|
// }
|
||||
|
// })
|
||||
|
// }
|
||||
|
// let depData = pakData(depMessage.data || [])
|
||||
|
return { |
||||
|
user: auth.user, |
||||
|
// depMessage: depMessage.data || [],
|
||||
|
// depLoading: depMessage.isRequesting,
|
||||
|
// depData,
|
||||
|
}; |
||||
|
} |
||||
|
export default connect(mapStateToProps)(Building); |
@ -0,0 +1,30 @@ |
|||||
|
import React, { useState, useEffect } from 'react'; |
||||
|
import { connect } from 'react-redux'; |
||||
|
import { getAssess, delAssess, editAssess } from '../actions/assess'; |
||||
|
import ProTable from '@ant-design/pro-table'; |
||||
|
import AssessModal from '../components/assessModal'; |
||||
|
import { Form, Space, DatePicker, Button, Select, Popconfirm } from 'antd' |
||||
|
import moment from 'moment'; |
||||
|
|
||||
|
function VideoCenter (props) { |
||||
|
const { dispatch, vcmpWebUrl, vcmpMirrorId } = props; |
||||
|
|
||||
|
useEffect(() => { |
||||
|
return () => { }; |
||||
|
}, []); |
||||
|
|
||||
|
return ( |
||||
|
<div> |
||||
|
<iframe src={`${vcmpWebUrl}/callService?mid=${vcmpMirrorId}`} style={{ height: 'calc(100vh - 142px)', width: '100%', display: 'block' }} frameBorder={0}></iframe> |
||||
|
</div> |
||||
|
); |
||||
|
} |
||||
|
function mapStateToProps (state) { |
||||
|
const { auth, global } = state |
||||
|
return { |
||||
|
user: auth.user, |
||||
|
vcmpWebUrl: global.vcmpWebUrl, |
||||
|
vcmpMirrorId: global.vcmpMirrorId, |
||||
|
} |
||||
|
} |
||||
|
export default connect(mapStateToProps)(VideoCenter); |
@ -1,61 +1,123 @@ |
|||||
import React from 'react' |
import React from 'react' |
||||
import Module from '../../../public/module' |
import Module from '../../../public/module' |
||||
import { Col, Row } from 'antd' |
import { Col, Row } from 'antd' |
||||
|
import { useEffect, useState } from 'react' |
||||
|
import { connect } from 'react-redux' |
||||
|
import ReactECharts from 'echarts-for-react'; |
||||
|
import { getNearestAssessData } from "../../../../actions/example" |
||||
|
|
||||
// const unit =['个','个',]
|
// const unit =['个','个',]
|
||||
const icon = [ |
const icon = [ |
||||
'assets/images/quanju/jiancha.png', |
'assets/images/quanju/jiancha.png', |
||||
'assets/images/quanju/yushui.png', |
'assets/images/quanju/yushui.png', |
||||
'assets/images/quanju/lupai.png', |
'assets/images/quanju/lupai.png', |
||||
'assets/images/quanju/zerenpai.png' |
'assets/images/quanju/zerenpai.png' |
||||
] |
] |
||||
const RightCenter = (props) => { |
const RightCenter = (props) => { |
||||
const { highwaysData } = props |
const { highwaysData, dispatch } = props |
||||
const style = { height: "31%", marginTop: "3%" } |
|
||||
const textStyle = { fontSize: 14, color: '#E9F7FF' } |
const [data, setData] = useState([]) |
||||
const numStyle = { color: '#fff', fontSize: 21, fontFamily: 'YouSheBiaoTiHei', textShadow: '0px 0px 8px #1C60FE', marginTop: 8 } |
|
||||
let list = highwaysData?.sort((a, b) => a.id - b.id) |
const style = { height: "31%", marginTop: "3%" } |
||||
list = highwaysData?.slice(4, 8).map((h,index)=>{ |
// const textStyle = { fontSize: 14, color: '#E9F7FF' }
|
||||
|
// const numStyle = { color: '#fff', fontSize: 21, fontFamily: 'YouSheBiaoTiHei', textShadow: '0px 0px 8px #1C60FE', marginTop: 8 }
|
||||
|
// let list = highwaysData?.sort((a, b) => a.id - b.id)
|
||||
|
// list = highwaysData?.slice(4, 8).map((h, index) => {
|
||||
|
// return {
|
||||
|
// id: h.id,
|
||||
|
// name: h.name,
|
||||
|
// count: h.count,
|
||||
|
// // unit:unit[index],
|
||||
|
// icon: icon[index]
|
||||
|
// }
|
||||
|
// })
|
||||
|
// const arrayChunk = (array, size) => {
|
||||
|
// let data = []
|
||||
|
// for (let i = 0; i < array.length; i += size) {
|
||||
|
// data.push(array.slice(i, i + size))
|
||||
|
// }
|
||||
|
// return data
|
||||
|
// }
|
||||
|
// let lists = list ? arrayChunk(list, 2) : []
|
||||
|
|
||||
|
|
||||
|
useEffect(() => { |
||||
|
dispatch(getNearestAssessData()).then(res => { |
||||
|
if (res.success) { |
||||
|
setData(res.payload.data) |
||||
|
} |
||||
|
}) |
||||
|
}, []) |
||||
|
|
||||
|
|
||||
|
return ( |
||||
|
<> |
||||
|
<Module style={style} title={"各乡镇考核得分情况"}> |
||||
|
<div style={{ paddingLeft: '8%' }}> |
||||
|
{/* { |
||||
|
lists?.map((item, index) => { |
||||
|
return <div style={{ display: 'flex', marginTop: "5%", justifyContent: 'space-around' }} key={index}> |
||||
|
{ |
||||
|
item?.map(i => ( |
||||
|
<div style={{ display: 'flex', width: '50%' }} key={i.id}> |
||||
|
<img src={'/' + i.icon} alt='icon' style={{ width: '36%', height: '100%' }} /> |
||||
|
<div style={{ marginLeft: 10 }}> |
||||
|
<div style={textStyle}>{i.name}</div> |
||||
|
<div style={numStyle}>{`${i.count}个`}</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
)) |
||||
|
} |
||||
|
</div> |
||||
|
}) |
||||
|
} */} |
||||
|
<ReactECharts |
||||
|
notMerge={true} |
||||
|
lazyUpdate={true} |
||||
|
option={{ |
||||
|
xAxis: { |
||||
|
type: 'category', |
||||
|
data: data.map(d => d.unit), |
||||
|
axisTick: { |
||||
|
show: false |
||||
|
} |
||||
|
}, |
||||
|
yAxis: { |
||||
|
type: 'value', |
||||
|
splitLine: { |
||||
|
show: false |
||||
|
} |
||||
|
}, |
||||
|
tooltip: { |
||||
|
trigger: "axis" |
||||
|
}, |
||||
|
series: [ |
||||
|
{ |
||||
|
data: data.map(d => d.totalPoints), |
||||
|
type: 'bar', |
||||
|
showBackground: true, |
||||
|
backgroundStyle: { |
||||
|
color: 'rgba(180, 180, 180, 0.2)' |
||||
|
} |
||||
|
} |
||||
|
], |
||||
|
grid: { |
||||
|
left: '3%', |
||||
|
right: '4%', |
||||
|
bottom: '21%', |
||||
|
top: '4%', |
||||
|
containLabel: true |
||||
|
}, |
||||
|
}} |
||||
|
/> |
||||
|
</div> |
||||
|
</Module> |
||||
|
</> |
||||
|
) |
||||
|
} |
||||
|
function mapStateToProps (state) { |
||||
return { |
return { |
||||
id:h.id, |
|
||||
name:h.name, |
|
||||
count:h.count, |
|
||||
// unit:unit[index],
|
|
||||
icon:icon[index] |
|
||||
} |
|
||||
}) |
|
||||
const arrayChunk = (array, size) => { |
|
||||
let data = [] |
|
||||
for (let i = 0; i < array.length; i += size) { |
|
||||
data.push(array.slice(i, i + size)) |
|
||||
} |
} |
||||
return data |
|
||||
} |
|
||||
let lists = list ? arrayChunk(list, 2) : [] |
|
||||
return ( |
|
||||
<> |
|
||||
<Module style={style} title={"各类附属设施数量统计"}> |
|
||||
<div style={{ paddingLeft: '8%' }}> |
|
||||
{ |
|
||||
lists?.map((item, index) => { |
|
||||
return <div style={{ display: 'flex', marginTop: "5%", justifyContent: 'space-around' }} key={index}> |
|
||||
{ |
|
||||
item?.map(i => ( |
|
||||
<div style={{ display: 'flex', width: '50%' }} key={i.id}> |
|
||||
<img src={'/'+i.icon} alt='icon' style={{ width: '36%', height: '100%' }} /> |
|
||||
<div style={{ marginLeft: 10 }}> |
|
||||
<div style={textStyle}>{i.name}</div> |
|
||||
<div style={numStyle}>{`${i.count}个`}</div> |
|
||||
</div> |
|
||||
</div> |
|
||||
)) |
|
||||
} |
|
||||
</div> |
|
||||
}) |
|
||||
} |
|
||||
</div> |
|
||||
</Module> |
|
||||
</> |
|
||||
) |
|
||||
} |
} |
||||
export default RightCenter |
export default connect(mapStateToProps)(RightCenter) |
@ -1,19 +1,30 @@ |
|||||
import React from 'react' |
import React, { useEffect, useState } from 'react' |
||||
import Left from './left' |
import Left from './left' |
||||
import Right from './right' |
import Right from './right' |
||||
import CenterLeft from "./centerLeft" |
import CenterLeft from "./centerLeft" |
||||
import Centerright from "./centerRight" |
import Centerright from "./centerRight" |
||||
|
import { connect } from 'react-redux' |
||||
|
import { getNearestAssessData, getVideoCenterList } from "../../../actions/example" |
||||
|
|
||||
const Leadership = (props) => { |
const Leadership = (props) => { |
||||
const { dispatch } = props |
const { dispatch } = props |
||||
|
|
||||
|
useEffect(() => { |
||||
|
dispatch(getVideoCenterList()) |
||||
|
}, []) |
||||
|
|
||||
return ( |
return ( |
||||
<> |
<> |
||||
<Left dispatch={dispatch} /> |
<Left dispatch={dispatch} /> |
||||
<CenterLeft dispatch={dispatch} /> |
<CenterLeft dispatch={dispatch} /> |
||||
<Right dispatch={dispatch} /> |
<Right dispatch={dispatch} /> |
||||
{/* <Centerright /> */} |
{/* <Centerright /> */} |
||||
|
|
||||
</> |
</> |
||||
) |
) |
||||
} |
} |
||||
export default Leadership |
function mapStateToProps (state) { |
||||
|
return { |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
export default connect(mapStateToProps)(Leadership) |
@ -1,95 +1,130 @@ |
|||||
import React, { useEffect, useState } from 'react' |
import React, { useEffect, useState } from 'react' |
||||
import Module from '../../../public/module' |
import Module from '../../../public/module' |
||||
import Lunbo from "../right/lunbo" |
import Lunbo from "../right/lunbo" |
||||
|
import { connect } from 'react-redux' |
||||
|
import { YSIframePlayer } from '../../../../../../components' |
||||
// import "./left.less"
|
// import "./left.less"
|
||||
|
|
||||
const Leftcenter = () => { |
const Leftcenter = ({ videoCenterList }) => { |
||||
const style = { height: "30%", marginTop: "5%" } |
const style = { height: "30%", marginTop: "5%" } |
||||
// const hualun = "auto"
|
// const hualun = "auto"
|
||||
const [num, setNum] = useState(1); |
const [num, setNum] = useState(1); |
||||
const [tu, setTu] = useState(""); |
const [tu, setTu] = useState(""); |
||||
const [name, setName] = useState(""); |
const [name, setName] = useState(""); |
||||
const [list, setList] = useState([ |
const [list, setList] = useState([ |
||||
{ name: '沙潭至五星', img: "/assets/images/leadership/fake/1.jpg" }, |
// { name: '沙潭至五星', img: "/assets/images/leadership/fake/1.jpg" },
|
||||
{ name: '滁槎至协城', img: "/assets/images/leadership/fake/2.jpg" }, |
// { name: '滁槎至协城', img: "/assets/images/leadership/fake/2.jpg" },
|
||||
{ name: '瓜山至广福', img: "/assets/images/leadership/fake/3.jpg" }, |
// { name: '瓜山至广福', img: "/assets/images/leadership/fake/3.jpg" },
|
||||
{ name: '罗舍至泗洪', img: "/assets/images/leadership/fake/4.jpg" }, |
// { name: '罗舍至泗洪', img: "/assets/images/leadership/fake/4.jpg" },
|
||||
{ name: '渔业至万州', img: "/assets/images/leadership/fake/5.jpg" }, |
// { name: '渔业至万州', img: "/assets/images/leadership/fake/5.jpg" },
|
||||
// { name: '小蓝至东新', img: "/assets/images/leadership/shiyantu.png" },
|
|
||||
]) |
|
||||
useEffect(() => { |
|
||||
const timer = setInterval(() => { |
|
||||
if (num == list.length) { |
|
||||
setNum(1); |
|
||||
setTu(list[0].img); |
|
||||
} else { |
|
||||
setNum(num + 1); |
|
||||
setTu(list[num].img); |
|
||||
} |
|
||||
}, 2000); |
|
||||
return () => clearInterval(timer); |
|
||||
}, [num]); |
|
||||
const renderBody = () => { |
|
||||
return ( |
|
||||
<div style={{ width: "100%", height: "55%" }}>{ |
|
||||
list.map((item, index) => { |
|
||||
return ( |
|
||||
// <div style={{ width: "100%", height: "100%" }} >
|
|
||||
// {/* <div style={{ width: "100%", height: "100%", }}> */}
|
|
||||
<li style={{ height: "20px", position: "relative", width: "100%", marginTop: index == 0 ? "4px" : "5px", listStyle: "none", borderLeft: num - 1 == index ? "2px solid #1C60FE" : "2px solid #113892", backgroundColor: "linear-gradient(to right, rgba(0,70,200,0.3000) , rgba(0,124,230,0))" }} onMouseEnter={() => { |
|
||||
setTu(item.img); |
|
||||
setNum(index + 1); |
|
||||
setName(item.name) |
|
||||
// console.log(list);
|
|
||||
}}> |
|
||||
<p style={{ position: "absolute", color: num - 1 == index ? "#fff" : "rgba(216,240,255,0.8)", left: "10%" }}>{item.name}</p> |
|
||||
<img src='/assets/images/leadership/juxing.png' style={{ width: "100%", height: "100%", position: "absolute" }} /> |
|
||||
</li> |
|
||||
// {/* </div> */}
|
|
||||
// </div>
|
|
||||
) |
|
||||
|
|
||||
}) |
// { name: '小蓝至东新', img: "/assets/images/leadership/shiyantu.png" },
|
||||
} |
]) |
||||
</div > |
|
||||
) |
|
||||
} |
|
||||
return ( |
|
||||
<> |
|
||||
<div style={{ width: "100%", height: "40px"/* , backgroundColor: "#fff" */, position: "relative" }}> |
|
||||
{/* <p>{title || []}</p> */} |
|
||||
<img src='/assets/images/quanju/icon.png' style={{ width: "24px", position: "absolute", left: "20px", top: "20%" }} /> |
|
||||
<span style={{ position: "absolute", color: "#FFFFFF", fontSize: "24px", fontFamily: "YouSheBiaoTiHei", left: "50px" }}>主要路段拥堵情况分析</span> |
|
||||
<img src='/assets/images/leadership/zibiaoti.png' style={{ width: "93%", height: "35px", position: "absolute", top: "8px", left: "35px" }} /> |
|
||||
</div> |
|
||||
<div style={{ width: "100%", height: "100%", marginTop: "3%" }}> |
|
||||
<div style={{ width: "60%", height: "100%", float: "left", marginLeft: "1%" }}> |
|
||||
{ |
|
||||
list.map((item, index) => { |
|
||||
return index + 1 == num ? |
|
||||
<div style={{ width: "100%", height: "100%", position: "relative" }}> |
|
||||
|
|
||||
<img style={{ width: "100%",height:'100%', position: "absolute", bottom: "5%" }} src={item.img} /> |
useEffect(() => { |
||||
<p style={{ |
if (videoCenterList.length) { |
||||
width: "100%", height: "3vh", position: "absolute", bottom: "3%", |
setList(videoCenterList.slice(0, 5)) |
||||
backgroundColor: "rgba(0,0,0,0.26)", lineHeight: "3vh", textAlign: "" |
} |
||||
}}> |
}, [videoCenterList]) |
||||
<img src='/assets/images/leadership/weizhis.png' style={{ width: "5%", height: "60%", marginLeft: "3%" }} /> |
|
||||
<span style={{ marginLeft: "3%", color: "#FFFFFF", fontSize: "12px", fontFamily: "PingFangSC-Regular, PingFang SC", fontWeight: 400 }}>{item.name}</span></p> |
|
||||
</div> : "" |
|
||||
|
|
||||
}) |
useEffect(() => { |
||||
} |
const timer = setInterval(() => { |
||||
|
if (num == list.length) { |
||||
|
setNum(1); |
||||
|
// setTu(list[0].img);
|
||||
|
} else { |
||||
|
setNum(num + 1); |
||||
|
// setTu(list[num].img);
|
||||
|
} |
||||
|
}, 2000 * 10); |
||||
|
return () => clearInterval(timer); |
||||
|
}, [num]); |
||||
|
|
||||
|
const renderBody = () => { |
||||
|
return ( |
||||
|
<div style={{ width: "100%", height: "55%" }}>{ |
||||
|
list.map((item, index) => { |
||||
|
return ( |
||||
|
// <div style={{ width: "100%", height: "100%" }} >
|
||||
|
// {/* <div style={{ width: "100%", height: "100%", }}> */}
|
||||
|
<li style={{ height: "20px", position: "relative", width: "100%", marginTop: index == 0 ? "4px" : "5px", listStyle: "none", borderLeft: num - 1 == index ? "2px solid #1C60FE" : "2px solid #113892", backgroundColor: "linear-gradient(to right, rgba(0,70,200,0.3000) , rgba(0,124,230,0))" }} onMouseEnter={() => { |
||||
|
setTu(item.img); |
||||
|
setNum(index + 1); |
||||
|
setName(item.deviceName) |
||||
|
// console.log(list);
|
||||
|
}}> |
||||
|
<p style={{ position: "absolute", color: num - 1 == index ? "#fff" : "rgba(216,240,255,0.8)", left: "10%" }}>{item.deviceName}</p> |
||||
|
<img src='/assets/images/leadership/juxing.png' style={{ width: "100%", height: "100%", position: "absolute" }} /> |
||||
|
</li> |
||||
|
// {/* </div> */}
|
||||
|
// </div>
|
||||
|
) |
||||
|
|
||||
|
}) |
||||
|
} |
||||
|
</div > |
||||
|
) |
||||
|
} |
||||
|
return ( |
||||
|
<> |
||||
|
<div style={{ width: "100%", height: "40px"/* , backgroundColor: "#fff" */, position: "relative" }}> |
||||
|
{/* <p>{title || []}</p> */} |
||||
|
<img src='/assets/images/quanju/icon.png' style={{ width: "24px", position: "absolute", left: "20px", top: "20%" }} /> |
||||
|
<span style={{ position: "absolute", color: "#FFFFFF", fontSize: "24px", fontFamily: "YouSheBiaoTiHei", left: "50px" }}>主要路段拥堵情况</span> |
||||
|
<img src='/assets/images/leadership/zibiaoti.png' style={{ width: "93%", height: "35px", position: "absolute", top: "8px", left: "35px" }} /> |
||||
</div> |
</div> |
||||
<Lunbo |
<div style={{ width: "100%", height: "100%", marginTop: "3%" }}> |
||||
// canScroll={true}
|
<div style={{ width: "60%", height: "100%", float: "left", marginLeft: "1%" }}> |
||||
content={renderBody()} |
{ |
||||
containerStyle={{ position: "relative", height: "100%", width: "35%", float: "right", marginRight: "2%", marginTop: "1%" }} |
list.map((item, index) => { |
||||
divHeight={"100%"} |
console.log(item); |
||||
divId={"screen-slope-midde-top-jiangxi"} |
return index + 1 == num ? |
||||
/> |
<div style={{ width: "100%", height: "100%", position: "relative" }}> |
||||
</div> |
|
||||
</> |
{/* <img style={{ width: "100%", height: '100%', position: "absolute", bottom: "5%" }} src={item.img} /> */} |
||||
) |
|
||||
|
<YSIframePlayer |
||||
|
containerId={`yingshiPlay_${index}`} |
||||
|
height='100%' |
||||
|
width="100%" |
||||
|
url={`ezopen://open.ys7.com/${item.deviceSerial}/${item.channelNo || '1'}.live`} |
||||
|
audio="0" |
||||
|
ysToken={item.token} |
||||
|
videoState={{ |
||||
|
status: item.status |
||||
|
}} |
||||
|
/> |
||||
|
|
||||
|
<p style={{ |
||||
|
width: "100%", height: "3vh", position: "absolute", bottom: "3%", |
||||
|
backgroundColor: "rgba(0,0,0,0.26)", lineHeight: "3vh", textAlign: "" |
||||
|
}}> |
||||
|
<img src='/assets/images/leadership/weizhis.png' style={{ width: "5%", height: "60%", marginLeft: "3%" }} /> |
||||
|
<span style={{ marginLeft: "3%", color: "#FFFFFF", fontSize: "12px", fontFamily: "PingFangSC-Regular, PingFang SC", fontWeight: 400 }}> |
||||
|
{item.deviceName} |
||||
|
</span> |
||||
|
</p> |
||||
|
|
||||
|
</div> : "" |
||||
|
}) |
||||
|
} |
||||
|
</div> |
||||
|
<Lunbo |
||||
|
// canScroll={true}
|
||||
|
content={renderBody()} |
||||
|
containerStyle={{ position: "relative", height: "100%", width: "35%", float: "right", marginRight: "2%", marginTop: "1%" }} |
||||
|
divHeight={"100%"} |
||||
|
divId={"screen-slope-midde-top-jiangxi"} |
||||
|
/> |
||||
|
</div> |
||||
|
</> |
||||
|
) |
||||
|
} |
||||
|
function mapStateToProps (state) { |
||||
|
const { videoCenterList } = state |
||||
|
|
||||
|
return { |
||||
|
videoCenterList: videoCenterList.data || [] |
||||
|
} |
||||
} |
} |
||||
export default Leftcenter |
export default connect(mapStateToProps)(Leftcenter) |
@ -0,0 +1,202 @@ |
|||||
|
import React, { Component } from 'react'; |
||||
|
import './left.less'; |
||||
|
import { connect } from 'react-redux' |
||||
|
import { YSIframePlayer } from '../../../../../../components' |
||||
|
|
||||
|
class ReactCarousel extends Component { |
||||
|
chunk (arr, size) { |
||||
|
var arr1 = new Array(); |
||||
|
for (var i = 0; i < Math.ceil(arr.length / size); i++) { |
||||
|
arr1[i] = new Array(); |
||||
|
} |
||||
|
var j = 0; |
||||
|
var x = 0; |
||||
|
for (var i = 0; i < arr.length; i++) { |
||||
|
if (!((i % size == 0) && (i != 0))) { |
||||
|
arr1[j][x] = arr[i]; |
||||
|
x++; |
||||
|
} else { |
||||
|
j++; |
||||
|
x = 0; |
||||
|
arr1[j][x] = arr[i]; |
||||
|
x++; |
||||
|
} |
||||
|
} |
||||
|
return arr1; |
||||
|
} |
||||
|
|
||||
|
constructor() { |
||||
|
super(); |
||||
|
this.state = { |
||||
|
imgs: [], |
||||
|
showIndex: 0, //显示第几个图片
|
||||
|
timer: null, // 定时器
|
||||
|
show: false, // 前后按钮显示
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
renderVideo = (item, index) => { |
||||
|
return <YSIframePlayer |
||||
|
containerId={`yingshiPlay_lu_${index}`} |
||||
|
height='100%' |
||||
|
width="100%" |
||||
|
url={`ezopen://open.ys7.com/${item.deviceSerial}/${item.channelNo || '1'}.live`} |
||||
|
audio="0" |
||||
|
ysToken={item.token} |
||||
|
videoState={{ |
||||
|
status: item.status |
||||
|
}} |
||||
|
/> |
||||
|
} |
||||
|
|
||||
|
render () { |
||||
|
console.log(this.props); |
||||
|
const { imgs } = this.state |
||||
|
return ( |
||||
|
<div className="ReactCarousel" style={{ width: "100%", height: "100%" }}> |
||||
|
<div className="contain" |
||||
|
onMouseEnter={() => { this.stop() }} //鼠标进入停止自动播放
|
||||
|
onMouseLeave={() => { this.start() }} //鼠标退出自动播放
|
||||
|
> |
||||
|
<ul className="ul"> |
||||
|
{ |
||||
|
this.state.imgs.map((value, index) => { |
||||
|
return ( |
||||
|
<li style={{ position: "relative", left: "8%", width: "100%", height: "100%", top: "-5%", fontSize: "12px" }} className={index === this.state.showIndex ? 'show' : ''} |
||||
|
key={index} |
||||
|
> |
||||
|
{ |
||||
|
imgs.map((value, index) => { |
||||
|
if (index == 0) { |
||||
|
return value?.deviceSerial ? <div style={{ width: "45%", height: "40%", backgroundSize: 'cover', position: "absolute", left: "-3%", top: "5%" }}> |
||||
|
{this.renderVideo(value, index)} |
||||
|
<div style={{ width: "100%", height: "100%", position: "absolute", top: "80%" }}> |
||||
|
<div style={{ width: "100%", height: "20%", backgroundColor: "rgba(0,0,0,0.6)", overflow: "hiddden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}> |
||||
|
<img src='/assets/images/leadership/weizhis.png' style={{ width: "6%", height: "80%", marginLeft: "3%", marginRight: "3%" }} /> |
||||
|
{value?.deviceName} |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> : '' |
||||
|
} else if (index == 1) { |
||||
|
return value?.deviceSerial ? <div style={{ width: "45%", height: "40%", backgroundSize: 'cover', position: "absolute", left: "45%", top: "5%" }}> |
||||
|
{this.renderVideo(value, index)} |
||||
|
<div style={{ width: "100%", height: "100%", position: "absolute", top: "80%" }}> |
||||
|
<div style={{ width: "100%", height: "20%", backgroundColor: "rgba(0,0,0,0.6)", overflow: "hiddden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}> |
||||
|
<img src='/assets/images/leadership/weizhis.png' style={{ width: "6%", height: "80%", marginLeft: "3%", marginRight: "3%" }} /> |
||||
|
{value?.deviceName} |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> : "" |
||||
|
} else if (index == 2) { |
||||
|
return value?.deviceSerial ? <div style={{ width: "45%", height: "40%", backgroundSize: 'cover', position: "absolute", left: "-3%", top: "49%" }}> |
||||
|
{this.renderVideo(value, index)} |
||||
|
<div style={{ width: "100%", height: "100%", position: "absolute", top: "80%" }}> |
||||
|
<div style={{ width: "100%", height: "20%", backgroundColor: "rgba(0,0,0,0.6)", overflow: "hiddden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}> |
||||
|
<img src='/assets/images/leadership/weizhis.png' style={{ width: "6%", height: "80%", marginLeft: "3%", marginRight: "3%" }} /> |
||||
|
{value?.deviceName} |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> : "" |
||||
|
} else if (index == 3) { |
||||
|
return value?.deviceSerial ? <div style={{ width: "45%", height: "40%", backgroundSize: 'cover', position: "absolute", left: "45%", top: "49%" }}> |
||||
|
{this.renderVideo(value, index)} |
||||
|
<div style={{ width: "100%", height: "100%", position: "absolute", top: "80%" }}> |
||||
|
<div style={{ width: "100%", height: "20%", backgroundColor: "rgba(0,0,0,0.6)", overflow: "hiddden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}> |
||||
|
<img src='/assets/images/leadership/weizhis.png' style={{ width: "6%", height: "80%", marginLeft: "3%", marginRight: "3%" }} /> |
||||
|
{value?.deviceName} |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> : "" |
||||
|
} else { |
||||
|
return undefined |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
</li> |
||||
|
) |
||||
|
}) |
||||
|
} |
||||
|
</ul> |
||||
|
{/* <div className="control" style={{ width: "100%", height: "10%" }}> |
||||
|
<span style={{ position: "absolute", top: "86%", width: "3%", height: "8%" }} className="left" onClick={(e) => { this.previous(e) }}> |
||||
|
<img src='/assets/images/leadership/zuofanye.png' style={{ width: "100%", height: "100%" }} /> |
||||
|
</span> |
||||
|
<span style={{ position: "absolute", top: "86%", width: "3%", height: "8%", right: "6%" }} className="right" onClick={(e) => { this.next(e) }}> |
||||
|
<img src='/assets/images/leadership/youofanye.png' style={{ width: "100%", height: "100%" }} /> |
||||
|
</span> |
||||
|
</div> */} |
||||
|
</div> |
||||
|
</div> |
||||
|
) |
||||
|
} |
||||
|
|
||||
|
componentWillReceiveProps (nextProps, oldProps) { |
||||
|
if (nextProps.videoCenterList && nextProps.videoCenterList.length && (!oldProps.videoCenterList || !oldProps.videoCenterList.length)) { |
||||
|
this.setState({ |
||||
|
imgs: nextProps.videoCenterList.slice(-4) |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
componentDidMount () { //一开始自动播放
|
||||
|
setTimeout(() => { |
||||
|
this.start(); |
||||
|
}, 0) |
||||
|
} |
||||
|
|
||||
|
componentWillUnmount () { //销毁前清除定时器
|
||||
|
this.stop(); |
||||
|
} |
||||
|
stop = () => { //暂停
|
||||
|
let { timer } = this.state; |
||||
|
clearInterval(timer); |
||||
|
} |
||||
|
start = () => { //开始
|
||||
|
let { timer } = this.state; |
||||
|
timer = setInterval(() => { |
||||
|
this.next(); |
||||
|
}, 300000); |
||||
|
this.setState({ |
||||
|
timer |
||||
|
}) |
||||
|
} |
||||
|
change = (index) => { //点击下面的按钮切换当前显示的图片
|
||||
|
let { showIndex } = this.state; |
||||
|
showIndex = index; |
||||
|
this.setState({ |
||||
|
showIndex |
||||
|
}) |
||||
|
} |
||||
|
previous = (e) => { //上一张
|
||||
|
let ev = e || window.event; |
||||
|
let { showIndex, imgs } = this.state; |
||||
|
if (showIndex <= 0) { |
||||
|
showIndex = imgs.length - 1; |
||||
|
} else { |
||||
|
showIndex--; |
||||
|
} |
||||
|
this.setState({ |
||||
|
showIndex |
||||
|
}) |
||||
|
} |
||||
|
next = (e) => { //下一张
|
||||
|
let ev = e || window.event; |
||||
|
let { showIndex, imgs } = this.state; |
||||
|
if (showIndex >= imgs.length - 1) { |
||||
|
showIndex = 0; |
||||
|
} else { |
||||
|
showIndex++; |
||||
|
} |
||||
|
this.setState({ |
||||
|
showIndex |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
function mapStateToProps (state) { |
||||
|
const { videoCenterList } = state |
||||
|
|
||||
|
return { |
||||
|
videoCenterList: videoCenterList.data || [] |
||||
|
} |
||||
|
} |
||||
|
export default connect(mapStateToProps)(ReactCarousel) |
Loading…
Reference in new issue