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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _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(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 _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; }

function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

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); }); }; }

import omit from 'lodash/omit';
import forEach from 'lodash/forEach';
import map from 'lodash/map';
import pick from 'lodash/pick';
import uuidV1 from 'uuid/v1';
import { axios } from '@choerodon/boot';
import isEmpty from 'lodash/isEmpty';
import JSONbig from 'json-bigint';
import { Base64 } from 'js-base64';
import dockerImg from "../images/docker.svg";
import jarImg from "../images/jar.svg";
var mapping = {
  deployWay: {
    value: 'deployType',
    options: [{
      value: 'env',
      label: '容器部署'
    }] // , {
    //   value: 'host',
    //   label: '主机部署',
    // }],

  },
  hostName: {
    value: 'hostId'
  },
  ip: {
    value: 'hostIp'
  },
  port: {
    value: 'hostPort'
  },
  deployObject: {
    value: 'deployObjectType',
    options: [{
      value: 'image',
      label: 'Docker镜像',
      img: dockerImg
    }, {
      value: 'jar',
      label: 'jar应用',
      img: jarImg
    }]
  },
  projectImageRepo: {
    value: 'repoId',
    textField: 'repoName',
    extraField: 'repoType'
  },
  image: {
    value: 'imageId',
    textField: 'imageName'
  },
  imageVersion: {
    value: 'tag'
  },
  containerName: {
    value: 'containerName'
  },
  nexus: {
    value: 'serverName'
  },
  projectProduct: {
    value: 'repositoryId'
  },
  groupId: {
    value: 'groupId'
  },
  artifactId: {
    value: 'artifactId'
  },
  jarVersion: {
    value: 'version'
  },
  workPath: {
    value: 'workingPath'
  },
  deploySource: {
    value: 'deploySource',
    options: [{
      value: 'repository',
      label: '项目制品库'
    }, {
      value: 'market',
      label: '市场应用'
    }]
  }
};

function getRandomName() {
  var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  var randomString = uuidV1();
  var realPrefix = prefix.split('_')[1] || prefix.split('_')[0];
  return realPrefix ? "".concat(realPrefix.substring(0, 24), "-").concat(randomString.substring(0, 5)) : randomString.substring(0, 30);
}

function formatAnnotation(postData) {
  var oldAnnotation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  var annotations = {};
  forEach(oldAnnotation, function (_ref) {
    var key = _ref.key,
        value = _ref.value;

    if (key && value) {
      annotations[key] = value;
    }
  }); // eslint-disable-next-line no-param-reassign

  postData.annotations = isEmpty(annotations) ? null : annotations;
}

function getRequired(_ref2) {
  var record = _ref2.record;
  return record.get(mapping.deployWay.value) === (mapping.deployWay.options.length > 1 ? mapping.deployWay.options[1].value : '');
}

function getIsMarket(_ref3) {
  var record = _ref3.record;
  return record.get(mapping.deploySource.value) === (mapping.deploySource.options.length > 1 ? mapping.deploySource.options[1].value : '');
}

export { mapping };
export default (function (_ref4) {
  var intlPrefix = _ref4.intlPrefix,
      formatMessage = _ref4.formatMessage,
      projectId = _ref4.projectId,
      envOptionsDs = _ref4.envOptionsDs,
      valueIdOptionsDs = _ref4.valueIdOptionsDs,
      versionOptionsDs = _ref4.versionOptionsDs,
      deployStore = _ref4.deployStore,
      networkDs = _ref4.networkDs,
      domainDs = _ref4.domainDs,
      organizationId = _ref4.organizationId,
      deployUseStore = _ref4.deployUseStore,
      hasHostDeploy = _ref4.hasHostDeploy,
      marketAndVersionOptionsDs = _ref4.marketAndVersionOptionsDs,
      marketServiceOptionsDs = _ref4.marketServiceOptionsDs,
      hasDevops = _ref4.hasDevops,
      random = _ref4.random;

  // 如果有该参数 部署方式增加主机部署
  if (hasHostDeploy) {
    mapping.deployWay.options = [{
      value: 'env',
      label: '容器部署'
    }, {
      value: 'host',
      label: '主机部署'
    }];
  } else {
    mapping.deployWay.options = [{
      value: 'env',
      label: '容器部署'
    }];
  }

  function handleCreate(_ref5) {
    var dataSet = _ref5.dataSet,
        record = _ref5.record;
    deployStore.loadAppService(projectId, record.get('appServiceSource'));
  }

  function handleUpdate(_ref6) {
    var dataSet = _ref6.dataSet,
        record = _ref6.record,
        name = _ref6.name,
        value = _ref6.value;
    var networkRecord = record.getCascadeRecords('devopsServiceReqVO')[0];
    var domainRecord = record.getCascadeRecords('devopsIngressVO')[0];

    switch (name) {
      case 'appServiceSource':
        deployStore.setAppService([]);
        value !== 'market_service' && deployStore.loadAppService(projectId, value);
        record.get('appServiceId') && record.set('appServiceId', null);
        break;

      case 'environmentId':
        record.getField('instanceName').checkValidity();

        if (record.get('appServiceSource') !== 'market_service') {
          loadValueList(record);
        }

        networkRecord.getField('name').checkValidity();
        domainRecord.getField('name').checkValidity();
        forEach(domainRecord.getCascadeRecords('pathList'), function (pathRecord) {
          pathRecord.getField('path').checkValidity();
        });
        domainRecord.get('certId') && domainRecord.set('certId', null);
        domainRecord.getField('certId').fetchLookup();
        break;

      case 'appServiceId':
        record.get('appServiceVersionId') && record.set('appServiceVersionId', null);
        record.getField('appServiceVersionId').reset();

        if (value) {
          record.getField('appServiceVersionId').set('lookupAxiosConfig', {
            url: "/devops/v1/projects/".concat(projectId, "/app_service_versions/page_by_options?app_service_id=").concat(value.split('**')[0], "&deploy_only=true&do_page=true&page=1&size=40"),
            method: 'post'
          });
          record.set('instanceName', getRandomName(value.split('**')[1]));
        }

        loadValueList(record);
        break;

      case 'appServiceVersionId':
        if (!record.get('valueId')) {
          value && deployStore.loadDeployValue(projectId, value);
          !value && deployStore.setConfigValue('');
        }

        break;

      case 'valueId':
        if (value) {
          deployStore.loadConfigValue(projectId, value);
        } else if (record.get('appServiceVersionId')) {
          deployStore.loadDeployValue(projectId, record.get('appServiceVersionId'));
        } else {
          deployStore.setConfigValue('');
        }

        break;

      case 'marketAppAndVersion':
        record.get('marketService') && record.set('marketService', null);

        if (value && value.value) {
          var _value$value;

          marketServiceOptionsDs.setQueryParameter('marketVersionId', (_value$value = value.value) === null || _value$value === void 0 ? void 0 : _value$value.id);
          marketServiceOptionsDs.query();
        }

        break;

      case 'marketService':
        if (value && !isEmpty(value.marketServiceDeployObjectVO)) {
          var _value$marketServiceD = value.marketServiceDeployObjectVO,
              deployObjectId = _value$marketServiceD.id,
              devopsAppServiceCode = _value$marketServiceD.devopsAppServiceCode;
          record.set('instanceName', getRandomName(devopsAppServiceCode));
          record.get(mapping.deployWay.value) === mapping.deployWay.options[0].value && deployStore.loadMarketDeployValue(projectId, deployObjectId);
        } else {
          record.get('instanceName') && record.set('instanceName', null);
        }

        break;

      case mapping.deployWay.value:
        if (record.get(mapping.deployObject.value) !== mapping.deployObject.options[0].value) {
          loadMarketService(record, value === mapping.deployWay.options[0].value ? 'image' : 'jar');
        }

        break;

      case mapping.deployObject.value:
        loadMarketService(record, value === mapping.deployObject.options[0].value ? 'image' : 'jar');
        break;

      default:
        break;
    }
  }

  function loadMarketService(record, type) {
    marketServiceOptionsDs.setQueryParameter('type', type);

    if (record.get('marketAppAndVersion')) {
      record.get('marketService') && record.set('marketService', null);
      marketServiceOptionsDs.query();
    }
  }

  function loadValueList(record) {
    if (record.get('environmentId') && record.get('appServiceId')) {
      // eslint-disable-next-line no-param-reassign
      valueIdOptionsDs.transport.read.url = "/devops/v1/projects/".concat(projectId, "/deploy_value/list_by_env_and_app?env_id=").concat(record.get('environmentId'), "&app_service_id=").concat(record.get('appServiceId').split('**')[0]);
      valueIdOptionsDs.query();
    } else {
      valueIdOptionsDs.removeAll();
    }

    record.set('valueId', null);
  }

  function checkName(_x, _x2, _x3) {
    return _checkName.apply(this, arguments);
  }

  function _checkName() {
    _checkName = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(value, name, record) {
      var pa, res;
      return regeneratorRuntime.wrap(function _callee$(_context) {
        while (1) {
          switch (_context.prev = _context.next) {
            case 0:
              if (!(record.get(mapping.deployWay.value) === mapping.deployWay.options[0].value)) {
                _context.next = 20;
                break;
              }

              pa = /^[a-z]([-a-z0-9]*[a-z0-9])?$/;

              if (!(value && pa.test(value))) {
                _context.next = 19;
                break;
              }

              if (record.get('environmentId')) {
                _context.next = 5;
                break;
              }

              return _context.abrupt("return");

            case 5:
              _context.prev = 5;
              _context.next = 8;
              return axios.get("/devops/v1/projects/".concat(projectId, "/app_service_instances/check_name?instance_name=").concat(value, "&env_id=").concat(record.get('environmentId')));

            case 8:
              res = _context.sent;

              if (!(res && res.failed || !res)) {
                _context.next = 11;
                break;
              }

              return _context.abrupt("return", formatMessage({
                id: 'checkNameExist'
              }));

            case 11:
              return _context.abrupt("return", true);

            case 14:
              _context.prev = 14;
              _context.t0 = _context["catch"](5);
              return _context.abrupt("return", formatMessage({
                id: 'checkNameFailed'
              }));

            case 17:
              _context.next = 20;
              break;

            case 19:
              return _context.abrupt("return", formatMessage({
                id: 'checkNameReg'
              }));

            case 20:
              return _context.abrupt("return", true);

            case 21:
            case "end":
              return _context.stop();
          }
        }
      }, _callee, null, [[5, 14]]);
    }));
    return _checkName.apply(this, arguments);
  }

  return {
    autoCreate: true,
    autoQuery: false,
    paging: false,
    children: {
      devopsServiceReqVO: networkDs,
      devopsIngressVO: domainDs
    },
    transport: {
      create: function create(_ref7) {
        var _res2, _res$hostConnectionVO;

        var _ref7$data = _slicedToArray(_ref7.data, 1),
            data = _ref7$data[0],
            dataSet = _ref7.dataSet;

        // 如果是环境部署
        if (data[mapping.deployWay.value] === mapping.deployWay.options[0].value) {
          var _res = pick(data, ['values', 'devopsServiceReqVO', 'devopsIngressVO', 'environmentId', 'instanceName', 'type', 'isNotChange']);

          var isMarket = data.appServiceSource === 'market_service';

          var _ref8 = data.marketService || {},
              marketServiceDeployObjectVO = _ref8.marketServiceDeployObjectVO,
              marketAppServiceId = _ref8.id;

          var appServiceId = isMarket ? marketAppServiceId : data.appServiceId.split('**')[0];

          if (isMarket) {
            _res.marketAppServiceId = marketAppServiceId;
            _res.marketDeployObjectId = marketServiceDeployObjectVO && marketServiceDeployObjectVO.id;
          } else {
            _res.appServiceId = appServiceId;
            _res.appServiceVersionId = data.appServiceVersionId;
            _res.valueId = data.valueId;
          }

          if (data.devopsServiceReqVO[0] && data.devopsServiceReqVO[0].name) {
            var newPorts = map(data.devopsServiceReqVO[0].ports, function (_ref9) {
              var port = _ref9.port,
                  targetPort = _ref9.targetPort,
                  nodePort = _ref9.nodePort,
                  protocol = _ref9.protocol;
              return {
                port: Number(port),
                targetPort: Number(targetPort),
                nodePort: nodePort ? Number(nodePort) : null,
                protocol: data.devopsServiceReqVO[0].type === 'NodePort' ? protocol : null
              };
            }); // eslint-disable-next-line no-param-reassign

            data.devopsServiceReqVO[0].ports = newPorts; // eslint-disable-next-line prefer-destructuring

            _res.devopsServiceReqVO = data.devopsServiceReqVO[0];
            var externalIp = _res.devopsServiceReqVO.externalIp;
            _res.devopsServiceReqVO.externalIp = externalIp && externalIp.length ? externalIp.join(',') : null;
            _res.devopsServiceReqVO.targetInstanceCode = data.instanceName;
            _res.devopsServiceReqVO.envId = data.environmentId;
          } else {
            _res.devopsServiceReqVO = null;
          }

          if (data.devopsIngressVO[0] && data.devopsIngressVO[0].name) {
            // eslint-disable-next-line prefer-destructuring
            _res.devopsIngressVO = data.devopsIngressVO[0];
            _res.devopsIngressVO.envId = data.environmentId;
            _res.devopsIngressVO.appServiceId = appServiceId;
            formatAnnotation(_res.devopsIngressVO, data.devopsIngressVO[0].annotations);
          } else {
            _res.devopsIngressVO = null;
          }

          return {
            url: "/devops/v1/projects/".concat(projectId, "/app_service_instances").concat(isMarket ? '/market/instances' : ''),
            method: 'post',
            data: _res
          };
        } // 如果是主机部署


        var res = (_res2 = {}, _defineProperty(_res2, mapping.deployWay.value, data[mapping.deployWay.value]), _defineProperty(_res2, mapping.deployObject.value, data[mapping.deployObject.value]), _res2);
        res.hostConnectionVO = (_res$hostConnectionVO = {}, _defineProperty(_res$hostConnectionVO, mapping.hostName.value, data[mapping.hostName.value]), _defineProperty(_res$hostConnectionVO, mapping.ip.value, data[mapping.ip.value]), _defineProperty(_res$hostConnectionVO, mapping.port.value, data[mapping.port.value]), _defineProperty(_res$hostConnectionVO, "hostSource", 'existHost'), _res$hostConnectionVO);
        var deploySource = data[mapping.deploySource.value];
        var deployObject = data[mapping.deployObject.value]; // 项目制品库

        if (deploySource === mapping.deploySource.options[0].value) {
          // 如果部署对象是Docker镜像
          if (deployObject === mapping.deployObject.options[0].value) {
            var _res$imageDeploy;

            res.imageDeploy = (_res$imageDeploy = {}, _defineProperty(_res$imageDeploy, mapping.projectImageRepo.value, data[mapping.projectImageRepo.value]), _defineProperty(_res$imageDeploy, mapping.projectImageRepo.textField, dataSet.current.getField(mapping.projectImageRepo.value).lookup.find(function (l) {
              return l.repoId === data[mapping.projectImageRepo.value];
            }).repoName), _defineProperty(_res$imageDeploy, mapping.projectImageRepo.extraField, dataSet.current.getField(mapping.projectImageRepo.value).lookup.find(function (l) {
              return l.repoId === data[mapping.projectImageRepo.value];
            }).repoType), _defineProperty(_res$imageDeploy, mapping.image.value, data[mapping.image.value]), _defineProperty(_res$imageDeploy, mapping.image.textField, dataSet.current.getField(mapping.image.value).lookup.find(function (l) {
              return l.imageId === data[mapping.image.value];
            }).imageName), _defineProperty(_res$imageDeploy, mapping.imageVersion.value, data[mapping.imageVersion.value]), _defineProperty(_res$imageDeploy, mapping.containerName.value, data[mapping.containerName.value]), _defineProperty(_res$imageDeploy, "value", Base64.encode(deployUseStore.getImageYaml)), _res$imageDeploy);
          } else {
            var _res$jarDeploy;

            //  如果部署对象是jar应用
            res.jarDeploy = (_res$jarDeploy = {}, _defineProperty(_res$jarDeploy, mapping.nexus.value, data[mapping.nexus.value]), _defineProperty(_res$jarDeploy, mapping.projectProduct.value, data[mapping.projectProduct.value]), _defineProperty(_res$jarDeploy, mapping.groupId.value, data[mapping.groupId.value]), _defineProperty(_res$jarDeploy, mapping.artifactId.value, data[mapping.artifactId.value]), _defineProperty(_res$jarDeploy, mapping.jarVersion.value, data[mapping.jarVersion.value]), _defineProperty(_res$jarDeploy, mapping.workPath.value, data[mapping.workPath.value]), _defineProperty(_res$jarDeploy, "value", Base64.encode(deployUseStore.getJarYaml)), _res$jarDeploy);
          }
        } else {
          // 市场应用
          var _ref10 = data.marketService || {},
              _marketServiceDeployObjectVO = _ref10.marketServiceDeployObjectVO;

          var deployObjectId = _marketServiceDeployObjectVO && _marketServiceDeployObjectVO.id;
          res.appSource = 'market';

          if (deployObject === mapping.deployObject.options[0].value) {
            var _res$imageDeploy2;

            res.imageDeploy = (_res$imageDeploy2 = {
              deployObjectId: deployObjectId
            }, _defineProperty(_res$imageDeploy2, mapping.containerName.value, data[mapping.containerName.value]), _defineProperty(_res$imageDeploy2, "value", Base64.encode(deployUseStore.getImageYaml)), _res$imageDeploy2);
          } else {
            var _res$jarDeploy2;

            res.jarDeploy = (_res$jarDeploy2 = {
              deployObjectId: deployObjectId
            }, _defineProperty(_res$jarDeploy2, mapping.workPath.value, data[mapping.workPath.value]), _defineProperty(_res$jarDeploy2, "value", Base64.encode(deployUseStore.getJarYaml)), _res$jarDeploy2);
          }
        }

        return {
          url: "/devops/v1/projects/".concat(projectId, "/deploy/host"),
          method: 'post',
          data: res
        };
      }
    },
    fields: [{
      name: mapping.deployWay.value,
      type: 'string',
      label: '部署方式',
      defaultValue: mapping.deployWay.options[0].value
    }, {
      name: mapping.hostName.value,
      type: 'string',
      label: '主机名称',
      textField: 'name',
      valueField: 'id',
      lookupAxiosConfig: function lookupAxiosConfig() {
        return {
          method: 'post',
          url: "/devops/v1/projects/".concat(projectId, "/hosts/page_by_options?random=").concat(random),
          data: {
            searchParam: {
              type: 'deploy'
            },
            params: []
          },
          transformResponse: function transformResponse(res) {
            var newRes = res;

            try {
              newRes = JSONbig.parse(newRes);
              return newRes;
            } catch (e) {
              return newRes;
            }
          }
        };
      }
    }, {
      name: mapping.ip.value,
      type: 'string',
      label: 'IP',
      disabled: true,
      dynamicProps: {
        required: getRequired
      }
    }, {
      name: mapping.port.value,
      type: 'string',
      label: '端口',
      disabled: true,
      dynamicProps: {
        required: getRequired
      }
    }, {
      name: mapping.deployObject.value,
      type: 'string',
      label: '部署对象',
      defaultValue: mapping.deployObject.options[0].value,
      dynamicProps: {
        required: getRequired
      }
    }, {
      name: mapping.projectImageRepo.value,
      type: 'string',
      label: '项目镜像仓库',
      textField: 'repoName',
      valueField: 'repoId',
      dynamicProps: {
        required: function required(_ref11) {
          var record = _ref11.record;
          return getRequired({
            record: record
          }) && !getIsMarket({
            record: record
          }) && record.get(mapping.deployObject.value) === mapping.deployObject.options[0].value;
        }
      },
      lookupAxiosConfig: function lookupAxiosConfig() {
        return {
          method: 'get',
          url: "/rdupm/v1/harbor-choerodon-repos/listImageRepo?projectId=".concat(projectId),
          transformResponse: function transformResponse(data) {
            var newData = data;

            try {
              newData = JSON.parse(newData);
              return newData;
            } catch (e) {
              return newData;
            }
          }
        };
      }
    }, {
      name: mapping.image.value,
      type: 'string',
      label: '镜像',
      textField: 'imageName',
      valueField: 'imageId',
      dynamicProps: {
        disabled: function disabled(_ref12) {
          var record = _ref12.record;
          return !record.get(mapping.projectImageRepo.value);
        },
        required: function required(_ref13) {
          var record = _ref13.record;
          return getRequired({
            record: record
          }) && !getIsMarket({
            record: record
          }) && record.get(mapping.deployObject.value) === mapping.deployObject.options[0].value;
        },
        lookupAxiosConfig: function lookupAxiosConfig(_ref14) {
          var record = _ref14.record;
          return {
            method: 'get',
            url: record.get(mapping.projectImageRepo.value) && "rdupm/v1/harbor-choerodon-repos/listHarborImage?repoId=".concat(record.get(mapping.projectImageRepo.value), "&repoType=").concat(function () {
              var _lookup$find;

              var _record$getField = record.getField(mapping.projectImageRepo.value),
                  lookup = _record$getField.lookup;

              return lookup === null || lookup === void 0 ? void 0 : (_lookup$find = lookup.find(function (l) {
                return String(l.repoId) === String(record.get(mapping.projectImageRepo.value));
              })) === null || _lookup$find === void 0 ? void 0 : _lookup$find.repoType;
            }()),
            transformResponse: function transformResponse(data) {
              var newData = data;

              try {
                newData = JSON.parse(newData);
                return newData;
              } catch (e) {
                return newData;
              }
            }
          };
        }
      }
    }, {
      name: mapping.imageVersion.value,
      type: 'string',
      label: '镜像版本',
      textField: 'tagName',
      valueField: 'tagName',
      dynamicProps: {
        required: function required(_ref15) {
          var record = _ref15.record;
          return getRequired({
            record: record
          }) && !getIsMarket({
            record: record
          }) && record.get(mapping.deployObject.value) === mapping.deployObject.options[0].value;
        },
        disabled: function disabled(_ref16) {
          var record = _ref16.record;
          return !record.get(mapping.image.value);
        },
        lookupAxiosConfig: function lookupAxiosConfig(_ref17) {
          var record = _ref17.record;
          return {
            method: 'get',
            url: record.get(mapping.projectImageRepo.value) && record.get(mapping.image.value) && "rdupm/v1/harbor-image-tag/list/".concat(projectId, "?page=0&size=10&repoName=").concat(function () {
              var projectImageRepo = record.get(mapping.projectImageRepo.value);
              var projectImageRepoLookup = record.getField(mapping.projectImageRepo.value).lookup;
              var image = record.get(mapping.image.value);
              var imageLookup = record.getField(mapping.image.value).lookup;

              var _projectImageRepoLook = projectImageRepoLookup.find(function (l) {
                return l.repoId === projectImageRepo;
              }),
                  repoName = _projectImageRepoLook.repoName;

              var _imageLookup$find = imageLookup.find(function (l) {
                return l.imageId === image;
              }),
                  imageName = _imageLookup$find.imageName;

              return "".concat(repoName, "/").concat(imageName);
            }()),
            transformResponse: function transformResponse(data) {
              var newData = data;

              try {
                newData = JSON.parse(newData);
                return newData;
              } catch (e) {
                return newData;
              }
            }
          };
        }
      }
    }, {
      name: mapping.containerName.value,
      type: 'string',
      label: '容器名称',
      required: true,
      maxLength: 30,
      dynamicProps: {
        required: function required(_ref18) {
          var record = _ref18.record;
          return getRequired({
            record: record
          }) && record.get(mapping.deployObject.value) === mapping.deployObject.options[0].value;
        }
      }
    }, {
      name: mapping.nexus.value,
      type: 'string',
      label: 'Nexus服务',
      textField: 'serverName',
      valueField: 'configId',
      dynamicProps: {
        required: function required(_ref19) {
          var record = _ref19.record;
          return getRequired({
            record: record
          }) && !getIsMarket({
            record: record
          }) && record.get(mapping.deployObject.value) === (mapping.deployObject.options.length > 1 ? mapping.deployObject.options[1].value : '');
        }
      },
      lookupAxiosConfig: function lookupAxiosConfig() {
        return {
          method: 'get',
          url: "/devops/v1/nexus/choerodon/".concat(organizationId, "/project/").concat(projectId, "/nexus/server/list")
        };
      }
    }, {
      name: mapping.projectProduct.value,
      type: 'string',
      label: '项目制品库',
      textField: 'neRepositoryName',
      valueField: 'repositoryId',
      dynamicProps: {
        required: function required(_ref20) {
          var record = _ref20.record;
          return getRequired({
            record: record
          }) && !getIsMarket({
            record: record
          }) && record.get(mapping.deployObject.value) === (mapping.deployObject.options.length > 1 ? mapping.deployObject.options[1].value : '');
        },
        disabled: function disabled(_ref21) {
          var record = _ref21.record;
          return !record.get(mapping.nexus.value);
        },
        lookupAxiosConfig: function lookupAxiosConfig(_ref22) {
          var record = _ref22.record;
          return {
            method: 'get',
            url: record.get(mapping.nexus.value) && "rdupm/v1/nexus-repositorys/choerodon/".concat(organizationId, "/project/").concat(projectId, "/repo/maven/list?configId=").concat(record.get(mapping.nexus.value))
          };
        }
      }
    }, {
      name: mapping.groupId.value,
      type: 'string',
      label: 'groupId',
      textField: 'name',
      valueField: 'value',
      dynamicProps: {
        required: function required(_ref23) {
          var record = _ref23.record;
          return getRequired({
            record: record
          }) && !getIsMarket({
            record: record
          }) && record.get(mapping.deployObject.value) === (mapping.deployObject.options.length > 1 ? mapping.deployObject.options[1].value : '');
        },
        disabled: function disabled(_ref24) {
          var record = _ref24.record;
          return !record.get(mapping.projectProduct.value);
        },
        lookupAxiosConfig: function lookupAxiosConfig(_ref25) {
          var record = _ref25.record;
          return {
            method: 'get',
            url: record.get(mapping.projectProduct.value) && "/rdupm/v1/nexus-repositorys/choerodon/".concat(organizationId, "/project/").concat(projectId, "/repo/maven/groupId?repositoryId=").concat(record.get(mapping.projectProduct.value)),
            transformResponse: function transformResponse(data) {
              try {
                var array = JSON.parse(data);
                return array.map(function (i) {
                  return {
                    value: i,
                    name: i
                  };
                });
              } catch (e) {
                return data;
              }
            }
          };
        }
      }
    }, {
      name: mapping.artifactId.value,
      type: 'string',
      label: 'artifactId',
      textField: 'name',
      valueField: 'value',
      dynamicProps: {
        required: function required(_ref26) {
          var record = _ref26.record;
          return getRequired({
            record: record
          }) && !getIsMarket({
            record: record
          }) && record.get(mapping.deployObject.value) === (mapping.deployObject.options.length > 1 ? mapping.deployObject.options[1].value : '');
        },
        disabled: function disabled(_ref27) {
          var record = _ref27.record;
          return !record.get(mapping.groupId.value);
        },
        lookupAxiosConfig: function lookupAxiosConfig(_ref28) {
          var record = _ref28.record;
          return {
            method: 'get',
            url: record.get(mapping.projectProduct.value) && "/rdupm/v1/nexus-repositorys/choerodon/".concat(organizationId, "/project/").concat(projectId, "/repo/maven/artifactId?repositoryId=").concat(record.get(mapping.projectProduct.value)),
            transformResponse: function transformResponse(data) {
              try {
                var array = JSON.parse(data);
                return array.map(function (i) {
                  return {
                    value: i,
                    name: i
                  };
                });
              } catch (e) {
                return data;
              }
            }
          };
        }
      }
    }, {
      name: mapping.jarVersion.value,
      type: 'string',
      label: 'jar包版本',
      textField: 'version',
      valueField: 'version',
      dynamicProps: {
        required: function required(_ref29) {
          var record = _ref29.record;
          return getRequired({
            record: record
          }) && !getIsMarket({
            record: record
          }) && record.get(mapping.deployObject.value) === (mapping.deployObject.options.length > 1 ? mapping.deployObject.options[1].value : '');
        },
        disabled: function disabled(_ref30) {
          var record = _ref30.record;
          return !record.get(mapping.groupId.value) || !record.get(mapping.artifactId.value);
        },
        lookupAxiosConfig: function lookupAxiosConfig(_ref31) {
          var record = _ref31.record;
          return {
            method: 'get',
            url: record.get(mapping.projectProduct.value) && record.get(mapping.groupId.value) && record.get(mapping.artifactId.value) && "/rdupm/v1/nexus-components/".concat(organizationId, "/project/").concat(projectId, "?page=0&size=10&repositoryId=").concat(record.get(mapping.projectProduct.value), "&repositoryName=").concat(function () {
              var repositoryId = record.get(mapping.projectProduct.value);

              var _record$getField2 = record.getField(mapping.projectProduct.value),
                  lookup = _record$getField2.lookup;

              return lookup.find(function (l) {
                return l.repositoryId === repositoryId;
              }).neRepositoryName;
            }(), "&groupId=").concat(record.get(mapping.groupId.value), "&artifactId=").concat(record.get(mapping.artifactId.value))
          };
        }
      }
    }, {
      name: mapping.workPath.value,
      type: 'string',
      label: '工作目录',
      defaultValue: './',
      dynamicProps: {
        required: function required(_ref32) {
          var record = _ref32.record;
          return getRequired({
            record: record
          }) && record.get(mapping.deployObject.value) === (mapping.deployObject.options.length > 1 ? mapping.deployObject.options[1].value : '');
        }
      }
    }, {
      name: mapping.deploySource.value,
      type: 'string',
      label: '部署来源',
      defaultValue: 'repository',
      dynamicProps: {
        required: getRequired
      }
    }, {
      name: 'appServiceId',
      type: 'string',
      label: formatMessage({
        id: "".concat(intlPrefix, ".app")
      }),
      dynamicProps: {
        required: function required(_ref33) {
          var record = _ref33.record;
          return record.get(mapping.deployWay.value) === mapping.deployWay.options[0].value && record.get('appServiceSource') !== 'market_service';
        }
      }
    }, {
      name: 'appServiceVersionId',
      type: 'string',
      textField: 'version',
      valueField: 'id',
      label: formatMessage({
        id: "".concat(intlPrefix, ".app.version")
      }),
      dynamicProps: {
        required: function required(_ref34) {
          var record = _ref34.record;
          return record.get(mapping.deployWay.value) === mapping.deployWay.options[0].value && record.get('appServiceSource') !== 'market_service';
        }
      }
    }, {
      name: 'environmentId',
      type: 'string',
      textField: 'name',
      valueField: 'id',
      label: formatMessage({
        id: 'environment'
      }),
      dynamicProps: {
        required: function required(_ref35) {
          var record = _ref35.record;
          return record.get(mapping.deployWay.value) === mapping.deployWay.options[0].value;
        }
      },
      options: envOptionsDs
    }, {
      name: 'instanceName',
      type: 'string',
      label: formatMessage({
        id: "".concat(intlPrefix, ".instance.name")
      }),
      dynamicProps: {
        required: function required(_ref36) {
          var record = _ref36.record;
          return record.get(mapping.deployWay.value) === mapping.deployWay.options[0].value;
        },
        maxLength: function maxLength(_ref37) {
          var record = _ref37.record;
          return record.get(mapping.deployWay.value) === mapping.deployWay.options[0].value ? 53 : null;
        }
      },
      validator: checkName
    }, {
      name: 'valueId',
      type: 'string',
      textField: 'name',
      valueField: 'id',
      label: formatMessage({
        id: "".concat(intlPrefix, ".config")
      }),
      options: valueIdOptionsDs
    }, {
      name: 'values',
      type: 'string'
    }, {
      name: 'type',
      type: 'string',
      defaultValue: 'create'
    }, {
      name: 'isNotChange',
      type: 'boolean',
      defaultValue: false
    }, {
      name: 'appServiceSource',
      type: 'string',
      defaultValue: hasDevops ? 'normal_service' : 'share_service'
    }, {
      name: 'marketAppAndVersion',
      label: formatMessage({
        id: "".concat(intlPrefix, ".appAndVersion")
      }),
      type: 'object',
      dynamicProps: {
        required: function required(_ref38) {
          var record = _ref38.record;
          return record.get(mapping.deployWay.value) === mapping.deployWay.options[0].value && record.get('appServiceSource') === 'market_service' || getRequired({
            record: record
          }) && getIsMarket({
            record: record
          });
        }
      },
      ignore: 'always'
    }, {
      name: 'marketService',
      type: 'object',
      label: formatMessage({
        id: "".concat(intlPrefix, ".marketServiceAndVersion")
      }),
      textField: 'marketServiceName',
      valueField: 'id',
      dynamicProps: {
        required: function required(_ref39) {
          var record = _ref39.record;
          return record.get(mapping.deployWay.value) === mapping.deployWay.options[0].value && record.get('appServiceSource') === 'market_service' || getRequired({
            record: record
          }) && getIsMarket({
            record: record
          });
        }
      },
      options: marketServiceOptionsDs
    }],
    events: {
      create: handleCreate,
      update: handleUpdate
    }
  };
});