index.jsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. import React, { Component } from 'react';
  2. import Taro from '@tarojs/taro';
  3. import { View, Picker, ScrollView } from '@tarojs/components'
  4. import { getPublicReleaseList } from '../../utils/servers/servers';
  5. import dayjs from 'dayjs';
  6. import {
  7. AtSearchBar,
  8. AtTabs,
  9. AtTabsPane,
  10. AtList,
  11. AtListItem,
  12. AtIcon
  13. } from 'taro-ui';
  14. import { clockState } from '../../utils/tools/config';
  15. import './index.less';
  16. import 'taro-ui/dist/style/components/tabs.scss';
  17. import "taro-ui/dist/style/components/flex.scss";
  18. import "taro-ui/dist/style/components/action-sheet.scss";
  19. import "taro-ui/dist/style/components/icon.scss";
  20. import "taro-ui/dist/style/components/list.scss";
  21. import "taro-ui/dist/style/components/icon.scss";
  22. import MyList from './myList';
  23. import MessageNoticebar from "../../components/common/messageNoticebar";
  24. class Examine extends Component {
  25. constructor(props) {
  26. super(props);
  27. this.state = {
  28. typeList: [
  29. { title: '审核', type: 1 },
  30. { title: '查看公出', type: 2 },
  31. { title: '查看协单', type: 3 }],
  32. current: 0,
  33. isPickerRender: false,
  34. validDates: '',
  35. list: [],
  36. pageNo: 1,
  37. listState: 'LOADING',
  38. starts: {},
  39. clockInStarts: '',
  40. rangeEndVal: '',
  41. rangeStartVal: '',
  42. rangeEndMinuteVal: '',
  43. rangeStartMinuteVal: '',
  44. }
  45. this.getPublicReleaseList = this.getPublicReleaseList.bind(this);
  46. this.getMyList = this.getMyList.bind(this);
  47. this.onSetPickerTime = this.onSetPickerTime.bind(this);
  48. this.onPickerHide = this.onPickerHide.bind(this)
  49. }
  50. componentDidShow() {
  51. Taro.eventCenter.on('listOperation', (data) => {
  52. if (!isNaN(parseInt(data.index))) {
  53. let arr = this.state.list.concat([]);
  54. arr[data.index] = {
  55. ...arr[data.index],
  56. ...data
  57. }
  58. this.setState({
  59. list: arr
  60. })
  61. }
  62. })
  63. }
  64. async componentDidMount() {
  65. await this.getPublicReleaseList();
  66. }
  67. onPullDownRefresh() {
  68. this.getPublicReleaseList();
  69. }
  70. onReachBottom() {
  71. this.getPublicReleaseList(true);
  72. }
  73. onTabItemTap(obj) {
  74. if (obj.index === 1) {
  75. this.onTabTap();
  76. }
  77. }
  78. onPickerHide() {
  79. this.setState({
  80. isPickerRender: false,
  81. });
  82. }
  83. async onSetPickerTime(val) {
  84. let data = val.detail;
  85. await this.setState({
  86. rangeStartMinuteVal: dayjs(data.selectStartTime).format("YYYY-MM-DD"),
  87. rangeEndMinuteVal: dayjs(data.selectEndTime).format("YYYY-MM-DD")
  88. })
  89. await this.getMyList(1);
  90. }
  91. async onTabTap() {
  92. await this.getMyList(1);
  93. }
  94. async getPublicReleaseList(lv) {
  95. await this.getMyList(lv ? this.state.pageNo + 1 : 1);
  96. Taro.stopPullDownRefresh();
  97. }
  98. async getMyList(pageNo) {
  99. const { current } = this.state
  100. this.setState({
  101. listState: 'LOADING'
  102. })
  103. let data = {
  104. pageNo: pageNo,
  105. pageSize: 10,
  106. type: current === 0
  107. ? "1" : current === 1
  108. ? "2" : current === 2 && "3",
  109. releaseStarts: this.state.rangeStartMinuteVal || undefined,
  110. releaseEnds: this.state.rangeEndMinuteVal || undefined,
  111. status: isNaN(parseInt(this.state.starts.id)) ? undefined : String(this.state.starts.id),
  112. clockIn: this.state.clockInStarts || undefined,
  113. userName: this.state.searchValue || undefined,
  114. }
  115. for (let i in data) {
  116. if (!data[i]) {
  117. delete data[i]
  118. }
  119. }
  120. let msg = await getPublicReleaseList(data);
  121. if (msg.error.length === 0) {
  122. if (msg.data.totalCount === 0) {
  123. this.setState({
  124. listState: 'NO_DATA'
  125. })
  126. } else if (msg.data.totalCount === this.state.list.length && pageNo !== 1) {
  127. Taro.showToast({ title: '没有更多数据了', icon: 'none' });
  128. this.setState({
  129. listState: 'NO_MORE_DATA'
  130. })
  131. } else {
  132. if (msg.data.totalCount === (pageNo === 1 ? msg.data.list : this.state.list.concat(msg.data.list)).length) {
  133. this.setState({
  134. listState: 'NO_MORE_DATA'
  135. })
  136. }
  137. }
  138. this.setState({
  139. list: pageNo === 1 ? msg.data.list : this.state.list.concat(msg.data.list),
  140. pageNo: msg.data.pageNo
  141. })
  142. } else {
  143. Taro.showToast({ title: msg.error[0].message, icon: 'none' });
  144. this.setState({
  145. listState: msg.error[0].field === '403' ? 'NO_DATA' : 'RELOAD'
  146. })
  147. }
  148. Taro.stopPullDownRefresh();
  149. }
  150. onPageScroll(event) {
  151. let touchMove = event.scrollTop;
  152. if (touchMove >= 37) {
  153. this.setState({
  154. openSearch: true
  155. })
  156. } else {
  157. this.setState({
  158. openSearch: false
  159. })
  160. }
  161. }
  162. render() {
  163. return (
  164. <View className='indexPage' >
  165. <MessageNoticebar />
  166. <View className='searchContent'>
  167. <View className='searchTop'>
  168. <AtSearchBar
  169. showActionButton
  170. placeholder='请输入企业/渠道'
  171. value={this.state.searchValue}
  172. onActionClick={() => {
  173. this.getPublicReleaseList();
  174. }}
  175. onChange={(value) => {
  176. this.setState({
  177. searchValue: value
  178. })
  179. }}
  180. onClear={() => {
  181. this.setState({
  182. searchValue: ''
  183. })
  184. }}
  185. />
  186. </View>
  187. <ScrollView className={this.state.openSearch ? 'searchBottomLOL' : ''} scrollX style={{ width: '100%' }}>
  188. <View className='searchBottom'>
  189. <View className='searchItem' style={{ paddingLeft: '5px' }}>
  190. <Picker
  191. value={this.state.starts.id}
  192. range={clockState} rangeKey='title' mode='selector'
  193. onChange={(e) => {
  194. this.setState({
  195. starts: clockState[e.detail.value],
  196. }, () => {
  197. this.getPublicReleaseList();
  198. })
  199. }}>
  200. {
  201. !this.state.starts.title ?
  202. <View className='shortValuecontent'>
  203. <View className='selectTitle'>审核状态</View>
  204. <View className='iconContent'><AtIcon value='chevron-down' size='10' color='#FFFFFF' /></View>
  205. </View> :
  206. <View className='shortValuecontent'>
  207. <View className='selectValue'>
  208. {this.state.starts.title}
  209. </View>
  210. <View className='iconContent' />
  211. </View>
  212. }
  213. </Picker>
  214. {
  215. this.state.starts.title &&
  216. <View className='searchSelectContent'>
  217. <View className='selectIcon'
  218. onClick={(e) => {
  219. e.stopPropagation();
  220. this.setState({
  221. starts: {}
  222. }, () => {
  223. this.getPublicReleaseList();
  224. })
  225. }}>
  226. <AtIcon value='close-circle' size='10' color='#FFFFFF' />
  227. </View>
  228. </View>
  229. }
  230. </View>
  231. <View className='searchItem' >
  232. <Picker
  233. value={this.state.clockInStarts}
  234. range={['未打卡', '已打卡']}
  235. mode='selector'
  236. onChange={(e) => {
  237. this.setState({
  238. clockInStarts: String(e.detail.value)
  239. }, () => {
  240. this.getPublicReleaseList();
  241. })
  242. }}>
  243. {
  244. !this.state.clockInStarts ?
  245. <View className='shortValuecontent'>
  246. <View className='selectTitle'>打卡状态</View>
  247. <View className='iconContent'><AtIcon value='chevron-down' size='10' color='#FFFFFF' /></View>
  248. </View> :
  249. <View className='shortValuecontent'>
  250. <View className='selectValue'>
  251. {
  252. this.state.clockInStarts === '1'
  253. ? '已打卡' : this.state.clockInStarts === '0'
  254. ? '未打卡' : ''
  255. }
  256. </View>
  257. <View className='iconContent' />
  258. </View>
  259. }
  260. </Picker>
  261. {
  262. this.state.clockInStarts ?
  263. <View className='searchSelectContent'>
  264. <View className='selectIcon'
  265. onClick={(e) => {
  266. e.stopPropagation();
  267. this.setState({
  268. clockInStarts: '',
  269. }, () => {
  270. this.getPublicReleaseList();
  271. })
  272. }}>
  273. <AtIcon value='close-circle' size='10' color='#FFFFFF' />
  274. </View>
  275. </View> : null
  276. }
  277. </View>
  278. {/* */}
  279. {/* 多选时间框 */}
  280. <View className='searchItem' onClick={() => {
  281. this.setState({
  282. isPickerRender: true
  283. })
  284. }}>
  285. <View>
  286. {
  287. !this.state.rangeStartMinuteVal ?
  288. <View className='valuecontent' style={{ width: '200px' }}>
  289. <View className='selectTitle' style={{ paddingLeft: '50px' }}>开始及结束时间</View>
  290. <View className='iconContent' style={{ paddingLeft: '20px' }}><AtIcon value='chevron-down' size='10' color='#FFFFFF' /></View>
  291. </View> :
  292. <View className='valuecontent' style={{ width: '200px' }}>
  293. <View className='selectValue' >
  294. {this.state.rangeStartMinuteVal + "~" + this.state.rangeEndMinuteVal}
  295. </View>
  296. <View className='iconContent' />
  297. </View>
  298. }
  299. </View>
  300. {
  301. this.state.rangeStartMinuteVal &&
  302. <View className='searchSelectContent'>
  303. <View className='selectIcon'
  304. onClick={(e) => {
  305. e.stopPropagation();
  306. this.setState({
  307. rangeStartMinuteVal: '',
  308. rangeEndMinuteVal: '',
  309. }, () => {
  310. this.getPublicReleaseList();
  311. })
  312. }}>
  313. <AtIcon value='close-circle' size='10' color='#FFFFFF' />
  314. </View>
  315. </View>
  316. }
  317. </View>
  318. <timePicker
  319. config={{
  320. endDate: true,
  321. column: "minute",
  322. dateLimit: false,
  323. limitStartTime: dayjs().subtract(3, 'year').format('YYYY-MM-DD '),
  324. limitEndTime: dayjs().add(3, 'year').format('YYYY-MM-DD ')
  325. }}
  326. isPartition
  327. pickerShow={this.state.isPickerRender}
  328. onconditionaljudgment={(v) => {
  329. // let a = dayjs(dayjs(v.detail.endTime).second(0).format('YYYY-MM-DD'));
  330. // let b = dayjs(dayjs().second(0).format('YYYY-MM-DD'))
  331. // if(a.isBefore(b)){
  332. // Taro.showToast({
  333. // title:'结束时间不能小于当前时间',
  334. // icon:'none'
  335. // })
  336. // v.detail.setLv(false);
  337. // }
  338. }}
  339. onhidepicker={() => {
  340. this.onPickerHide()
  341. }}
  342. onsetpickertime={(v) => {
  343. this.onSetPickerTime(v)
  344. }}>
  345. </timePicker>
  346. </View>
  347. </ScrollView>
  348. </View>
  349. <AtTabs
  350. current={this.state.current || 0}
  351. tabList={this.state.typeList}
  352. onClick={(current) => {
  353. this.setState({
  354. pageNo: 1,
  355. current,
  356. }, () => {
  357. this.getPublicReleaseList();
  358. })
  359. }}>
  360. {
  361. this.state.typeList?.map((item, index) =>
  362. <AtTabsPane
  363. key={item.type}
  364. current={this.state.current}
  365. index={index}
  366. >
  367. <MyList
  368. type={item.type}
  369. typelist={this.state.typeList}
  370. seeView={this.state.current}
  371. list={this.state.list}
  372. listState={this.state.listState}
  373. onRefresh={() => {
  374. this.getPublicReleaseList(true);
  375. }} />
  376. </AtTabsPane>
  377. )
  378. }
  379. </AtTabs>
  380. </View>
  381. )
  382. }
  383. }
  384. export default Examine