index.jsx 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. import React, { Component } from 'react';
  2. import Taro from '@tarojs/taro';
  3. import { View, Picker, ScrollView, Button } from '@tarojs/components'
  4. import { getProjectList, listRecord } from '../../utils/servers/servers';
  5. import dayjs from 'dayjs';
  6. import {
  7. AtTabs,
  8. AtTabsPane,
  9. AtIcon,
  10. } from 'taro-ui';
  11. import './index.less';
  12. import 'taro-ui/dist/style/components/tabs.scss';
  13. import "taro-ui/dist/style/components/flex.scss";
  14. import "taro-ui/dist/style/components/action-sheet.scss";
  15. import "taro-ui/dist/style/components/icon.scss";
  16. import "taro-ui/dist/style/components/list.scss";
  17. import "taro-ui/dist/style/components/icon.scss";
  18. import "taro-ui/dist/style/components/modal.scss";
  19. import MyList from './myList';
  20. class Examine extends Component {
  21. constructor(props) {
  22. super(props);
  23. this.state = {
  24. typeList: [
  25. { title: '全部', type: 0 },
  26. { title: '待审核', type: 1 },
  27. { title: '已审核', type: 2 },
  28. { title: '已驳回', type: 3 }],
  29. seltype: {},
  30. current: 0,
  31. tlist: [{ title: '我的打卡', type: 0 }],
  32. tabs: 0,
  33. list: [],
  34. pageNum: 1,
  35. listState: 'LOADING',
  36. isPickerRender: false,
  37. rangeEndMinuteVal: '',
  38. rangeStartMinuteVal: '',
  39. }
  40. this.getPublicReleaseList = this.getPublicReleaseList.bind(this);
  41. this.getMyList = this.getMyList.bind(this);
  42. }
  43. componentDidShow() {
  44. let roles = Taro.getStorageSync('roles');
  45. // 项目经理 技术总监
  46. if (roles.includes("manage") || roles.includes("Inspector")) {
  47. this.setState({
  48. tlist: [{ title: '我的打卡', type: 0 }, { title: '审核', type: 1 }]
  49. })
  50. }
  51. this.getPublicReleaseList();
  52. }
  53. async componentDidMount() {
  54. await this.getPublicReleaseList();
  55. }
  56. onPullDownRefresh() {
  57. this.getPublicReleaseList();
  58. }
  59. onReachBottom() {
  60. this.getPublicReleaseList(true);
  61. }
  62. onTabItemTap(obj) {
  63. if (obj.index === 1) {
  64. this.onTabTap();
  65. }
  66. }
  67. async onTabTap() {
  68. await this.getMyList(1);
  69. }
  70. async getPublicReleaseList(lv) {
  71. await this.getMyList(lv ? this.state.pageNum + 1 : 1);
  72. Taro.stopPullDownRefresh();
  73. }
  74. async getMyList(pageNum) {
  75. const { current } = this.state
  76. this.setState({
  77. listState: 'LOADING'
  78. })
  79. let data = {
  80. processStatus: this.state.current != 0 ? this.state.current : "",
  81. pageNum: pageNum,
  82. pageSize: 10,
  83. roleType: this.state.tabs,
  84. startTime: this.state.rangeStartMinuteVal || undefined,
  85. endTime: this.state.rangeEndMinuteVal || undefined,
  86. }
  87. for (let i in data) {
  88. if (!data[i] && data[i] != 0) {
  89. delete data[i]
  90. }
  91. }
  92. let msg = await listRecord(data);
  93. if (msg.code === 200) {
  94. if (msg.total === 0) {
  95. this.setState({
  96. listState: 'NO_DATA'
  97. })
  98. } else if (msg.total === this.state.list.length && pageNum !== 1) {
  99. !this.state.isOpen && Taro.showToast({ title: '没有更多数据了', icon: 'none' });
  100. this.setState({
  101. listState: 'NO_MORE_DATA'
  102. })
  103. } else {
  104. if (msg.total === (pageNum === 1 ? msg.rows : this.state.list.concat(msg.rows)).length) {
  105. this.setState({
  106. listState: 'NO_MORE_DATA'
  107. })
  108. }
  109. }
  110. this.setState({
  111. list: pageNum === 1 ? msg.rows : this.state.list.concat(msg.rows),
  112. pageNum: msg.rows.length === 0 ? this.state.pageNum : msg.next - 1
  113. })
  114. } else {
  115. Taro.showToast({ title: msg.msg, icon: 'none' });
  116. this.setState({
  117. // listState: msg.error[0].field === '403' ? 'NO_DATA' : 'RELOAD'
  118. })
  119. }
  120. Taro.stopPullDownRefresh();
  121. }
  122. onPickerHide() {
  123. this.setState({
  124. isPickerRender: false,
  125. });
  126. }
  127. async onSetPickerTime(val) {
  128. let data = val.detail;
  129. await this.setState({
  130. rangeStartMinuteVal: dayjs(data.selectStartTime).format("YYYY-MM-DD"),
  131. rangeEndMinuteVal: dayjs(data.selectEndTime).format("YYYY-MM-DD")
  132. })
  133. await this.getMyList(1);
  134. }
  135. render() {
  136. return (
  137. <View className='indexPage' >
  138. <View className='searchContent'>
  139. <View className='searchTop'>
  140. {/* <AtSearchBar
  141. showActionButton
  142. placeholder='请输入企业/渠道'
  143. value={this.state.searchValue}
  144. onActionClick={() => {
  145. this.getPublicReleaseList();
  146. }}
  147. onChange={(value) => {
  148. this.setState({
  149. searchValue: value
  150. })
  151. }}
  152. onClear={() => {
  153. this.setState({
  154. searchValue: ''
  155. })
  156. }}
  157. /> */}
  158. </View>
  159. <AtTabs
  160. swipeable={false}
  161. current={this.state.tabs || 0}
  162. tabList={this.state.tlist}
  163. onClick={(tabs) => {
  164. this.setState({
  165. list: [],
  166. pageNum: 1,
  167. tabs: this.state.tlist[tabs].type,
  168. }, () => {
  169. this.getPublicReleaseList();
  170. })
  171. }}
  172. >
  173. </AtTabs>
  174. <ScrollView className={this.state.openSearch ? 'searchBottomLOL' : ''} scrollX style={{ width: '100%' }}>
  175. <View className='searchBottom'>
  176. <View className='searchItem' style={{ paddingLeft: '5px' }}>
  177. <Picker
  178. value={this.state.seltype.type}
  179. range={this.state.typeList} rangeKey='title' mode='selector'
  180. onChange={(e) => {
  181. this.setState({
  182. seltype: this.state.typeList[e.detail.value],
  183. current: this.state.typeList[e.detail.value].type,
  184. }, () => {
  185. this.getPublicReleaseList();
  186. })
  187. }}>
  188. {
  189. !this.state.seltype.title ?
  190. <View className='shortValuecontent'>
  191. <View className='selectTitle'>审核状态</View>
  192. <View className='iconContent'><AtIcon value='chevron-down' size='10' color='#FFFFFF' /></View>
  193. </View> :
  194. <View className='shortValuecontent'>
  195. <View className='selectValue'>
  196. {this.state.seltype.title}
  197. </View>
  198. <View className='iconContent' />
  199. </View>
  200. }
  201. </Picker>
  202. {
  203. this.state.seltype.title &&
  204. <View className='searchSelectContent'>
  205. <View className='selectIcon'
  206. onClick={(e) => {
  207. e.stopPropagation();
  208. this.setState({
  209. seltype: {},
  210. current: 0,
  211. }, () => {
  212. this.getPublicReleaseList();
  213. })
  214. }}>
  215. <AtIcon value='close-circle' size='10' color='#FFFFFF' />
  216. </View>
  217. </View>
  218. }
  219. </View>
  220. {/* 多选时间框 */}
  221. <View className='searchItem'
  222. onClick={() => {
  223. this.setState({
  224. isPickerRender: true
  225. })
  226. }}>
  227. <View>
  228. {
  229. !this.state.rangeStartMinuteVal ?
  230. <View className='valuecontent' style={{ width: '200px' }}>
  231. <View className='selectTitle' style={{ paddingLeft: '50px' }}>开始及结束时间</View>
  232. <View className='iconContent' style={{ paddingLeft: '20px' }}><AtIcon value='chevron-down' size='10' color='#FFFFFF' /></View>
  233. </View> :
  234. <View className='valuecontent' style={{ width: '200px' }}>
  235. <View className='selectValue' >
  236. {this.state.rangeStartMinuteVal + "~" + this.state.rangeEndMinuteVal}
  237. </View>
  238. <View className='iconContent' />
  239. </View>
  240. }
  241. </View>
  242. {
  243. this.state.rangeStartMinuteVal &&
  244. <View className='searchSelectContent'>
  245. <View className='selectIcon'
  246. onClick={(e) => {
  247. e.stopPropagation();
  248. this.setState({
  249. rangeStartMinuteVal: '',
  250. rangeEndMinuteVal: '',
  251. }, () => {
  252. this.getPublicReleaseList();
  253. })
  254. }}>
  255. <AtIcon value='close-circle' size='10' color='#FFFFFF' />
  256. </View>
  257. </View>
  258. }
  259. </View>
  260. </View>
  261. </ScrollView>
  262. {
  263. this.state.typeList?.map((item, index) =>
  264. <MyList
  265. type={this.state.tabs}
  266. title={item.title}
  267. typelist={this.state.typeList}
  268. seeView={this.state.current}
  269. list={this.state.list}
  270. listState={this.state.listState}
  271. onRefresh={() => {
  272. this.getProjectList(true);
  273. }}
  274. />
  275. )
  276. }
  277. </View>
  278. <timePicker
  279. config={{
  280. endDate: true,
  281. column: "day",
  282. dateLimit: false,
  283. limitStartTime: dayjs().subtract(3, 'year').format('YYYY-MM-DD '),
  284. limitEndTime: dayjs().add(3, 'year').format('YYYY-MM-DD ')
  285. }}
  286. isPartition
  287. pickerShow={this.state.isPickerRender}
  288. onconditionaljudgment={(v) => {
  289. }}
  290. onhidepicker={() => {
  291. this.onPickerHide()
  292. }}
  293. onsetpickertime={(v) => {
  294. this.onSetPickerTime(v)
  295. }}>
  296. </timePicker>
  297. </View>
  298. )
  299. }
  300. }
  301. export default Examine