function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
import { downloadFile, getVtxToken } from '@vtx/utils';
import { Button, Image, message, Space } from 'antd';
import { useContext } from 'react';
import { VmInfoCollection, VmTable, VmTitle, VmWrapper } from "../../../_components";
import VtxBaseModal from "../../../vtx-base-modal";
import { BasicService } from "../../api";
import { RestaurantContext } from "../../index";
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
var Content = function Content(_ref) {
  var id = _ref.id;
  var data = BasicService.useContactInfo({
    id: id
  });
  var infoData = [{
    label: '合同编号',
    value: data.contractNumber,
    key: 'contractNumber'
  }, {
    label: '垃圾类型',
    value: data.garbageTypeStr,
    key: 'garbageTypeStr'
  }, {
    label: '甲方名称',
    value: data.firstParty,
    key: 'firstParty'
  }, {
    label: '乙方名称',
    value: data.secondParty,
    key: 'secondParty'
  }, {
    label: '运输地址',
    value: data.transportAddress,
    key: 'transportAddress',
    isAddress: true
  }].concat(_toConsumableArray(data.garbageType === 'ccfqw' ? [{
    label: '运输频次',
    value: data.frequencyStr,
    key: 'frequencyStr'
  }, {
    label: '运输时间',
    value: data.time,
    key: 'time'
  }] : []), [{
    label: '运输量',
    value: data.garbageType === 'fqyz' ? "".concat(data.trafficWeek || '-', "\u516C\u65A4/\u5468\uFF0C").concat(data.trafficMonth || '-') : "".concat(data.trafficDay || '-', "\u516C\u65A4/\u5929"),
    key: 'trafficDay'
  }], _toConsumableArray(data.garbageType === 'fqyz' ? [{
    label: '收运频次',
    value: data.frequencyStr,
    key: 'frequencyStr'
  }, {
    label: '收运时间',
    value: data.time,
    key: 'time'
  }, {
    label: '费用支付方式',
    value: data.paymentMethod,
    key: 'paymentMethod'
  }] : [{
    label: '签约金额',
    value: "".concat(data.contractAmount || '-', "\u5143/\u5E74"),
    key: 'contractAmount'
  }]), [{
    label: '甲方未按规定分类违约金',
    value: "".concat(data.classifyPenalty || '-', "\u5143/\u5428"),
    key: 'classifyPenalty'
  }], _toConsumableArray(data.garbageType === 'fqyz' ? [{
    label: '协议违反解约期限',
    value: "".concat(data.terminationPeriod || '-', "\u5929"),
    key: 'terminationPeriod'
  }] : [{
    label: '甲方转交其他单位个人收运违约金',
    value: "".concat(data.transferOtherPenalty || '-', "\u5143/\u6B21"),
    key: 'terminationPeriod'
  }]));
  var columns = [{
    title: '容量',
    dataIndex: 'capacity',
    align: 'center'
  }, {
    title: '桶数',
    dataIndex: 'barrelage',
    align: 'center'
  }];
  var token = getVtxToken('token');
  return /*#__PURE__*/_jsx("div", {
    children: /*#__PURE__*/_jsx(VmWrapper, {
      title: "\u5408\u540C\u4FE1\u606F",
      rightContent: /*#__PURE__*/_jsxs(Space, {
        children: [/*#__PURE__*/_jsx(Button, {
          onClick: function onClick() {
            if (data.contractId) {
              downloadFile("/cloudFile/common/downloadFile?id=".concat(data.contractId, "&token=").concat(token), {}, 'form');
            } else {
              message.warning('还没有合同生成');
            }
          },
          children: "\u4E0B\u8F7D\u5408\u540C(word)"
        }), /*#__PURE__*/_jsx(Button, {
          type: "primary",
          onClick: function onClick() {
            message.config({
              prefixCls: 'my-message'
            });
            if (data.contractPdfId) {
              downloadFile("/cloudFile/common/downloadFile?id=".concat(data.contractPdfId, "&token=").concat(token), {}, 'form');
            } else {
              message.warning('还没有合同生成');
            }
          },
          children: "\u4E0B\u8F7D\u5408\u540C(pdf)"
        })]
      }),
      children: /*#__PURE__*/_jsxs(_Fragment, {
        children: [/*#__PURE__*/_jsx(VmInfoCollection, {
          data: infoData,
          horizontal: true,
          width: "50%",
          ellipsis: true
        }), /*#__PURE__*/_jsx(VmTitle, {
          title: '免费桶配置'
        }), /*#__PURE__*/_jsx(VmTable, {
          columns: columns,
          dataSource: [{
            capacity: '120L',
            barrelage: data.bucketNumberOne || ''
          }, {
            capacity: '240L',
            barrelage: data.bucketNumberTwo || ''
          }],
          height: 220,
          pagination: false
        }), /*#__PURE__*/_jsx(VmInfoCollection, {
          data: [{
            label: '押金',
            value: "".concat(data.deposit || '-', "\u5143"),
            key: 'deposit'
          }].concat(_toConsumableArray(data.garbageType === 'ccfqw' ? [{
            label: '配小桶',
            value: "".concat(data.keg || '-', "\u4E2A"),
            key: 'keg'
          }] : [])),
          horizontal: true,
          width: "50%",
          ellipsis: true
        }), /*#__PURE__*/_jsx(VmTitle, {
          title: '甲方信息'
        }), /*#__PURE__*/_jsx(VmInfoCollection, {
          data: [{
            label: '签字',
            value: data.firstSign,
            key: 'firstSign',
            render: data.firstSign ? function () {
              return /*#__PURE__*/_jsx(Image, {
                src: "/vortex/rest/cloud/np/file/downloadFileThumbnail?outputQuality=0.5&scale=0.2&id=".concat(data === null || data === void 0 ? void 0 : data.firstSign, "&token=").concat(token),
                preview: {
                  destroyOnClose: true,
                  src: "/cloudFile/common/downloadFile?id=".concat(data === null || data === void 0 ? void 0 : data.firstSign, "&token=").concat(token),
                  maskClassName: 'maskClass'
                },
                alt: "\u7B7E\u5B57",
                style: {
                  width: 100,
                  height: 100
                }
              });
            } : undefined
          }, {
            label: '签章',
            value: data.firstSignature,
            key: 'firstSignature',
            componentType: 'image'
          }, {
            label: '法定代表人',
            value: data.firstRepresentative,
            key: 'firstRepresentative'
          }, {
            label: '委托代理人',
            value: data.firstProxy,
            key: 'firstProxy'
          }, {
            label: '通讯地址',
            value: data.firstMailingAddress,
            key: 'firstMailingAddress',
            isAddress: true
          }, {
            label: '联系电话',
            value: data.firstPhone,
            key: 'firstPhone',
            isAddress: true
          }],
          horizontal: true,
          width: "50%",
          ellipsis: true
        }), /*#__PURE__*/_jsx(VmTitle, {
          title: '乙方信息'
        }), /*#__PURE__*/_jsx(VmInfoCollection, {
          data: [{
            label: '签字',
            value: data.secondSign,
            key: 'secondSign',
            render: data.secondSign ? function () {
              return /*#__PURE__*/_jsx(Image, {
                src: "/vortex/rest/cloud/np/file/downloadFileThumbnail?outputQuality=0.5&scale=0.2&id=".concat(data === null || data === void 0 ? void 0 : data.secondSign, "&token=").concat(token),
                preview: {
                  destroyOnClose: true,
                  src: "/cloudFile/common/downloadFile?id=".concat(data === null || data === void 0 ? void 0 : data.secondSign, "&token=").concat(token),
                  maskClassName: 'maskClass'
                },
                alt: "\u7B7E\u5B57",
                style: {
                  width: 100,
                  height: 100
                }
              });
            } : undefined
          }, {
            label: '签章',
            value: data.collectSignature,
            key: 'collectSignature',
            componentType: 'image'
          }, {
            label: '法定代表人',
            value: data.secondRepresentative,
            key: 'secondRepresentative'
          }, {
            label: '委托代理人',
            value: data.secondProxy,
            key: 'secondProxy'
          }, {
            label: '通讯地址',
            value: data.secondMailingAddress,
            key: 'secondMailingAddress',
            isAddress: true
          }, {
            label: '联系电话',
            value: data.secondPhone,
            key: 'secondPhone',
            isAddress: true
          }],
          horizontal: true,
          width: "50%",
          ellipsis: true
        }), /*#__PURE__*/_jsx(VmTitle, {
          title: '时效信息'
        }), /*#__PURE__*/_jsx(VmInfoCollection, {
          data: [{
            label: '生效日期',
            value: data.effectiveTime,
            key: 'effectiveTime'
          }, {
            label: '终止日期',
            value: data.terminationTime,
            key: 'terminationTime'
          }, {
            label: '签约日期',
            value: data.signTime,
            key: 'signTime'
          }, {
            label: '纸质合同附件',
            value: data.paperContractAttachments,
            key: 'paperContractAttachments',
            componentType: 'ATTACHS'
          }],
          horizontal: true,
          width: "50%",
          ellipsis: true
        })]
      })
    })
  });
};
var ContactDetail = function ContactDetail(_ref2) {
  var onCancel = _ref2.onCancel,
    id = _ref2.id;
  var _useContext = useContext(RestaurantContext),
    theme = _useContext.theme;
  return /*#__PURE__*/_jsx(VtxBaseModal, {
    title: '合同管理 > 查看',
    tabs: [{
      key: 'info'
    }],
    contents: {
      info: /*#__PURE__*/_jsx(Content, {
        id: id
      })
    },
    visible: true,
    onCancel: onCancel,
    theme: theme
  });
};
export default ContactDetail;