CuspSupplierProfileModal.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <div ref="globalModal">
  3. <BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="title" :get-container="() => globalModal" width="90%" @ok="handleSubmit" :maskClosable="false">
  4. <BasicForm @register="registerForm" ref="formRef" name="CuspSupplierProfileForm"/>
  5. <!-- 子表单区域 -->
  6. <a-tabs v-model:activeKey="activeKey" animated @change="handleChangeTabs">
  7. <a-tab-pane tab="联系人(link man)" key="cuspSupplierProfileMan" :forceRender="true">
  8. <JVxeTable
  9. keep-source
  10. resizable
  11. ref="cuspSupplierProfileMan"
  12. :loading="cuspSupplierProfileManTable.loading"
  13. :columns="cuspSupplierProfileManTable.columns"
  14. :dataSource="cuspSupplierProfileManTable.dataSource"
  15. :maxHeight="340"
  16. :rowNumber="true"
  17. :rowSelection="true"
  18. :disabled="formDisabled"
  19. :toolbar="true"
  20. >
  21. <template #action="props">
  22. <a-divider type="vertical"/>
  23. <a-popconfirm title="确定删除吗?" @confirm="handleDelete(props)">
  24. <a>删除(delete)</a>
  25. </a-popconfirm>
  26. </template>
  27. </JVxeTable>
  28. </a-tab-pane>
  29. <a-tab-pane tab="资质信息(qualification information)" key="cuspSupplierProfileQualification" :forceRender="true">
  30. <JVxeTable
  31. keep-source
  32. resizable
  33. ref="cuspSupplierProfileQualification"
  34. :loading="cuspSupplierProfileQualificationTable.loading"
  35. :columns="cuspSupplierProfileQualificationTable.columns"
  36. :dataSource="cuspSupplierProfileQualificationTable.dataSource"
  37. :maxHeight="340"
  38. :rowNumber="true"
  39. :rowSelection="true"
  40. :disabled="formDisabled"
  41. :toolbar="true"
  42. >
  43. <template #action="props">
  44. <a-divider type="vertical"/>
  45. <a-popconfirm title="确定删除吗?" @confirm="handleDelete1(props)">
  46. <a>删除(delete)</a>
  47. </a-popconfirm>
  48. </template></JVxeTable>
  49. </a-tab-pane>
  50. </a-tabs>
  51. </BasicModal>
  52. </div>
  53. </template>
  54. <script lang="ts" setup>
  55. import {ref, computed, unref,reactive} from 'vue';
  56. import {BasicModal, useModalInner} from '/@/components/Modal';
  57. import {BasicForm, useForm} from '/@/components/Form/index';
  58. import { JVxeTable } from '/@/components/jeecg/JVxeTable'
  59. import { useJvxeMethod } from '/@/hooks/system/useJvxeMethods.ts'
  60. import {formSchema,cuspSupplierProfileManColumns,cuspSupplierProfileQualificationColumns} from '../CuspSupplierProfile.data';
  61. import {saveOrUpdate,cuspSupplierProfileManList,cuspSupplierProfileQualificationList} from '../CuspSupplierProfile.api';
  62. import { VALIDATE_FAILED } from '/@/utils/common/vxeUtils'
  63. // Emits声明
  64. const emit = defineEmits(['register','success']);
  65. const isUpdate = ref(true);
  66. const formDisabled = ref(false);
  67. const globalModal = ref()
  68. const refKeys = ref(['cuspSupplierProfileMan', 'cuspSupplierProfileQualification', ]);
  69. const activeKey = ref('cuspSupplierProfileMan');
  70. const cuspSupplierProfileMan = ref();
  71. const cuspSupplierProfileQualification = ref();
  72. const tableRefs = {cuspSupplierProfileMan, cuspSupplierProfileQualification, };
  73. const cuspSupplierProfileManTable = reactive({
  74. loading: false,
  75. dataSource: [],
  76. columns:cuspSupplierProfileManColumns
  77. })
  78. const cuspSupplierProfileQualificationTable = reactive({
  79. loading: false,
  80. dataSource: [],
  81. columns:cuspSupplierProfileQualificationColumns
  82. })
  83. //表单配置
  84. const [registerForm, {setProps,resetFields, setFieldsValue, validate}] = useForm({
  85. schemas: formSchema,
  86. showActionButtonGroup: false,
  87. baseColProps: {span: 8}
  88. });
  89. //表单赋值
  90. const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => {
  91. //重置表单
  92. await reset();
  93. setModalProps({confirmLoading: false,showCancelBtn:data?.showFooter,showOkBtn:data?.showFooter});
  94. isUpdate.value = !!data?.isUpdate;
  95. formDisabled.value = !data?.showFooter;
  96. if (unref(isUpdate)) {
  97. //表单赋值
  98. await setFieldsValue({
  99. ...data.record,
  100. });
  101. requestSubTableData(cuspSupplierProfileManList, {id:data?.record?.id}, cuspSupplierProfileManTable)
  102. requestSubTableData(cuspSupplierProfileQualificationList, {id:data?.record?.id}, cuspSupplierProfileQualificationTable)
  103. }
  104. // 隐藏底部时禁用整个表单
  105. setProps({ disabled: !data?.showFooter })
  106. });
  107. //方法配置
  108. const [handleChangeTabs,handleSubmit,requestSubTableData,formRef] = useJvxeMethod(requestAddOrEdit,classifyIntoFormData,tableRefs,activeKey,refKeys);
  109. //设置标题
  110. const title = computed(() => (!unref(isUpdate) ? '新增' : !unref(formDisabled) ? '编辑' : '详情'));
  111. async function reset(){
  112. await resetFields();
  113. activeKey.value = 'cuspSupplierProfileMan';
  114. cuspSupplierProfileManTable.dataSource = [];
  115. cuspSupplierProfileQualificationTable.dataSource = [];
  116. }
  117. function classifyIntoFormData(allValues) {
  118. let main = Object.assign({}, allValues.formValue)
  119. return {
  120. ...main, // 展开
  121. cuspSupplierProfileManList: allValues.tablesValue[0].tableData,
  122. cuspSupplierProfileQualificationList: allValues.tablesValue[1].tableData,
  123. }
  124. }
  125. //表单提交事件
  126. async function requestAddOrEdit(values) {
  127. try {
  128. setModalProps({confirmLoading: true});
  129. //提交表单
  130. await saveOrUpdate(values, isUpdate.value);
  131. //关闭弹窗
  132. closeModal();
  133. //刷新列表
  134. emit('success');
  135. } finally {
  136. setModalProps({confirmLoading: false});
  137. }
  138. }
  139. function handleDelete({row}) {
  140. cuspSupplierProfileMan.value?.removeRows(row)
  141. }
  142. function handleDelete1({row}) {
  143. cuspSupplierProfileQualification.value?.removeRows(row)
  144. }
  145. </script>
  146. <style lang="less" scoped>
  147. /** 时间和数字输入框样式 */
  148. :deep(.ant-input-number) {
  149. width: 100%;
  150. }
  151. :deep(.ant-calendar-picker) {
  152. width: 100%;
  153. }
  154. /deep/.ant-form-item{
  155. margin-bottom: 8px !important;
  156. }
  157. /deep/.ant-tabs{
  158. margin-left: 2%;
  159. }
  160. /deep/.ant-modal{
  161. top: 34px;
  162. }
  163. </style>