• 封装弹出框vue3


    需求:点击按钮会出现弹出框

    父组件

    1. v-if="modalchoosePayeeVisible"
    2. :modalVisible="modalchoosePayeeVisible"
    3. @doSelectPayee="doSelectPayee"
    4. />
    5. import contractChoosePayee from './contractChoosePayee.vue';
    6. components: {contractChoosePayee},

    回显

    1. //付款方
    2. const doSelectPayee = (modalVisible: any, selectedRows: any) => {
    3. modalchoosePayeeVisible.value = modalVisible;
    4. let selectedPro = {} as any;
    5. //selectedRows 为选中的数据
    6. if (selectedRows == undefined) {
    7. return;
    8. }
    9. selectedPro = selectedRows[0];//只能单选
    10. if (contractData.formData.baseContractDTO) {
    11. contractData.formData.baseContractDTO.payee_name = selectedPro.name;
    12. (contractData.formData.baseContractDTO as any).payee_account = selectedPro.account_no;
    13. (contractData.formData.baseContractDTO as any).payee_bank_no = selectedPro.bank_name;
    14. }
    15. };

    子组件(弹出框)

    1. <template>
    2. <div class="page_wrap enclosure_wrap">
    3. <a-modal
    4. class="gic-modal enclosure-modal"
    5. v-model:visible="modalchoosePayeeVisible"
    6. title="付款方"
    7. width="1000px"
    8. @ok="hideChooseProModal"
    9. >
    10. <template #footer>
    11. <a-button key="submit" type="primary" @click="handleChooseProModalOk">确定a-button>
    12. template>
    13. <div class="modal-content">
    14. <div class="filter_container">
    15. <a-form class="form_item_right" layout="inline" :model="queries">
    16. <a-form-item label="请输入:">
    17. <a-input
    18. style="width: 230px"
    19. v-model:value="queries.query_filed"
    20. placeholder="请输入"
    21. >a-input>
    22. a-form-item>
    23. <a-form-item>
    24. <a-button class="form_btn" type="primary" @click="getTableData">查询a-button>
    25. a-form-item>
    26. a-form>
    27. div>
    28. <gap-table
    29. :configData="configData"
    30. :dataSource="dataSource"
    31. @pageChange="handlePageChange"
    32. class="bill_table"
    33. >gap-table>
    34. div>
    35. a-modal>
    36. div>
    37. template>
    38. <script lang="ts">
    39. import {
    40. chooseProject,
    41. choosePayee,
    42. showPmCateSetCode,
    43. } from '@/api/gic/contract/contractEnteringForm';
    44. import { message } from 'ant-design-vue';
    45. import gapTable from '@/components/gap3/gap-components/gap-table/gap-table.vue';
    46. import { defineComponent, onMounted, reactive, ref, toRefs,watch } from 'vue';
    47. import { validateThousands } from '@/utils';
    48. export default defineComponent({
    49. name: 'contractChoosePayee',
    50. components: {
    51. gapTable,
    52. },
    53. props: {
    54. modalVisible: {
    55. type: Boolean,
    56. },
    57. },
    58. setup(props, { emit }) {
    59. const chooseProData = reactive({
    60. queries: {
    61. query_filed: '',
    62. },
    63. curPage: 1,
    64. size: 10,
    65. configData: {
    66. viewConfig: {},
    67. cusPagination: {
    68. pageSize: 2,
    69. current: 1,
    70. total: 1,
    71. },
    72. columns: [],
    73. },
    74. dataSource: [],
    75. formState: {
    76. attach_type_code: '',
    77. attach_type_name: '',
    78. business_types: [],
    79. is_enabled: 2,
    80. remark: '',
    81. },
    82. modalvisible: false,
    83. modalTitle: '',
    84. });
    85. let selRows: any = ref([]);
    86. let modalchoosePayeeVisible = ref(false);
    87. const initViewData = () => {
    88. modalchoosePayeeVisible.value = props.modalVisible;
    89. };
    90. watch(
    91. () => props.modalVisible,
    92. () => {
    93. initViewData();
    94. },
    95. );
    96. onMounted(() => {
    97. initViewData();
    98. });
    99. watch(modalchoosePayeeVisible, () => {
    100. emit('doSelectPayee', modalchoosePayeeVisible.value, undefined);
    101. });
    102. let proTypeCodeList = ref<Array>([]);
    103. /** 设置表格字段 */
    104. const initTableColumn = () => {
    105. chooseProData.configData.viewConfig = {
    106. code: 'enclosuretable',
    107. pagination: true,
    108. rowSelection: {
    109. onChange: (selectedRowKeys: any, selectedRows: any) => {
    110. selRows.value = selectedRows;
    111. },
    112. },
    113. };
    114. chooseProData.configData.cusPagination = {
    115. pageSize: 10,
    116. current: 1,
    117. total: 1,
    118. };
    119. (chooseProData.configData.cusPagination as any) = null;
    120. (chooseProData.configData.columns as any) = [
    121. {
    122. title: '序号',
    123. dataIndex: 'order_num',
    124. key: 'order_num',
    125. width: 50,
    126. customRender: function (t: any) {
    127. return t.index + 1;
    128. },
    129. },
    130. {
    131. title: '供应商名称',
    132. dataIndex: 'name',
    133. key: 'name',
    134. width: 200,
    135. },
    136. {
    137. title: '账户',
    138. dataIndex: 'account_no',
    139. key: 'account_no',
    140. width: 100,
    141. },
    142. {
    143. title: '开户行名称',
    144. dataIndex: 'bank_name',
    145. key: 'bank_name',
    146. width: 200,
    147. },
    148. ];
    149. };
    150. initTableColumn();
    151. /** 获取单据列表数据 */
    152. const getTableData = async () => {
    153. const res: any = await choosePayee({
    154. page: 1,
    155. queryFiled: '',
    156. rows: 100,
    157. });
    158. if (res.status_code == '0000') {
    159. chooseProData.dataSource = res.data.rows;
    160. } else {
    161. message.error(res.reason);
    162. }
    163. };
    164. getTableData();
    165. /** 当前页变化 */
    166. const handlePageChange = (page: number, pageSize: number) => {
    167. chooseProData.configData.cusPagination.current = page;
    168. chooseProData.configData.cusPagination.pageSize = pageSize;
    169. getTableData();
    170. };
    171. const hideChooseProModal = () => {
    172. modalchoosePayeeVisible.value = false;
    173. console.log('==========', modalchoosePayeeVisible.value);
    174. };
    175. const handleChooseProModalOk = async () => {
    176. modalchoosePayeeVisible.value = false;
    177. emit('doSelectPayee', modalchoosePayeeVisible.value, selRows.value);
    178. };
    179. return {
    180. ...toRefs(chooseProData),
    181. modalchoosePayeeVisible,
    182. getTableData,
    183. handlePageChange,
    184. hideChooseProModal,
    185. handleChooseProModalOk,
    186. };
    187. },
    188. });
    189. script>
    190. <style lang="less">style>

  • 相关阅读:
    Python是最受欢迎的语言?名不副实
    WebRTC Native M96编码规范向导(C++ C Python Java Oc Gn)
    QT第三方库加载pro解读
    shell编程规范与变量
    2022年全球市场氨苯蝶啶原料药总体规模、主要生产商、主要地区、产品和应用细分研究报告
    module ‘numpy‘ has no attribute ‘object‘
    【软件设计师-从小白到大牛】上午题基础篇:第二章 操作系统
    PostgreSQL的学习心得和知识总结(九十一)|深入理解PostgreSQL数据库开源MPP扩展Citus的安装过程及其Makefile的理解
    吴恩达的机器学习,属实牛逼
    【PowerQuery】PowerQuery学习路径
  • 原文地址:https://blog.csdn.net/ping_lvy/article/details/126343715