"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getLastProcessRecord = exports.getInfo = exports.getFillPage = exports.getCirculationPage = exports.getCheckPage = exports.getBottleOperateType = void 0;

var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));

var _utils = require("@vtx/utils");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }

var url = '/cloud/gas/api/v1/bottleInfo';

var getInfo = /*#__PURE__*/function () {
  var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(id) {
    var res;
    return _regenerator["default"].wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            _context.next = 2;
            return _utils.request.get("".concat(url, "/get"), {
              body: {
                id: id
              }
            });

          case 2:
            res = _context.sent;

            if (!((res === null || res === void 0 ? void 0 : res.result) == 0)) {
              _context.next = 5;
              break;
            }

            return _context.abrupt("return", (res === null || res === void 0 ? void 0 : res.data) || {});

          case 5:
            return _context.abrupt("return", {});

          case 6:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));

  return function getInfo(_x) {
    return _ref.apply(this, arguments);
  };
}();

exports.getInfo = getInfo;

var getBottleOperateType = function getBottleOperateType() {
  return _utils.request.get('/cloud/gas/api/v1/common/enumList', {
    body: {
      className: 'GasUserTypeEnum'
    }
  });
};

exports.getBottleOperateType = getBottleOperateType;

var getFillPage = function getFillPage(id, dataSearch) {
  return /*#__PURE__*/function () {
    var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(_ref2, formData) {
      var current, pageSize, body, list, total, res, _res$data;

      return _regenerator["default"].wrap(function _callee2$(_context2) {
        while (1) {
          switch (_context2.prev = _context2.next) {
            case 0:
              current = _ref2.current, pageSize = _ref2.pageSize;
              body = _objectSpread(_objectSpread({
                operateType: formData.operateType
              }, dataSearch), {}, {
                bottleInfoId: id,
                page: current - 1,
                size: pageSize
              });
              list = [];
              total = 0;
              _context2.next = 6;
              return _utils.request.get("".concat(url, "/bottleFillPageList"), {
                body: body
              });

            case 6:
              res = _context2.sent;

              if ((res === null || res === void 0 ? void 0 : res.result) === 0) {
                if (Array.isArray((_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.rows)) {
                  list = res.data.rows.map(function (item) {
                    return _objectSpread(_objectSpread({}, item), {}, {
                      key: item.id
                    });
                  });
                  total = res.data.total;
                }
              }

              return _context2.abrupt("return", {
                list: list,
                total: total
              });

            case 9:
            case "end":
              return _context2.stop();
          }
        }
      }, _callee2);
    }));

    return function (_x2, _x3) {
      return _ref3.apply(this, arguments);
    };
  }();
};

exports.getFillPage = getFillPage;

var getCirculationPage = function getCirculationPage(id, dataSearch) {
  return /*#__PURE__*/function () {
    var _ref5 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(_ref4, formData) {
      var current, pageSize, body, list, total, res, _res$data2;

      return _regenerator["default"].wrap(function _callee3$(_context3) {
        while (1) {
          switch (_context3.prev = _context3.next) {
            case 0:
              current = _ref4.current, pageSize = _ref4.pageSize;
              body = _objectSpread(_objectSpread({
                operateType: formData.operateType
              }, dataSearch), {}, {
                bottleInfoId: id,
                page: current - 1,
                size: pageSize
              });
              list = [];
              total = 0;
              _context3.next = 6;
              return _utils.request.get("".concat(url, "/bottleCirculationPageList"), {
                body: body
              });

            case 6:
              res = _context3.sent;

              if ((res === null || res === void 0 ? void 0 : res.result) === 0) {
                if (Array.isArray((_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.rows)) {
                  list = res.data.rows.map(function (item) {
                    return _objectSpread(_objectSpread({}, item), {}, {
                      key: item.id
                    });
                  });
                  total = res.data.total;
                }
              }

              return _context3.abrupt("return", {
                list: list,
                total: total
              });

            case 9:
            case "end":
              return _context3.stop();
          }
        }
      }, _callee3);
    }));

    return function (_x4, _x5) {
      return _ref5.apply(this, arguments);
    };
  }();
};

exports.getCirculationPage = getCirculationPage;

var getCheckPage = function getCheckPage(id, dataSearch) {
  return /*#__PURE__*/function () {
    var _ref7 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(_ref6, formData) {
      var current, pageSize, body, list, total, res, _res$data3;

      return _regenerator["default"].wrap(function _callee4$(_context4) {
        while (1) {
          switch (_context4.prev = _context4.next) {
            case 0:
              current = _ref6.current, pageSize = _ref6.pageSize;
              body = _objectSpread(_objectSpread({
                operateType: formData.operateType
              }, dataSearch), {}, {
                bottleInfoId: id,
                page: current - 1,
                size: pageSize
              });
              list = [];
              total = 0;
              _context4.next = 6;
              return _utils.request.get("".concat(url, "/bottleCheckPageList"), {
                body: body
              });

            case 6:
              res = _context4.sent;

              if ((res === null || res === void 0 ? void 0 : res.result) === 0) {
                if (Array.isArray((_res$data3 = res.data) === null || _res$data3 === void 0 ? void 0 : _res$data3.rows)) {
                  list = res.data.rows.map(function (item) {
                    return _objectSpread(_objectSpread({}, item), {}, {
                      key: item.id
                    });
                  });
                  total = res.data.total;
                }
              }

              return _context4.abrupt("return", {
                list: list,
                total: total
              });

            case 9:
            case "end":
              return _context4.stop();
          }
        }
      }, _callee4);
    }));

    return function (_x6, _x7) {
      return _ref7.apply(this, arguments);
    };
  }();
};

exports.getCheckPage = getCheckPage;

var getLastProcessRecord = /*#__PURE__*/function () {
  var _ref8 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5(id) {
    var res, lastProcessList;
    return _regenerator["default"].wrap(function _callee5$(_context5) {
      while (1) {
        switch (_context5.prev = _context5.next) {
          case 0:
            _context5.next = 2;
            return _utils.request.get('/cloud/gas/api/v1/bottleOperateLog/lastProcessRecord', {
              body: {
                bottleInfoId: id
              }
            });

          case 2:
            res = _context5.sent;
            lastProcessList = [];

            if (Array.isArray(res === null || res === void 0 ? void 0 : res.data)) {
              lastProcessList = res.data;
            }

            return _context5.abrupt("return", lastProcessList);

          case 6:
          case "end":
            return _context5.stop();
        }
      }
    }, _callee5);
  }));

  return function getLastProcessRecord(_x8) {
    return _ref8.apply(this, arguments);
  };
}();

exports.getLastProcessRecord = getLastProcessRecord;
//# sourceMappingURL=api.js.map
