index.jsx 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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 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. constructor(props) {
  40. super(props);
  41. this.state = {
  42. current: 0,
  43. enterpriseInfor: {},
  44. selectArrderLocation: {},
  45. resultState: 0,
  46. resultId: "",
  47. punchClockInfor: {},
  48. // colors: "primary",
  49. // color: "secondary",
  50. // selectColor: 0,
  51. type: 0,
  52. isShow: false,
  53. tipList: [],
  54. // 需要面谈的客户列表,只有业务员自己的客户才能面谈
  55. interviewCustomerList: [],
  56. interviewIdx: 0,
  57. // 面谈后返回的id
  58. uaiIdList: []
  59. };
  60. }
  61. componentDidShow() {
  62. Taro.eventCenter.on("enterprise", (arg) => {
  63. arg.type = this.state.type;
  64. // 跳转
  65. this.setState({
  66. current: 1,
  67. enterpriseInfor: arg,
  68. interviewCustomerList: arg.list.filter(item => item.myUser === 1),
  69. interviewIdx: 0
  70. });
  71. });
  72. Taro.eventCenter.on("publicContent", (arg) => {
  73. this.setState({
  74. current: 2,
  75. resultState: arg.code,
  76. resultId: arg.data ? arg.data.id : "",
  77. punchClockInfor: arg.data || {},
  78. isShow: arg.isShow,
  79. tipList: arg?.list,
  80. });
  81. });
  82. Taro.eventCenter.on("enterpriseBack", () => {
  83. const { interviewCustomerList } = this.state;
  84. if (interviewCustomerList.length) {
  85. this.setState({ interviewIdx: interviewCustomerList.length - 1 });
  86. } else {
  87. this.setState({
  88. current: 0,
  89. });
  90. }
  91. });
  92. Taro.eventCenter.on("result", () => {
  93. this.setState({
  94. current: 0,
  95. enterpriseInfor: {},
  96. selectArrderLocation: {},
  97. resultState: 0,
  98. resultId: "",
  99. punchClockInfor: {},
  100. });
  101. });
  102. //获取地区选定数据
  103. const chooseLocation = requirePlugin("chooseLocation");
  104. const location = chooseLocation.getLocation();
  105. if (location) {
  106. this.setState({
  107. selectArrderLocation: location,
  108. });
  109. }
  110. }
  111. componentDidMount() { }
  112. onReachBottom() {
  113. if (this.state.current === 0) {
  114. Taro.eventCenter.trigger("applyDepartSearchList");
  115. }
  116. }
  117. handleCustomerPrev() {
  118. const { interviewIdx } = this.state;
  119. if (interviewIdx == 0) {
  120. this.setState({ current: 0, interviewIdx: -1 });
  121. } else {
  122. interviewIdx -= 1;
  123. this.setState({ interviewIdx });
  124. }
  125. }
  126. handleCustomerNext({ uaiId }) {
  127. let { interviewIdx, uaiIdList } = this.state;
  128. interviewIdx = interviewIdx + 1;
  129. uaiIdList.push(uaiId);
  130. this.setState({ interviewIdx, uaiIdList });
  131. }
  132. render() {
  133. let userInfor = Taro.getStorageSync('userInfor');
  134. const { interviewCustomerList, interviewIdx } = this.state;
  135. return (
  136. <View className="applyDepart">
  137. <MessageNoticebar />
  138. <UserFloatingLayer />
  139. <View className="atStepsContent">
  140. <AtSteps items={items} current={this.state.current} />
  141. <View
  142. style={{ display: this.state.current === 0 ? "block" : "none" }}
  143. >
  144. <View style={{ display: "flex", padding: "0 5px" }}>
  145. {[
  146. { type: 0, title: "业务公出" },
  147. { type: 1, title: "技术公出" },
  148. { type: 2, title: "行政公出" },
  149. ].map((item, index) => (
  150. <View style={{ margin: "0 5px" }} key={item.type}>
  151. <AtButton
  152. circle
  153. size="small"
  154. disabled={item.type === 1 && userInfor.type !== 3}
  155. type={
  156. this.state.type == item.type ? "primary" : "secondary"
  157. }
  158. onClick={() => {
  159. this.setState({
  160. type: item.type,
  161. });
  162. }}
  163. >
  164. {item.title}
  165. </AtButton>
  166. </View>
  167. ))}
  168. <View style={{ flex: "1" }}></View>
  169. </View>
  170. </View>
  171. <View className="content">
  172. <View
  173. style={{ display: this.state.current === 0 ? "block" : "none" }}
  174. >
  175. <Enterprise type={this.state.type} />
  176. </View>
  177. <View
  178. style={{ display: this.state.current === 1 ? "block" : "none" }}
  179. >
  180. {
  181. this.state.type == 0 && interviewCustomerList.length && interviewIdx < interviewCustomerList.length ? (
  182. <InterviewCustomer
  183. interviewIdx={interviewIdx}
  184. customerList={interviewCustomerList}
  185. onPrevClick={this.handleCustomerPrev.bind(this)}
  186. onNextClick={this.handleCustomerNext.bind(this)}
  187. />
  188. ) : (
  189. <PublicContent
  190. enterpriseInfor={this.state.enterpriseInfor}
  191. selectArrderLocation={this.state.selectArrderLocation}
  192. uaiIdList={this.state.uaiIdList}
  193. />
  194. )
  195. }
  196. </View>
  197. <View
  198. style={{ display: this.state.current === 2 ? "block" : "none" }}
  199. >
  200. <Result
  201. resultState={this.state.resultState}
  202. resultId={this.state.resultId}
  203. punchClockInfor={this.state.punchClockInfor}
  204. isShow={this.state.isShow}
  205. tipList={this.state.tipList}
  206. type={this.state.type}
  207. />
  208. </View>
  209. </View>
  210. </View>
  211. </View>
  212. );
  213. }
  214. }
  215. export default ApplyDepart;