SubOneToOneTabView.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <a-page-header
  3. :title="Language.getNameTrl($i18n.locale, tab)"
  4. style="border-bottom: 1px solid rgb(235, 237, 240); padding: 0px;"
  5. />
  6. <div class="m-row clearfix">
  7. <div>
  8. <div
  9. v-if="tabFormFields && mModelData"
  10. :class="{
  11. 'form-inline': tab.tabFormView.multipleColumn,
  12. 'form-horizontal': !tab.tabFormView.multipleColumn,
  13. }"
  14. >
  15. <template
  16. v-for="fieldItem in tabFormFields" :key="
  17. 'FieldEditView_' +
  18. windowNo +
  19. '_' +
  20. tab.tabIndex +
  21. '_' +
  22. fieldItem.fieldName +
  23. '_' +
  24. fieldItem.entityFieldIndex
  25. "
  26. >
  27. <FieldEditView
  28. ref="fieldItem1" :class-name="tab.tabDataSource.className" :field="fieldItem"
  29. :model-data="mModelData" :window-no="windowNo" :tab-index="tab.tabIndex" :js-url="jsUrl"
  30. :is-chinese-english="curdWindow.isChineseEnglish" :multiple-column="tab.tabFormView.multipleColumn"
  31. @execute-callout="executeCallout(fieldItem)"
  32. />
  33. </template>
  34. </div>
  35. </div>
  36. </div>
  37. </template>
  38. <script setup>
  39. import Common from '../../common/Common';
  40. import FieldEditView from './TabFormFieldView.vue';
  41. import WindowClientUtil from '../../resource/dictionary/WindowClientUtil.js';
  42. import Language from '../../common/Language.js';
  43. import ProcessReportResource from '../../api/dic/ProcessReportResource.js';
  44. import { ref, reactive, defineEmits, defineProps, watch } from 'vue';
  45. import { debounce } from 'lodash';
  46. // 接受父组件传递的数据
  47. const props = defineProps({
  48. tab: {
  49. type: Object,
  50. default: ()=>{
  51. return {};
  52. },
  53. },
  54. parentModelData: {
  55. type: Object,
  56. default: ()=>{
  57. return {};
  58. },
  59. },
  60. curdWindow: {
  61. type: Object,
  62. default: ()=>{
  63. return {};
  64. },
  65. },
  66. windowNo: {
  67. type: String,
  68. default: null,
  69. },
  70. jsUrl: {
  71. type: String,
  72. default: null,
  73. },
  74. isChineseEnglish: {
  75. type: Boolean,
  76. default: false,
  77. },
  78. });
  79. const mModelData = ref({});
  80. const tabFormFields = ref([]);
  81. const emits = defineEmits([]);
  82. /**
  83. * 查询一对一页签数据
  84. */
  85. const getOneToOneTabData = function () {
  86. const params = {
  87. windowNo: props.windowNo,
  88. tabIndex: props.tab.tabIndex,
  89. parentId: props.parentModelData == undefined ? undefined : props.parentModelData.id,
  90. };
  91. $.ajax({
  92. url: Common.getApiURL('CurdWindowResource/oneToOneTabData'),
  93. async: false,
  94. dataType: 'json',
  95. type: 'post',
  96. data: JSON.stringify(params),
  97. contentType: 'application/json',
  98. beforeSend: function (request) {
  99. Common.addTokenToRequest(request);
  100. },
  101. success: function (data) {
  102. mModelData.value = data;
  103. },
  104. error: function (XMLHttpRequest, textStatus, errorThrown) {
  105. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  106. },
  107. });
  108. };
  109. /**
  110. * 执行Callout
  111. */
  112. const executeCallout = function (fieldItem) {
  113. if (fieldItem.calloutProcessReportNo != null) {
  114. callout(fieldItem.calloutProcessReportNo);
  115. }
  116. };
  117. /**
  118. * callout
  119. * @param {[type]} calloutProcessReportNo [description]
  120. * @return {[type]} [description]
  121. */
  122. const callout = function (calloutProcessReportNo) {
  123. // 查询流程和报表的定义
  124. ProcessReportResource.uniqueByNo(calloutProcessReportNo).then(
  125. successData => {
  126. if (successData == null) {
  127. return;
  128. }
  129. // 执行服务端的脚本
  130. ProcessReportResource.runCallout(
  131. calloutProcessReportNo,
  132. mModelData.value,
  133. ).then(
  134. successData => {
  135. if (successData && successData.modelData) {
  136. mModelData.value = successData.modelData;
  137. }
  138. },
  139. errorData => {
  140. Common.processException(errorData);
  141. },
  142. );
  143. },
  144. errorData => {
  145. Common.processException(errorData);
  146. },
  147. );
  148. };
  149. /**
  150. * 延迟获取页面的数据
  151. */
  152. const debounceGetOneToOneTabData = debounce(() => {
  153. getOneToOneTabData();
  154. }, 1000);
  155. watch(
  156. () => [props.windowNo, props.tab, props.parentModelData],
  157. (newValue, oldValue) => {
  158. debounceGetOneToOneTabData();
  159. },
  160. { immediate: true },
  161. );
  162. watch(
  163. () => props.tab,
  164. (newValue, oldValue) => {
  165. tabFormFields.value = WindowClientUtil.getDetailField(newValue);
  166. console.log(tabFormFields.value);
  167. },
  168. { immediate: true },
  169. );
  170. </script>
  171. <style scoped></style>