FileUploadModal.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <a-modal
  3. :title="title"
  4. width="45%"
  5. :visible="visible"
  6. :maskClosable="false"
  7. ref="FileUploadModalRef"
  8. switchFullscreen
  9. @ok = "handleOk"
  10. @cancel="handleCancel">
  11. <div>
  12. <a-card >
  13. <div class="table-page-search-wrapper">
  14. <a-form :model="queryParams" :label-col="labelCol" :wrapper-col="wrapperCol" ref="formDataRef">
  15. <a-row :gutter="24">
  16. <a-col :xl="24" :lg="24" :md="24">
  17. <a-form-item label="产品(product name)" name="productId">
  18. <a-select v-model:value="queryParams.productId" style="width: 100%;" @change="changeProduct" allowClear>
  19. <a-select-option v-for="item in productOption" :key="item.id" :value="item.id">{{ item.label }}</a-select-option>
  20. </a-select>
  21. </a-form-item>
  22. </a-col>
  23. <a-col :xl="24" :lg="24" :md="24">
  24. <a-form-item label="名称(name)" name="name">
  25. <a-input v-model:value="queryParams.name" AutoComplete='off'></a-input>
  26. </a-form-item>
  27. </a-col>
  28. <a-col :xl="24" :lg="24" :md="24">
  29. <a-form-item label="附件(attachs)" name="attachs">
  30. <JUpload v-model:value="queryParams.attachs"></JUpload>
  31. </a-form-item>
  32. </a-col>
  33. </a-row>
  34. </a-form>
  35. </div>
  36. </a-card>
  37. </div>
  38. </a-modal>
  39. </template>
  40. <script lang="ts" setup>
  41. import {ref,reactive } from 'vue';
  42. import { defHttp } from '/@/utils/http/axios';
  43. import { message,Modal } from 'ant-design-vue';
  44. import { ApiSelect, } from '/@/components/Form/index';
  45. import JUpload from '/@/components/Form/src/jeecg/components/JUpload/JUpload.vue';
  46. const emit = defineEmits([ 'addList']); //定义emit
  47. var visible = ref(false)
  48. var title = ref('')
  49. var formDataRef=ref();
  50. var executeMethod =ref('')
  51. const labelCol = reactive({
  52. xs:24,
  53. sm:4,
  54. });
  55. const wrapperCol = reactive({
  56. xs: 24,
  57. sm: 16,
  58. });
  59. var productOption = ref([]);
  60. const FileUploadModalRef = ref();
  61. const queryParams = ref({
  62. name:'',
  63. attachs:'',
  64. headId:'',
  65. type:'',
  66. productId:"",
  67. productName:''
  68. });
  69. function handleOk(){
  70. let executeUrl = ''
  71. if(executeMethod.value=='add'){
  72. executeUrl = '/saleCode/saleDeliveryFiles/add'
  73. }else{
  74. executeUrl = '/saleCode/saleDeliveryFiles/edit'
  75. }
  76. defHttp.post({ url: executeUrl, params: queryParams.value }, { isTransformResponse: false }).then((res) => {
  77. if (res.success) {
  78. emit('addList');
  79. message.warning(res.message);
  80. handleCancel()
  81. } else {
  82. message.warning(res.message);
  83. }
  84. })
  85. }
  86. function handleCancel(){
  87. visible.value = false
  88. formDataRef.value.resetFields()
  89. Modal.destroyAll();
  90. }
  91. function getTable(fatherId,fatherTitle,status,id){
  92. visible.value = true
  93. queryParams.value.headId = fatherId.value
  94. title.value = fatherTitle.value=='customsClearanceDocuments'?'清关资料(customs clearance documents)':'证书/报告(certificate/report)'
  95. queryParams.value.type = fatherTitle.value=='customsClearanceDocuments'?'1':'2'
  96. executeMethod.value = status
  97. if(status=='edit'){
  98. getForm(id)
  99. }
  100. productListList()
  101. }
  102. function getForm(id){
  103. defHttp.get({ url: '/saleCode/saleDeliveryFiles/queryById', params: {id:id} }, { isTransformResponse: false }).then((res) => {
  104. if (res.success) {
  105. queryParams.value = res.result
  106. } else {
  107. message.warning(res.message);
  108. }
  109. })
  110. }
  111. function productListList(){
  112. productOption.value = []
  113. defHttp.get({ url: '/baseCode/baseProductArchive/list', params: {pageSize:-1} }, { isTransformResponse: false }).then((res) => {
  114. if (res.success) {
  115. res.result.records.map(item=>{
  116. productOption.value.push({
  117. id:item.id,
  118. label:item.chineseName
  119. })
  120. })
  121. } else {
  122. message.warning(res.message);
  123. }
  124. })
  125. }
  126. function changeProduct(date){
  127. productOption.value.map(item=>{
  128. if(item.id==date){
  129. queryParams.value.productName = item.label
  130. }
  131. })
  132. }
  133. defineExpose({
  134. getTable
  135. });
  136. </script>
  137. <style scoped lang="less">
  138. /deep/.ant-form-item{
  139. margin-bottom: 8px !important;
  140. }
  141. // /deep/.ant-table-wrapper .ant-table-thead > tr > th, .ant-table-wrapper .ant-table-thead > tr > td{
  142. // padding: 8px !important;
  143. // }
  144. </style>