模拟对接 预警人数据

This commit is contained in:
wangsongsole 2022-05-25 10:52:35 +08:00
parent 11cf60815e
commit db4f0c904a
1 changed files with 104 additions and 5 deletions

View File

@ -7,6 +7,8 @@ import FormItem from '../../../components/form-item/main'
import rules from './rules' import rules from './rules'
import moment from 'moment' import moment from 'moment'
import { deWeightThree } from '../../../utils' import { deWeightThree } from '../../../utils'
import { isSameDay } from 'date-fns'
import Bus from '../../../assets/eventBus.js'
import { import {
Select, Select,
Button, Button,
@ -40,6 +42,10 @@ const receiveTypeList = [
] ]
// //
const earlyPerList = ['70', '50', '30', '20'] const earlyPerList = ['70', '50', '30', '20']
const initArray = (targetNum) => {
return Array.from({ length: targetNum }, (_, index) => index)
}
export default class addKnockGold extends Component { export default class addKnockGold extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
@ -127,8 +133,6 @@ export default class addKnockGold extends Component {
} else { } else {
model.effect_date_type = '' model.effect_date_type = ''
} }
console.log(model.effect_date_type)
model.effect_date = this.props.data.time_limit.use_time.effect_day model.effect_date = this.props.data.time_limit.use_time.effect_day
model.usable_time = this.props.data.time_limit.use_time.type model.usable_time = this.props.data.time_limit.use_time.type
model.early_notifier = this.props.data.early_notifier.map((item) => { model.early_notifier = this.props.data.early_notifier.map((item) => {
@ -151,7 +155,60 @@ export default class addKnockGold extends Component {
} }
// //
getUserSelectList() {} getUserSelectList() {
const data = [
{
real_name: '黎明',
mobile: '18555454545'
},
{
real_name: '彤彤',
mobile: '18547777744'
},
{
real_name: '杨洋',
mobile: '15874574122'
},
{
real_name: '何欢媛',
mobile: '18695241254'
},
{
real_name: '林青松',
mobile: '15184342032'
},
{
real_name: '韦多伦',
mobile: '15874747474'
},
{
real_name: 'zh',
mobile: '15184345036'
}
]
const defaultDta = ['何欢媛', '韦多伦']
const model = this.state.model
const newData = data.map((item) => {
if (defaultDta.indexOf(item.real_name) !== -1) {
const obj = {
key: item.mobile,
text: item.real_name,
disabled: true,
closable: false
}
model.early_notifier.push(obj)
return obj
} else {
return {
key: item.mobile,
text: item.real_name,
closable: true
}
}
})
this.setState({ userSelectList: newData, model: model })
}
/* x时间控件禁用 */ /* x时间控件禁用 */
onDisabledRange = (date, type) => { onDisabledRange = (date, type) => {
@ -165,6 +222,45 @@ export default class addKnockGold extends Component {
return disabled return disabled
} }
/* x时间控件禁用 */
onDisabledRange1 = (date, type) => {
let step1 = JSON.parse(sessionStorage.getItem('knockGold_effectDate'))
let isdisabled = false
let str = moment(date).format('YYYY-MM-DD HH:mm:ss')
if (type == 'start') {
isdisabled =
moment(str).isBefore(step1.begin_time) ||
moment(str).isAfter(step1.end_time)
}
if (type == 'end') {
isdisabled =
moment(str).add(1, 'days').isBefore(step1.begin_time) ||
moment(str).isAfter(step1.end_time)
}
return isdisabled
}
onDisabledTime = (date, type) => {
const min = new Date()
const hour = min.getHours()
const minute = min.getMinutes()
const second = min.getSeconds()
const isSame = isSameDay(date, min)
return isSame
? {
disabledHours: () => initArray(hour),
disabledMinutes: (hourValue) =>
hourValue === hour ? initArray(minute) : [],
disabledSeconds: (hourValue, minuteValue) =>
hourValue === hour && minuteValue === minute
? initArray(second)
: []
}
: {}
}
/* 当预警百分比自定义输入框经行操作时从 early_per 数组中找出并过滤 */ /* 当预警百分比自定义输入框经行操作时从 early_per 数组中找出并过滤 */
filterEarlyPer() { filterEarlyPer() {
const new_early_per = this.state.model.early_per.filter( const new_early_per = this.state.model.early_per.filter(
@ -668,7 +764,7 @@ export default class addKnockGold extends Component {
className='zent-datepicker-plan' className='zent-datepicker-plan'
showTime={{ showTime={{
format: 'HH:mm:ss', format: 'HH:mm:ss',
defaultTime: [moment().format('HH:mm:ss'), '23:59:59'] defaultTime: ['00:00:00', '23:59:59']
}} }}
format='YYYY-MM-DD HH:mm:ss' format='YYYY-MM-DD HH:mm:ss'
disabled={[ disabled={[
@ -678,9 +774,11 @@ export default class addKnockGold extends Component {
width={245} width={245}
value={this.state.model.entry_time} value={this.state.model.entry_time}
onChange={(value) => { onChange={(value) => {
Bus.emit('change', 'date_time', value)
this.onHandleChange(value, 'entry_time') this.onHandleChange(value, 'entry_time')
}} }}
disabledDate={this.onDisabledRange} disabledTime={this.onDisabledTime}
disabledDate={this.onDisabledRange1}
/> />
</FormItem> </FormItem>
{this.state.model.timer_type === '2' ? ( {this.state.model.timer_type === '2' ? (
@ -874,6 +972,7 @@ export default class addKnockGold extends Component {
<div className='bt_se'> <div className='bt_se'>
<Select <Select
clearable clearable
className='bt_se_select'
options={this.state.userSelectList} options={this.state.userSelectList}
placeholder='选择一项' placeholder='选择一项'
size={'xl'} size={'xl'}