123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609 |
- import React, { Component } from 'react';
- import Taro from '@tarojs/taro';
- import { View, Picker, ScrollView, Button } from '@tarojs/components'
- import { getPublicReleaseList, techReject, getReleasetDails } from '../../utils/servers/servers';
- import dayjs from 'dayjs';
- import {
- AtSearchBar,
- AtTabs,
- AtTabsPane,
- AtIcon,
- AtModal,
- AtModalContent,
- AtModalAction,
- AtTextarea
- } from 'taro-ui';
- import { clockState } from '../../utils/tools/config';
- import './index.less';
- import 'taro-ui/dist/style/components/tabs.scss';
- import "taro-ui/dist/style/components/flex.scss";
- import "taro-ui/dist/style/components/action-sheet.scss";
- import "taro-ui/dist/style/components/icon.scss";
- import "taro-ui/dist/style/components/list.scss";
- import "taro-ui/dist/style/components/icon.scss";
- import "taro-ui/dist/style/components/modal.scss";
- import MyList from '../project/myList';
- import MessageNoticebar from "../../components/common/messageNoticebar";
- import InquiryModal from "../../components/common/inquiryModal";
- import PublicContent from "../egressDetails/publicContent";
- import { resourceAddress } from "../../utils/config";
- class Examine extends Component {
- constructor(props) {
- super(props);
- this.state = {
- typeList: [
- { title: '我的公出' },
- { title: '我的协单' }],
- current: 0,
- isPickerRender: false,
- validDates: '',
- list: [],
- pageNo: 1,
- listState: 'LOADING',
- starts: {},
- clockInStarts: '',
- rangeEndVal: '',
- rangeStartVal: '',
- rangeEndMinuteVal: '',
- rangeStartMinuteVal: '',
- id: "",
- rmk: "",
- isOpen: false,
- coorder: [
- { title: '协单助手', type: 3 },
- { title: '技术协单', type: 2 },
- { title: '全部', type: 4 }],
- selcotype: 4,
- }
- this.getPublicReleaseList = this.getPublicReleaseList.bind(this);
- this.getMyList = this.getMyList.bind(this);
- this.onSetPickerTime = this.onSetPickerTime.bind(this);
- this.onPickerHide = this.onPickerHide.bind(this);
- this.getReleasetDails = this.getReleasetDails.bind(this);
- }
- componentDidShow() {
- Taro.eventCenter.on('listOperation', (data) => {
- if (!isNaN(parseInt(data.index))) {
- let arr = this.state.list.concat([]);
- arr[data.index] = {
- ...arr[data.index],
- ...data
- }
- this.setState({
- list: arr
- })
- }
- })
- //获取地区选定数据
- const chooseLocation = requirePlugin("chooseLocation");
- const location = chooseLocation.getLocation();
- if (location) {
- this.setState({
- selectArrderLocation: location,
- });
- }
- this.getPublicReleaseList();
- }
- async componentDidMount() {
- await this.getPublicReleaseList();
- }
- onPullDownRefresh() {
- this.getPublicReleaseList();
- }
- onReachBottom() {
- this.getPublicReleaseList(true);
- }
- onTabItemTap(obj) {
- if (obj.index === 1) {
- this.onTabTap();
- }
- }
- onPickerHide() {
- this.setState({
- isPickerRender: false,
- });
- }
- // 公出详情
- getReleasetDails(id) {
- getReleasetDails({
- id: id
- }).then((v) => {
- if (v.error.length === 0) {
- if (v.data) {
- let list = [];
- for (let i of v.data.annexUrl.split(",")) {
- if (i) {
- list.push({ url: resourceAddress + i });
- }
- }
- v.data.annexUrl = list;
- this.setState({
- dtails: v.data,
- selectArrderLocation: {
- longitude: parseFloat(v.data.prdList[0]?.longitude),
- latitude: parseFloat(v.data.prdList[0]?.latitude),
- name: v.data.prdList[0]?.districtName,
- },
- })
- }
- } else {
- Taro.showToast({ title: v.error[0].message, icon: "none" });
- }
- }).catch((err) => {
- // Taro.showToast({ title: "系统错误,请稍后再试", icon: "none" });
- });
- }
- async onSetPickerTime(val) {
- let data = val.detail;
- await this.setState({
- rangeStartMinuteVal: dayjs(data.selectStartTime).format("YYYY-MM-DD"),
- rangeEndMinuteVal: dayjs(data.selectEndTime).format("YYYY-MM-DD")
- })
- await this.getMyList(1);
- }
- async onTabTap() {
- await this.getMyList(1);
- }
- async getPublicReleaseList(lv) {
- await this.getMyList(lv ? this.state.pageNo + 1 : 1);
- Taro.stopPullDownRefresh();
- }
- async getMyList(pageNo) {
- this.setState({
- listState: 'LOADING'
- })
- let data = {
- pageNo: pageNo,
- pageSize: 10,
- type: '0',
- assist: this.state.current === 0 ? 0 : this.state.selcotype,
- releaseStarts: this.state.rangeStartMinuteVal || undefined,
- releaseEnds: this.state.rangeEndMinuteVal || undefined,
- status: isNaN(parseInt(this.state.starts.id)) ? undefined : String(this.state.starts.id),
- clockIn: this.state.clockInStarts || undefined,
- userName: this.state.searchValue || undefined,
- }
- for (let i in data) {
- if (!data[i]) {
- delete data[i]
- }
- }
- let msg = await getPublicReleaseList(data);
- if (msg.error.length === 0) {
- if (msg.data.totalCount === 0) {
- this.setState({
- listState: 'NO_DATA'
- })
- } else if (msg.data.totalCount === this.state.list.length && pageNo !== 1) {
- // 防止提示挡住驳回弹窗
- !this.state.isOpen && Taro.showToast({ title: '没有更多数据了', icon: 'none' });
- this.setState({
- listState: 'NO_MORE_DATA'
- })
- } else {
- if (msg.data.totalCount === (pageNo === 1 ? msg.data.list : this.state.list.concat(msg.data.list)).length) {
- this.setState({
- listState: 'NO_MORE_DATA'
- })
- }
- }
- this.setState({
- list: pageNo === 1 ? msg.data.list : this.state.list.concat(msg.data.list),
- pageNo: msg.data.list.length === 0 ? this.state.pageNo : msg.data.pageNo
- })
- } else {
- Taro.showToast({ title: msg.error[0].message, icon: 'none' });
- this.setState({
- listState: msg.error[0].field === '403' ? 'NO_DATA' : 'RELOAD'
- })
- }
- Taro.stopPullDownRefresh();
- }
- onPageScroll(event) {
- let touchMove = event.scrollTop;
- if (touchMove >= 37) {
- this.setState({
- openSearch: true
- })
- } else {
- this.setState({
- openSearch: false
- })
- }
- }
- submit() {
- if (!this.state.rmk) {
- Taro.showToast({ title: '请填写备注!', icon: 'none' });
- return
- }
- Taro.showLoading({ title: '正在提交...' });
- techReject({
- id: this.state.id,
- remarks: this.state.rmk,
- }).then(v => {
- Taro.hideLoading()
- if (v.error.length === 0) {
- Taro.showToast({ title: '提交成功', icon: 'none' });
- this.getPublicReleaseList();
- this.setState({
- isOpen: false,
- rmk: "",
- })
- } else {
- Taro.showToast({ title: v.error[0].message, icon: 'none' })
- }
- }).catch(() => {
- Taro.hideLoading()
- Taro.showToast({
- title: '系统错误,请稍后再试',
- icon: 'none'
- })
- })
- }
- render() {
- return (
- <View className='indexPage' >
- <MessageNoticebar />
- <View className='searchContent'>
- <View className='searchTop'>
- <AtSearchBar
- showActionButton
- placeholder='请输入企业/渠道'
- value={this.state.searchValue}
- onActionClick={() => {
- this.getPublicReleaseList();
- }}
- onChange={(value) => {
- this.setState({
- searchValue: value
- })
- }}
- onClear={() => {
- this.setState({
- searchValue: ''
- })
- }}
- />
- </View>
- <ScrollView className={this.state.openSearch ? 'searchBottomLOL' : ''} scrollX style={{ width: '100%' }}>
- <View className='searchBottom'>
- <View className='searchItem' style={{ paddingLeft: '5px' }}>
- <Picker
- value={this.state.starts.id}
- range={clockState} rangeKey='title' mode='selector'
- onChange={(e) => {
- this.setState({
- starts: clockState[e.detail.value],
- }, () => {
- this.getPublicReleaseList();
- })
- }}>
- {
- !this.state.starts.title ?
- <View className='shortValuecontent'>
- <View className='selectTitle'>审核状态</View>
- <View className='iconContent'><AtIcon value='chevron-down' size='10' color='#FFFFFF' /></View>
- </View> :
- <View className='shortValuecontent'>
- <View className='selectValue'>
- {this.state.starts.title}
- </View>
- <View className='iconContent' />
- </View>
- }
- </Picker>
- {
- this.state.starts.title &&
- <View className='searchSelectContent'>
- <View className='selectIcon'
- onClick={(e) => {
- e.stopPropagation();
- this.setState({
- starts: {}
- }, () => {
- this.getPublicReleaseList();
- })
- }}>
- <AtIcon value='close-circle' size='10' color='#FFFFFF' />
- </View>
- </View>
- }
- </View>
- <View className='searchItem' >
- <Picker
- value={this.state.clockInStarts}
- range={['未打卡', '已打卡', '异常打卡']}
- mode='selector'
- onChange={(e) => {
- this.setState({
- clockInStarts: String(e.detail.value)
- }, () => {
- this.getPublicReleaseList();
- })
- }}>
- {
- !this.state.clockInStarts ?
- <View className='shortValuecontent'>
- <View className='selectTitle'>打卡状态</View>
- <View className='iconContent'><AtIcon value='chevron-down' size='10' color='#FFFFFF' /></View>
- </View> :
- <View className='shortValuecontent'>
- <View className='selectValue'>
- {
- this.state.clockInStarts === '2'
- ? '异常打卡' : this.state.clockInStarts === '1'
- ? '已打卡' : this.state.clockInStarts === '0'
- ? '未打卡' : ''
- }
- </View>
- <View className='iconContent' />
- </View>
- }
- </Picker>
- {
- this.state.clockInStarts ?
- <View className='searchSelectContent'>
- <View className='selectIcon'
- onClick={(e) => {
- e.stopPropagation();
- this.setState({
- clockInStarts: '',
- }, () => {
- this.getPublicReleaseList();
- })
- }}>
- <AtIcon value='close-circle' size='10' color='#FFFFFF' />
- </View>
- </View> : null
- }
- </View>
- {/* */}
- {/* 多选时间框 */}
- <View className='searchItem' onClick={() => {
- this.setState({
- isPickerRender: true
- })
- }}>
- <View>
- {
- !this.state.rangeStartMinuteVal ?
- <View className='valuecontent' style={{ width: '200px' }}>
- <View className='selectTitle' style={{ paddingLeft: '50px' }}>开始及结束时间</View>
- <View className='iconContent' style={{ paddingLeft: '20px' }}><AtIcon value='chevron-down' size='10' color='#FFFFFF' /></View>
- </View> :
- <View className='valuecontent' style={{ width: '200px' }}>
- <View className='selectValue' >
- {this.state.rangeStartMinuteVal + "~" + this.state.rangeEndMinuteVal}
- </View>
- <View className='iconContent' />
- </View>
- }
- </View>
- {
- this.state.rangeStartMinuteVal &&
- <View className='searchSelectContent'>
- <View className='selectIcon'
- onClick={(e) => {
- e.stopPropagation();
- this.setState({
- rangeStartMinuteVal: '',
- rangeEndMinuteVal: '',
- }, () => {
- this.getPublicReleaseList();
- })
- }}>
- <AtIcon value='close-circle' size='10' color='#FFFFFF' />
- </View>
- </View>
- }
- </View>
- </View>
- </ScrollView>
- </View>
- <AtTabs
- swipeable={false}
- current={this.state.current || 0}
- tabList={this.state.typeList}
- onClick={(current) => {
- this.setState({
- list: [],
- pageNo: 1,
- current,
- }, () => {
- this.getPublicReleaseList();
- })
- }}>
- {
- this.state.typeList?.map((item, index) =>
- <AtTabsPane
- current={this.state.current}
- index={index}
- >
- {
- this.state.current === 1 &&
- <View className='navs'>
- {
- this.state.coorder.map((it) =>
- <View className={this.state.selcotype == it.type ? 'nitems' : 'nitem'}
- key={it.type}
- onClick={() => {
- this.setState({
- list: [],
- pageNo: 1,
- selcotype: it.type,
- }, () => {
- this.getPublicReleaseList();
- })
- }}
- >{it.title}</View>
- )
- }
- </View>
- }
- <MyList
- type={0}
- title={item.title}
- typelist={this.state.typeList}
- seeView={this.state.current}
- list={this.state.list}
- listState={this.state.listState}
- onRefresh={() => {
- this.getPublicReleaseList(true);
- }}
- opens={e => {
- this.setState({
- id: e,
- isOpen: true,
- })
- }}
- again={e => {
- this.getReleasetDails(e.id)
- this.setState({
- isInquiryOpened: true,
- inquiryTitle: "温馨提示",
- inquiryContent: "您确定需再次公出拜访同一家企业吗?",
- inquiryFn: () => {
- },
- });
- }}
- />
- </AtTabsPane>
- )
- }
- </AtTabs>
- <timePicker
- config={{
- endDate: true,
- column: "day",
- dateLimit: false,
- limitStartTime: dayjs().subtract(3, 'year').format('YYYY-MM-DD '),
- limitEndTime: dayjs().add(3, 'year').format('YYYY-MM-DD ')
- }}
- isPartition
- pickerShow={this.state.isPickerRender}
- onconditionaljudgment={(v) => {
- // let a = dayjs(dayjs(v.detail.endTime).second(0).format('YYYY-MM-DD'));
- // let b = dayjs(dayjs().second(0).format('YYYY-MM-DD'))
- // if(a.isBefore(b)){
- // Taro.showToast({
- // title:'结束时间不能小于当前时间',
- // icon:'none'
- // })
- // v.detail.setLv(false);
- // }
- }}
- onhidepicker={() => {
- this.onPickerHide()
- }}
- onsetpickertime={(v) => {
- this.onSetPickerTime(v)
- }}>
- </timePicker>
- {/* 驳回协单 */}
- {
- this.state.isOpen &&
- <AtModal
- isOpened={this.state.isOpen}
- >
- <AtModalContent>
- <AtTextarea
- value={this.state.rmk}
- onChange={e => {
- this.setState({ rmk: e })
- }}
- maxLength={200}
- placeholder='请填写备注~'
- />
- </AtModalContent>
- <AtModalAction>
- <Button type='secondary' onClick={() => { this.setState({ isOpen: false }) }}>取消</Button>
- <Button type='primary' onClick={this.submit.bind(this)}>提交</Button>
- </AtModalAction>
- </AtModal>
- }
- {/* 再次公出申请 */}
- {
- this.state.isInquiryOpened &&
- <InquiryModal
- isOpened={this.state.isInquiryOpened}
- title={this.state.inquiryTitle}
- content={this.state.inquiryContent}
- color="black"
- isNo={this.state.isNo}
- onClose={() => {
- this.setState({
- isInquiryOpened: false,
- dtails: {},
- inquiryTitle: "",
- inquiryContent: "",
- isNo: true,
- });
- }}
- onDetermine={() => {
- this.setState({
- isModifyOpened: true,
- isInquiryOpened: false,
- inquiryTitle: "",
- inquiryContent: "",
- isNo: true,
- inquiryFn: () => { },
- });
- }}
- />
- }
- {/* 再次公出详情 */}
- {
- this.state.isModifyOpened &&
- <AtModal
- isOpened={this.state.isModifyOpened}
- onClose={() => {
- this.setState({
- isModifyOpened: false,
- dtails: {},
- })
- }}
- >
- <AtModalContent>
- <PublicContent
- again={true}
- onClose={() => {
- this.setState({
- isModifyOpened: false,
- dtails: {},
- })
- }}
- locationInfor={this.state.selectArrderLocation}
- dtails={this.state.dtails}
- isOpened={this.state.isModifyOpened}
- />
- </AtModalContent>
- </AtModal>
- }
- </View>
- )
- }
- }
- export default Examine
|