UNPKG

zhsz-common-ui

Version:

This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.

60 lines (53 loc) 2.06 kB
import {computed} from "vue"; import _ from 'lodash' import useUserStore from "@/store/modules/user.js"; export default function () { const dynamicsHeight = computed(() => { return (...args) => { const [commonSearchRef, showSearch, showMore, otherHeight = 0] = args if (showSearch) { if (commonSearchRef) { return `calc(100vh - 65px - 89px - 50px - 32px - ${commonSearchRef.clientHeight}px - ${otherHeight}px )` } } else { return `calc(100vh - 65px - 89px - 50px - 32px - 1rem - ${otherHeight}px)` } return '100%' } }) const showColumns = computed(() => { return (columns) => { return _.filter(columns, (item) => (item.type !== 'index' && item.type !== 'selection' && item.type !== 'action')) } }) // 有点小问题,但是可以用 const getDictFormItem = computed(() => (items = [], obj = {}) => { const {proxy} = getCurrentInstance() const cloneItems = _.cloneDeep(items) return _.map(cloneItems, (item) => { if (item.dict) { item.options = proxy.useDict(item.dict)[item.dict].value } return item }) }) const getTagByStatus = computed(() => (obj, label) => { if (obj) { return obj[label] === 'primary' ? '' : obj[label] } if (label === 'label') { return '--' } return 'info' }) // dropdowm 下拉按钮权限 const isHasPermi = computed(() => (v = []) => { const all_permission = "*:*:*"; const permissions = useUserStore().permissions const permissionFlag = v return permissions.some(permission => { return all_permission === permission || permissionFlag.includes(permission) }) }) return {dynamicsHeight, showColumns, getDictFormItem, getTagByStatus, isHasPermi} }