index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <RenderHeaderDefault />
  3. </template>
  4. <script setup lang="tsx" name="LjHeaderMenu">
  5. import { ref, reactive, computed, watch, nextTick, useSlots, onMounted } from "vue";
  6. import { useI18n } from "vue-i18n";
  7. import { convertStrToObj } from "@/utils";
  8. import ButtonGroup from "@/components/LjDetail/components/ButtonGroup.vue";
  9. import { detailAction } from "@/components/LjDetail/interface";
  10. import { useAuthButtons } from "@/hooks/useAuthButtons";
  11. import { useGlobalStore } from "@/stores/modules/global";
  12. // import { useDesign } from "@/hooks/useDesign";
  13. const { t } = useI18n();
  14. const slots = useSlots();
  15. // const { prefixCls } = useDesign("header-menu");
  16. interface LjHeaderMenuProps {
  17. /**
  18. * @argument 业务动作列表
  19. * @example 支持二维数组嵌套,会以下拉菜单形式渲染,结构允许:[{},{},...] [[{},{},..], {}]
  20. */
  21. action?: detailAction[][] | detailAction[];
  22. /**
  23. * @description ButtonGroup组件:update
  24. */
  25. update?: any;
  26. /**
  27. * @description ButtonGroup组件:data
  28. */
  29. data?: any;
  30. groupCls?: string;
  31. }
  32. const { assemblySize } = useGlobalStore();
  33. const { CheckPower, funcFilterPower, funcRightActionPower } = useAuthButtons(t);
  34. const orderBtnGroup = ref([]);
  35. const props = withDefaults(defineProps<LjHeaderMenuProps>(), {
  36. action: () => [],
  37. groupCls: ""
  38. });
  39. onMounted(() => {
  40. // props.action && (orderBtnGroup.value = funcFilterPower(props.action));
  41. });
  42. /**
  43. * @deascription 渲染:默认头部render
  44. * @param rProp prop
  45. */
  46. const RenderHeaderDefault = (rProp: any) => {
  47. console.log("RenderHeaderDefault rProp :>> ", rProp);
  48. // let nameValue = convertStrToObj(_mainData.value, props.header.fieldNames?.name);
  49. // let _params =
  50. // orderStatus.value == "new" ? infoParam.value : orderStatus.value == "edit" ? reactive(_mainData.value) : _mainData.value;
  51. let _assemblySize = assemblySize == "small" ? "default" : "large";
  52. let _height = assemblySize == "small" ? "32px" : "40px";
  53. // let allowPowerAction = orderBtnGroup.value;
  54. /**
  55. * @description 折叠的单据功能菜单
  56. */
  57. let _render_right_action: any = [];
  58. // let hasRightAction = rProp?.rightAction && rProp.rightAction.length;
  59. // if (hasRightAction) {
  60. // orderOtherFunc.value.map((item: any) => {
  61. // _render_right_action.push(
  62. // <DropdownList
  63. // target="detail-button-group"
  64. // buttons={item}
  65. // data={_params}
  66. // assemblySize={_assemblySize}
  67. // />
  68. // );
  69. // });
  70. // }
  71. // /**
  72. // * @description 右侧固定下拉菜单
  73. // */
  74. // let _render_right_fixed_action: any = [];
  75. // let hasRightFixedAction = rProp?.rightFixedAction && rProp.rightFixedAction.length;
  76. // if (hasRightFixedAction) {
  77. // rProp.rightFixedAction.map((itemAction: any) => {
  78. // if (!getRightActionPower(itemAction)) return;
  79. // switch (itemAction) {
  80. // case "print":
  81. // // 订单打印
  82. // let _render_dd_item = getRenderRightFixedAction();
  83. // let hasPrinterList = Boolean(printerTpList.value.length);
  84. // let _slotsRightFixedAction = {
  85. // dropdown: () => {
  86. // return (
  87. // <>
  88. // <el-dropdown-menu>
  89. // <>
  90. // {hasPrinterList && _render_dd_item}
  91. // <el-dropdown-item divided={hasPrinterList} onClick={() => openPrint("")}>
  92. // <div class="flx-center">
  93. // <el-icon>
  94. // <Setting />
  95. // </el-icon>
  96. // {t("common.setText")}
  97. // </div>
  98. // </el-dropdown-item>
  99. // </>
  100. // </el-dropdown-menu>
  101. // </>
  102. // );
  103. // }
  104. // };
  105. // _render_right_fixed_action.push(
  106. // <el-dropdown
  107. // trigger="contextmenu"
  108. // placement="bottom-end"
  109. // ref={printerListTpDropdownRef}
  110. // v-slots={_slotsRightFixedAction}
  111. // >
  112. // <el-button icon={Printer} circle onClick={handleCheckPrintTemplateList}></el-button>
  113. // </el-dropdown>
  114. // );
  115. // break;
  116. // case "printMx":
  117. // // 明细打印
  118. // break;
  119. // default:
  120. // break;
  121. // }
  122. // });
  123. // }
  124. return (
  125. <>
  126. <div class={["flx w-full flx-justify-between", "lj-header-menu"]} style={{ height: _height }}>
  127. <div id="detail-button-group" class={`flx-1 ${props.groupCls ? props.groupCls : "flx-start"}`}>
  128. {props.action.length > 0 && (
  129. <ButtonGroup
  130. update={props.update}
  131. target="detail-button-group"
  132. buttons={props.action}
  133. data={props.data}
  134. assemblySize={_assemblySize}
  135. ></ButtonGroup>
  136. )}
  137. </div>
  138. <div class="flx-end flx-shrink mr-12">
  139. {/* {nameValue && (
  140. <>
  141. <span class={["text-h4-r", "text-disable", hasRightAction ? "mr-8" : ""]}>{nameValue}</span>
  142. </>
  143. )} */}
  144. {_render_right_action}
  145. {/* {_render_right_fixed_action} */}
  146. {/* {(nameValue || hasRightAction) && <el-divider direction="vertical" />} */}
  147. <div class="setting-part">
  148. {/* {<el-button circle icon={Operation} onClick={handleShowDetailSetting}></el-button>} */}
  149. {slots.rightBtn && slots.rightBtn?.()}
  150. </div>
  151. </div>
  152. </div>
  153. </>
  154. );
  155. };
  156. </script>