step8.jsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  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. cols.push({ title: '建议值', dataIndex: 'recommend', key: 'recommend', render: (text) => { return money(text || 0) + '元' } });
  135. return cols;
  136. },
  137. step1Data() {
  138. const step = this.state.record[0], { industries, subIndustries, districts } = this.state;
  139. const { transferTypes, leftTimes } = this.state.dictMap;
  140. return step ? [{
  141. key: "技术名称",
  142. text: step.name
  143. }, {
  144. key: "所属主行业",
  145. text: getText(industries, String(step.industry), 'name')
  146. }, {
  147. key: "所属子行业",
  148. text: step.subIndustry.split(',').map(it => {
  149. return getText(subIndustries, it, 'name');
  150. }).join(',')
  151. }, {
  152. key: "转让方式",
  153. text: getText(transferTypes, String(step.transferType))
  154. }, {
  155. key: "预估技术剩余寿命",
  156. text: getText(leftTimes, String(step.timeLeft))
  157. }, {
  158. key: "转让区域",
  159. text: step.transferArea.split(',').map(it => {
  160. return districts[it] || it;
  161. }).join(',')
  162. }, {
  163. key: "评估基准日",
  164. text: step.benchmarkDate
  165. }, {
  166. key: "评估币种",
  167. text: step.currencyType
  168. }] : []
  169. },
  170. step2Data() {
  171. const step = this.state.record[1];
  172. const { accessMethods, legalStatus, maintenanceStatus, confidentialities, decidabilities, rightLimitations } = this.state.dictMap;
  173. return step ? [{
  174. key: "取得方式",
  175. text: getText(accessMethods, String(step.accessMethod))
  176. }, {
  177. key: "法律状态",
  178. text: getText(legalStatus, String(step.legalStatus))
  179. }, {
  180. key: "专利维护",
  181. text: getText(maintenanceStatus, String(step.patentMaintenance))
  182. }, {
  183. key: "保密性",
  184. text: getText(confidentialities, String(step.confidentiality))
  185. }, {
  186. key: "他人侵权的易判定性",
  187. text: getText(decidabilities, String(step.decidability))
  188. }, {
  189. key: "是否涉及质押、担保、诉讼等权利限制",
  190. text: getText(rightLimitations, String(step.hasRightLimitation))
  191. }] : []
  192. },
  193. step3Data() {
  194. const step = this.state.record[2];
  195. const { progressiveness, innovativeness, ripeness, alternatives,
  196. defensive, prospect, supplyAndDemand, rangeOfApplication, imitable, profitability } = this.state.dictMap;
  197. return step ? [{
  198. key: "先进性",
  199. text: getText(progressiveness, String(step.progressiveness))
  200. }, {
  201. key: "创新性",
  202. text: getText(innovativeness, String(step.innovativeness))
  203. }, {
  204. key: "成熟度",
  205. text: getText(ripeness, String(step.ripeness))
  206. }, {
  207. key: "替代性",
  208. text: getText(alternatives, String(step.alternatives))
  209. }, {
  210. key: "技术防御力",
  211. text: getText(defensive, String(step.defensive))
  212. }, {
  213. key: "技术领域发展前景",
  214. text: getText(prospect, String(step.prospect))
  215. }, {
  216. key: "供求关系",
  217. text: getText(supplyAndDemand, String(step.supplyAndDemand))
  218. }, {
  219. key: "产品应用范围",
  220. text: getText(rangeOfApplication, String(step.rangeOfApplication))
  221. }, {
  222. key: "遭他人模仿可能性",
  223. text: getText(imitable, String(step.imitable))
  224. }, {
  225. key: "独立获利能力",
  226. text: getText(profitability, String(step.profitability))
  227. }] : []
  228. },
  229. step4Data() {
  230. const step = this.state.record[3];
  231. return step.hasIncome == 2 && step.incomes || []
  232. },
  233. step5Data() {
  234. const step = this.state.record[4], { recommends } = this.state;
  235. let res = [];
  236. if (step.forecastIncomes) {
  237. step.forecastIncomes.forEach((it, idx) => {
  238. res.push(Object.assign({}, it, {
  239. key: idx,
  240. recommend: recommends[idx]
  241. }))
  242. })
  243. }
  244. return res
  245. },
  246. step6Data() {
  247. const step = this.state.record[5];
  248. return step ? [{
  249. key: "企业所得税率预估",
  250. text: step.taxRate + '%'
  251. }] : []
  252. },
  253. step7Data() {
  254. const step = this.state.record[6];
  255. const { political, technical, market, capital, management } = this.state.dictMap;
  256. return step ? [{
  257. key: "政策风险",
  258. text: getText(political, String(step.political))
  259. }, {
  260. key: "技术风险",
  261. text: getText(technical, String(step.technical))
  262. }, {
  263. key: "市场风险",
  264. text: getText(market, String(step.market))
  265. }, {
  266. key: "资金风险",
  267. text: getText(capital, String(step.capital))
  268. }, {
  269. key: "管理风险",
  270. text: getText(management, String(step.management))
  271. }] : []
  272. },
  273. step5Title() {
  274. const step = this.state.record[4];
  275. let title = "收入直接预估"
  276. switch (step.type) {
  277. case "2":
  278. title = "市场占比预估"
  279. break;
  280. case "3":
  281. title = "产品开发预估"
  282. break;
  283. }
  284. return title;
  285. },
  286. calc() {
  287. if(this.state.loading) {
  288. return;
  289. }
  290. this.setState({
  291. loading: true
  292. })
  293. $.ajax({
  294. url: globalConfig.context + '/api/user/evaluate/calc/' + this.props.id
  295. }).done(function (res) {
  296. let val = res && res.data || 0;
  297. this.setState({
  298. value: val,
  299. loading: false
  300. })
  301. if (this.props.next) {
  302. this.props.next(val)
  303. }
  304. }.bind(this)).fail(function () {
  305. this.setState({
  306. loading: false
  307. })
  308. }.bind(this));
  309. },
  310. render() {
  311. let { loading, record, value } = this.state;
  312. const tableProps = {
  313. showHeader: false,
  314. pagination: false,
  315. size: 'middle'
  316. }
  317. return (
  318. <Spin spinning={loading}>
  319. <div className="steps-result">
  320. <div className="steps-name">基本信息</div>
  321. <Table {...tableProps} columns={this.step1Col()} dataSource={this.step1Data()}></Table>
  322. <div className="steps-name">法律状况评估</div>
  323. <Table {...tableProps} columns={this.step1Col()} dataSource={this.step2Data()}></Table>
  324. <div className="steps-name">技术状况评估</div>
  325. <Table {...tableProps} columns={this.step1Col()} dataSource={this.step3Data()}></Table>
  326. <div className="steps-name">历史收入</div>
  327. <Table columns={this.step4Col()} dataSource={this.step4Data()} locale={{ emptyText: "无历史收入" }} rowKey="year" pagination={false} size="middle"></Table>
  328. <div className="steps-name">收入预估</div>
  329. <Table columns={this.step5Col()} dataSource={this.step5Data()} pagination={false} size="middle" showHeader={true} title={this.step5Title}></Table>
  330. <div className="steps-name">所得税预估</div>
  331. <Table {...tableProps} columns={this.step1Col()} dataSource={this.step6Data()}></Table>
  332. <div className="steps-name">风险预估</div>
  333. <Table {...tableProps} columns={this.step1Col()} dataSource={this.step7Data()}></Table>
  334. {
  335. value ? <div><div className="steps-name">价值评估结果:</div>
  336. <div className="steps-value">{money(value)}元</div></div> : <div />
  337. }
  338. </div>
  339. <div className="steps-action">
  340. {
  341. value ? <Button type="primary" onClick={() => message.success('3级用户才能查看评估报告!')}>查看评估报告</Button>
  342. : <Button type="primary" onClick={this.calc}>确认表单,开始估值</Button>
  343. }
  344. <Button style={{ marginLeft: 8 }} onClick={() => this.prev()}>上一步</Button>
  345. </div>
  346. </Spin>
  347. )
  348. },
  349. }));
  350. export default EvaluateStep8;