import { defineComponent, ref, watchEffect, watch, openBlock, createElementBlock, createVNode, withCtx, createElementVNode, withModifiers, normalizeStyle } from "vue";
import { showConfirmDialog } from "vant";
import { c as _sfc_main$1, d as _sfc_main$2, e as _sfc_main$3, f as _sfc_main$4 } from "./index2.js";
import "@wltech/svg";
import "dayjs";
import "qs";
import "vuedraggable";
import "vue-router";
var index_vue_vue_type_style_index_0_lang = "";
const _hoisted_1 = {
  class: "fail-popup",
  "data-weiling-mobile-ui-bc-business-stage-popup-fail-popup": ""
};
const _hoisted_2 = { class: "header" };
const _hoisted_3 = /* @__PURE__ */ createElementVNode("p", null, "\u5176\u4ED6", -1);
const _hoisted_4 = ["onClick"];
const _hoisted_5 = ["onClick"];
const _hoisted_6 = { class: "wl-textarea-wrap" };
const __default__ = {
  name: "FailPopup"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...__default__,
  props: {
    modelValue: { type: Boolean, default: false },
    list: { default: null }
  },
  emits: ["onConfirm", "onConfirmField", "update:modelValue"],
  setup(__props, { emit }) {
    const props = __props;
    const message = ref("");
    const fieldVisible = ref(false);
    const fieldItemData = ref(null);
    const popupVisible = ref(false);
    watchEffect(() => {
      popupVisible.value = props.modelValue;
    });
    watch(
      () => popupVisible.value,
      (val) => emit("update:modelValue", val)
    );
    const onSelect = (item) => {
      const { type = "" } = item;
      if (type === "ipt") {
        fieldVisible.value = true;
        fieldItemData.value = item;
      } else {
        showConfirmDialog({
          message: "\u786E\u8BA4\u4E22\u5355",
          title: "",
          confirmButtonColor: "rgba(255, 69, 69, 1)"
        }).then(() => {
          emit("onConfirm", { stage_value: item });
        });
      }
    };
    const onCloseField = () => {
      fieldVisible.value = false;
      popupVisible.value = false;
    };
    const onConfirmField = () => {
      if (!message.value)
        return;
      showConfirmDialog({
        message: "\u786E\u8BA4\u4E22\u5355",
        title: "",
        confirmButtonColor: "rgba(255, 69, 69, 1)"
      }).then(() => {
        emit("onConfirmField", {
          stage_value: {
            fail_reason_desc: message.value,
            ...fieldItemData.value
          }
        });
        fieldVisible.value = false;
        popupVisible.value = false;
      });
    };
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", null, [
        createVNode(_sfc_main$1, {
          modelValue: popupVisible.value,
          "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => popupVisible.value = $event),
          actions: __props.list,
          "cancel-text": "\u53D6\u6D88",
          selectedClose: false,
          teleport: "body",
          "close-on-click-action": "",
          onCancel: _cache[1] || (_cache[1] = ($event) => popupVisible.value = false),
          onSelect
        }, null, 8, ["modelValue", "actions"]),
        createVNode(_sfc_main$2, {
          position: "bottom",
          round: "",
          modelValue: fieldVisible.value,
          "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => fieldVisible.value = $event),
          style: { "height": "fit-content" },
          onOnClose: onCloseField
        }, {
          default: withCtx(() => [
            createElementVNode("div", _hoisted_1, [
              createElementVNode("div", _hoisted_2, [
                createVNode(_sfc_main$3, { showBack: false }, {
                  header_part_left: withCtx(() => [
                    createElementVNode("p", {
                      class: "canel",
                      onClick: withModifiers(onCloseField, ["stop"])
                    }, "\u53D6\u6D88", 8, _hoisted_4)
                  ]),
                  header_part_right: withCtx(() => [
                    createElementVNode("p", {
                      class: "confirm",
                      style: normalizeStyle(`color: ${message.value ? "" : "var(--wl-text-color-placeholder)"}`),
                      onClick: withModifiers(onConfirmField, ["stop"])
                    }, " \u5B8C\u6210 ", 12, _hoisted_5)
                  ]),
                  default: withCtx(() => [
                    _hoisted_3
                  ]),
                  _: 1
                })
              ]),
              createElementVNode("div", _hoisted_6, [
                createVNode(_sfc_main$4, {
                  class: "wl-textarea",
                  modelValue: message.value,
                  "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => message.value = $event),
                  rows: "2",
                  autosize: "",
                  autofocus: "",
                  type: "textarea",
                  maxlength: 50,
                  placeholder: "\u8BF7\u8F93\u5165\u4E22\u5355\u539F\u56E0\uFF08\u5FC5\u586B\uFF09",
                  "show-word-limit": ""
                }, null, 8, ["modelValue"])
              ])
            ])
          ]),
          _: 1
        }, 8, ["modelValue"])
      ]);
    };
  }
});
export { _sfc_main as default };
