export const onlAutoListMixin = {
  data : function() {
    let self = this;
    let style = {
      top : 0,
      left : 0,
      height : "100%",
      margin : 0,
      padding : 0
    };
    return {
      fieldHrefSlots : [],
      hrefComponent : {
        model : {
          title : "",
          width : "100%",
          visible : false,
          destroyOnClose : true,
          style : style,
          dialogStyle : style,
          bodyStyle : {
            padding : "8px",
            height : "calc(100vh - 108px)",
            overflow : "auto",
            overflowX : "hidden"
          },
          cancelButtonProps : {
            style : {
              display : "none"
            }
          }
        },
        on : {
          ok : function() {
            return self.hrefComponent.model.visible = false;
          },
          cancel : function() {
            return self.hrefComponent.model.visible = false;
          }
        },
        is : null,
        params : {}
      }
    };
  },
  methods : {
    handleAcceptHrefParams() {
      this.acceptHrefParams = {};
      let query = this.$route.query;
      if (query) {
        this.acceptHrefParams = Object.assign({}, query);
      }
    },
    handleClickFieldHref(field, record) {
      let href = field.href;
      let urlPattern = /(ht|f)tp(s?):\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?,'\/\\\+&amp;%\$#_]*)?/;
      let compPattern = /\.vue(\?.*)?$/;
      let jsPattern = /{{([^}]+)}}/g;
      if ("string" === typeof href) {
        href = href.trim().replace(/\${([^}]+)?}/g, function(canCreateDiscussions, recname) {
          return record[recname];
        });
        if (jsPattern.test(href)) {
          href = href.replace(jsPattern, function(match, p1) {
            try {
              return eval(p1);
            } catch (e) {
              return match;
            }
          });
        }
        if (urlPattern.test(href)) {
          window.open(href, "_blank");
        } else {
          if (compPattern.test(href)) {
            this.openHrefCompModal(href);
          } else {
            this.$router.push(href);
          }
        }
      }
    },
    openHrefCompModal : function(value) {
      let i = value.indexOf("?");
      let url = value;
      if (-1 !== i) {
        url = value.substring(0, i);
        let componentsStr = value.substring(i + 1, value.length);
        let pipelets = componentsStr.split("&");
        let img_envs = {};
        pipelets.forEach(function(clusterShardData) {
          let env_data = clusterShardData.split("=");
          img_envs[env_data[0]] = env_data[1];
        });
        this.hrefComponent.params = img_envs;
      } else {
        this.hrefComponent.params = {};
      }
      this.hrefComponent.model.visible = true;
      this.hrefComponent.model.title = "操作";
      this.hrefComponent.is = function() {
        return __webpack_require__$jscomp$6("9dac")("./" + (url.startsWith("/") ? url.slice(1) : url));
      };
    },
    handleColumnShowLength : function(src) {
      let createElement = this.$createElement;
      let length = src.showLength;
      /** @type {function(!Object): ?} */
      let nodeName = src.customRender;
      if (length && "function" != typeof nodeName) {
        /**
         * @param {!Object} obj
         * @return {?}
         */
        src.customRender = function(obj) {
          return obj && obj.length > length ? createElement("span", {
            attrs : {
              title : obj
            }
          }, [obj.substr(0, length), "..."]) : obj;
        };
      }
    },
    handleColumnHrefAndDict : function() {
      let e = this;
      let that = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
      let gradient = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
      let _h = this.$createElement;
      let start = that.customRender;
      let i = that.hrefSlotName;
      let name = that.fieldType;
      if ("Date" == name) {
        /**
         * @param {!Object} obj
         * @return {?}
         */
        that.customRender = function(obj) {
          return obj ? obj.length > 10 ? obj.substring(0, 10) : obj : "";
        };
      } else {
        if (!i && that.scopedSlots && that.scopedSlots.customRender && gradient.hasOwnProperty(that.scopedSlots.customRender) && (i = that.scopedSlots.customRender), start || i) {
          var t = start;
          /** @type {string} */
          var s = "_replace_text_";
          /**
           * @param {!Object} obj
           * @param {string} name
           * @return {?}
           */
          that.customRender = function(obj, name) {
            /** @type {!Object} */
            var data = obj;
            if (t) {
              if (t.startsWith(s)) {
                var val = t.replace(s, "");
                data = name[val];
              } else {
                data = e.$filterMultiDictText(e.dictOptions[t], obj);
              }
            }
            if (that.showLength && data && data.length > that.showLength && (data = data.substr(0, that.showLength) + "..."), i) {
              var step = gradient[i];
              if (step) {
                return _h("a", {
                  on : {
                    click : function() {
                      return e.handleClickFieldHref(step, name);
                    }
                  }
                }, [data]);
              }
            }
            return data;
          };
        }
      }
    }
  }
}