modify.jsx 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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 { updatePublicRelease } from "../../utils/servers/servers";
  13. import "taro-ui/dist/style/components/modal.scss";
  14. import Taro from "@tarojs/taro";
  15. class Modify extends Component {
  16. constructor(props) {
  17. super(props);
  18. this.state = {
  19. data: {},
  20. dtails: props.dtails,
  21. modifyType: 2,
  22. // colors: "primary",
  23. // color: "secondary",
  24. type: 0,
  25. visibles: true,
  26. };
  27. this.submit = this.submit.bind(this);
  28. this.onChange = this.onChange.bind(this);
  29. this.onVisible = this.onVisible.bind(this);
  30. }
  31. submit() {
  32. if (Object.keys(this.state.data).length === 0) {
  33. Taro.showToast({ title: "请先选择公出的企业", icon: "none" });
  34. return;
  35. } else if (this.state.type == 1) {
  36. Taro.showToast({ title: "技术公出请直接点击公出企业", icon: "none" });
  37. return;
  38. }
  39. this.setState({
  40. modifyType: 2,
  41. });
  42. }
  43. onVisible() {
  44. this.setState({
  45. visibles: false,
  46. });
  47. }
  48. componentWillUnmount() {
  49. this.setState({
  50. data: {},
  51. });
  52. }
  53. onChange(value, visi) {
  54. console.log("----", value, visi);
  55. value.type = this.state.type;
  56. this.setState({
  57. dtails: {
  58. ...this.state.dtails,
  59. ...value,
  60. },
  61. data: value,
  62. modifyType: 2,
  63. });
  64. //判断不明确暂时注释,明确后再行修改
  65. // if (visi == 0) {
  66. // this.setState({
  67. // dtails: {
  68. // ...this.state.dtails,
  69. // ...value,
  70. // },
  71. // data: value,
  72. // });
  73. // } else {
  74. // value.type = this.state.type;
  75. // this.setState({
  76. // dtails: {
  77. // ...this.state.dtails,
  78. // ...value,
  79. // },
  80. // data: value,
  81. // modifyType: 2,
  82. // });
  83. // }
  84. }
  85. render() {
  86. return (
  87. <AtModal isOpened={this.props.isOpened} onClose={this.props.onModalClose}>
  88. {this.state.modifyType === 1 ? (
  89. <View
  90. style={{ display: "flex", margin: "10px 0 0 0", padding: "0 5px" }}
  91. >
  92. {[
  93. { type: 0, title: "业务公出" },
  94. { type: 1, title: "技术公出" },
  95. { type: 2, title: "行政公出" },
  96. ].map((item) => (
  97. <View style={{ margin: "0 5px" }} key={item.type}>
  98. <AtButton
  99. circle
  100. size="small"
  101. type={this.state.type == item.type ? "primary" : "secondary"}
  102. onClick={() => {
  103. this.setState({
  104. type: item.type,
  105. });
  106. item.type != 1 &&
  107. this.setState({
  108. visibles: true,
  109. });
  110. }}
  111. >
  112. {item.title}
  113. </AtButton>
  114. </View>
  115. ))}
  116. {/* <View style={{ margin: '0 10px' }}>
  117. <AtButton circle size='small' type={this.state.colors} onClick={() => {
  118. this.setState({
  119. colors: 'primary',
  120. color: 'secondary',
  121. type: 0,
  122. visibles:true
  123. })
  124. }}>业务/行政公出</AtButton>
  125. </View>
  126. <AtButton type={this.state.color} circle size='small' onClick={() => {
  127. this.setState({
  128. colors: 'secondary',
  129. color: 'primary',
  130. type: 1,
  131. })
  132. }}>技术公出</AtButton> */}
  133. <View style={{ flex: "1" }}></View>
  134. </View>
  135. ) : (
  136. ""
  137. )}
  138. <AtModalContent>
  139. {this.state.modifyType === 1 ? (
  140. <Enterprise
  141. type={this.state.type}
  142. isOpened={this.props.isOpened}
  143. onChange={this.onChange}
  144. />
  145. ) : (
  146. <PublicContent
  147. permission={this.props.permission}
  148. index={this.props.index}
  149. type={this.state.type}
  150. onClose={() => {
  151. this.props.onClose();
  152. }}
  153. locationInfor={this.props.locationInfor}
  154. dtails={this.state.dtails}
  155. isOpened={this.props.isOpened}
  156. onChange={this.onChange}
  157. onBack={() => {
  158. this.setState({
  159. modifyType: 1,
  160. });
  161. }}
  162. />
  163. )}
  164. </AtModalContent>
  165. {this.state.modifyType === 1 ? (
  166. <AtModalAction>
  167. <Button
  168. onClick={() => {
  169. this.props.onClose();
  170. }}
  171. >
  172. 取消
  173. </Button>
  174. <Button onClick={this.submit}>下一步</Button>
  175. </AtModalAction>
  176. ) : null}
  177. </AtModal>
  178. );
  179. }
  180. }
  181. export default Modify;