index.jsx 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. import React, { Component } from "react";
  2. import { connect } from "react-redux";
  3. import { View } from "@tarojs/components";
  4. import { AtSteps, AtButton } from "taro-ui";
  5. import "taro-ui/dist/style/components/steps.scss";
  6. import "taro-ui/dist/style/components/icon.scss";
  7. import "taro-ui/dist/style/components/tabs.scss";
  8. import UserFloatingLayer from "../../components/common/userFloatingLayer";
  9. import { add, minus, asyncAdd } from "../../actions/counter";
  10. import Enterprise from "./enterprise";
  11. import PublicContent from "./publicContent";
  12. import Result from "./result";
  13. import "./index.less";
  14. import Taro, { getCurrentInstance } from "@tarojs/taro";
  15. import MessageNoticebar from "../../components/common/messageNoticebar";
  16. import InterviewCustomer from "../../pages/interview/index";
  17. const items = [
  18. { title: "选择公出企业" },
  19. { title: "填写公出内容" },
  20. { title: "提交公出审核" },
  21. ];
  22. @connect(
  23. ({ counter }) => ({
  24. counter,
  25. }),
  26. (dispatch) => ({
  27. add() {
  28. dispatch(add());
  29. },
  30. dec() {
  31. dispatch(minus());
  32. },
  33. asyncAdd() {
  34. dispatch(asyncAdd());
  35. },
  36. })
  37. )
  38. class ApplyDepart extends Component {
  39. $instance = getCurrentInstance();
  40. constructor(props) {
  41. super(props);
  42. this.state = {
  43. current: 0,
  44. enterpriseInfor: {},
  45. selectArrderLocation: {},
  46. resultState: 0,
  47. resultId: "",
  48. punchClockInfor: {},
  49. // colors: "primary",
  50. // color: "secondary",
  51. // selectColor: 0,
  52. type: 0,
  53. isShow: false,
  54. tipList: [],
  55. // 需要面谈的客户列表,只有业务员自己的客户才能面谈
  56. interviewCustomerList: [],
  57. interviewIdx: 0,
  58. // 面谈后返回的id
  59. uaiIdList: [],
  60. refreshInterview: false
  61. };
  62. }
  63. componentDidShow() {
  64. const publicInfo = Taro.getStorageSync('publicInfo');
  65. if (!!publicInfo) {
  66. const { type, customerList } = publicInfo;
  67. const ids = customerList.map(item => item.id).join(',');
  68. const names = customerList.map(item => item.name).join(',');
  69. this.setState({
  70. type,
  71. interviewCustomerList: type === 0 ? customerList : [],
  72. interviewIdx: 0,
  73. current: 1,
  74. enterpriseInfor: { type, id: ids, name: names },
  75. refreshInterview: type === 0 ? true : false,
  76. }, () => {
  77. Taro.removeStorageSync('publicInfo');
  78. this.setState({ refreshInterview: false });
  79. });
  80. }
  81. Taro.eventCenter.on("enterprise", (arg) => {
  82. arg.type = this.state.type;
  83. // 跳转
  84. this.setState({
  85. current: 1,
  86. enterpriseInfor: arg,
  87. // interviewCustomerList: arg.list.filter(item => item.myUser === 1),
  88. interviewCustomerList: arg.list,
  89. interviewIdx: 0
  90. });
  91. });
  92. Taro.eventCenter.on("publicContent", (arg) => {
  93. this.setState({
  94. current: 2,
  95. resultState: arg.code,
  96. resultId: arg.data ? arg.data.id : "",
  97. punchClockInfor: arg.data || {},
  98. isShow: arg.isShow,
  99. tipList: arg?.list,
  100. });
  101. });
  102. Taro.eventCenter.on("enterpriseBack", () => {
  103. const { type, interviewCustomerList } = this.state;
  104. if (type == 0 && interviewCustomerList.length) {
  105. this.setState({ interviewIdx: interviewCustomerList.length - 1 });
  106. } else {
  107. this.setState({
  108. current: 0,
  109. });
  110. }
  111. });
  112. Taro.eventCenter.on("result", () => {
  113. this.setState({
  114. current: 0,
  115. enterpriseInfor: {},
  116. selectArrderLocation: {},
  117. resultState: 0,
  118. resultId: "",
  119. punchClockInfor: {},
  120. uaiIdList: []
  121. });
  122. });
  123. //获取地区选定数据
  124. const chooseLocation = requirePlugin("chooseLocation");
  125. const location = chooseLocation.getLocation();
  126. if (location) {
  127. this.setState({
  128. selectArrderLocation: location,
  129. });
  130. }
  131. }
  132. onReachBottom() {
  133. if (this.state.current === 0) {
  134. Taro.eventCenter.trigger("applyDepartSearchList");
  135. }
  136. }
  137. handleCustomerPrev() {
  138. let { interviewIdx } = this.state;
  139. if (interviewIdx == 0) {
  140. this.setState({ current: 0, interviewIdx: -1 });
  141. } else {
  142. interviewIdx -= 1;
  143. this.setState({ interviewIdx });
  144. }
  145. }
  146. handleCustomerNext({ uid, uaiId }) {
  147. let { interviewIdx, uaiIdList } = this.state;
  148. uaiIdList[interviewIdx] = {uid, uaiId};
  149. interviewIdx = interviewIdx + 1;
  150. this.setState({ interviewIdx, uaiIdList });
  151. }
  152. setTabDisabled(item) {
  153. let userInfo = Taro.getStorageSync('userInfor');
  154. if ([1, 2].indexOf(item.type) > -1 && userInfo.type !== 3) {
  155. return true;
  156. }
  157. // else if (item.type === 2 && userInfo.position === 1) {
  158. // return true;
  159. // }
  160. return false;
  161. }
  162. render() {
  163. const { interviewCustomerList, interviewIdx } = this.state;
  164. return (
  165. <View className="applyDepart">
  166. <MessageNoticebar />
  167. <UserFloatingLayer />
  168. <View className="atStepsContent">
  169. <AtSteps items={items} current={this.state.current} />
  170. <View
  171. style={{ display: this.state.current === 0 ? "block" : "none" }}
  172. >
  173. <View style={{ display: "flex", padding: "0 5px" }}>
  174. {[
  175. { type: 0, title: "业务公出" },
  176. { type: 1, title: "技术公出" },
  177. { type: 2, title: "行政公出" },
  178. ].map((item, index) => (
  179. <View style={{ margin: "0 5px" }} key={item.type}>
  180. <AtButton
  181. circle
  182. size="small"
  183. disabled={this.setTabDisabled(item)}
  184. type={
  185. this.state.type == item.type ? "primary" : "secondary"
  186. }
  187. onClick={() => {
  188. this.setState({
  189. type: item.type,
  190. interviewCustomerList: [],
  191. interviewIdx: 0
  192. });
  193. }}
  194. >
  195. {item.title}
  196. </AtButton>
  197. </View>
  198. ))}
  199. <View style={{ flex: "1" }}></View>
  200. </View>
  201. </View>
  202. <View className="content">
  203. <View
  204. style={{ display: this.state.current === 0 ? "block" : "none" }}
  205. >
  206. <Enterprise type={this.state.type} />
  207. </View>
  208. <View
  209. style={{ display: this.state.current === 1 ? "block" : "none" }}
  210. >
  211. {
  212. this.state.type == 0 && interviewCustomerList.length && interviewIdx < interviewCustomerList.length && interviewIdx > -1 ? (
  213. <InterviewCustomer
  214. interviewIdx={interviewIdx}
  215. customerList={interviewCustomerList}
  216. uaiIdList={this.state.uaiIdList}
  217. refreshInterview={this.state.refreshInterview}
  218. onPrevClick={this.handleCustomerPrev.bind(this)}
  219. onNextClick={this.handleCustomerNext.bind(this)}
  220. />
  221. ) : (
  222. <PublicContent
  223. enterpriseInfor={this.state.enterpriseInfor}
  224. selectArrderLocation={this.state.selectArrderLocation}
  225. uaiIdList={this.state.uaiIdList.map(item => item.uaiId)}
  226. />
  227. )
  228. }
  229. </View>
  230. <View
  231. style={{ display: this.state.current === 2 ? "block" : "none" }}
  232. >
  233. <Result
  234. resultState={this.state.resultState}
  235. resultId={this.state.resultId}
  236. punchClockInfor={this.state.punchClockInfor}
  237. isShow={this.state.isShow}
  238. tipList={this.state.tipList}
  239. type={this.state.type}
  240. />
  241. </View>
  242. </View>
  243. </View>
  244. </View>
  245. );
  246. }
  247. }
  248. export default ApplyDepart;