import React, { Component } from "react"; import { AtCalendar, AtModal, AtModalAction, AtModalContent, AtButton, } from "taro-ui"; import { Button, View } from "@tarojs/components"; import Enterprise from "./enterprise"; import PublicContent from "./publicContent"; import { getNewList } from "../../utils/tools"; import { updatePublicRelease } from "../../utils/servers/servers"; import "taro-ui/dist/style/components/modal.scss"; import Taro from "@tarojs/taro"; class Modify extends Component { constructor(props) { super(props); this.state = { data: {}, dtails: props.dtails, modifyType: 2, // colors: "primary", // color: "secondary", type: 0, visibles: true, // newList: getNewList(props.dtails.uids, props.dtails.userNames), newList: [], jsList: [], }; this.submit = this.submit.bind(this); this.onChange = this.onChange.bind(this); this.onVisible = this.onVisible.bind(this); this.onListChange = this.onListChange.bind(this); this.getValue = this.getValue.bind(this); } getValue(arr, key) { return arr.map(obj => { return obj[key]; }).join(",") } submit() { // if (this.state.type == 1) { // Taro.showToast({ title: "技术公出请直接点击公出企业", icon: "none" }); // return; // } else if (this.state.length == 0) { // Taro.showToast({ title: "请先选择公出的企业", icon: "none" }); // return; // } // if (Object.keys(this.state.data).length === 0) { // Taro.showToast({ title: "请先选择公出的企业", icon: "none" }); // return; // } else if (this.state.type == 1) { // Taro.showToast({ title: "技术公出请直接点击公出企业", icon: "none" }); // return; // } let obj = {} if (this.state.type != 1) { obj = { uids: this.getValue(this.state.newList, "id"), userNames: this.getValue(this.state.newList, "name"), type: this.state.type, newList: this.state.newList } } else { obj = { uids: this.getValue(this.state.jsList, "id"), userNames: this.getValue(this.state.jsList, "name"), type: this.state.type, newList: this.state.newList } } this.setState({ dtails: { ...this.state.dtails, ...obj, }, data: obj, }) this.setState({ modifyType: 2, }); } onVisible() { this.setState({ visibles: false, }); } componentWillUnmount() { this.setState({ data: {}, }); } onListChange(list) { this.setState({ newList: list }) } onChange(value, visi) { value.type = this.state.type; this.setState({ dtails: { ...this.state.dtails, ...value, }, data: value, modifyType: 2, }); // if (visi == 0) { // this.setState({ // dtails: { // ...this.state.dtails, // ...value, // }, // data: value, // }); // } else { // value.type = this.state.type; // this.setState({ // dtails: { // ...this.state.dtails, // ...value, // }, // data: value, // modifyType: 2, // }); // } } render() { let userInfor = Taro.getStorageSync('userInfor'); return ( {this.state.modifyType === 1 ? ( {[ { type: 0, title: "业务公出" }, { type: 1, title: "技术公出" }, { type: 2, title: "行政公出" }, ].map((item) => ( { this.setState({ type: item.type, }); item.type != 1 && this.setState({ visibles: true, }); }} > {item.title} ))} ) : ( "" )} {this.state.modifyType === 1 ? ( ) : ( { this.props.onClose(); }} locationInfor={this.props.locationInfor} dtails={this.state.dtails} isOpened={this.props.isOpened} isVerify={this.props.isVerify} reason={this.props.reason}//修改原因 onChange={this.onChange} onBack={() => { this.setState({ modifyType: 1, }); }} /> )} {this.state.modifyType === 1 ? ( ) : null} ); } } export default Modify;