3.公司里面的弹框

提交数据的弹框

<template>
  <BasicModal  v-bind="$attrs" :width="ModalWidthEnum.COMMON" @register="registerModal" :canFullscreen="false" :title="getTitle" @ok="handleSubmit" >
    <BasicForm
      @register="registerForm"
      :schemas="schedulerModelFormSchema">
    </BasicForm>

    <BasicTable @register="registerTable" >
    </BasicTable>
  </BasicModal>
</template>

<script setup lang="ts">
import {computed, onMounted, reactive, ref, unref} from 'vue';
import {
  schedulerModelColumns,schedulerModelFormSchema
} from './data';
import {useMessage} from '@/hooks/web/useMessage';
import {BasicModal, useModalInner} from '@/components/Modal';
import {useI18n} from "@/hooks/web/useI18n";
import { BasicForm,useForm } from '@/components/Form';
import {BasicTable, useTable} from "@/components/Table";
import {listTransShipmentApi} from "@/api/tms/transShipment/transShipment.api";
import { ModalWidthEnum, shipmentStatusEnum} from "@/enums";
import {
  inTransSchedulerApi,
  sendTransSchedulerApi
} from "@/api/tms/transScheduler/transScheduler.api";
import moment from "moment";
// 定义国际化
const { t } = useI18n();
const emit = defineEmits(['success']);
const {createMessage} = useMessage();
const isUpdate = ref(true);

/** 标题初始化 */
const getTitle = computed(() => (t('public.describe.confirmDelivery')));
const variable = reactive<any>({
  ids: [],
  fatherParam:{},
});

const pageFunction=(params)=>{
  return listTransShipmentApi({schedulerNo:variable.fatherParam.schedulerNo});
}


/** 明细列表 **/
const [registerTable, { reload, getForm,getSelectRows, }] = useTable({
  api: pageFunction,
  striped: true,
  useSearchForm: false,
  rowKey: 'id',
  bordered: true,
  showIndexColumn: true,
  clickToRowSelect: true,
  columns:schedulerModelColumns,
  showTableSetting: false,
  rowSelection: {
    type: 'checkbox',
    onChange: (selectedRowKeys, selectRows) => {
      variable.ids = selectedRowKeys as string[];
    },
  },
});

const [registerForm,
  {
    setFieldsValue: setFieldsValue,
    resetFields: resetFields,
    validate: validate,
    cleanFields:cleanFields,
    clearValidate:clearValidate,
    getFieldsValue:getFieldsValue,
  }] = useForm({
  labelWidth: 120,
  showActionButtonGroup: false,
  actionColOptions: {
    span: 24,
  },
});


const [registerModal, {setModalProps, closeModal,changeOkLoading,changeLoading}] = useModalInner(async (data) => {
  variable.fatherParam=JSON.parse(JSON.stringify(data.fatherParam))
  reload()
  //设置当前时间
  let current=moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
  await setFieldsValue(variable.fatherParam)
  await setFieldsValue({actDeliveryTime:current})

});


/** 提交按钮 */
async function handleSubmit() {
  let rows = getSelectRows()
  if (rows.length < 1) {
    createMessage.error(t('public.prompted.pleaseSelectOneRecord'))
    variable.confirmLoading=false
    return
  }
  let data=JSON.parse(JSON.stringify(rows))
  changeOkLoading(true);
  changeLoading(true);
  let allData=getFieldsValue();
  allData.schedulerDetailList=data
  sendTransSchedulerApi(allData).then(() => {
    createMessage.success(t('public.prompted.successfullySend'))
    closeModal();
  }).finally(() => {
    changeOkLoading(false);
    changeLoading(false);
  })

}
</script>



使用弹框

 <!--弹框 -->
  <XXXModal @register="registerModal" @success="handleModalSuccess"></XXXModal>

引入

在这里插入代码片

注册

const [registerModal, { openModal,closeModal }] = useModal();
  /** 弹框成功事件 **/
const handleModalSuccess=(records)=>{
  
  
  
}

打开弹窗

 openModal(true, {fatherParam:record});

单纯查询的弹框

<template>
  <BasicModal  v-bind="$attrs" :width="ModalWidthEnum.COMMON" @register="registerModal" :canFullscreen="false" :title="getTitle" @ok="handleSubmit" >
    <BasicTable @register="registerTable" >

      <template #form-customerId="{ model, field }">
        <CustomerApiModal v-model:value="model[field]"   />
      </template>
    </BasicTable>
  </BasicModal>
</template>

<script setup lang="ts">
import {computed, onMounted, reactive, ref, unref} from 'vue';
import {

  unSchedulerUnSchedulerModelColumns,
  UnSchedulerModelSearchFormSchema,
} from './data';
import {useMessage} from '@/hooks/web/useMessage';
import {BasicModal, useModalInner} from '@/components/Modal';
import {useI18n} from "@/hooks/web/useI18n";
import {BasicTable, useTable} from "@/components/Table";
import {listTransShipmentApi} from "@/api/tms/transShipment/transShipment.api";
import {
  inTransSchedulerApi,
} from "@/api/tms/transScheduler/transScheduler.api";
import { ModalWidthEnum, shipmentStatusEnum} from "@/enums";
import CustomerApiModal from "@/views/base/customer/CustomerApiModal.vue";
// 定义国际化
const { t } = useI18n();
const emit = defineEmits(['success']);
const {createMessage} = useMessage();
const isUpdate = ref(true);

/** 标题初始化 */
const getTitle = computed(() => (t('public.describe.confirmDelivery')));
const variable = reactive<any>({
  ids: [],
  fatherParam:{},
  shipmentIds:[],
});

const pageFunction=(params)=>{
  return listTransShipmentApi({...params,neIdList:variable.shipmentIds,status:shipmentStatusEnum.COMFIRM});
}


/** 托运单明细列表 **/
const [registerTable, { reload, getForm,getSelectRows }] = useTable({
  api: pageFunction,
  striped: true,
  useSearchForm: true,
  rowKey: 'id',
  bordered: true,
  showIndexColumn: true,
  clickToRowSelect: true,
  columns:unSchedulerUnSchedulerModelColumns,
  formConfig: {
    labelWidth: 120,
    schemas: UnSchedulerModelSearchFormSchema,
  },
  showTableSetting: false,
  rowSelection: {
    type: 'checkbox',
    onChange: (selectedRowKeys, selectRows) => {
      variable.ids = selectedRowKeys as string[];
    },
  },
});



const [registerModal, {setModalProps, closeModal,changeOkLoading,changeLoading}] = useModalInner(async (data) => {
  variable.shipmentIds=data.shipmentIds
  variable.fatherParam=JSON.parse(JSON.stringify(data.fatherParam))
   reload()
});


/** 提交按钮 */
async function handleSubmit() {
  let rows = getSelectRows()
  if (rows.length < 1) {
    createMessage.error(t('public.prompted.pleaseSelectOneRecord'))
    variable.confirmLoading=false
    return
  }

  let data=JSON.parse(JSON.stringify(rows))
  emit("success",data)
}
</script>

使用弹框

 <!--弹框 -->
  <XXXModal @register="registerModal" @success="handleModalSuccess"></XXXModal>

引入

在这里插入代码片

注册

const [registerModal, { openModal,closeModal }] = useModal();
  /** 弹框成功事件 **/
const handleModalSuccess=(records)=>{
  
  
  
}

打开弹窗

 openModal(true, {fatherParam:record});
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值