/* empty css                                               */
/* empty css                                                */
/* empty css                                                  */
/* empty css                                                 */
/* empty css                                                */
/* empty css                                                     */
/* empty css                                               */
/* empty css                                              */
/* empty css                                                       */
/* empty css                                                 */
/* empty css                                               */
/* empty css                                               */
/* empty css                                                */
/* empty css                                                  */
/* empty css                                                */
/* empty css                                                     */
/* empty css                                                 */
/* empty css                                                            */
import { ref, reactive, createElementBlock, openBlock, Fragment, createVNode, withCtx, renderList, createBlock, normalizeClass, unref, isRef, createElementVNode, createCommentVNode } from "vue";
/* empty css                  */
import _export_sfc from "../../../../../../_virtual/_plugin-vue_export-helper.mjs";
import { ActionBar } from "../../../../node_modules/vant/es/action-bar/index.mjs";
import { ActionBarButton } from "../../../../node_modules/vant/es/action-bar-button/index.mjs";
import { Popup } from "../../../../node_modules/vant/es/popup/index.mjs";
import { Field } from "../../../../node_modules/vant/es/field/index.mjs";
import { Picker } from "../../../../node_modules/vant/es/picker/index.mjs";
const _hoisted_1 = { class: "appPopContent" };
const _hoisted_2 = { class: "appOptContent" };
const _sfc_main = {
  __name: "ApprovalBar",
  props: {
    actionBarOptions: {
      type: Array,
      default: []
    }
  },
  setup(__props) {
    const showAgreePop = ref(false);
    const showOtherPop = ref(false);
    const showOpinionPicker = ref(false);
    const showTargetNodePicker = ref(false);
    const currentActionItem = ref({});
    const opinionForm = reactive({
      opinionType: "",
      opinionContent: "",
      targetNode: ""
    });
    function clickHandler(item) {
      console.log("🚀 ~ clickHandler ~ item:", item);
      if (item.approvalType == "agree") {
        showAgreePop.value = true;
      } else if (item.approvalType == "other") {
        currentActionItem.value = item;
        opinionForm.opinionType = "";
        opinionForm.opinionContent = "";
        opinionForm.targetNode = "";
        showOtherPop.value = true;
      }
    }
    function onOpinionConfirm({ selectedOptions }) {
      var _a;
      opinionForm.opinionType = ((_a = selectedOptions[0]) == null ? void 0 : _a.value) || "";
      showOpinionPicker.value = false;
    }
    function onTargetNodeConfirm({ selectedOptions }) {
      var _a;
      opinionForm.targetNode = ((_a = selectedOptions[0]) == null ? void 0 : _a.value) || "";
      showTargetNodePicker.value = false;
    }
    function submitOpinion() {
      console.log("提交审批意见:", opinionForm);
      showOtherPop.value = false;
    }
    return (_ctx, _cache) => {
      const _component_van_action_bar_button = ActionBarButton;
      const _component_van_action_bar = ActionBar;
      const _component_van_popup = Popup;
      const _component_van_field = Field;
      const _component_van_picker = Picker;
      return openBlock(), createElementBlock(Fragment, null, [
        createVNode(_component_van_action_bar, { "safe-area-inset-bottom": "" }, {
          default: withCtx(() => [
            (openBlock(true), createElementBlock(Fragment, null, renderList(__props.actionBarOptions, (item) => {
              return openBlock(), createBlock(_component_van_action_bar_button, {
                class: normalizeClass(item.bgClass || "icon-blue"),
                text: item.text,
                onClick: ($event) => clickHandler(item)
              }, null, 8, ["class", "text", "onClick"]);
            }), 256))
          ]),
          _: 1
        }),
        createVNode(_component_van_popup, {
          show: unref(showAgreePop),
          "onUpdate:show": _cache[0] || (_cache[0] = ($event) => isRef(showAgreePop) ? showAgreePop.value = $event : null),
          round: "",
          position: "bottom",
          style: { height: "30%" }
        }, null, 8, ["show"]),
        createVNode(_component_van_popup, {
          show: unref(showOtherPop),
          "onUpdate:show": _cache[6] || (_cache[6] = ($event) => isRef(showOtherPop) ? showOtherPop.value = $event : null),
          round: "",
          position: "bottom"
        }, {
          default: withCtx(() => [
            createElementVNode("div", _hoisted_1, [
              createElementVNode("div", _hoisted_2, [
                createVNode(_component_van_field, {
                  modelValue: unref(currentActionItem).opinionType,
                  "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => unref(currentActionItem).opinionType = $event),
                  "is-link": "",
                  readonly: "",
                  label: "审批意见",
                  placeholder: "请选择审批意见",
                  onClick: _cache[2] || (_cache[2] = ($event) => showOpinionPicker.value = true)
                }, null, 8, ["modelValue"]),
                unref(currentActionItem).needTargetNode ? (openBlock(), createBlock(_component_van_field, {
                  key: 0,
                  modelValue: unref(opinionForm).targetNode,
                  "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => unref(opinionForm).targetNode = $event),
                  "is-link": "",
                  readonly: "",
                  label: "目标节点",
                  placeholder: "请选择目标节点",
                  onClick: _cache[4] || (_cache[4] = ($event) => showTargetNodePicker.value = true)
                }, null, 8, ["modelValue"])) : createCommentVNode("", true),
                createVNode(_component_van_field, {
                  modelValue: unref(opinionForm).opinionContent,
                  "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => unref(opinionForm).opinionContent = $event),
                  rows: "6",
                  autosize: "",
                  label: "意见内容",
                  type: "textarea",
                  maxlength: "500",
                  "show-word-limit": "",
                  placeholder: "请输入审批意见"
                }, null, 8, ["modelValue"])
              ]),
              createVNode(_component_van_action_bar, { "safe-area-inset-bottom": "" }, {
                default: withCtx(() => [
                  createVNode(_component_van_action_bar_button, {
                    class: normalizeClass("icon-blue"),
                    text: "提交",
                    onClick: submitOpinion
                  })
                ]),
                _: 1
              })
            ])
          ]),
          _: 1
        }, 8, ["show"]),
        createVNode(_component_van_popup, {
          show: unref(showOpinionPicker),
          "onUpdate:show": _cache[8] || (_cache[8] = ($event) => isRef(showOpinionPicker) ? showOpinionPicker.value = $event : null),
          round: "",
          position: "bottom"
        }, {
          default: withCtx(() => [
            createVNode(_component_van_picker, {
              columns: unref(currentActionItem).opinionOptions || [],
              onConfirm: onOpinionConfirm,
              onCancel: _cache[7] || (_cache[7] = ($event) => showOpinionPicker.value = false)
            }, null, 8, ["columns"])
          ]),
          _: 1
        }, 8, ["show"]),
        createVNode(_component_van_popup, {
          show: unref(showTargetNodePicker),
          "onUpdate:show": _cache[10] || (_cache[10] = ($event) => isRef(showTargetNodePicker) ? showTargetNodePicker.value = $event : null),
          round: "",
          position: "bottom"
        }, {
          default: withCtx(() => [
            createVNode(_component_van_picker, {
              columns: unref(currentActionItem).targetNodeOptions || [],
              onConfirm: onTargetNodeConfirm,
              onCancel: _cache[9] || (_cache[9] = ($event) => showTargetNodePicker.value = false)
            }, null, 8, ["columns"])
          ]),
          _: 1
        }, 8, ["show"])
      ], 64);
    };
  }
};
const _ApprovalBar = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-fc8cdb72"]]);
export {
  _ApprovalBar as default
};
