CuspSupplierProfileForm.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <div>
  3. <BasicForm @register="registerForm" ref="formRef"/>
  4. <!-- 子表单区域 -->
  5. <a-tabs v-model:activeKey="activeKey" animated @change="handleChangeTabs">
  6. <a-tab-pane tab="供应商档案-联系人" key="cuspSupplierProfileMan" :forceRender="true">
  7. <JVxeTable
  8. keep-source
  9. resizable
  10. ref="cuspSupplierProfileMan"
  11. v-if="cuspSupplierProfileManTable.show"
  12. :loading="cuspSupplierProfileManTable.loading"
  13. :columns="cuspSupplierProfileManTable.columns"
  14. :dataSource="cuspSupplierProfileManTable.dataSource"
  15. :height="340"
  16. :rowNumber="true"
  17. :rowSelection="true"
  18. :disabled="formDisabled"
  19. :toolbar="true"
  20. />
  21. </a-tab-pane>
  22. <a-tab-pane tab="供应商档案-资质信息" key="cuspSupplierProfileQualification" :forceRender="true">
  23. <JVxeTable
  24. keep-source
  25. resizable
  26. ref="cuspSupplierProfileQualification"
  27. v-if="cuspSupplierProfileQualificationTable.show"
  28. :loading="cuspSupplierProfileQualificationTable.loading"
  29. :columns="cuspSupplierProfileQualificationTable.columns"
  30. :dataSource="cuspSupplierProfileQualificationTable.dataSource"
  31. :height="340"
  32. :rowNumber="true"
  33. :rowSelection="true"
  34. :disabled="formDisabled"
  35. :toolbar="true"
  36. />
  37. </a-tab-pane>
  38. </a-tabs>
  39. <div style="width: 100%;text-align: center" v-if="!formDisabled">
  40. <a-button @click="handleSubmit" pre-icon="ant-design:check" type="primary">提 交</a-button>
  41. </div>
  42. </div>
  43. </template>
  44. <script lang="ts">
  45. import {BasicForm, useForm} from '/@/components/Form/index';
  46. import { computed, defineComponent, reactive, ref, unref } from 'vue';
  47. import {defHttp} from '/@/utils/http/axios';
  48. import { propTypes } from '/@/utils/propTypes';
  49. import { useJvxeMethod } from '/@/hooks/system/useJvxeMethods';
  50. import { VALIDATE_FAILED } from '/@/utils/common/vxeUtils';
  51. import {getBpmFormSchema,cuspSupplierProfileManColumns,cuspSupplierProfileQualificationColumns} from '../CuspSupplierProfile.data';
  52. import {saveOrUpdate,cuspSupplierProfileManList,cuspSupplierProfileQualificationList} from '../CuspSupplierProfile.api';
  53. export default defineComponent({
  54. name: "CuspSupplierProfileForm",
  55. components:{
  56. BasicForm,
  57. },
  58. props:{
  59. formData: propTypes.object.def({}),
  60. formBpm: propTypes.bool.def(true),
  61. },
  62. setup(props){
  63. const [registerForm, { setFieldsValue, setProps }] = useForm({
  64. labelWidth: 150,
  65. schemas: getBpmFormSchema(props.formData),
  66. showActionButtonGroup: false,
  67. baseColProps: {span: 8}
  68. });
  69. const formDisabled = computed(()=>{
  70. if(props.formData.disabled === false){
  71. return false;
  72. }
  73. return true;
  74. });
  75. const refKeys = ref(['cuspSupplierProfileMan', 'cuspSupplierProfileQualification', ]);
  76. const activeKey = ref('cuspSupplierProfileMan');
  77. const cuspSupplierProfileMan = ref();
  78. const cuspSupplierProfileQualification = ref();
  79. const tableRefs = {cuspSupplierProfileMan, cuspSupplierProfileQualification, };
  80. const cuspSupplierProfileManTable = reactive({
  81. loading: false,
  82. dataSource: [],
  83. columns:cuspSupplierProfileManColumns,
  84. show: false
  85. })
  86. const cuspSupplierProfileQualificationTable = reactive({
  87. loading: false,
  88. dataSource: [],
  89. columns:cuspSupplierProfileQualificationColumns,
  90. show: false
  91. })
  92. const [handleChangeTabs,handleSubmit,requestSubTableData,formRef] = useJvxeMethod(requestAddOrEdit,classifyIntoFormData,tableRefs,activeKey,refKeys,validateSubForm);
  93. function classifyIntoFormData(allValues) {
  94. let main = Object.assign({}, allValues.formValue)
  95. return {
  96. ...main, // 展开
  97. cuspSupplierProfileManList: allValues.tablesValue[0].tableData,
  98. cuspSupplierProfileQualificationList: allValues.tablesValue[1].tableData,
  99. }
  100. }
  101. //表单提交事件
  102. async function requestAddOrEdit(values) {
  103. await saveOrUpdate(values, true);
  104. }
  105. const queryByIdUrl = '/cuspCode/cuspSupplierProfile/queryById';
  106. async function initFormData(){
  107. let params = {id: props.formData.dataId};
  108. const data = await defHttp.get({url: queryByIdUrl, params});
  109. //设置表单的值
  110. await setFieldsValue({...data});
  111. requestSubTableData(cuspSupplierProfileManList, {id: data.id}, cuspSupplierProfileManTable, ()=>{
  112. cuspSupplierProfileManTable.show = true;
  113. });
  114. requestSubTableData(cuspSupplierProfileQualificationList, {id: data.id}, cuspSupplierProfileQualificationTable, ()=>{
  115. cuspSupplierProfileQualificationTable.show = true;
  116. });
  117. //默认是禁用
  118. await setProps({disabled: formDisabled.value})
  119. }
  120. initFormData();
  121. return {
  122. registerForm,
  123. formDisabled,
  124. formRef,
  125. handleSubmit,
  126. activeKey,
  127. handleChangeTabs,
  128. cuspSupplierProfileMan,
  129. cuspSupplierProfileQualification,
  130. cuspSupplierProfileManTable,
  131. cuspSupplierProfileQualificationTable,
  132. }
  133. }
  134. });
  135. </script>