diff --git a/src/composables/useRole.js b/src/composables/useRole.js index 95b585283..4d93679f6 100644 --- a/src/composables/useRole.js +++ b/src/composables/useRole.js @@ -27,10 +27,20 @@ export function useRole() { return false; } + function likeAny(roles) { + const roleStore = state.getRoles(); + for (const role of roles) { + if (!roleStore.value.findIndex((rs) => rs.startsWith(role)) !== -1) + return true; + } + + return false; + } return { fetch, hasAny, + likeAny, state, }; } diff --git a/src/pages/Item/components/ItemProposal.vue b/src/pages/Item/components/ItemProposal.vue index 50c60a1d9..153d825ad 100644 --- a/src/pages/Item/components/ItemProposal.vue +++ b/src/pages/Item/components/ItemProposal.vue @@ -3,11 +3,17 @@ import { ref, computed } from 'vue'; import { useI18n } from 'vue-i18n'; import VnPaginate from 'components/ui/VnPaginate.vue'; import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue'; +import FetchedTags from 'components/ui/FetchedTags.vue'; import { useSession } from 'src/composables/useSession'; const { t } = useI18n(); const session = useSession(); +const primaryColor = 'red'; +const colorSpacer = '#ecf0f1'; +const gradientStyle = computed(() => { + return `linear-gradient(to right, ${primaryColor} ${compatibility.value}, ${colorSpacer} 10%)`; +}); const $props = defineProps({ item: { type: Object, @@ -30,36 +36,39 @@ const defaultColumnAttrs = { align: 'left', sortable: true, }; +const compatibility = ref(null); +// const compatibility = computed(() => `linear-gradient(to right,red 10%, white 10%);`); const statusConditionalValue = (row) => { - const total = [5, 6, 7, 8].reduce((acc, i) => acc + row[`match${i}`], 0); - const STATUS_VALUES = { 2: '$secondary', 3: 'positive', 4: 'warning' }; - const status = STATUS_VALUES[total - 2]; - if (!status) return 'white'; - return status; + const values = [5, 6, 7, 8]; + const total = values.reduce((acc, i) => acc + row[`match${i}`], 0); + const STATUS_VALUES = { 1: 'white', 2: '$secondary', 3: 'positive', 4: 'warning' }; + const status = STATUS_VALUES[total]; + compatibility.value = `${100 * (total / values.length)}%`; + return { status, total, compatibility }; }; -const conditionalValue = (tag) => (tag === 1 ? 'match' : 'not-match'); +// const conditionalValue = (tag) => (tag === 1 ? 'match' : 'not-match'); const conditionalValuePrice = (price) => price > currentTicket.value.price * 1.3 ? 'match' : 'not-match'; -const changeTicket = (type, _index = 0) => { - const value = type ? 1 : -1; - const nextIndex = index.value + value + _index; - const ticket = $props.tickets[nextIndex]; - if (ticket.ticketFk === currentTicket.value.ticketFk) - return changeTicket(true, nextIndex - 1); - index.value = nextIndex; -}; +// const changeTicket = (type, _index = 0) => { +// const value = type ? 1 : -1; +// const nextIndex = index.value + value + _index; +// const ticket = $props.tickets[nextIndex]; +// if (ticket.ticketFk === currentTicket.value.ticketFk) +// return changeTicket(true, nextIndex - 1); +// index.value = nextIndex; +// }; const columns = computed(() => [ { ...defaultColumnAttrs, - label: t('proposal.counter'), - name: 'counter', - field: 'counter', + label: t('proposal.available'), + name: 'available', + field: 'available', }, { ...defaultColumnAttrs, - label: t('proposal.itemFk'), - name: 'id', - field: 'id', + label: t('proposal.difference'), + name: 'difference', + field: (item) => 21, }, { ...defaultColumnAttrs, @@ -67,6 +76,13 @@ const columns = computed(() => [ name: 'status', field: statusConditionalValue, }, + { + ...defaultColumnAttrs, + label: t('proposal.counter'), + name: 'counter', + field: 'counter', + }, + { align: 'center', sortable: true, @@ -74,13 +90,13 @@ const columns = computed(() => [ name: 'longName', field: 'longName', }, - { - ...defaultColumnAttrs, - label: t('proposal.subName'), - name: 'subName', - field: 'subName', - }, - { + // { + // ...defaultColumnAttrs, + // label: t('proposal.subName'), + // name: 'subName', + // field: 'subName', + // }, + /*{ ...defaultColumnAttrs, label: t('proposal.value5'), name: 'value5', @@ -107,12 +123,18 @@ const columns = computed(() => [ name: 'value8', field: 'value8', classes: ({ match8 }) => conditionalValue(match8), - }, + },*/ { ...defaultColumnAttrs, - label: t('proposal.available'), - name: 'available', - field: 'available', + label: t('proposal.tags'), + name: 'tags', + }, + + { + ...defaultColumnAttrs, + label: t('proposal.price2'), + name: 'price2', + field: 'price2', }, { ...defaultColumnAttrs, @@ -120,12 +142,6 @@ const columns = computed(() => [ name: 'minQuantity', field: 'minQuantity', }, - { - ...defaultColumnAttrs, - label: t('proposal.price2'), - name: 'price2', - field: 'price2', - }, { ...defaultColumnAttrs, label: t('proposal.located'), @@ -156,7 +172,7 @@ async function confirm() { {{ item.longName }} + {{ item.longName }} @@ -233,18 +252,41 @@ async function confirm() { + +