123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- <script lang="ts" setup>
- /**
- * @Name: DataTableSlot.vue
- * @Description: 商品监控-表格插槽
- * @Author: Cheney
- */
- import { useCountryInfoStore } from '/@/stores/countryInfo';
- import { Delete, Operation } from '@element-plus/icons-vue';
- import PermissionButton from '/@/components/PermissionButton/index.vue';
- import ProductInfo from '/@/views/product-manage/product-list/component/ProductInfo.vue';
- import { getTagType } from '/@/utils/useTagColor';
- const props = defineProps<{
- row: any,
- field: any
- }>();
- const { row, field } = props;
- const emit = defineEmits([ 'edit-row', 'handle-delete' ]);
- const countryInfoStore = useCountryInfoStore();
- const country = countryInfoStore.countries.find(c => c.code == row.country_code);
- const color = country ? country.color : '#3875F6';
- const statusText = row.status === 1 ? '在售' : '停售';
- const statusType = row.status === 1 ? 'success' : 'info';
- function handleEdit(row: any) {
- emit('edit-row', row);
- }
- function handleDelete(row: any) {
- emit('handle-delete', row);
- }
- </script>
- <template>
- <div class="font-medium">
- <div v-if="field === 'product_info'">
- <ProductInfo :img-width="50" :item="row.goods" style="min-width: 230px" />
- </div>
- <div v-else-if="field === 'country_code'">
- <el-tag :disable-transitions="true" :style="{ color: color, borderColor: color }" effect="plain" round>
- {{ country ? country.name : '--' }}
- </el-tag>
- </div>
- <div v-else-if="field === 'shop_name'">
- <el-tag :disable-transitions="true" :type=getTagType(row.shop_name)>
- {{ row.shop_name ?? '--' }}
- </el-tag>
- </div>
- <div v-else-if="field === 'tag'">
- <el-tag :disable-transitions="true" :type=getTagType(row.goods.tag)>
- {{ row.goods.tag ?? '--' }}
- </el-tag>
- </div>
- <div v-else-if="field === 'brand'">
- <el-tag :disable-transitions="true" :type=getTagType(row.goods.brand) effect="plain" round>
- {{ row.goods.brand ?? '--' }}
- </el-tag>
- </div>
- <div v-else-if="field === 'price_info'">
- <div v-if="row.goods.price > 0" class="font-medium">
- <p>现 价:{{ row.goods.currency_code + '' + row.goods.price }}</p>
- <p>折 扣:{{ row.goods.discount > 0 ? row.goods.discount + '%' : '-' }}</p>
- <p>优惠劵:{{ !row || row.goods.coupon <= 0 ? '-' : row.goods.currency_code + '' + row.goods.coupon }}</p>
- </div>
- </div>
- <div v-else-if="field === 'show_price'">
- <div class="font-medium">
- {{ row.goods.show_price ? row.goods.currency_code + row.goods.show_price : '--' }}
- </div>
- </div>
- <div v-else-if="field === 'activity_price'">
- <div class="font-medium">
- {{ row.goods.activity_price ? row.goods.currency_code + row.goods.activity_price : '--' }}
- </div>
- </div>
- <div v-else-if="field === 'minimum_price'">
- <div class="font-medium">
- {{ row.goods.minimum_price ? row.goods.currency_code + row.goods.minimum_price : '--' }}
- </div>
- </div>
- <div v-else-if="field === 'score'">
- <template v-if="row.goods.score !== null && row.goods.score !== undefined && row.goods.score !== ''">
- <el-rate
- v-if="row.goods.score > 0"
- v-model="row.goods.score"
- :colors="['#FF0000', '#FF9900', '#67C23A']"
- disabled
- show-score
- text-color="#1e293b"
- />
- <span v-else>{{ row.goods.score }}</span> <!-- 值为0时显示0 -->
- </template>
- <template v-else>
- <span>--</span> <!-- 无值时显示'--' -->
- </template>
- </div>
- <div v-else-if="field === 'all_score'">
- <template v-if="row.goods.all_score !== null && row.goods.all_score !== undefined && row.goods.all_score !== ''">
- <el-rate
- v-if="row.goods.all_score > 0"
- v-model="row.goods.all_score"
- :colors="['#FF0000', '#FF9900', '#67C23A']"
- disabled
- show-score
- text-color="#1e293b"
- />
- <span v-else>{{ row.goods.all_score }}</span>
- </template>
- <template v-else>
- <span>--</span>
- </template>
- </div>
- <div v-else-if="field === 'stars'" class="flex flex-col font-normal" style="min-width: 170px">
- <div v-for="i in [5,4,3,2,1]" :key="i" class="w-full flex items-center">
- <span class="w-10 text-right mr-2">{{ i }}星</span>
- <el-progress
- striped
- striped-flow
- :color="'#3A8EE6'"
- :percentage="row.goods[`ratings${i}`]"
- :stroke-width="10"
- class="flex-1"
- />
- </div>
- </div>
- <div v-else-if="field === 'all_stars'" class="flex flex-col font-normal" style="min-width: 170px">
- <div v-for="i in [5,4,3,2,1]" :key="i" class="w-full flex items-center">
- <span class="w-10 text-right mr-2">{{ i }}星</span>
- <el-progress
- striped
- striped-flow
- :color="'#3A8EE6'"
- :percentage="row.goods[`all_rate${i}`]"
- :stroke-width="10"
- class="flex-1"
- />
- </div>
- </div>
- <div v-else-if="field === 'status'">
- <el-tag :disable-transitions="true" :type=statusType>
- {{ statusText }}
- </el-tag>
- </div>
- <div v-else-if="field === 'operate'">
- <div class="flex justify-center gap-2">
- <PermissionButton circle plain type="warning" @click="handleEdit(row)">
- <el-icon>
- <Operation />
- </el-icon>
- </PermissionButton>
- <PermissionButton circle plain type="danger" @click="handleDelete(row)">
- <el-icon>
- <Delete />
- </el-icon>
- </PermissionButton>
- </div>
- </div>
- <div v-else>
- {{ row.goods[field] }}
- </div>
- </div>
- </template>
- <style scoped>
- :deep(.flex-1 .el-progress__text) {
- font-size: 14px !important;
- }
- </style>
|