step8.jsx 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. import React from 'react';
  2. import { Spin, Form, Button, message, Table } from 'antd';
  3. import ajax from 'jquery/src/ajax/xhr.js'
  4. import $ from 'jquery/src/ajax';
  5. import dict from './dict.js';
  6. import money from '@/money.js';
  7. const FormItem = Form.Item;
  8. const formItemLayout = {
  9. labelCol: { span: 4 },
  10. wrapperCol: { span: 10 },
  11. };
  12. const NUMBERS = {
  13. 1: '第一年',
  14. 2: '第二年',
  15. 3: '第三年',
  16. 4: '第四年',
  17. 5: '第五年',
  18. }
  19. const getText = (map, key, field) => {
  20. if (field) {
  21. return map[key] ? (map[key][field || 'text'] || '') : key;
  22. }
  23. return map[key] ? map[key] : key;
  24. }
  25. const EvaluateStep8 = Form.create({})(React.createClass({
  26. getInitialState() {
  27. return {
  28. loading: true,
  29. record: {},
  30. industries: {},
  31. subIndustries: {},
  32. districts: {},
  33. value: 0,
  34. recommends: []
  35. };
  36. },
  37. componentWillMount() {
  38. let record = this.props.record || {}, dictMap = {};
  39. if (record[0] && record[0].industry) {
  40. this.loadData(record[0].industry);
  41. } else {
  42. this.state.loading = false;
  43. }
  44. this.state.record = record;
  45. this.state.value = this.props.value || 0;
  46. for (let key in dict) {
  47. if (dict.hasOwnProperty(key) && key != 'toMap') {
  48. dictMap[key] = dict.toMap(dict[key]);
  49. }
  50. }
  51. this.state.dictMap = dictMap;
  52. },
  53. loadData(pid) {
  54. $.when($.ajax({
  55. url: globalConfig.context + '/open/findIndustryCategory'
  56. }), $.ajax({
  57. url: globalConfig.context + '/open/findIndustryCategory',
  58. data: { id: pid }
  59. }), $.ajax({
  60. url: globalConfig.context + '/open/findDistrict'
  61. }), $.ajax({
  62. url: globalConfig.context + '/api/user/evaluate/step5/' + this.props.id
  63. })).done(function (industryRes, subIndustryRes, districtRes, recommendRes) {
  64. let i = {}, si = {}, d = { 0: "全国" }, r = [];
  65. if (industryRes[0] && industryRes[0].data) {
  66. industryRes[0].data.forEach(it => {
  67. i[String(it.id)] = it;
  68. })
  69. }
  70. if (subIndustryRes[0] && subIndustryRes[0].data) {
  71. subIndustryRes[0].data.forEach(it => {
  72. si[String(it.id)] = it;
  73. })
  74. }
  75. if (districtRes[0] && districtRes[0].data) {
  76. districtRes[0].data.forEach(it => {
  77. d[String(it.id)] = it.name;
  78. })
  79. }
  80. if (recommendRes[0] && recommendRes[0].data) {
  81. r = recommendRes[0].data;
  82. }
  83. this.setState({
  84. loading: false,
  85. industries: i,
  86. subIndustries: si,
  87. districts: d,
  88. recommends: r
  89. })
  90. }.bind(this)).fail(function () {
  91. this.setState({
  92. loading: false
  93. })
  94. }.bind(this));
  95. },
  96. next() {
  97. if (this.props.next) {
  98. this.props.next();
  99. }
  100. },
  101. prev() {
  102. if (this.props.prev) {
  103. this.props.prev();
  104. }
  105. },
  106. step1Col() {
  107. return [{ dataIndex: 'key', key: 'key', width: '40%', className: 'steps-cell-key' }, { dataIndex: 'text', key: 'text', width: '60%' }]
  108. },
  109. step4Col() {
  110. return [{
  111. title: '年份', dataIndex: 'year', key: 'year'
  112. }, {
  113. title: '营收', dataIndex: 'income', key: 'income', render: (text) => { return money(text || 0) + '元' }
  114. }, {
  115. title: '利润率', dataIndex: 'profit', key: 'profit', render: (text) => { return (text || 0) + '%' }
  116. }]
  117. },
  118. step5Col() {
  119. const step = this.state.record[4];
  120. let cols = [{
  121. title: '年份', dataIndex: 'key', key: 'key', render: (text) => { return NUMBERS[text + 1] }
  122. }]
  123. switch (step.type) {
  124. case "2":
  125. cols.push({ title: '市场规模', dataIndex: 'marketScale', key: 'marketScale', render: (text) => { return money(text || 0) + '元' } });
  126. cols.push({ title: '技术覆盖率/市场份额', dataIndex: 'marketRate', key: 'marketRate', render: (text) => { return (text || 0) + '%' } });
  127. break;
  128. case "3":
  129. cols.push({ title: '单价', dataIndex: 'unitPrice', key: 'unitPrice', render: (text) => { return money(text || 0) + '元' } });
  130. cols.push({ title: '销量', dataIndex: 'saleCount', key: 'saleCount' });
  131. break;
  132. }
  133. cols.push({ title: '营业收入', dataIndex: 'income', key: 'income', render: (text) => { return money(text || 0) + '元' } });
  134. if(this.state.record[3].hasIncome=='2') {
  135. cols.push({ title: '建议值', dataIndex: 'recommend', key: 'recommend', render: (text) => { return money(text || 0) + '元' } });
  136. }
  137. return cols;
  138. },
  139. step1Data() {
  140. const step = this.state.record[0], { industries, subIndustries, districts } = this.state;
  141. const { transferTypes, leftTimes } = this.state.dictMap;
  142. return step ? [{
  143. key: "技术名称",
  144. text: step.name
  145. }, {
  146. key: "所属主行业",
  147. text: getText(industries, String(step.industry), 'name')
  148. }, {
  149. key: "所属子行业",
  150. text: step.subIndustry.split(',').map(it => {
  151. return getText(subIndustries, it, 'name');
  152. }).join(',')
  153. }, {
  154. key: "转让方式",
  155. text: getText(transferTypes, String(step.transferType))
  156. }, {
  157. key: "预估技术剩余寿命",
  158. text: getText(leftTimes, String(step.timeLeft))
  159. }, {
  160. key: "转让区域",
  161. text: step.transferArea.split(',').map(it => {
  162. return districts[it] || it;
  163. }).join(',')
  164. }, {
  165. key: "评估基准日",
  166. text: step.benchmarkDate
  167. }, {
  168. key: "评估币种",
  169. text: step.currencyType
  170. }] : []
  171. },
  172. step2Data() {
  173. const step = this.state.record[1];
  174. const { accessMethods, legalStatus, maintenanceStatus, confidentialities, decidabilities, rightLimitations } = this.state.dictMap;
  175. return step ? [{
  176. key: "取得方式",
  177. text: getText(accessMethods, String(step.accessMethod))
  178. }, {
  179. key: "法律状态",
  180. text: getText(legalStatus, String(step.legalStatus))
  181. }, {
  182. key: "专利维护",
  183. text: getText(maintenanceStatus, String(step.patentMaintenance))
  184. }, {
  185. key: "保密性",
  186. text: getText(confidentialities, String(step.confidentiality))
  187. }, {
  188. key: "他人侵权的易判定性",
  189. text: getText(decidabilities, String(step.decidability))
  190. }, {
  191. key: "是否涉及质押、担保、诉讼等权利限制",
  192. text: getText(rightLimitations, String(step.hasRightLimitation))
  193. }] : []
  194. },
  195. step3Data() {
  196. const step = this.state.record[2];
  197. const { progressiveness, innovativeness, ripeness, alternatives,
  198. defensive, prospect, supplyAndDemand, rangeOfApplication, imitable, profitability } = this.state.dictMap;
  199. return step ? [{
  200. key: "先进性",
  201. text: getText(progressiveness, String(step.progressiveness))
  202. }, {
  203. key: "创新性",
  204. text: getText(innovativeness, String(step.innovativeness))
  205. }, {
  206. key: "成熟度",
  207. text: getText(ripeness, String(step.ripeness))
  208. }, {
  209. key: "替代性",
  210. text: getText(alternatives, String(step.alternatives))
  211. }, {
  212. key: "技术防御力",
  213. text: getText(defensive, String(step.defensive))
  214. }, {
  215. key: "技术领域发展前景",
  216. text: getText(prospect, String(step.prospect))
  217. }, {
  218. key: "供求关系",
  219. text: getText(supplyAndDemand, String(step.supplyAndDemand))
  220. }, {
  221. key: "产品应用范围",
  222. text: getText(rangeOfApplication, String(step.rangeOfApplication))
  223. }, {
  224. key: "遭他人模仿可能性",
  225. text: getText(imitable, String(step.imitable))
  226. }, {
  227. key: "独立获利能力",
  228. text: getText(profitability, String(step.profitability))
  229. }] : []
  230. },
  231. step4Data() {
  232. const step = this.state.record[3];
  233. return step.hasIncome == 2 && step.incomes || []
  234. },
  235. step5Data() {
  236. const step = this.state.record[4], { recommends } = this.state;
  237. let res = [];
  238. if (step.forecastIncomes) {
  239. step.forecastIncomes.forEach((it, idx) => {
  240. res.push(Object.assign({}, it, {
  241. key: idx,
  242. recommend: recommends[idx]
  243. }))
  244. })
  245. }
  246. return res
  247. },
  248. step6Data() {
  249. const step = this.state.record[5];
  250. return step ? [{
  251. key: "企业所得税率预估",
  252. text: step.taxRate + '%'
  253. }] : []
  254. },
  255. step7Data() {
  256. const step = this.state.record[6];
  257. const { political, technical, market, capital, management } = this.state.dictMap;
  258. return step ? [{
  259. key: "政策风险",
  260. text: getText(political, String(step.political))
  261. }, {
  262. key: "技术风险",
  263. text: getText(technical, String(step.technical))
  264. }, {
  265. key: "市场风险",
  266. text: getText(market, String(step.market))
  267. }, {
  268. key: "资金风险",
  269. text: getText(capital, String(step.capital))
  270. }, {
  271. key: "管理风险",
  272. text: getText(management, String(step.management))
  273. }] : []
  274. },
  275. step5Title() {
  276. const step = this.state.record[4];
  277. let title = "收入直接预估"
  278. switch (step.type) {
  279. case "2":
  280. title = "市场占比预估"
  281. break;
  282. case "3":
  283. title = "产品开发预估"
  284. break;
  285. }
  286. return title;
  287. },
  288. calc() {
  289. if(this.state.loading) {
  290. return;
  291. }
  292. this.setState({
  293. loading: true
  294. })
  295. $.ajax({
  296. url: globalConfig.context + '/api/user/evaluate/calc/' + this.props.id
  297. }).done(function (res) {
  298. let val = res && res.data || 0;
  299. this.setState({
  300. value: val,
  301. loading: false
  302. })
  303. if (this.props.next) {
  304. this.props.next(val)
  305. }
  306. }.bind(this)).fail(function () {
  307. this.setState({
  308. loading: false
  309. })
  310. }.bind(this));
  311. },
  312. render() {
  313. let { loading, record, value } = this.state;
  314. const tableProps = {
  315. showHeader: false,
  316. pagination: false,
  317. size: 'middle'
  318. }
  319. return (
  320. <Spin spinning={loading}>
  321. <div className="steps-result">
  322. <div className="steps-name">基本信息</div>
  323. <Table {...tableProps} columns={this.step1Col()} dataSource={this.step1Data()}></Table>
  324. <div className="steps-name">法律状况评估</div>
  325. <Table {...tableProps} columns={this.step1Col()} dataSource={this.step2Data()}></Table>
  326. <div className="steps-name">技术状况评估</div>
  327. <Table {...tableProps} columns={this.step1Col()} dataSource={this.step3Data()}></Table>
  328. <div className="steps-name">历史收入</div>
  329. <Table columns={this.step4Col()} dataSource={this.step4Data()} locale={{ emptyText: "无历史收入" }} rowKey="year" pagination={false} size="middle"></Table>
  330. <div className="steps-name">收入预估</div>
  331. <Table columns={this.step5Col()} dataSource={this.step5Data()} pagination={false} size="middle" showHeader={true} title={this.step5Title}></Table>
  332. <div className="steps-name">所得税预估</div>
  333. <Table {...tableProps} columns={this.step1Col()} dataSource={this.step6Data()}></Table>
  334. <div className="steps-name">风险预估</div>
  335. <Table {...tableProps} columns={this.step1Col()} dataSource={this.step7Data()}></Table>
  336. {
  337. value ? <div><div className="steps-name">价值评估结果:</div>
  338. <div className="steps-value">{money(value)}元</div></div> : <div />
  339. }
  340. </div>
  341. <div className="steps-action">
  342. {
  343. value ? <Button type="primary" onClick={() => window.open(globalConfig.context + '/user/account/evaluateInfo?id=' + this.props.id)}>查看评估报告</Button>
  344. : <Button type="primary" onClick={this.calc}>确认表单,开始估值</Button>
  345. }
  346. <Button style={{ marginLeft: 8 }} onClick={() => this.prev()}>上一步</Button>
  347. </div>
  348. </Spin>
  349. )
  350. },
  351. }));
  352. export default EvaluateStep8;