"use strict";

var _interopRequireDefault = require("F:/GIT/opu-components-vue/node_modules/@babel/runtime/helpers/interopRequireDefault.js").default;

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

require("core-js/modules/es.number.constructor.js");

require("core-js/modules/es.array.concat.js");

var _babelHelperVueJsxMergeProps = _interopRequireDefault(require("@vue/babel-helper-vue-jsx-merge-props"));

var _objectSpread2 = _interopRequireDefault(require("F:/GIT/opu-components-vue/node_modules/@babel/runtime/helpers/esm/objectSpread2.js"));

var _TextArea = require("ant-design-vue/lib/input/TextArea");

var _modal = require("../../modal");

var _default = {
  name: "InputNumber",
  components: {
    Modal: _modal.Modal
  },
  props: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, _TextArea.TextAreaProps), {}, {
    value: {
      type: [String, Number]
    }
  }),
  model: {
    prop: "value",
    event: "update"
  },
  data: function data() {
    return {
      visible: false,
      modalTextareaValue: ""
    };
  },
  watch: {},
  computed: {
    modalTitle: function modalTitle() {
      var propsData = this.$options.propsData;
      console.log(propsData);
      return propsData.modalTitle || "编辑";
    }
  },
  created: function created() {},
  mounted: function mounted() {},
  updated: function updated() {},
  methods: {
    focus: function focus() {
      this.$refs.modalTextarea.focus();
    },
    onShowModal: function onShowModal() {
      debugger;
      this.modalTextareaValue = this.value;
      this.visible = true;
    },
    onModalSubmit: function onModalSubmit() {
      this.$emit("update", this.modalTextareaValue);
      this.$emit("change", this.modalTextareaValue);
      this.visible = false;
    },
    onModalCancel: function onModalCancel() {
      this.visible = false;
    }
  },
  render: function render() {
    var _this = this;

    var h = arguments[0];
    var $listeners = this.$listeners;
    var that = this;
    var propsData = this.$options.propsData;
    var listeners = {};

    var _loop = function _loop(key) {
      listeners[key] = function () {
        for (var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++) {
          arg[_key] = arguments[_key];
        }

        that.$emit.apply(that, [key].concat(arg));
      };
    };

    for (var key in $listeners) {
      _loop(key);
    }

    var props = {
      style: {
        width: "100%"
      },
      ref: "modalTextarea",
      props: (0, _objectSpread2.default)({}, propsData),
      on: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, listeners), {}, {
        change: function change(value) {
          value = value || value === 0 ? value : "";

          _this.$emit("update", value);

          if (_this.value !== value) {
            _this.$emit("change", value);
          }
        },
        pressEnter: function pressEnter(e) {
          _this.$emit("pressEnter", e);
        }
      })
    };
    return h("div", {
      "class": "textarea-edit-wraper"
    }, [h("a-textarea", (0, _babelHelperVueJsxMergeProps.default)([{}, props])), h("a", {
      "class": "showmodal-btn",
      "on": {
        "click": this.onShowModal
      }
    }, [h("a-icon", {
      "attrs": {
        "type": "arrows-alt"
      }
    })]), h("modal", {
      "props": (0, _objectSpread2.default)({}, {
        centered: true,
        title: this.modalTitle,
        value: this.visible,
        maskClosable: false,
        destroyOnClose: true,
        width: this.modalWidth || 800
      }),
      "on": (0, _objectSpread2.default)({}, {
        ok: this.onModalSubmit,
        cancel: this.onModalCancel
      })
    }, [h("a-textarea", {
      "props": (0, _objectSpread2.default)({}, {
        value: this.modalTextareaValue,
        destroyOnClose: true
      }),
      "on": (0, _objectSpread2.default)({}, {
        change: function change(e) {
          _this.modalTextareaValue = e.target.value;
        }
      }),
      "attrs": {
        "rows": propsData.modalTextareaRows || 20
      }
    })])]);
  }
};
exports.default = _default;