contract-edit.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <audit-form-top-banner :handel-save-form="saveForm" @handelSaveForm="saveForm">
  3. <sd-detail-form
  4. ref="docform"
  5. :page-id="this.$route.query.pageId ? this.$route.query.pageId : null"
  6. :record-id="this.id"
  7. :read-only="false"
  8. :class="[$style.form]"
  9. @close="close(true)"
  10. @saved="saved"
  11. >
  12. <template v-slot="{ formData, model, fields }">
  13. <table :class="$style.detailForm">
  14. <tr>
  15. <td colspan="4" style="border:none">
  16. <sd-form-by-builder :form-data="initDaF(formData.pageFormData)"></sd-form-by-builder>
  17. </td>
  18. </tr>
  19. </table>
  20. </template>
  21. </sd-detail-form>
  22. </audit-form-top-banner>
  23. </template>
  24. <script>
  25. import axios from '@/common/services/axios-instance'
  26. import { message } from '@/common/one-ui'
  27. import auditFormTopBanner from '@product/iam/components/audit-form-top-banner'
  28. // 注意此处,需要将-import之前,修改为与文件同名
  29. import components from './_import-components/contract-edit-import'
  30. export default {
  31. name: 'ContractEdit',
  32. metaInfo: {
  33. title: '合同签订',
  34. },
  35. components: {
  36. ...components,
  37. auditFormTopBanner,
  38. },
  39. data() {
  40. return {
  41. initialled: false,
  42. id: this.$route.query.id ? this.$route.query.id : '',
  43. flag: true,
  44. }
  45. },
  46. methods: {
  47. saved(t) {
  48. // 保存后执行
  49. const idobj = t.pageFormData.pageFieldInfos.find((i) => i.name === 'id').value
  50. this.id = idobj
  51. const id = this.$route.params.id ? this.$route.params.id : this.$route.query.id
  52. if (id === null || id === undefined || id === '') {
  53. let path = this.$route.fullPath
  54. path = path.replace('?id=&pageId', '?id=' + this.id + '&pageId')
  55. window.location.href = '#' + path
  56. }
  57. },
  58. // 保存
  59. saveForm() {
  60. // this.wjsdRuleCheck();
  61. this.droolsRuleCheck()
  62. },
  63. droolsRuleCheck() {
  64. var ruleServiceUrl = 'http://localhost:8082/applyContractRules'
  65. const contractData = this.getContractData()
  66. axios({
  67. method: 'post',
  68. url: ruleServiceUrl,
  69. data: contractData,
  70. }).then((res) => {
  71. if (res.status === 200) {
  72. if (res.data.status === '提醒') {
  73. message.warning('提醒:' + res.data.message)
  74. }
  75. if (res.data.status === '阻断') {
  76. message.error('阻断:' + res.data.message)
  77. }
  78. if (res.data.status == null) {
  79. this.$refs.docform.saveBtnClick()
  80. return true
  81. }
  82. }
  83. })
  84. return false
  85. },
  86. getContractData() {
  87. const companyList = [
  88. '北京东方联合投资管理有限公司',
  89. '网信集团有限公司',
  90. '普信资产管理有限公司',
  91. '北京经讯时代科技有限公司',
  92. '太极股份',
  93. '河南**燃气管道有限公司',
  94. '新乡**发电有限公司',
  95. ]
  96. var contractData = {
  97. companyName:
  98. companyList[this.$refs.docform.getFieldValue('childTableInline0')[0].xdfmc - 1],
  99. contractAmount: this.$refs.docform.getFieldValue('htje'),
  100. netCapital: this.$refs.docform.getFieldValue('szk'),
  101. }
  102. return contractData
  103. },
  104. wjsdRuleCheck() {
  105. var ruleServiceUrl = 'http://172.20.98.64:9999/rule/callRule/service'
  106. var ruleData = {
  107. user: 'admin',
  108. password: '1',
  109. request: {
  110. ruleName: 'POC-001',
  111. ruleVersion: '1',
  112. ruleFact: [],
  113. },
  114. }
  115. const contractData = this.getContractData()
  116. ruleData.request.ruleFact = [contractData]
  117. console.log(ruleData)
  118. console.log(JSON.stringify(ruleData))
  119. const fd = new FormData()
  120. fd.append('req', JSON.stringify(ruleData))
  121. axios({
  122. method: 'post',
  123. url: ruleServiceUrl,
  124. data: fd,
  125. }).then((res) => {
  126. console.log(res)
  127. const data = res.data
  128. if (data.response.ruleCode === '0000') {
  129. if (data.response.ruleFact.status === '提醒') {
  130. message.warning('提醒:' + data.response.ruleFact.message)
  131. }
  132. if (data.response.ruleFact.status === '阻断') {
  133. message.error('阻断:' + data.response.ruleFact.message)
  134. }
  135. if (data.response.ruleFact.status === 'OK') {
  136. this.$refs.docform.saveBtnClick()
  137. return true
  138. }
  139. } else {
  140. message.error('数据请求错误:' + data.response.ruleMsg)
  141. }
  142. })
  143. return false
  144. },
  145. close(flag) {
  146. window.close()
  147. },
  148. initDaF(array) {
  149. if (array) {
  150. array.attrFD.keepHiddenCell = false
  151. }
  152. if (this.flag) {
  153. setTimeout(() => {
  154. this.$refs.docform.setFieldValue('BASE_INFO', 'true')
  155. this.$refs.docform.setFieldValue('SUPPORT_LIST', 'true')
  156. }, 1000)
  157. this.flag = false
  158. }
  159. return array
  160. },
  161. },
  162. }
  163. </script>
  164. <style module lang="scss">
  165. @use '@/common/design' as *;
  166. @import '@/webflow/sd-flow-form.scss';
  167. .detailForm {
  168. width: 100% !important;
  169. margin: 0;
  170. :global(.sd-form-table) {
  171. // width: 100% !important;
  172. }
  173. }
  174. </style>