|
@@ -6,10 +6,12 @@ import './index.less';
|
|
|
import DateTimePicker from '../../components/common/DateTimePicker';
|
|
|
|
|
|
import ImagePicker from '../../components/common/imagePicker'
|
|
|
-import {resourceAddress} from '../../utils/config';
|
|
|
+import {resourceAddress,radiusRange} from '../../utils/config';
|
|
|
|
|
|
import { AtButton,AtTextarea ,AtIcon,AtCalendar } from 'taro-ui'
|
|
|
-import {updatePublicRelease} from '../../utils/servers/servers';
|
|
|
+import {updatePublicRelease,getWorkingHoursList} from '../../utils/servers/servers';
|
|
|
+
|
|
|
+import {getNumHourse} from '../../utils/tools';
|
|
|
|
|
|
import 'taro-ui/dist/style/components/form.scss';
|
|
|
import 'taro-ui/dist/style/components/button.scss';
|
|
@@ -35,10 +37,14 @@ class PublicContent extends Component{
|
|
|
validDates:[],
|
|
|
totalDuration:0,
|
|
|
loading:false,
|
|
|
+
|
|
|
+ workTypeList:[],
|
|
|
+ workType:0,
|
|
|
}
|
|
|
this.onSubmit = this.onSubmit.bind(this);
|
|
|
this.selectArrder = this.selectArrder.bind(this);
|
|
|
this.onChange = this.onChange.bind(this);
|
|
|
+ this.getWorkingHoursList = this.getWorkingHoursList.bind(this);
|
|
|
}
|
|
|
|
|
|
componentDidMount() {
|
|
@@ -58,6 +64,7 @@ class PublicContent extends Component{
|
|
|
rangeStartVal:dayjs(this.props.dtails.releaseStarts).format('YYYY-MM-DD'),
|
|
|
rangeStartMinuteVal: dayjs(this.props.dtails.releaseStarts).format('YYYY-MM-DD HH:mm:ss'),
|
|
|
})
|
|
|
+ this.getWorkingHoursList();
|
|
|
}
|
|
|
|
|
|
componentWillUnmount() {
|
|
@@ -77,61 +84,32 @@ class PublicContent extends Component{
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- getHours(startTime,endTime){
|
|
|
- let a1 = dayjs(startTime);
|
|
|
- let b1 = dayjs(endTime);
|
|
|
- let c1 = b1.diff(a1,'minutes');
|
|
|
- let hourse = parseInt(c1/60);
|
|
|
- let minutes = c1%60
|
|
|
- let minutes1 = parseInt(minutes / 30)*0.5;
|
|
|
-
|
|
|
- //开始时间在12:00之前 包括12:00
|
|
|
- if(!a1.isAfter(dayjs(a1.format('YYYY-MM-DD')+' 12:00'))){
|
|
|
- if(b1.isAfter(dayjs(b1.format('YYYY-MM-DD')+' 13:30'))){
|
|
|
- return hourse+minutes1-1.5
|
|
|
- }else if(!b1.isAfter(dayjs(b1.format('YYYY-MM-DD')+' 12:00'))){
|
|
|
- return hourse+minutes1
|
|
|
- }else{
|
|
|
- let a2 = dayjs(startTime);
|
|
|
- let b2 = dayjs(b1.format('YYYY-MM-DD')+' 12:00');
|
|
|
- let c2 = b2.diff(a2,'minutes');
|
|
|
- let hourse2 = parseInt(c2/60);
|
|
|
- let minutes2 = c2%60
|
|
|
- let minutes3 = parseInt(minutes2 / 30)*0.5;
|
|
|
- return hourse2+minutes3
|
|
|
- }
|
|
|
- // 开始时间在12:00之后13:30之前
|
|
|
- }else if(a1.isBefore(dayjs(a1.format('YYYY-MM-DD')+' 13:30')) && a1.isAfter(dayjs(a1.format('YYYY-MM-DD')+' 12:00'))){
|
|
|
- if(b1.isAfter(dayjs(b1.format('YYYY-MM-DD')+' 13:30'))){
|
|
|
- let a2 = dayjs(a1.format('YYYY-MM-DD')+' 13:30');
|
|
|
- let b2 = dayjs(endTime);
|
|
|
- let c2 = b2.diff(a2,'minutes');
|
|
|
- let hourse2 = parseInt(c2/60);
|
|
|
- let minutes2 = c2%60
|
|
|
- let minutes3 = parseInt(minutes2 / 30)*0.5;
|
|
|
- return hourse2+minutes3
|
|
|
+ getWorkingHoursList(){
|
|
|
+ getWorkingHoursList({}).then((v)=>{
|
|
|
+ if(v.error.length === 0){
|
|
|
+ let obj = Taro.getStorageSync('userInfor');
|
|
|
+ let index = v.data.findIndex(value=>value.type === obj.workTimeInfor.type);
|
|
|
+ this.setState({
|
|
|
+ workType:index !== -1 ? index : 0
|
|
|
+ })
|
|
|
+ this.setState({
|
|
|
+ workTypeList:v.data
|
|
|
+ })
|
|
|
}else{
|
|
|
- return 0;
|
|
|
+ Taro.showToast({
|
|
|
+ title:v.error[0].message,
|
|
|
+ icon:'none'
|
|
|
+ })
|
|
|
}
|
|
|
- //开始时间在13:30之后 包括13:30
|
|
|
- }else if(!a1.isBefore(dayjs(a1.format('YYYY-MM-DD')+' 13:30'))){
|
|
|
- return hourse+minutes1
|
|
|
- }
|
|
|
+ }).catch(err=>{
|
|
|
+ console.log(err)
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
getNumHourse(startTime,endTime){
|
|
|
- if(dayjs(dayjs(startTime).format('YYYY-MM-DD')).isSame(dayjs(dayjs(endTime).format('YYYY-MM-DD')))){
|
|
|
- this.setState({
|
|
|
- totalDuration:this.getHours(startTime,endTime)
|
|
|
- })
|
|
|
- }else{
|
|
|
- let a = this.getHours(startTime,dayjs(startTime.format('YYYY-MM-DD')+' 17:30'));
|
|
|
- let b = this.getHours(dayjs(endTime.format('YYYY-MM-DD')+' 8:30'),endTime);
|
|
|
- let c = (this.state.validDates.length-2)*7.5;
|
|
|
- this.setState({
|
|
|
- totalDuration:a+b+c
|
|
|
- })
|
|
|
- }
|
|
|
+ this.setState({
|
|
|
+ totalDuration:getNumHourse(startTime,endTime,this.state.validDates.length)
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
|
|
@@ -226,10 +204,37 @@ class PublicContent extends Component{
|
|
|
const {dtails} = this.props;
|
|
|
return (
|
|
|
<View className='publicContent'>
|
|
|
- <View className='formItem'>
|
|
|
- <View className='formName'>公出企业:</View>
|
|
|
- <View className='formValue'>{dtails.nickname}</View>
|
|
|
+ <View className='formItem'>
|
|
|
+ <View className='formName'>公出企业:</View>
|
|
|
+ <View className='formValue'>{dtails.nickname}</View>
|
|
|
+ </View>
|
|
|
+ <View className='formItem'>
|
|
|
+ <View className='formName'>作息时间类型:</View>
|
|
|
+ <View className='formValue'>
|
|
|
+ <picker onChange={(e)=>{
|
|
|
+ this.setState({
|
|
|
+ workType: e.detail.value
|
|
|
+ })
|
|
|
+ if(this.state.workTypeList[e.detail.value]){
|
|
|
+ let obj = Taro.getStorageSync('userInfor');
|
|
|
+ obj.workTimeInfor = this.state.workTypeList[e.detail.value];
|
|
|
+ Taro.setStorageSync('userInfor', obj);
|
|
|
+ this.rangeEndRef.clear();
|
|
|
+ this.rangeStartRef.clear();
|
|
|
+ this.setState({
|
|
|
+ rangeStartVal:'',
|
|
|
+ rangeStartMinuteVal: '',
|
|
|
+ validDates:[],
|
|
|
+ totalDuration:0
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }} value={this.state.workType} rangeKey='name' range={this.state.workTypeList}>
|
|
|
+ <view >
|
|
|
+ {this.state.workTypeList[this.state.workType] ? this.state.workTypeList[this.state.workType].name : ''}
|
|
|
+ </view>
|
|
|
+ </picker>
|
|
|
</View>
|
|
|
+ </View>
|
|
|
<View className='formItem'>
|
|
|
<View className='formName'>公出开始时间:</View>
|
|
|
<View className='formValue'>
|
|
@@ -390,7 +395,7 @@ class PublicContent extends Component{
|
|
|
<AtIcon value='chevron-right' size='30' color='#bbbbbb'/>
|
|
|
</View>
|
|
|
</View>
|
|
|
- <View className='tips'>以地图中红标为中心100米范围为可打卡区域,移动红标只需要拖动地图即可</View>
|
|
|
+ <View className='tips'>以地图中红标为中心{radiusRange}米范围为可打卡区域,移动红标只需要拖动地图即可</View>
|
|
|
<View className='formItem' style={{display:'block',paddingTop:'15px'}}>
|
|
|
<View className='formName'>公出事由:</View>
|
|
|
<View className='formValue' style={{paddingTop:'10px',textAlign:'left'}}>
|