index.jsx 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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. const { 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 (item.type === 1 && userInfo.type !== 3) {
  155. return true;
  156. } else if (item.type === 2 && userInfo.position === 1) {
  157. return true;
  158. }
  159. return false;
  160. }
  161. render() {
  162. const { interviewCustomerList, interviewIdx } = this.state;
  163. return (
  164. <View className="applyDepart">
  165. <MessageNoticebar />
  166. <UserFloatingLayer />
  167. <View className="atStepsContent">
  168. <AtSteps items={items} current={this.state.current} />
  169. <View
  170. style={{ display: this.state.current === 0 ? "block" : "none" }}
  171. >
  172. <View style={{ display: "flex", padding: "0 5px" }}>
  173. {[
  174. { type: 0, title: "业务公出" },
  175. { type: 1, title: "技术公出" },
  176. { type: 2, title: "行政公出" },
  177. ].map((item, index) => (
  178. <View style={{ margin: "0 5px" }} key={item.type}>
  179. <AtButton
  180. circle
  181. size="small"
  182. disabled={this.setTabDisabled(item)}
  183. type={
  184. this.state.type == item.type ? "primary" : "secondary"
  185. }
  186. onClick={() => {
  187. this.setState({
  188. type: item.type,
  189. interviewCustomerList: [],
  190. interviewIdx: 0
  191. });
  192. }}
  193. >
  194. {item.title}
  195. </AtButton>
  196. </View>
  197. ))}
  198. <View style={{ flex: "1" }}></View>
  199. </View>
  200. </View>
  201. <View className="content">
  202. <View
  203. style={{ display: this.state.current === 0 ? "block" : "none" }}
  204. >
  205. <Enterprise type={this.state.type} />
  206. </View>
  207. <View
  208. style={{ display: this.state.current === 1 ? "block" : "none" }}
  209. >
  210. {
  211. this.state.type == 0 && interviewCustomerList.length && interviewIdx < interviewCustomerList.length && interviewIdx > -1 ? (
  212. <InterviewCustomer
  213. interviewIdx={interviewIdx}
  214. customerList={interviewCustomerList}
  215. uaiIdList={this.state.uaiIdList}
  216. refreshInterview={this.state.refreshInterview}
  217. onPrevClick={this.handleCustomerPrev.bind(this)}
  218. onNextClick={this.handleCustomerNext.bind(this)}
  219. />
  220. ) : (
  221. <PublicContent
  222. enterpriseInfor={this.state.enterpriseInfor}
  223. selectArrderLocation={this.state.selectArrderLocation}
  224. uaiIdList={this.state.uaiIdList.map(item => item.uaiId)}
  225. />
  226. )
  227. }
  228. </View>
  229. <View
  230. style={{ display: this.state.current === 2 ? "block" : "none" }}
  231. >
  232. <Result
  233. resultState={this.state.resultState}
  234. resultId={this.state.resultId}
  235. punchClockInfor={this.state.punchClockInfor}
  236. isShow={this.state.isShow}
  237. tipList={this.state.tipList}
  238. type={this.state.type}
  239. />
  240. </View>
  241. </View>
  242. </View>
  243. </View>
  244. );
  245. }
  246. }
  247. export default ApplyDepart;