gxczx.jsx 15 KB

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