sd-component-library.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <script>
  2. /* eslint-disable */
  3. // sd-skip-auto-import
  4. import util from"./util";import components from"./_import-components/sd-component-library-import";var _render=function e(){var t=this,i=t._self._c;return i("a-collapse",{class:t.$style.wrapper,attrs:{"default-active-key":t.expandedKeys}},[t._t("default"),t._l(t.librariesComputed,(function(e){return i("a-collapse-panel",{key:e.key,attrs:{header:e.name}},[i("sd-draggable",{attrs:{list:e.items,title:"通过 双击/拖拽 来添加",group:{name:t.formProps.tableName+("layout"===e.key?"_layout":""),pull:"clone",put:false},draggable:"."+t.$style.draggable}},t._l(e.items,(function(s){return i("div",{key:s.fileName,class:{[t.$style.item]:true,[t.$style.draggable]:-1===t.disabledCids.indexOf(s.attrFD.cid),"sd-layout-component":"layout"===e.key},on:{dblclick:function(e){return t.$emit("itemDblClick",s)}}},[i("a-icon",{class:t.$style.icon,attrs:{type:s.icon}}),t._v(t._s(s.caption)+" ")],1)})),0)],1)}))],2)};var staticRenderFns=[];_render._withStripped=true;export default{name:"SdComponentLibrary",components:components,mixins:[util.mixin],data(){return{libraries:null}},computed:{librariesComputed(){return this.layoutable?this.libraryLayout.concat(this.libraries):this.libraries}},created(){const e=e=>{if(e.deprecated)return false;if(e.singleton)this.designer.singletonCids.push(e.attrFD.cid);const t=!e.excludeFormTypes?.includes(this.formProps.attrFD.type);return t};const t={name:"布局控件",key:"layout",items:[]};const i={name:"基础控件",key:"basic",items:[]};const s={name:"高级控件",key:"advance",items:[]};const r=util.getComponentLibrary();const a=[];r.forEach((r=>{if("wep"===r.key)r.items.filter(e).forEach((e=>{if("layout"===e.category)t.items.push(e);else if("basic"===e.category)i.items.push(e);else s.items.push(e)}));else a.push({name:r.name??"扩展控件",key:r.key,items:r.items.filter(e)})}));this.libraries=[i,s,...a];this.libraryLayout=[t];this.expandedKeys=this.libraries.map((e=>e.key)).concat("layout")},methods:{},render:_render,staticRenderFns:staticRenderFns};</script>
  5. <style module lang="scss">
  6. @use '@/common/design' as *;
  7. .wrapper {
  8. &:global(.ant-collapse) {
  9. border: none;
  10. > :global(.ant-collapse-item) > :global(.ant-collapse-header) {
  11. /* stylelint-disable-next-line */
  12. line-height: 23px;
  13. }
  14. }
  15. .item {
  16. display: inline-block;
  17. width: 48%;
  18. padding: 5px 10px;
  19. margin: 1%;
  20. &:not(.draggable) {
  21. color: $disabled-color;
  22. pointer-events: none;
  23. }
  24. }
  25. .draggable {
  26. background-color: $layout-body-background;
  27. &:hover {
  28. color: $primary-5;
  29. /* stylelint-disable-next-line */
  30. outline: 1px dashed $primary-color;
  31. /* stylelint-disable-next-line */
  32. outline-offset: -1px;
  33. }
  34. }
  35. }
  36. .icon {
  37. margin-right: 5px;
  38. }
  39. </style>