modify.jsx 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. import React, { Component } from "react";
  2. import {
  3. AtCalendar,
  4. AtModal,
  5. AtModalAction,
  6. AtModalContent,
  7. AtButton,
  8. } from "taro-ui";
  9. import { Button, View } from "@tarojs/components";
  10. import Enterprise from "./enterprise";
  11. import PublicContent from "./publicContent";
  12. import { getNewList } from "../../utils/tools";
  13. import { updatePublicRelease } from "../../utils/servers/servers";
  14. import "taro-ui/dist/style/components/modal.scss";
  15. import Taro from "@tarojs/taro";
  16. class Modify extends Component {
  17. constructor(props) {
  18. super(props);
  19. this.state = {
  20. data: {},
  21. dtails: props.dtails,
  22. modifyType: 2,
  23. // colors: "primary",
  24. // color: "secondary",
  25. type: 0,
  26. visibles: true,
  27. // newList: getNewList(props.dtails.uids, props.dtails.userNames),
  28. newList: [],
  29. jsList: [],
  30. };
  31. this.submit = this.submit.bind(this);
  32. this.onChange = this.onChange.bind(this);
  33. this.onVisible = this.onVisible.bind(this);
  34. this.onListChange = this.onListChange.bind(this);
  35. this.getValue = this.getValue.bind(this);
  36. }
  37. getValue(arr, key) {
  38. return arr.map(obj => { return obj[key]; }).join(",")
  39. }
  40. submit() {
  41. // if (this.state.type == 1) {
  42. // Taro.showToast({ title: "技术公出请直接点击公出企业", icon: "none" });
  43. // return;
  44. // } else if (this.state.length == 0) {
  45. // Taro.showToast({ title: "请先选择公出的企业", icon: "none" });
  46. // return;
  47. // }
  48. // if (Object.keys(this.state.data).length === 0) {
  49. // Taro.showToast({ title: "请先选择公出的企业", icon: "none" });
  50. // return;
  51. // } else if (this.state.type == 1) {
  52. // Taro.showToast({ title: "技术公出请直接点击公出企业", icon: "none" });
  53. // return;
  54. // }
  55. let obj = {}
  56. if (this.state.type != 1) {
  57. obj = { uids: this.getValue(this.state.newList, "id"), userNames: this.getValue(this.state.newList, "name"), type: this.state.type, newList: this.state.newList }
  58. } else {
  59. obj = { uids: this.getValue(this.state.jsList, "id"), userNames: this.getValue(this.state.jsList, "name"), type: this.state.type, newList: this.state.newList }
  60. }
  61. this.setState({
  62. dtails: {
  63. ...this.state.dtails,
  64. ...obj,
  65. },
  66. data: obj,
  67. })
  68. this.setState({
  69. modifyType: 2,
  70. });
  71. }
  72. onVisible() {
  73. this.setState({
  74. visibles: false,
  75. });
  76. }
  77. componentWillUnmount() {
  78. this.setState({
  79. data: {},
  80. });
  81. }
  82. onListChange(list) {
  83. this.setState({
  84. newList: list
  85. })
  86. }
  87. onChange(value, visi) {
  88. value.type = this.state.type;
  89. this.setState({
  90. dtails: {
  91. ...this.state.dtails,
  92. ...value,
  93. },
  94. data: value,
  95. modifyType: 2,
  96. });
  97. // if (visi == 0) {
  98. // this.setState({
  99. // dtails: {
  100. // ...this.state.dtails,
  101. // ...value,
  102. // },
  103. // data: value,
  104. // });
  105. // } else {
  106. // value.type = this.state.type;
  107. // this.setState({
  108. // dtails: {
  109. // ...this.state.dtails,
  110. // ...value,
  111. // },
  112. // data: value,
  113. // modifyType: 2,
  114. // });
  115. // }
  116. }
  117. render() {
  118. let userInfor = Taro.getStorageSync('userInfor');
  119. return (
  120. <AtModal isOpened={this.props.isOpened} onClose={this.props.onModalClose}>
  121. {this.state.modifyType === 1 ? (
  122. <View
  123. style={{ display: "flex", margin: "10px 0 0 0", padding: "0 5px" }}
  124. >
  125. {[
  126. { type: 0, title: "业务公出" },
  127. { type: 1, title: "技术公出" },
  128. { type: 2, title: "行政公出" },
  129. ].map((item) => (
  130. <View style={{ margin: "0 5px" }} key={item.type}>
  131. <AtButton
  132. circle
  133. size="small"
  134. disabled={item.type === 1 && userInfor.type !== 3}
  135. type={this.state.type == item.type ? "primary" : "secondary"}
  136. onClick={() => {
  137. this.setState({
  138. type: item.type,
  139. });
  140. item.type != 1 &&
  141. this.setState({
  142. visibles: true,
  143. });
  144. }}
  145. >
  146. {item.title}
  147. </AtButton>
  148. </View>
  149. ))}
  150. <View style={{ flex: "1" }}></View>
  151. </View>
  152. ) : (
  153. ""
  154. )}
  155. <AtModalContent>
  156. {this.state.modifyType === 1 ? (
  157. <Enterprise
  158. type={this.state.type}
  159. isOpened={this.props.isOpened}
  160. isVerify={this.props.isVerify} //判断是否在审核中修改
  161. onChange={this.onChange}
  162. newList={this.state.newList}
  163. jsList={this.state.jsList}
  164. onListChange={this.onListChange}
  165. />
  166. ) : (
  167. <PublicContent
  168. permission={this.props.permission}
  169. index={this.props.index}
  170. type={this.state.type}
  171. onClose={() => {
  172. this.props.onClose();
  173. }}
  174. locationInfor={this.props.locationInfor}
  175. dtails={this.state.dtails}
  176. isOpened={this.props.isOpened}
  177. isVerify={this.props.isVerify}
  178. reason={this.props.reason}//修改原因
  179. onChange={this.onChange}
  180. onBack={() => {
  181. this.setState({
  182. modifyType: 1,
  183. });
  184. }}
  185. />
  186. )}
  187. </AtModalContent>
  188. {this.state.modifyType === 1 ? (
  189. <AtModalAction>
  190. <Button
  191. onClick={() => {
  192. this.props.onClose();
  193. }}
  194. >
  195. 取消
  196. </Button>
  197. <Button onClick={this.submit}>下一步</Button>
  198. </AtModalAction>
  199. ) : null}
  200. </AtModal>
  201. );
  202. }
  203. }
  204. export default Modify;