gxczx.jsx 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. import React, { Component } from "react";
  2. import { Form, Button, Radio, Modal, Input, message, Switch } from "antd";
  3. import { knowledgeList, auditList, addDeductionList, } from "@/dataDic.js";
  4. /**
  5. * 高新纯咨询合同说明添加和详情
  6. */
  7. const RadioButton = Radio.Button;
  8. const RadioGroup = Radio.Group;
  9. const radioStyle = {
  10. display: 'block',
  11. height: '30px',
  12. lineHeight: '30px',
  13. };
  14. let num = 1;
  15. const FormItem = Form.Item;
  16. class Gxczx extends Component {
  17. constructor(props) {
  18. super(props);
  19. this.state = {
  20. gxczx: "", //高新纯咨询合同说明弹窗
  21. knowledgeOther: "",
  22. auditOther: "",
  23. addDeductionOther: "",
  24. }
  25. }
  26. componentDidMount() {
  27. }
  28. componentWillUnmount() {
  29. num = 1
  30. }
  31. componentWillReceiveProps(nextProps) {
  32. const { knowledgeServices, auditServices, addDeductionServices,
  33. knowledgeOther, auditOther, addDeductionOther, isCreat = false } = this.props
  34. if (knowledgeServices != null && auditServices != null && addDeductionServices != null) {
  35. if (isCreat) {
  36. // 防止刷新进入,只能第一次渲染的时候触发 选择未签会让值变成-1(除了1,其他都归-1) 导致找不到label
  37. if (num == 1 && this.state.gxczx == "") {
  38. if (knowledgeServices != -1 && auditServices != -1 && addDeductionServices != -1) {
  39. this.setState({
  40. knowledgeText: knowledgeServices == 0
  41. ? knowledgeOther
  42. : knowledgeList.find(v => { return v.value == knowledgeServices }).label,
  43. auditText: auditServices == 0
  44. ? auditOther
  45. : auditList.find(v => { return v.value == auditServices }).label,
  46. addDeductionText: addDeductionServices == 0
  47. ? addDeductionOther
  48. : addDeductionList.find(v => { return v.value == addDeductionServices }).label,
  49. zscq: knowledgeServices == null
  50. ? null
  51. : (knowledgeServices != 1 ? -1 : 1),
  52. sjfw: auditServices == null
  53. ? null
  54. : (auditServices != 1 ? -1 : 1),
  55. jjkc: addDeductionServices == null
  56. ? null
  57. : (addDeductionServices != 1 ? -1 : 1),
  58. }, () => {
  59. num++
  60. })
  61. }
  62. }
  63. } else {
  64. this.setState({
  65. knowledgeText: knowledgeServices == 0
  66. ? knowledgeOther
  67. : knowledgeList.find(v => { return v.value == knowledgeServices }).label,
  68. auditText: auditServices == 0
  69. ? auditOther
  70. : auditList.find(v => { return v.value == auditServices }).label,
  71. addDeductionText: addDeductionServices == 0
  72. ? addDeductionOther
  73. : addDeductionList.find(v => { return v.value == addDeductionServices }).label,
  74. })
  75. }
  76. }
  77. }
  78. render() {
  79. const { knowledgeServices, auditServices, addDeductionServices, isCreat = false, isShow } = this.props
  80. return (
  81. <div>
  82. {
  83. // 是否可编辑
  84. isCreat ?
  85. <div>
  86. <h3
  87. style={{
  88. marginLeft: 10,
  89. fontWeight: 800,
  90. marginBottom: 10,
  91. }}
  92. >
  93. 高新纯咨询合同说明 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
  94. <Switch checkedChildren="开" unCheckedChildren="关" checked={isShow}
  95. onChange={e => { this.props.onSwitch(e) }} />
  96. </h3>
  97. {
  98. isShow &&
  99. <div>
  100. <FormItem
  101. labelCol={{ span: 5 }}
  102. wrapperCol={{ span: 19 }}
  103. label={<span><strong style={{ color: "#f00" }}>*</strong>知识产权</span>}
  104. >
  105. <RadioGroup
  106. value={this.state.zscq}
  107. onChange={e => {
  108. num = 2
  109. this.setState({
  110. knowledgeServices: e.target.value == 1 ? 1 : undefined,
  111. zscq: e.target.value,
  112. gxczx: e.target.value == -1 ? "zscq" : "",
  113. })
  114. this.props.selknowledge({ knowledgeServices: e.target.value })
  115. }}>
  116. <RadioButton value={1}>已签</RadioButton>
  117. <RadioButton value={-1}>未签</RadioButton>
  118. </RadioGroup>
  119. <span style={{ marginLeft: 19 }}>
  120. {this.props.knowledgeServices == 1 ? "" : this.state.knowledgeText}
  121. </span>
  122. </FormItem>
  123. <FormItem
  124. labelCol={{ span: 5 }}
  125. wrapperCol={{ span: 19 }}
  126. label={<span><strong style={{ color: "#f00" }}>*</strong>审计服务</span>}
  127. >
  128. <RadioGroup
  129. value={this.state.sjfw}
  130. onChange={e => {
  131. num = 2
  132. this.setState({
  133. auditServices: e.target.value == 1 ? 1 : undefined,
  134. sjfw: e.target.value,
  135. gxczx: e.target.value == -1 ? "sjfw" : "",
  136. })
  137. this.props.selaudit({ auditServices: e.target.value })
  138. }}>
  139. <RadioButton value={1}>已签</RadioButton>
  140. <RadioButton value={-1}>未签</RadioButton>
  141. </RadioGroup>
  142. <span style={{ marginLeft: 19 }}>
  143. {this.props.auditServices == 1 ? "" : this.state.auditText}
  144. </span>
  145. </FormItem>
  146. <FormItem
  147. labelCol={{ span: 5 }}
  148. wrapperCol={{ span: 19 }}
  149. label={<span><strong style={{ color: "#f00" }}>*</strong>加计扣除服务</span>}
  150. >
  151. <RadioGroup
  152. value={this.state.jjkc}
  153. onChange={e => {
  154. num = 2
  155. this.setState({
  156. addDeductionServices: e.target.value == 1 ? 1 : undefined,
  157. jjkc: e.target.value,
  158. gxczx: e.target.value == -1 ? "jjkc" : ""
  159. })
  160. this.props.seladdDeduction({ addDeductionServices: e.target.value })
  161. }}>
  162. <RadioButton value={1}>已签</RadioButton>
  163. <RadioButton value={-1}>未签</RadioButton>
  164. </RadioGroup>
  165. <span style={{ marginLeft: 19 }}>
  166. {this.props.addDeductionServices == 1 ? "" : this.state.addDeductionText}
  167. </span>
  168. </FormItem>
  169. </div>
  170. }
  171. </div> :
  172. <div>
  173. {
  174. (knowledgeServices == null || auditServices == null || addDeductionServices == null)
  175. ? null :
  176. <div>
  177. <h3
  178. style={{
  179. marginLeft: 10,
  180. fontWeight: 800,
  181. marginBottom: 10,
  182. }}
  183. >
  184. 高新纯咨询合同说明
  185. </h3>
  186. <div>
  187. <FormItem
  188. labelCol={{ span: 5 }}
  189. wrapperCol={{ span: 19 }}
  190. label="知识产权"
  191. >
  192. {<Button type="primary" size="default">{knowledgeServices == 1 ? "已签" : "未签"}</Button>}
  193. <span style={{ marginLeft: 19 }}>
  194. {knowledgeServices == 1 ? "" : this.state.knowledgeText}
  195. </span>
  196. </FormItem>
  197. <FormItem
  198. labelCol={{ span: 5 }}
  199. wrapperCol={{ span: 19 }}
  200. label="审计服务"
  201. >
  202. {<Button type="primary" size="default">{auditServices == 1 ? "已签" : "未签"}</Button>}
  203. <span style={{ marginLeft: 19 }}>
  204. {auditServices == 1 ? "" : this.state.auditText}
  205. </span>
  206. </FormItem>
  207. <FormItem
  208. labelCol={{ span: 5 }}
  209. wrapperCol={{ span: 19 }}
  210. label="加计扣除服务"
  211. >
  212. {<Button type="primary" size="default">{addDeductionServices == 1 ? "已签" : "未签"}</Button>}
  213. <span style={{ marginLeft: 19 }}>
  214. {addDeductionServices == 1 ? "" : this.state.addDeductionText}
  215. </span>
  216. </FormItem>
  217. </div>
  218. </div>
  219. }
  220. </div>
  221. }
  222. {
  223. this.state.gxczx != "" &&
  224. <Modal
  225. title="请选择"
  226. visible={this.state.gxczx != ""}
  227. closable={false}
  228. footer={[
  229. <Button type="primary" key="submit"
  230. onClick={() => {
  231. let reason = ""
  232. if (this.state.gxczx == "zscq") {
  233. if (this.state.knowledgeServices == undefined) {
  234. message.warn("请选择原因!")
  235. return
  236. }
  237. reason = this.state.knowledgeServices == 0
  238. ? this.state.knowledgeOther
  239. : knowledgeList.find(v => { return v.value == this.state.knowledgeServices }).label
  240. this.setState({
  241. knowledgeText: reason
  242. })
  243. this.props.selknowledge({ knowledgeServices: this.state.knowledgeServices, knowledgeOther: this.state.knowledgeOther })
  244. } else if (this.state.gxczx == "sjfw") {
  245. if (this.state.auditServices == undefined) {
  246. message.warn("请选择原因!")
  247. return
  248. }
  249. reason = this.state.auditServices == 0
  250. ? this.state.auditOther
  251. : auditList.find(v => { return v.value == this.state.auditServices }).label
  252. this.setState({
  253. auditText: reason
  254. })
  255. this.props.selaudit({ auditServices: this.state.auditServices, auditOther: this.state.auditOther })
  256. } else if (this.state.gxczx == "jjkc") {
  257. if (this.state.addDeductionServices == undefined) {
  258. message.warn("请选择原因!")
  259. return
  260. }
  261. reason = this.state.addDeductionServices == 0
  262. ? this.state.addDeductionOther
  263. : addDeductionList.find(v => { return v.value == this.state.addDeductionServices }).label
  264. this.setState({
  265. addDeductionText: reason
  266. })
  267. this.props.seladdDeduction({ addDeductionServices: this.state.addDeductionServices, addDeductionOther: this.state.addDeductionOther })
  268. }
  269. if (!reason) {
  270. message.warn("请填写原因!")
  271. return
  272. }
  273. if (!reason.replace(/\s+/g, '')) {
  274. message.warn("请填写原因!")
  275. return
  276. }
  277. this.setState({
  278. gxczx: "",
  279. })
  280. }}
  281. >确定</Button>
  282. ]
  283. }
  284. >
  285. {
  286. this.state.gxczx == "zscq" ?
  287. <RadioGroup onChange={e => { this.setState({ knowledgeServices: e.target.value }) }} value={this.state.knowledgeServices}>
  288. {
  289. knowledgeList.map(item =>
  290. item.value != 1 &&
  291. <Radio style={radioStyle} value={item.value}>{item.label}
  292. {(this.state.knowledgeServices === 0 && item.value == 0) ?
  293. <Input
  294. placeholder="请填写原因"
  295. style={{ width: 400, marginLeft: 10 }}
  296. value={this.state.knowledgeOther}
  297. onChange={e => {
  298. this.setState({
  299. knowledgeOther: e.target.value
  300. })
  301. }}
  302. /> : null}
  303. </Radio>
  304. )
  305. }
  306. </RadioGroup> :
  307. this.state.gxczx == "sjfw" ?
  308. <RadioGroup onChange={e => { this.setState({ auditServices: e.target.value }) }} value={this.state.auditServices}>
  309. {
  310. auditList.map(item =>
  311. item.value != 1 &&
  312. <Radio style={radioStyle} value={item.value}>{item.label}
  313. {(this.state.auditServices === 0 && item.value == 0) ?
  314. <Input
  315. placeholder="请填写原因"
  316. style={{ width: 400, marginLeft: 10 }}
  317. value={this.state.auditOther}
  318. onChange={e => {
  319. this.setState({
  320. auditOther: e.target.value
  321. })
  322. }}
  323. /> : null}
  324. </Radio>
  325. )
  326. }
  327. </RadioGroup> :
  328. this.state.gxczx == "jjkc" &&
  329. <RadioGroup onChange={e => { this.setState({ addDeductionServices: e.target.value }) }} value={this.state.addDeductionServices}>
  330. {
  331. addDeductionList.map(item =>
  332. item.value != 1 &&
  333. <Radio style={radioStyle} value={item.value}>{item.label}
  334. {(this.state.addDeductionServices === 0 && item.value == 0) ?
  335. <Input
  336. placeholder="请填写原因"
  337. style={{ width: 400, marginLeft: 10 }}
  338. value={this.state.addDeductionOther}
  339. onChange={e => {
  340. this.setState({
  341. addDeductionOther: e.target.value
  342. })
  343. }}
  344. /> : null}
  345. </Radio>
  346. )
  347. }
  348. </RadioGroup>
  349. }
  350. </Modal >
  351. }
  352. </div >
  353. );
  354. }
  355. }
  356. export default Gxczx;