abracadabra icon indicating copy to clipboard operation
abracadabra copied to clipboard

I didn't find a valid if statement to convert from current selection

Open yinluobing opened this issue 5 months ago • 5 comments

Describe the bug

I didn't find a valid if statement to convert from current selection I didn't find a valid...

Screenshots

vue3 typescript setup

<script lang="ts" setup>
import { bdApi } from '@/api/bd'
import { formatDate, getFutureDate } from '@/utils/date'
import { useDictData, useDictOptions } from '@/hooks/useDictOptions'
import { usePaging } from '@/hooks/usePaging'
import Popup from '@/components/popup/index.vue'
import FileItem from '@/components/material/file.vue'
import preview from '@/components/material/preview.vue'
import { number } from 'echarts';
import type { PropType } from 'vue'
const props = defineProps({
    userId: {
        // 弹窗标题
        type: [Number, String] as PropType<number | string>,
        required: true
    },
    pageNo: {
        // 页面
        type: [Number] as PropType<number>,
        default: 1
    },
})
const emit = defineEmits(['success', 'close'])
// const formRef = shallowRef<FormInstance>()
const imageList = shallowRef<InstanceType<typeof Popup>>()
const selectedImags = ref<any[]>([[], [], []])
const imageSize = ref('1140*640');
const filters = ref<any[]>([{ 'field': 'width', 'op': 'eq', 'values': '1140' }, { 'field': 'height', 'op': 'eq', 'values': '640' }])
const queryParams = reactive({
    api: "ImageManageService",
    fun: "getImageList",
    userId: props.userId,
    filters: filters,
})

watch(queryParams, (newQueryParams, oldQueryParams) => { getLists(); }, { deep: true })

const { pager, getLists, resetPage, resetParams } = usePaging({
    fetchFun: bdApi,
    params: queryParams,
    size: 6,
    page: props.pageNo
})
// one all three
const mode = ref('all')
const popupTitle = computed(() => {
    return mode.value = '图片列表'
})

const showPreview = ref(false)
const previewUrl = ref('')
const handlePreview = (row: any, index = -1) => {
    if (index == -1) {
        previewUrl.value = row.url
    } else {
        previewUrl.value = selectedImags.value[index].map((v: any) => v.url).join()
    }
    showPreview.value = true

}

const handleSubmit = async () => {
    imageList.value?.close();
    emit('success', pager.lists);
};


const handleDelete = async (row: any) => {

}

const handleSelectImageSize = async (v: any) => {
    if (v == '0') { queryParams.filters = [] } else {
        const imageSizeArr = imageSize.value.split('*')
        queryParams.filters = [{ 'field': 'width', 'op': 'eq', 'values': [imageSizeArr[0]] }, { 'field': 'height', 'op': 'eq', 'values': [imageSizeArr[1]] }]
    }
}

const handleSelectTables = async (v: any) => {
    if (imageSize.value == '1140*640') {
        if (mode.value == 'all') {
            selectedImags.value[0] = 1
        } else {
            selectedImags.value[0] = 2
        }
        // [...new Set([...v])]
    }
    if (imageSize.value == '640*1140') { selectedImags.value[1] = [...new Set([...v])] }
    if (imageSize.value == '750*1000') { selectedImags.value[2] = [...new Set([...v])] }
}

const handleAdd = async (row: any) => {
    emit('success', [row])
    imageList.value?.close()
}

const open = (type = 'all', filters = [{ 'field': 'width', 'op': 'eq', 'values': ['1140'] }, { 'field': 'height', 'op': 'eq', 'values': ['640'] }]) => {
    queryParams.filters = filters
    imageList.value?.open()
}

const handleClose = () => {
    emit('close')
    imageList.value?.close()
}
defineExpose({
    open,
})
getLists()
</script>

yinluobing avatar Sep 22 '24 03:09 yinluobing