UNPKG

@aplus-frontend/ui

Version:

2 lines (1 loc) 3.95 kB
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),u=require("@aplus-frontend/antdv"),E=require("../../../ap-field/index.js");require("../../../ap-form/ap-form.vue.js");require("../../../config-provider/index.js");const h=require("../../../config-provider/hooks/use-token.js");require("../../ap-tag/index.js");const S=require("../hooks/use-view-provide.js"),q=require("../icons/line-delete.vue.js"),g=require("../style/index.js"),m=require("../utils/enum.js"),D=require("../../../config-provider/hooks/use-namespace.js"),K=require("../../../config-provider/hooks/use-locale.js"),B=require("../../ap-tag/ap-tag.vue.js"),f=require("../../../ap-form/ap-form.vue2.js"),T={class:"menu-list-content-name"},z=["title"],I={key:0,class:"menu-list-content-default"},M={class:"menu-list-content-action-delete"},b={class:"menu-list-content-edit"},L=e.defineComponent({__name:"menu-list-content",props:{view:{}},setup(w){const{b:a}=D.useNamespace("ap-view"),c=g.default("ap-view"),{token:p}=h.useToken(),{t:n}=K.useLocale(),t=w,{currentViewKey:_,changeCurrentViewKey:V,viewListCRUD:r,tableKey:s,menuOpen:d}=S.useViewInject(),o=e.ref(!1),v=e.ref(),k=()=>{V(t.view.viewKey),d.value=!1},N=()=>{r?.changeView?.({...t.view,tableKey:s,isDefault:!0})},y=()=>{r?.removeView?.({tableKey:s,viewKey:t.view.viewKey})},C=async()=>{const l=await v.value?.validate?.();r?.changeView?.({...t.view,tableKey:s,viewName:l?.viewName||t.view.viewName}),o.value=!1};return e.watch(()=>d.value,l=>{l&&(o.value=!1)}),(l,i)=>o.value===!1?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass({[e.unref(a)()]:!0,[e.unref(a)("menu-list-content")]:!0,[e.unref(a)("menu-list-content-active")]:t.view?.viewKey===e.unref(_),[e.unref(c)]:!0}),onClick:k},[e.createElementVNode("div",T,[e.createElementVNode("span",{title:t.view?.viewName},e.toDisplayString(t.view?.viewName),9,z)]),t.view?.viewKey!==e.unref(m.SYSTEM_VIEW_KEY)&&t.view?.isDefault?(e.openBlock(),e.createElementBlock("div",I,[e.createVNode(e.unref(B.default),{text:e.unref(n)("ap.apView.default"),size:"small",color:e.unref(p).colorLink},null,8,["text","color"])])):e.createCommentVNode("",!0),t.view?.viewKey!==e.unref(m.SYSTEM_VIEW_KEY)?(e.openBlock(),e.createElementBlock("div",{key:1,class:"menu-list-content-action",onClick:i[1]||(i[1]=e.withModifiers(()=>{},["stop"]))},[e.createVNode(e.unref(u.Space),{size:8},{default:e.withCtx(()=>[e.createElementVNode("div",{class:"menu-list-content-action-text",onClick:i[0]||(i[0]=x=>o.value=!0)},e.toDisplayString(e.unref(n)("ap.apView.rename")),1),t.view?.isDefault?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",{key:0,class:"menu-list-content-action-text",onClick:N},e.toDisplayString(e.unref(n)("ap.apView.setDefault")),1)),e.createElementVNode("div",M,[e.createVNode(e.unref(u.Popconfirm),{title:e.unref(n)("ap.apView.deleteTip"),"ok-text":e.unref(n)("ap.apView.ok"),onConfirm:y},{default:e.withCtx(()=>[e.createVNode(q.default)]),_:1},8,["title","ok-text"])])]),_:1})])):e.createCommentVNode("",!0)],2)):(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass([e.unref(a)("menu-list-content"),e.unref(a)("menu-list-content-edit"),e.unref(c)])},[e.createVNode(f.default,{ref_key:"formRef",ref:v,"initial-values":{viewName:t.view?.viewName}},{default:e.withCtx(()=>[e.createElementVNode("div",b,[e.createVNode(e.unref(u.Space),{size:8},{default:e.withCtx(()=>[e.createVNode(f.default.FormItem,{name:"viewName"},{default:e.withCtx(()=>[e.createVNode(e.unref(E.ApField).Text,{maxlength:20})]),_:1}),e.createElementVNode("div",{class:"menu-list-content-action-text",onClick:C},e.toDisplayString(e.unref(n)("ap.apView.save")),1),e.createElementVNode("div",{class:"menu-list-content-action-text",onClick:i[2]||(i[2]=x=>o.value=!1)},e.toDisplayString(e.unref(n)("ap.apView.cancel")),1)]),_:1})])]),_:1},8,["initial-values"])],2))}});exports.default=L;