import { _ as _extends } from '../_rollupPluginBabelHelpers-736b301a.js';
import React__default, { useRef, useState, useEffect } from 'react';
import { Form, Select, Radio, Input } from 'antd';
import Modal from '../Modal/index.js';
import LabelValue from '../LabelValue/index.js';
import ImageView from '../ImageView/index.js';
import Player from '../Player/index.js';
import CaptureBox from '../CaptureCard/index.js';
import 'moment';
import 'lodash';
import '@zenview/micro-basic-library';
import '../IconFont/index.js';
import '@zenview/micro-utils';
import '../AuthComponent/index.js';
import '@cloud-app-dev/mpegts.js';
import 'hls.js';
import '../index-71189681.js';
import '../_commonjsHelpers-e7b0df42.js';
import 'react-is';
import 'react-dom';
import 'ahooks';
import 'lamejs';
import 'mobx-react';
import '../RangePicker/index.js';
import '../Title/index.js';
import '../BetweenBox/index.js';
import 'rc-queue-anim';
import 'add-dom-event-listener';
import '../CaptureImgView/index.js';
import '../Picture/index.js';
import '../MoveContent/index.js';
import '../FullScreen/index.js';
import '../index-19c4ec5b.js';
import 'react-router-dom';
import '../index-4c050215.js';
import '../waterMakeDom-7959ac3b.js';
import '../mobx.esm-dee4cf9f.js';
import 'js-audio-recorder';
import '../index-07cebbd5.js';
import '../ToolsBar/index.js';

const FormItem = Form.Item;
const {
  TextArea
} = Input;
const {
  Option
} = Select;
/**
 * @desc 审批与下载，确认的弹窗组件
 * @param {Object} data 申请记录的详细信息
 * @param {Object} dataArray 组装显示的详细信息
 * （imageDetails=[] 图片/fileData={} 视频，downloadContent=[]
 * 下载内容，applyPersonInfo=[] 申请人信息， candidateReviewers=[] 审批人多个）
 * @param {bool} visible 弹窗开关
 * @param {String} title 弹窗标题
 * @param {Function} agreeAndRefuse 同意or拒绝下载申请的事件
 * @param {Function} toSubmit 提交下载申请
 * @param {Function} toCancel 取消下载申请
 * @param {Function} showPicDetail 查看图片详细
 * @param {bool} isCheck 是否审批模式
 * @param {bool} isApply 是否申请模式
 * @param {bool} isEdit 是否编辑模式
 * @param {bool} isOnceAgain 是否再次提交
 * @param {bool} isShowCheckPerson 是否显示审批人信息
 *
 */
const DownloadModal = ({
  data = {},
  dataArray = {},
  visible,
  title = '下载申请',
  agreeAndRefuse,
  toSubmit,
  toCancel,
  showPicDetail,
  isCheck = false,
  isApply = false,
  isEdit = false,
  isOnceAgain = false,
  isShowCheckPerson = false,
  form,
  isBatchDownload = false,
  containerDom,
  ...props
}) => {
  const formRef = useRef();
  const [downType, setDownType] = useState();
  const getFooterProps = () => {
    let footerProps = {
      hasFooter: false
    };
    if (isCheck && isEdit) {
      footerProps = {
        hasFooter: true,
        okText: '同意',
        onOk: () => agreeAndRefuse(formRef.current.getFieldsValue(), 1),
        cancelText: '拒绝',
        onFootCancel: () => agreeAndRefuse(formRef.current.getFieldsValue(), 0)
      };
    }
    if (isApply) {
      footerProps = {
        hasFooter: true,
        cancelText: '取消',
        okText: isOnceAgain ? '再次提交' : '提交',
        onOk: () => toSubmit(formRef.current.getFieldsValue()),
        onCancel: toCancel
      };
    }
    return footerProps;
  };
  const downTypeChange = value => {
    setDownType(value);
    if (value === 'offline') {
      formRef.current.setFieldsValue({
        downloadFormat: '2'
      });
    }
  };
  useEffect(() => {
    setDownType();
  }, [visible]);
  let {
    imageDetails = [],
    fileData = {},
    downloadContent = [],
    applyPersonInfo = [],
    candidateReviewers = []
  } = dataArray;
  const footerProps = getFooterProps();
  return /*#__PURE__*/React__default.createElement(Modal, _extends({
    title: title,
    destroyOnClose: true,
    onOk: toCancel,
    onCancel: toCancel,
    visible: visible,
    width: "480px",
    className: "check-detail-modal-box"
  }, footerProps, props, {
    zIndex: 1001
  }), /*#__PURE__*/React__default.createElement(Form, {
    ref: formRef,
    className: "check-content"
  }, !isBatchDownload && /*#__PURE__*/React__default.createElement("div", {
    className: "img-video-box"
  }, imageDetails.length > 0 ? imageDetails.length === 1 ? imageDetails.map(v => /*#__PURE__*/React__default.createElement("div", {
    className: "img-item-one"
  }, /*#__PURE__*/React__default.createElement(ImageView, {
    src: v.url
  }))) : imageDetails.map(v => /*#__PURE__*/React__default.createElement(CaptureBox, {
    key: v.id,
    imgUrl: v.url,
    deviceName: v.deviceName,
    captureTime: v.startTime,
    relativeIcon: false,
    className: "img-item-more",
    checkboxItem: false,
    onClick: () => showPicDetail && showPicDetail(v)
  })) : /*#__PURE__*/React__default.createElement(Player, {
    isFrontEnd: +fileData.videoType === 1,
    startTime: fileData.startTime,
    endTime: fileData.endTime,
    title: fileData.deviceName,
    cid: fileData.cid,
    key: fileData.cid,
    isLive: false,
    historyList: fileData.historyList,
    hasHistory: false
  })), !!downloadContent.length && /*#__PURE__*/React__default.createElement(ItemBox, {
    title: "\u4E0B\u8F7D\u5185\u5BB9"
  }, downloadContent.map((item, index) => /*#__PURE__*/React__default.createElement(LabelValue, {
    key: index,
    className: item.label !== '设备名称' ? 'item' : 'item deviceItem',
    label: item.label,
    value: item.value || ''
  }))), /*#__PURE__*/React__default.createElement(ItemBox, {
    title: "\u9009\u62E9\u4E0B\u8F7D\u65B9\u5F0F",
    isFormItem: true,
    getFieldDecorator: {
      name: 'downType',
      rules: [{
        required: true,
        message: '请选择下载方式'
      }],
      initialValue: data.downType && String(data.downType) || 'online'
    }
  }, /*#__PURE__*/React__default.createElement(Select, {
    onChange: downTypeChange,
    className: "select-download-format",
    dropdownClassName: "select-filter-drop",
    style: {
      width: 170,
      marginRight: '12px'
    }
  }, /*#__PURE__*/React__default.createElement(Option, {
    value: "online",
    key: 'online'
  }, "\u5728\u7EBF\u4E0B\u8F7D"), /*#__PURE__*/React__default.createElement(Option, {
    value: "offline",
    key: 'offline'
  }, "\u79BB\u7EBF\u4EFB\u52A1"))), !!downloadContent.length && !imageDetails.length && fileData.videoType !== 1 && /*#__PURE__*/React__default.createElement(ItemBox, {
    title: "\u9009\u62E9\u4E0B\u8F7D\u683C\u5F0F",
    isFormItem: true,
    getFieldDecorator: {
      name: 'downloadFormat',
      rules: [{
        required: true,
        message: '是否选择视频格式'
      }],
      initialValue: data.downloadFormat && String(data.downloadFormat) || '2'
    }
  }, /*#__PURE__*/React__default.createElement(Select, {
    disabled: downType === 'offline',
    className: "select-download-format",
    dropdownClassName: "select-filter-drop",
    style: {
      width: 170,
      marginRight: '12px'
    }
  }, /*#__PURE__*/React__default.createElement(Option, {
    value: "1",
    key: 'ts'
  }, "TS\u683C\u5F0F"), /*#__PURE__*/React__default.createElement(Option, {
    value: "2",
    key: 'mp4'
  }, "MP4\u683C\u5F0F"))), !!applyPersonInfo.length && /*#__PURE__*/React__default.createElement(ItemBox, {
    title: "\u7533\u8BF7\u4EBA\u4FE1\u606F"
  }, applyPersonInfo && applyPersonInfo.map(item => /*#__PURE__*/React__default.createElement(LabelValue, {
    className: "item",
    label: item.label,
    value: item.value || ''
  }))), isCheck && /*#__PURE__*/React__default.createElement(ItemBox, {
    title: "\u4E0B\u8F7D\u539F\u56E0"
  }, /*#__PURE__*/React__default.createElement(LabelValue, {
    className: "item",
    label: '下载原因',
    value: data.applyReason || ''
  })), isCheck && data.resourceType === '121301' && /*#__PURE__*/React__default.createElement(ItemBox, {
    title: "\u662F\u5426\u6709\u6C34\u5370"
  }, /*#__PURE__*/React__default.createElement(LabelValue, {
    className: "item",
    label: '水印',
    value: data.hasMarker ? '有' : '无'
  })), isCheck && !isEdit && isShowCheckPerson && /*#__PURE__*/React__default.createElement(ItemBox, {
    title: "\u5BA1\u6279\u4EBA"
  }, /*#__PURE__*/React__default.createElement(LabelValue, {
    className: "item",
    label: '说明',
    value: '以下人员均可审批此条申请'
  }), /*#__PURE__*/React__default.createElement("div", {
    className: "check-person",
    style: {
      paddingLeft: '80px',
      fontSize: '12px'
    }
  }, candidateReviewers.length > 0 ? candidateReviewers.map(v => v.name).join('，') : '')), isCheck && !isEdit && /*#__PURE__*/React__default.createElement(ItemBox, {
    title: "\u5BA1\u6279\u5907\u6CE8"
  }, /*#__PURE__*/React__default.createElement(LabelValue, {
    className: "item",
    label: '审批备注',
    value: data.reviewNotes || ''
  })), isCheck && isEdit && /*#__PURE__*/React__default.createElement(ItemBox, {
    title: "\u5BA1\u6279\u5907\u6CE8",
    isFormItem: true,
    getFieldDecorator: {
      name: 'reviewNotes',
      initialValue: data.reviewNotes || ''
    }
  }, /*#__PURE__*/React__default.createElement(TextArea, {
    style: {
      minHeight: '64px',
      fontSize: '12px'
    },
    maxLength: 201,
    placeholder: "\u8BF7\u586B\u5199\u60A8\u7684\u5907\u6CE8\u4FE1\u606F\uFF0C\u6700\u5927\u957F\u5EA6\u4E0D\u8D85\u8FC7200"
  })), isApply && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(ItemBox, {
    title: "\u4E0B\u8F7D\u539F\u56E0",
    className: "reason",
    isFormItem: true,
    getFieldDecorator: {
      name: 'applyReason',
      initialValue: data.applyReason || ''
    }
  }, /*#__PURE__*/React__default.createElement(TextArea, {
    style: {
      minHeight: '64px',
      fontSize: '12px'
    },
    maxLength: 201,
    placeholder: "\u8BF7\u586B\u5199\u60A8\u7684\u4E0B\u8F7D\u539F\u56E0\uFF0C\u6700\u5927\u957F\u5EA6\u4E0D\u8D85\u8FC7200"
  })), imageDetails.length >= 1 && /*#__PURE__*/React__default.createElement(ItemBox, {
    title: "\u6C34\u5370",
    isFormItem: true,
    getFieldDecorator: {
      name: 'hasMarker',
      rules: [{
        required: true,
        message: '是否有水印必须选择'
      }],
      initialValue: data.hasOwnProperty('hasMarker') ? data.hasMarker ? 1 : 0 : 1
    }
  }, /*#__PURE__*/React__default.createElement(Radio.Group, {
    style: {
      fontSize: '12px'
    }
  }, /*#__PURE__*/React__default.createElement(Radio, {
    value: 1
  }, "\u6253\u6C34\u5370"), /*#__PURE__*/React__default.createElement(Radio, {
    value: 0
  }, "\u4E0D\u6253\u6C34\u5370")))), /*#__PURE__*/React__default.createElement("div", {
    className: `watermark
            ${data && data.reviewStatus === 1 ? 'agree' : ''}
            ${data && data.reviewStatus === 0 ? 'refuse' : ''}
          `
  })));
};
const ItemBox = ({
  title,
  className = '',
  isFormItem = false,
  getFieldDecorator,
  children
}) => {
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("h2", null, title, "\uFF1A"), isFormItem ? /*#__PURE__*/React__default.createElement(FormItem, _extends({
    label: title,
    className: `form-detail-desc ${className}`
  }, getFieldDecorator), children) : children);
};

export { DownloadModal as default };
//# sourceMappingURL=index.js.map
