当前位置: 首页 > news >正文

react中的 Modal.confirm

在这里插入图片描述
改引入的还要引入

import React from 'react';
import { ElSearchTable } from '@/components/el';
import EditModal from './EditModal/index';
import { commonExport } from '@/utils/utils'; // 导出
import {
  getTableSearchFormItems,
  InvalidBounced, // 作废弹框查询
  getTableColumns,
  getTableActionButtons
} from './definitConfig';
import CancellationModal from './CancellationModal'; // 作废弹框
import dayjs from 'dayjs';
import { ElNotification } from '@/components/el';
import { Spin, Modal,Input } from 'antd';
import { getPrepaidType, rejected, review } from './service';
import * as service from './service';
import { history } from 'react-router-dom';

interface State {
  editData: object;
  modalVisible: Boolean,
  mark: String,
  data: any;
  formRef: any; //表单的ref
  selectedRowKeys: any;// 表格勾选行keys
  selectedRows: any;// 表格勾选行rows
  loading: boolean;
  MessageModalLoading: boolean, //消息弹框的loading
  areaValue: string; //  接收的原因说明字段
}

class PurcStatementDefinit extends React.Component<Props, State> {
  tableRef: any;
  modalRef: any;
  constructor(props) {
    super(props);
    this.state = {
      editData: null,
      mark: 'create', // creact新增, edit编辑
      modalVisible: false,
      data: null,
      formRef: null, //表单的ref
      selectedRowKeys: [], // 表格勾选行keys
      selectedRows: [], // 表格勾选行rows
      loading: false,
      MessageModalLoading: false, //消息弹框的loading
      areaValue: '' // 接收的原因说明字段
    };
  }

/**
   * 点击审核拒绝
   * @param rowKeys 选择行的keys 
   * @param rows 选择的行
   * @returns 
   */
  handleApproveRefused = async (rowKeys, rows) => { // 接收选中行的参数,进行判断
    console.log(rows[0].id ,  ‘如果支持多选,可以直接打印roeKeys看看是不是一个数组形式的,我这里接收的是选中的单个id值’)
    if (!(rows[0].invState === '1')) {
    // if (rows.some(val => val.state !== 'DRAFT')) { // 或者是这种写法判断
      return ElNotification({
        type: 'warning',
        message: '请选择<状态>为【待审批】的单据!'
      });
    }
    const { TextArea } = Input // 引入antd中的组件
    Modal.confirm({
      width: 500,
      maskClosable: true,
      centered: true,
      title: '审批拒绝理由',
      onOk: (e) => this.refused(e, rows[0].id), // 点击确定时要执行的事件
      onCancel: () => { return },
      content: ( // 执行的内容
        <TextArea
          onChange={this.areaChange} // 改变事件
          autoSize={{ minRows: 8, maxRows: 10 }}
          placeholder='请输入理由(一百个字以内)'
        />
      ),
      cancelText: '取消',
      okText: '确认'
    });
  }

  /**
   * 审批拒绝确认
   * @param e 
   * @param rowKeys 选择行的keys
   */
  async refused(e, rowKeys) {
    if (!this.state.areaValue) {
      ElNotification({
        type: 'warning',
        message: '请填写拒绝理由'
      })
      e.preventDefault()
    } else if (this.state.areaValue.length > 100) {
      ElNotification({
        type: 'warning',
        message: '拒绝理由超过一百个字'
      })
      e.preventDefault()
    } else {
      const params = { 
      	id: rowKeys,  // 接收单选非数组 
      	reason: this.state.areaValue }
      const res = await rejected(params)
      if (res && res.success) {
        ElNotification({
          type: 'success',
          message: res.msg || '操作成功'
        })
        this.tableRef.getTableData()
      } else {
        ElNotification({
          type: 'error',
          message: res.msg || '操作失败'
        })
      }
    }
  }

  /**
   * 审核拒绝理由改变
   * @param param0 
   */
  areaChange = ({ target: { value } }) => {
    this.setState({ areaValue: value });
  };

欢迎指正,交流。

相关文章:

  • 数据挖掘之决策树ID3算法(C#实现)
  • 【一小时入门】webpack 入门指南
  • Vue中 beforeRouteLeave离开路由之前要执行的操作
  • AF3.1.0简单二次封装
  • Vue 项目中 根目录中router路由拦截 beforeEach 常用的写法
  • 不同按钮模板自定义
  • react项目中没有路由守卫,需要拦截的话,只能在路径上拦截,可以自己去封装 Route
  • 跟锦数学160823-190322, 共 942 题
  • JavaScript新鲜事·第5期
  • vue 项目实战 递归
  • react 项目 tab列表 把返回的一个字段数组,全部 展示在一个字段里
  • Python语言学习 (六)1.2
  • js语法中 ?. 和 ?? 的含义以及用法说明
  • 工作中MySql常用操作
  • 命令模式-对象行为型
  • -------------------- 第二讲-------- 第一节------在此给出链表的基本操作
  • 【vuex入门系列02】mutation接收单个参数和多个参数
  • C# 免费离线人脸识别 2.0 Demo
  • Cumulo 的 ClojureScript 模块已经成型
  • Golang-长连接-状态推送
  • iOS 系统授权开发
  • iOS编译提示和导航提示
  • leetcode98. Validate Binary Search Tree
  • mac修复ab及siege安装
  • NLPIR语义挖掘平台推动行业大数据应用服务
  • VirtualBox 安装过程中出现 Running VMs found 错误的解决过程
  • vue学习系列(二)vue-cli
  • 数据科学 第 3 章 11 字符串处理
  • 译自由幺半群
  • 这几个编码小技巧将令你 PHP 代码更加简洁
  • 你学不懂C语言,是因为不懂编写C程序的7个步骤 ...
  • ​学习一下,什么是预包装食品?​
  • # Pytorch 中可以直接调用的Loss Functions总结:
  • ###51单片机学习(2)-----如何通过C语言运用延时函数设计LED流水灯
  • #pragma once与条件编译
  • (11)工业界推荐系统-小红书推荐场景及内部实践【粗排三塔模型】
  • (1综述)从零开始的嵌入式图像图像处理(PI+QT+OpenCV)实战演练
  • (大众金融)SQL server面试题(1)-总销售量最少的3个型号的车及其总销售量
  • (二)c52学习之旅-简单了解单片机
  • (六)Hibernate的二级缓存
  • (南京观海微电子)——COF介绍
  • (十八)用JAVA编写MP3解码器——迷你播放器
  • (转)Android学习系列(31)--App自动化之使用Ant编译项目多渠道打包
  • (转)负载均衡,回话保持,cookie
  • .NET Core 将实体类转换为 SQL(ORM 映射)
  • .Net 路由处理厉害了
  • .Net 知识杂记
  • .NetCore部署微服务(二)
  • .NET开源全面方便的第三方登录组件集合 - MrHuo.OAuth
  • .net快速开发框架源码分享
  • .NET值类型变量“活”在哪?
  • /var/spool/postfix/maildrop 下有大量文件
  • @拔赤:Web前端开发十日谈
  • [<MySQL优化总结>]
  • [ARC066F]Contest with Drinks Hard