processTemplateData.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. // 初始化处理template数据
  2. import React from "react";
  3. import checkBtnPermission from "./checkBtnPermission";
  4. import getAgreeType from '../functions/getAgreeTypes';
  5. export default async function processTemplate(template) {
  6. const {json} = this.state;
  7. const contractnum = template['contractList'].items.find(item => item.attrcode === 'contractnum');
  8. contractnum.render = (text, record, index) => {
  9. return (
  10. <span
  11. className="simple-table-title"
  12. style={{color: '#007ace', cursor: 'pointer'}}
  13. onClick={() => {
  14. this.viewContract(text, record, index);
  15. }}
  16. >
  17. {record && record['contractnum'] && record['contractnum'].value}
  18. </span>
  19. );
  20. };
  21. template['contractList'].items.push({
  22. attrcode: 'file',
  23. itemtype: 'customer',
  24. hyperlinkflag: false,
  25. label: json['cm6011-000146'], /* 国际化处理: 附件管理*/
  26. width: '80px',
  27. textAlign: 'center',
  28. visible: true,
  29. fixed: 'right',
  30. render: (text, record, index) => {
  31. return (
  32. <a style={{cursor: 'pointer'}}>
  33. <i className="icon iconfont icon-fujianshenpi" onClick={() => {
  34. checkBtnPermission(record.pk_psndoc_sub.value, 'attachment', 'contract', () => {
  35. this.fileManage(record.pk_psndoc_sub.value)
  36. })
  37. }}/>
  38. </a>
  39. )
  40. }
  41. });
  42. template['contractList'].items.push({
  43. itemtype: 'customer',
  44. width: '130px',
  45. label: json['cm6011-000064'],/* 国际化处理: 操作,操作*/
  46. visible: true,
  47. fixed: 'right',
  48. attrcode: 'opr',
  49. render: (text, record, index) => {
  50. return (
  51. record.lastflag && record.lastflag.value ? <div>
  52. <a
  53. href="javascript:void(0)"
  54. className="operator-btn"
  55. onClick={
  56. () => {
  57. this.editContract(text, record, index)
  58. }
  59. }
  60. >
  61. {json['cm6011-000067']}{/* 国际化处理: 修改*/}
  62. </a>
  63. </div> : null
  64. );
  65. }
  66. });
  67. //contcode
  68. const contcode = template['agreementList'].items.find(item => item.attrcode === 'contcode');
  69. contcode.render = (text, record, index) => {
  70. return (
  71. <span
  72. className="simple-table-title"
  73. style={{color: '#007ace', cursor: 'pointer'}}
  74. onClick={() => {
  75. this.viewAgree(text, record, index);
  76. }}
  77. >
  78. {record && record['contcode'] && record['contcode'].value}
  79. </span>
  80. );
  81. };
  82. template['agreementList'].items.push({
  83. attrcode: 'file',
  84. itemtype: 'customer',
  85. hyperlinkflag: false,
  86. label: json['cm6011-000146'], /* 国际化处理: 附件管理*/
  87. width: '80px',
  88. textAlign: 'center',
  89. visible: true,
  90. fixed: 'right',
  91. render: (text, record, index) => {
  92. return (
  93. <a style={{cursor: 'pointer'}}>
  94. <i className="icon iconfont icon-fujianshenpi" onClick={() => {
  95. checkBtnPermission(record.pk_agreement.value, 'attachment', 'agreement', () => {
  96. this.fileManage(record.pk_agreement.value)
  97. })
  98. }}/>
  99. </a>
  100. )
  101. }
  102. });
  103. template['agreementList'].items.push({
  104. itemtype: 'customer',
  105. width: '130px',
  106. label: json['cm6011-000064'],/* 国际化处理: 操作,操作*/
  107. visible: true,
  108. fixed: 'right',
  109. attrcode: 'opr',
  110. render: (text, record, index) => {
  111. return (
  112. record.lastflag && record.lastflag.value ? <div>
  113. <a
  114. href="javascript:void(0)"
  115. className="operator-btn"
  116. onClick={
  117. () => {
  118. this.editAgreement(text, record, index)
  119. }
  120. }
  121. >
  122. {json['cm6011-000067']}{/* 国际化处理: 修改*/}
  123. </a>
  124. </div> : null
  125. );
  126. }
  127. });
  128. const agreementTypes = await getAgreeType();
  129. const queryItem = template['agreementquery'].items.find(item => item.attrcode === 'hrcm_agreement.agreementtype');
  130. queryItem.options = agreementTypes.map(type => {
  131. return {
  132. "display": type.name,
  133. "value": type.code
  134. }
  135. });
  136. return template;
  137. }