gxczx.jsx 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. import React, { Component } from "react";
  2. import { Form, Button, Radio, Modal, Input, message } 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 ? null : (knowledgeServices != 1 ? -1 : 1),
  50. sjfw: auditServices == null ? null : (auditServices != 1 ? -1 : 1),
  51. jjkc: addDeductionServices == null ? null : (addDeductionServices != 1 ? -1 : 1),
  52. }, () => {
  53. num++
  54. })
  55. }
  56. }
  57. } else {
  58. this.setState({
  59. knowledgeText: knowledgeServices == 0
  60. ? knowledgeOther
  61. : knowledgeList.find(v => { return v.value == knowledgeServices }).label,
  62. auditText: auditServices == 0
  63. ? auditOther
  64. : auditList.find(v => { return v.value == auditServices }).label,
  65. addDeductionText: addDeductionServices == 0
  66. ? addDeductionOther
  67. : addDeductionList.find(v => { return v.value == addDeductionServices }).label,
  68. })
  69. }
  70. }
  71. }
  72. render() {
  73. const { knowledgeServices, auditServices, addDeductionServices, isCreat = false } = this.props
  74. return (
  75. <div>
  76. {
  77. // 是否可编辑
  78. isCreat ?
  79. <div>
  80. <h3
  81. style={{
  82. marginLeft: 10,
  83. fontWeight: 800,
  84. marginBottom: 10,
  85. }}
  86. >
  87. 高新纯咨询合同说明
  88. </h3>
  89. <div>
  90. <FormItem
  91. labelCol={{ span: 5 }}
  92. wrapperCol={{ span: 19 }}
  93. label={<span><strong style={{ color: "#f00" }}>*</strong>知识产权</span>}
  94. >
  95. <RadioGroup
  96. value={this.state.zscq}
  97. onChange={e => {
  98. num = 2
  99. this.setState({
  100. knowledgeServices: e.target.value == 1 ? 1 : undefined,
  101. zscq: e.target.value,
  102. gxczx: e.target.value == -1 ? "zscq" : "",
  103. })
  104. this.props.selknowledge({ knowledgeServices: e.target.value })
  105. }}>
  106. <RadioButton value={1}>已签</RadioButton>
  107. <RadioButton value={-1}>未签</RadioButton>
  108. </RadioGroup>
  109. <span style={{ marginLeft: 19 }}>
  110. {this.props.knowledgeServices == 1 ? "" : this.state.knowledgeText}
  111. </span>
  112. </FormItem>
  113. <FormItem
  114. labelCol={{ span: 5 }}
  115. wrapperCol={{ span: 19 }}
  116. label={<span><strong style={{ color: "#f00" }}>*</strong>审计服务</span>}
  117. >
  118. <RadioGroup
  119. value={this.state.sjfw}
  120. onChange={e => {
  121. num = 2
  122. this.setState({
  123. auditServices: e.target.value == 1 ? 1 : undefined,
  124. sjfw: e.target.value,
  125. gxczx: e.target.value == -1 ? "sjfw" : "",
  126. })
  127. this.props.selaudit({ auditServices: e.target.value })
  128. }}>
  129. <RadioButton value={1}>已签</RadioButton>
  130. <RadioButton value={-1}>未签</RadioButton>
  131. </RadioGroup>
  132. <span style={{ marginLeft: 19 }}>
  133. {this.props.auditServices == 1 ? "" : this.state.auditText}
  134. </span>
  135. </FormItem>
  136. <FormItem
  137. labelCol={{ span: 5 }}
  138. wrapperCol={{ span: 19 }}
  139. label={<span><strong style={{ color: "#f00" }}>*</strong>加计扣除服务</span>}
  140. >
  141. <RadioGroup
  142. value={this.state.jjkc}
  143. onChange={e => {
  144. num = 2
  145. this.setState({
  146. addDeductionServices: e.target.value == 1 ? 1 : undefined,
  147. jjkc: e.target.value,
  148. gxczx: e.target.value == -1 ? "jjkc" : ""
  149. })
  150. this.props.seladdDeduction({ addDeductionServices: e.target.value })
  151. }}>
  152. <RadioButton value={1}>已签</RadioButton>
  153. <RadioButton value={-1}>未签</RadioButton>
  154. </RadioGroup>
  155. <span style={{ marginLeft: 19 }}>
  156. {this.props.addDeductionServices == 1 ? "" : this.state.addDeductionText}
  157. </span>
  158. </FormItem>
  159. </div>
  160. </div> :
  161. <div>
  162. {
  163. (knowledgeServices == null || auditServices == null || addDeductionServices == null)
  164. ? null :
  165. <div>
  166. <h3
  167. style={{
  168. marginLeft: 10,
  169. fontWeight: 800,
  170. marginBottom: 10,
  171. }}
  172. >
  173. 高新纯咨询合同说明
  174. </h3>
  175. <div>
  176. <FormItem
  177. labelCol={{ span: 5 }}
  178. wrapperCol={{ span: 19 }}
  179. label="知识产权"
  180. >
  181. {<Button type="primary" size="default">{knowledgeServices == 1 ? "已签" : "未签"}</Button>}
  182. <span style={{ marginLeft: 19 }}>
  183. {knowledgeServices == 1 ? "" : this.state.knowledgeText}
  184. </span>
  185. </FormItem>
  186. <FormItem
  187. labelCol={{ span: 5 }}
  188. wrapperCol={{ span: 19 }}
  189. label="审计服务"
  190. >
  191. {<Button type="primary" size="default">{auditServices == 1 ? "已签" : "未签"}</Button>}
  192. <span style={{ marginLeft: 19 }}>
  193. {auditServices == 1 ? "" : this.state.auditText}
  194. </span>
  195. </FormItem>
  196. <FormItem
  197. labelCol={{ span: 5 }}
  198. wrapperCol={{ span: 19 }}
  199. label="加计扣除服务"
  200. >
  201. {<Button type="primary" size="default">{addDeductionServices == 1 ? "已签" : "未签"}</Button>}
  202. <span style={{ marginLeft: 19 }}>
  203. {addDeductionServices == 1 ? "" : this.state.addDeductionText}
  204. </span>
  205. </FormItem>
  206. </div>
  207. </div>
  208. }
  209. </div>
  210. }
  211. {
  212. this.state.gxczx != "" &&
  213. <Modal
  214. title="请选择"
  215. visible={this.state.gxczx != ""}
  216. closable={false}
  217. footer={[
  218. <Button type="primary" key="submit"
  219. onClick={() => {
  220. let reason = ""
  221. if (this.state.gxczx == "zscq") {
  222. if (this.state.knowledgeServices == undefined) {
  223. message.warn("请选择原因!")
  224. return
  225. }
  226. reason = this.state.knowledgeServices == 0
  227. ? this.state.knowledgeOther
  228. : knowledgeList.find(v => { return v.value == this.state.knowledgeServices }).label
  229. this.setState({
  230. knowledgeText: reason
  231. })
  232. this.props.selknowledge({ knowledgeServices: this.state.knowledgeServices, knowledgeOther: this.state.knowledgeOther })
  233. } else if (this.state.gxczx == "sjfw") {
  234. if (this.state.auditServices == undefined) {
  235. message.warn("请选择原因!")
  236. return
  237. }
  238. reason = this.state.auditServices == 0
  239. ? this.state.auditOther
  240. : auditList.find(v => { return v.value == this.state.auditServices }).label
  241. this.setState({
  242. auditText: reason
  243. })
  244. this.props.selaudit({ auditServices: this.state.auditServices, auditOther: this.state.auditOther })
  245. } else if (this.state.gxczx == "jjkc") {
  246. if (this.state.addDeductionServices == undefined) {
  247. message.warn("请选择原因!")
  248. return
  249. }
  250. reason = this.state.addDeductionServices == 0
  251. ? this.state.addDeductionOther
  252. : addDeductionList.find(v => { return v.value == this.state.addDeductionServices }).label
  253. this.setState({
  254. addDeductionText: reason
  255. })
  256. this.props.seladdDeduction({ addDeductionServices: this.state.addDeductionServices, addDeductionOther: this.state.addDeductionOther })
  257. }
  258. if (!reason) {
  259. message.warn("请填写原因!")
  260. return
  261. }
  262. if (!reason.replace(/\s+/g, '')) {
  263. message.warn("请填写原因!")
  264. return
  265. }
  266. this.setState({
  267. gxczx: "",
  268. })
  269. }}
  270. >确定</Button>
  271. ]
  272. }
  273. >
  274. {
  275. this.state.gxczx == "zscq" ?
  276. <RadioGroup onChange={e => { this.setState({ knowledgeServices: e.target.value }) }} value={this.state.knowledgeServices}>
  277. {
  278. knowledgeList.map(item =>
  279. item.value != 1 &&
  280. <Radio style={radioStyle} value={item.value}>{item.label}
  281. {(this.state.knowledgeServices === 0 && item.value == 0) ?
  282. <Input
  283. placeholder="请填写原因"
  284. style={{ width: 400, marginLeft: 10 }}
  285. value={this.state.knowledgeOther}
  286. onChange={e => {
  287. this.setState({
  288. knowledgeOther: e.target.value
  289. })
  290. }}
  291. /> : null}
  292. </Radio>
  293. )
  294. }
  295. </RadioGroup> :
  296. this.state.gxczx == "sjfw" ?
  297. <RadioGroup onChange={e => { this.setState({ auditServices: e.target.value }) }} value={this.state.auditServices}>
  298. {
  299. auditList.map(item =>
  300. item.value != 1 &&
  301. <Radio style={radioStyle} value={item.value}>{item.label}
  302. {(this.state.auditServices === 0 && item.value == 0) ?
  303. <Input
  304. placeholder="请填写原因"
  305. style={{ width: 400, marginLeft: 10 }}
  306. value={this.state.auditOther}
  307. onChange={e => {
  308. this.setState({
  309. auditOther: e.target.value
  310. })
  311. }}
  312. /> : null}
  313. </Radio>
  314. )
  315. }
  316. </RadioGroup> :
  317. this.state.gxczx == "jjkc" &&
  318. <RadioGroup onChange={e => { this.setState({ addDeductionServices: e.target.value }) }} value={this.state.addDeductionServices}>
  319. {
  320. addDeductionList.map(item =>
  321. item.value != 1 &&
  322. <Radio style={radioStyle} value={item.value}>{item.label}
  323. {(this.state.addDeductionServices === 0 && item.value == 0) ?
  324. <Input
  325. placeholder="请填写原因"
  326. style={{ width: 400, marginLeft: 10 }}
  327. value={this.state.addDeductionOther}
  328. onChange={e => {
  329. this.setState({
  330. addDeductionOther: e.target.value
  331. })
  332. }}
  333. /> : null}
  334. </Radio>
  335. )
  336. }
  337. </RadioGroup>
  338. }
  339. </Modal >
  340. }
  341. </div >
  342. );
  343. }
  344. }
  345. export default Gxczx;