"use strict";

function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = Dispose;
var _react = _interopRequireDefault(require("react"));
var _vmSubTabs = _interopRequireWildcard(require("../../../vm-sub-tabs"));
var _useSettings2 = _interopRequireDefault(require("../../../vm-hooks/useSettings"));
var _ahooks = require("ahooks");
require("./index.less");
var _components = require("@vtx/components");
var _vmFilter = require("../../../vm-filter");
var _antd = require("antd");
var _api = require("../../api");
var _vmTable = _interopRequireDefault(require("../../../vm-table"));
var _vmIframeModal = _interopRequireDefault(require("../../../vm-iframe-modal"));
var _FlowMap = _interopRequireDefault(require("./FlowMap"));
var _chart = _interopRequireDefault(require("../../../vm-appraisal-info/imgs/chart.png"));
var _chart_active = _interopRequireDefault(require("../../../vm-appraisal-info/imgs/chart_active.png"));
var _chart_active_light = _interopRequireDefault(require("../../../vm-appraisal-info/imgs/chart_active_light.png"));
var _list = _interopRequireDefault(require("../../../vm-appraisal-info/imgs/list.png"));
var _list_active = _interopRequireDefault(require("../../../vm-appraisal-info/imgs/list_active.png"));
var _list_active_light = _interopRequireDefault(require("../../../vm-appraisal-info/imgs/list_active_light.png"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
function Dispose(_ref) {
  var id = _ref.id,
    info = _ref.info;
  var _a, _b, _c;
  var _Form$useForm = _antd.Form.useForm(),
    _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
    form = _Form$useForm2[0];
  var _useSettings = (0, _useSettings2["default"])(),
    isDark = _useSettings.isDark,
    theme = _useSettings.theme;
  var isDeepTheme = isDark || theme === 'blue';
  var _useSetState = (0, _ahooks.useSetState)({
      tabKey: '1',
      flowData: []
    }),
    _useSetState2 = _slicedToArray(_useSetState, 2),
    state = _useSetState2[0],
    setState = _useSetState2[1];
  var tabKey = state.tabKey,
    flowData = state.flowData;
  var _useSetState3 = (0, _ahooks.useSetState)({
      src: '',
      visible: false,
      title: ''
    }),
    _useSetState4 = _slicedToArray(_useSetState3, 2),
    iframeModalInfo = _useSetState4[0],
    setIframeModalInfo = _useSetState4[1];
  var effectiveStatusList = (0, _api.fetchJzljEnum)('EffectiveStatusEnum');
  var garbageTypeList = (0, _api.getByParamTypeCode)('param_jzlj_disposal_garbage_type');
  var _BaseService$useCzzxx = _api.BaseService.useCzzxx(id),
    czzxxData = _BaseService$useCzzxx.czzxxData;
  var columns = [['运输单位', 'transportUnitName', {
    width: 120,
    render: function render(text) {
      return text ? /*#__PURE__*/_react["default"].createElement(_components.VtxEllipsisText, {
        text: text
      }) : '-';
    }
  }], ['运输起点', 'startingPointName', {
    width: 120,
    render: function render(text) {
      return text ? /*#__PURE__*/_react["default"].createElement(_components.VtxEllipsisText, {
        text: text
      }) : '-';
    }
  }], ['运输垃圾类型', 'garbageTypeName', {
    width: 120
  }], ['运输量(吨)', 'transportWeight', {
    width: 120,
    align: 'right'
  }], ['申报有效期', 'effectiveDate', {
    width: 200
  }], ['生效状态', 'effectiveStatusName', {
    width: 120
  }], ['运输车辆(辆)', 'effectiveCarCount', {
    width: 120,
    align: 'right'
  }], ['操作', 'action', {
    width: 60,
    render: function render(_, record) {
      return /*#__PURE__*/_react["default"].createElement("a", {
        onClick: function onClick() {
          setIframeModalInfo({
            visible: true,
            title: '处置证信息',
            src: "/jzlj/#/disposalApprovalFill?id=".concat(record.id)
          });
        }
      }, "\u67E5\u770B");
    }
  }]].map(function (item) {
    return Object.assign({
      title: item[0],
      dataIndex: item[1],
      key: item[1]
    }, item[2]);
  });
  var getTableData = function getTableData(_ref2, formData) {
    var current = _ref2.current,
      pageSize = _ref2.pageSize;
    _api.DisposeService.list(Object.assign(Object.assign({}, formData), {
      startingPointId: id
    })).then(function (res) {
      setState({
        flowData: (res === null || res === void 0 ? void 0 : res.data) || []
      });
    });
    return _api.DisposeService.page(Object.assign(Object.assign({}, formData), {
      startingPointId: id,
      page: current - 1,
      size: pageSize
    })).then(function (res) {
      var _a, _b;
      return {
        total: ((_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.total) || 0,
        list: ((_b = res === null || res === void 0 ? void 0 : res.data) === null || _b === void 0 ? void 0 : _b.rows) || []
      };
    });
  };
  var _useAntdTable = (0, _ahooks.useAntdTable)(getTableData, {
      defaultPageSize: 10,
      form: form
    }),
    tableProps = _useAntdTable.tableProps,
    search = _useAntdTable.search;
  var submit = search.submit,
    reset = search.reset;
  var myTableProps = Object.assign(Object.assign({}, tableProps), {
    rowKey: 'id',
    columns: columns,
    height: 350
  });
  var searchList = [{
    title: '运输单位',
    weight: 1,
    dom: (/*#__PURE__*/_react["default"].createElement(_antd.Form.Item, {
      name: "transportUnitName"
    }, /*#__PURE__*/_react["default"].createElement(_antd.Input, {
      placeholder: "\u8BF7\u8F93\u5165"
    })))
  }, {
    title: '运输起点',
    weight: 1,
    dom: (/*#__PURE__*/_react["default"].createElement(_antd.Form.Item, {
      name: "startingPointName"
    }, /*#__PURE__*/_react["default"].createElement(_antd.Input, {
      placeholder: "\u8BF7\u8F93\u5165"
    })))
  }, {
    title: '生效状态',
    weight: 1,
    dom: (/*#__PURE__*/_react["default"].createElement(_antd.Form.Item, {
      name: "effectiveStatusCode"
    }, /*#__PURE__*/_react["default"].createElement(_vmFilter.VMSelect, {
      style: {
        width: '100%'
      },
      placeholder: "\u8BF7\u9009\u62E9"
    }, effectiveStatusList.map(function (item) {
      return /*#__PURE__*/_react["default"].createElement(_antd.Select.Option, {
        key: item.value,
        value: item.value
      }, item.text);
    }))))
  }, {
    title: '运输垃圾类型',
    weight: 1,
    dom: (/*#__PURE__*/_react["default"].createElement(_antd.Form.Item, {
      name: "garbageTypeCode"
    }, /*#__PURE__*/_react["default"].createElement(_vmFilter.VMSelect, {
      style: {
        width: '100%'
      },
      placeholder: "\u8BF7\u9009\u62E9"
    }, garbageTypeList.map(function (item) {
      return /*#__PURE__*/_react["default"].createElement(_antd.Select.Option, {
        key: item.parmCode,
        value: item.parmCode
      }, item.parmName);
    }))))
  }];
  var listTotal = [{
    name: '处置证数量',
    num: (_a = czzxxData === null || czzxxData === void 0 ? void 0 : czzxxData.totalCzzCount) !== null && _a !== void 0 ? _a : 0,
    unit: '单'
  }, {
    name: '总已运量',
    num: (_b = czzxxData === null || czzxxData === void 0 ? void 0 : czzxxData.yysWeight) !== null && _b !== void 0 ? _b : 0,
    unit: '吨'
  }, {
    name: '剩余量',
    num: (_c = czzxxData === null || czzxxData === void 0 ? void 0 : czzxxData.syWeight) !== null && _c !== void 0 ? _c : 0,
    unit: '吨'
  }];
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "jzlj-xnc-dispose"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "jzlj-card jzlj-xnc-dispose-myTabs"
  }, /*#__PURE__*/_react["default"].createElement(_vmSubTabs["default"], {
    onChange: function onChange(key) {
      setState({
        tabKey: key
      });
    },
    activeKey: tabKey
  }, [{
    name: (/*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("img", {
      src: tabKey === '1' ? isDeepTheme ? _chart_active["default"] : _chart_active_light["default"] : _chart["default"]
    }), "\u56FE\u8868")),
    key: '1'
  }, {
    name: (/*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("img", {
      src: tabKey === '2' ? isDeepTheme ? _list_active["default"] : _list_active_light["default"] : _list["default"]
    }), "\u5217\u8868")),
    key: '2'
  }].map(function (ele) {
    return /*#__PURE__*/_react["default"].createElement(_vmSubTabs.SubTabPane, {
      subKey: ele.key,
      key: ele.key,
      tab: ele.name
    });
  }))), tabKey === '2' && (/*#__PURE__*/_react["default"].createElement("div", {
    className: "flex_center_around czz-total jzlj-card",
    style: {
      padding: 16,
      textAlign: 'center',
      marginTop: 16
    }
  }, listTotal.map(function (item) {
    return /*#__PURE__*/_react["default"].createElement("div", {
      key: item.name
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: "name"
    }, item.name), /*#__PURE__*/_react["default"].createElement("div", {
      className: "num"
    }, /*#__PURE__*/_react["default"].createElement("span", null, item.num), /*#__PURE__*/_react["default"].createElement("span", {
      className: "unit"
    }, item.unit)));
  }))), tabKey === '2' && (/*#__PURE__*/_react["default"].createElement("div", {
    className: "jzlj-card jzlj-xnc-dispose-mySearch"
  }, /*#__PURE__*/_react["default"].createElement(_antd.Form, {
    form: form,
    name: "query-form"
  }, /*#__PURE__*/_react["default"].createElement(_components.VtxSearch, {
    titles: searchList.map(function (item) {
      return item.title;
    }),
    gridWeight: searchList.map(function (item) {
      return item.weight;
    }),
    onConfirm: submit,
    onClear: reset
  }, searchList.map(function (item) {
    return item.dom;
  }))))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "jzlj-card jzlj-xnc-dispose-container"
  }, tabKey === '1' && /*#__PURE__*/_react["default"].createElement(_FlowMap["default"], {
    flowData: flowData,
    info: info
  }), tabKey === '2' && (/*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_vmTable["default"], Object.assign({}, myTableProps)))))), /*#__PURE__*/_react["default"].createElement(_vmIframeModal["default"], Object.assign({}, iframeModalInfo, {
    theme: theme,
    onCancel: function onCancel() {
      return setIframeModalInfo({
        visible: false
      });
    }
  })));
}
//# sourceMappingURL=index.js.map
