CurdWindowModal.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <TabFormEditModal
  3. v-model:open="openTabEditModal" :is-restore-data="tabEditViewIsRestoreData"
  4. :window-no="mCurdWindowNo" :tab-index="mTabIndex" :type="tabEditViewType" :model-data-id="tabEditViewRecordId"
  5. width="100%" :current-page="tabEditViewCurrentPage" :current-index="tabEditViewCurrentIndex"
  6. :total-records="tabEditViewTotalRecords" :task-info-id="tabEditViewTaskInfoId"
  7. :workflow-type="tabEditViewWorkflowType" :mask-closable="false" @open-tab-form-view="openTabFormView"
  8. />
  9. <TabFormViewModal
  10. v-model:open="openTabViewModal" :window-no="mCurdWindowNo" :tab-index="mTabIndex"
  11. :type="tabFormViewType" :model-data-id="tabFormViewRecordId" width="100%" :current-page="tabFormViewCurrentPage"
  12. :current-index="tabFormViewCurrentIndex" :total-records="tabFormViewTotalRecords"
  13. :task-info-id="tabFormViewTaskInfoId" :workflow-type="tabFormViewWorkflowType" :mask-closable="false"
  14. @open-tab-edit-view="openTabEditView"
  15. />
  16. </template>
  17. <script setup>
  18. import { ref, onMounted, defineEmits, watch, defineProps } from 'vue';
  19. import TabFormEditModal from './tabFormEdit/TabFormEditModal.vue';
  20. import TabFormViewModal from './tabFormView/TabFormViewModal.vue';
  21. const props = defineProps({
  22. // 是否打开
  23. open: {
  24. type: Boolean,
  25. default: false,
  26. },
  27. // 窗口类型
  28. // Edit:编辑界面,可选项如下(create:创建数据,edit:编辑数据,editRestore:恢复数据)
  29. // View:表单界面,可选项如下(view:视图数据,viewRestore:恢复数据)
  30. viewType: {
  31. type: String,
  32. default: '',
  33. },
  34. // CURD窗口编号
  35. curdWindowNo: {
  36. type: String,
  37. default: '',
  38. },
  39. // 页签编号
  40. tabIndex: {
  41. type: Number,
  42. default: 0,
  43. },
  44. // 数据记录Id
  45. modelDataId: {
  46. type: Number,
  47. default: null,
  48. },
  49. // 当前记录所在的页码
  50. currentPage: {
  51. type: Number,
  52. default: 0,
  53. },
  54. // 当前记录的排序
  55. currentIndex: {
  56. type: Number,
  57. default: 0,
  58. },
  59. // 记录的总数量
  60. totalRecords: {
  61. type: Number,
  62. default: 0,
  63. },
  64. // 窗口唯一Id(必须是唯一的)
  65. uuid: {
  66. type: String,
  67. default: '',
  68. },
  69. // 是否恢复草稿数据(false:不恢复,true:恢复)
  70. isRestoreData: {
  71. type: Boolean,
  72. default: false,
  73. },
  74. // 工作流任务Id(taskId)
  75. taskInfoId: {
  76. type: String,
  77. default: null,
  78. },
  79. // 工作流任务类型(approve:审批任务,copyTask:抄送任务)
  80. workflowType: {
  81. type: String,
  82. default: null,
  83. },
  84. });
  85. const mCurdWindowNo = ref('20240910_193059');
  86. const mTabIndex = ref(0);
  87. const openTabEditModal = ref(true);
  88. const tabEditViewType = ref('create');
  89. const tabEditViewRecordId = ref(null);
  90. const tabEditViewCurrentPage = ref(null);
  91. const tabEditViewCurrentIndex = ref(null);
  92. const tabEditViewTotalRecords = ref(null);
  93. const tabEditViewIsRestoreData = ref(false);
  94. const tabEditViewTaskInfoId = ref(null);
  95. const tabEditViewWorkflowType = ref(null);
  96. const openTabViewModal = ref(false);
  97. const tabFormViewType = ref('view');
  98. const tabFormViewRecordId = ref(null);
  99. const tabFormViewCurrentPage = ref(null);
  100. const tabFormViewCurrentIndex = ref(null);
  101. const tabFormViewTotalRecords = ref(null);
  102. const tabFormViewTaskInfoId = ref(null);
  103. const tabFormViewWorkflowType = ref(null);
  104. const emits = defineEmits(['update:open']);
  105. watch([openTabEditModal, openTabViewModal], (newValues, oldValues) => {
  106. console.log('First name or last name changed.');
  107. console.log('New values:', newValues);
  108. console.log('Old values:', oldValues);
  109. if(newValues[0] == false && newValues[1] == false){
  110. emits('update:open', false);
  111. }
  112. });
  113. onMounted(() => {
  114. if(props.open == false){
  115. openTabEditModal.value = false;
  116. openTabViewModal.value = false;
  117. return;
  118. }
  119. // 窗口类型
  120. // Edit:编辑界面,可选项如下(create:创建数据,edit:编辑数据,editRestore:恢复数据)
  121. // View:表单界面,可选项如下(view:视图数据,viewRestore:恢复数据)
  122. if(props.viewType == 'create' || props.viewType == 'edit' || props.viewType == 'editRestore'){
  123. openTabEditView({
  124. type: props.viewType,
  125. windowNo: props.curdWindowNo,
  126. tabIndex: props.tabIndex,
  127. modelDataId: props.modelDataId,
  128. currentPage: props.currentPage,
  129. currentIndex: props.currentIndex,
  130. totalRecords: props.totalRecords,
  131. uuid: props.uuid,
  132. isRestoreData: props.isRestoreData,
  133. taskInfoId: props.taskInfoId,
  134. workflowType: props.workflowType,
  135. });
  136. }else if(props.viewType == 'view' || props.viewType == 'viewRestore'){
  137. openTabFormView({
  138. type: props.viewType,
  139. windowNo: props.curdWindowNo,
  140. tabIndex: props.tabIndex,
  141. modelDataId: props.modelDataId,
  142. currentPage: props.currentPage,
  143. currentIndex: props.currentIndex,
  144. totalRecords: props.totalRecords,
  145. uuid: props.uuid,
  146. isRestoreData: props.isRestoreData,
  147. taskInfoId: props.taskInfoId,
  148. workflowType: props.workflowType,
  149. });
  150. }
  151. });
  152. /**
  153. * 打开页签视图模式
  154. * @param param 信息
  155. * 属性1: type: 类型,
  156. * 属性1: windowNo: CURD窗口编号,
  157. * 属性2: tabIndex: CURD页签编号,
  158. * 属性3: modelDataId: 数据记录id,
  159. * 属性4: currentPage: 当前记录所在的页码,
  160. * 属性5: currentIndex: 当前记录的排序,
  161. * 属性6: totalRecords: 记录的总数量,
  162. * 属性7: uuid: 窗口唯一Id,
  163. */
  164. const openTabFormView = function (param) {
  165. console.log('openTabFormView', param);
  166. tabFormViewType.value = param.type;
  167. mCurdWindowNo.value = param.windowNo;
  168. mTabIndex.value = param.tabIndex;
  169. tabFormViewRecordId.value = param.modelDataId;
  170. tabFormViewCurrentPage.value = param.currentPage;
  171. tabFormViewCurrentIndex.value = param.currentIndex;
  172. tabFormViewTotalRecords.value = param.totalRecords;
  173. openTabEditModal.value = false;
  174. openTabViewModal.value = true;
  175. };
  176. /**
  177. * 打开页签编辑模式
  178. * @param param 信息
  179. * 属性1: type: 类型,
  180. * 属性1: windowNo: CURD窗口编号,
  181. * 属性2: tabIndex: CURD页签编号,
  182. * 属性3: modelDataId: 数据记录id,
  183. * 属性4: currentPage: 当前记录所在的页码,
  184. * 属性5: currentIndex: 当前记录的排序,
  185. * 属性6: totalRecords: 记录的总数量,
  186. * 属性7: uuid: 窗口唯一Id,
  187. */
  188. const openTabEditView = function (param) {
  189. tabEditViewType.value = param.type;
  190. mCurdWindowNo.value = param.windowNo;
  191. mTabIndex.value = param.tabIndex;
  192. tabEditViewRecordId.value = param.modelDataId;
  193. tabEditViewCurrentPage.value = param.currentPage;
  194. tabEditViewCurrentIndex.value = param.currentIndex;
  195. tabEditViewTotalRecords.value = param.totalRecords;
  196. tabEditViewIsRestoreData.value = param.isRestoreData;
  197. openTabViewModal.value = false;
  198. openTabEditModal.value = true;
  199. };
  200. </script>