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