CurdWindowModal.vue 8.5 KB

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