fix: bug#18156
This commit is contained in:
parent
41ea25f927
commit
90104848c1
|
@ -25,7 +25,7 @@
|
|||
"event-source-polyfill": "^1.0.31",
|
||||
"global": "^4.4.0",
|
||||
"jetlinks-store": "^0.0.3",
|
||||
"jetlinks-ui-components": "^1.0.28",
|
||||
"jetlinks-ui-components": "^1.0.33",
|
||||
"js-cookie": "^3.0.1",
|
||||
"jsencrypt": "^3.3.2",
|
||||
"less": "^4.1.3",
|
||||
|
|
|
@ -1,5 +1,19 @@
|
|||
import { isObject, isArray } from 'lodash-es'
|
||||
|
||||
type TermsType = {
|
||||
column: string
|
||||
type: string
|
||||
value: string
|
||||
termsType: string
|
||||
terms: Array<TermsType>
|
||||
}
|
||||
|
||||
type ParamsType = {
|
||||
terms?: Array<TermsType>
|
||||
sorts?: Array<{name:string, order: string }>
|
||||
current?: any
|
||||
}
|
||||
|
||||
export const encodeParams = (params: Record<string, any>) => {
|
||||
const _params = new URLSearchParams()
|
||||
for (const key in params) {
|
||||
|
@ -10,6 +24,42 @@ export const encodeParams = (params: Record<string, any>) => {
|
|||
return _params.toString()
|
||||
}
|
||||
|
||||
const handleTermsToString = (queryTerms: any, terms: Array<TermsType>, parentKey?: string) => {
|
||||
terms.forEach((a, aIndex) => {
|
||||
Object.keys(a).forEach((b) => {
|
||||
const key = `${parentKey}[${aIndex}].${b}`
|
||||
if (b === 'terms') {
|
||||
handleTermsToString(queryTerms, a[b], `${key}.`)
|
||||
} else {
|
||||
queryTerms[key] = a[b]
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
export const paramsEncodeQuery = (params?: ParamsType) => {
|
||||
if (!params) return {}
|
||||
|
||||
const queryParams = {
|
||||
current: params.current,
|
||||
}
|
||||
|
||||
const { sorts, terms } = params
|
||||
|
||||
if (terms) {
|
||||
handleTermsToString(queryParams, terms, 'terms.')
|
||||
}
|
||||
|
||||
if (sorts) {
|
||||
sorts.forEach((item, index) => {
|
||||
queryParams[`sorts[${index}].name`] = item.name;
|
||||
queryParams[`sorts[${index}].order`] = item.order;
|
||||
})
|
||||
}
|
||||
return queryParams
|
||||
}
|
||||
|
||||
export default function encodeQuery(params: any) {
|
||||
if (!params) return {};
|
||||
const queryParam = {
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
<script lang="ts" setup>
|
||||
import { queryNoPagingPost } from '@/api/device/product';
|
||||
import { downloadFileByUrl } from '@/utils/utils';
|
||||
import encodeQuery from '@/utils/encodeQuery';
|
||||
import { paramsEncodeQuery } from '@/utils/encodeQuery';
|
||||
import { deviceExport } from '@/api/device/instance';
|
||||
|
||||
const emit = defineEmits(['close']);
|
||||
|
@ -88,7 +88,8 @@ const productName = computed(() => {
|
|||
})
|
||||
|
||||
const handleOk = async () => {
|
||||
const params = encodeQuery(props.data);
|
||||
console.log(props.data)
|
||||
const params = paramsEncodeQuery(props.data);
|
||||
// downloadFile(
|
||||
// deviceExport(modelRef.product || '', modelRef.fileType),
|
||||
// params,
|
||||
|
@ -109,4 +110,4 @@ const handleOk = async () => {
|
|||
const handleCancel = () => {
|
||||
emit('close');
|
||||
};
|
||||
</script>
|
||||
</script>
|
||||
|
|
32
yarn.lock
32
yarn.lock
|
@ -3738,33 +3738,18 @@ jetlinks-store@^0.0.3:
|
|||
resolved "https://registry.npmjs.org/jetlinks-store/-/jetlinks-store-0.0.3.tgz"
|
||||
integrity sha512-AZf/soh1hmmwjBZ00fr1emuMEydeReaI6IBTGByQYhTmK1Zd5pQAxC7WLek2snRAn/HHDgJfVz2hjditKThl6Q==
|
||||
|
||||
jetlinks-ui-components@^1.0.23:
|
||||
version "1.0.26"
|
||||
resolved "http://registry.jetlinks.cn/jetlinks-ui-components/-/jetlinks-ui-components-1.0.26.tgz#26896c578396b09d49649ac87c3943491af3a9ae"
|
||||
integrity sha512-HkLk52C6pDKe/Ca9O4w34h1/PrC7GdBUheiicPOX2V/Lc49N+WzI9wmrCd82XBm8MocPM4gAOJxNaTxY20EO9w==
|
||||
jetlinks-ui-components@^1.0.33:
|
||||
version "1.0.33"
|
||||
resolved "http://registry.jetlinks.cn/jetlinks-ui-components/-/jetlinks-ui-components-1.0.33.tgz#49ce2b8c1e7be66272864728d5df82f834ec4490"
|
||||
integrity sha512-vYUP4MhzO6r0golmKqO8lHk8w5ldhAkgXWZfFII1Zoa7JtUwveqpSywTU23iSmCN+4muPaSLvHw713k6OdzLmg==
|
||||
dependencies:
|
||||
"@vueuse/core" "^9.12.0"
|
||||
"@vueuse/router" "^9.13.0"
|
||||
ant-design-vue "^3.2.15"
|
||||
colorpicker-v3 "^2.10.2"
|
||||
jetlinks-ui-components "^1.0.23"
|
||||
lodash-es "^4.17.21"
|
||||
monaco-editor "^0.40.0"
|
||||
sortablejs "^1.15.0"
|
||||
vuedraggable "^4.1.0"
|
||||
|
||||
jetlinks-ui-components@^1.0.28:
|
||||
version "1.0.28"
|
||||
resolved "http://registry.jetlinks.cn/jetlinks-ui-components/-/jetlinks-ui-components-1.0.28.tgz#5b26937f9a0dc7e02006d230944d9044ea9fb4ee"
|
||||
integrity sha512-yuxOswVTAcR5hevPoxtfdZnosiGy+KmoPMWxShr3B2UDAMybNjps10nKKMsn70Tdvm5VnYZFw5GvTktRxyr/JA==
|
||||
dependencies:
|
||||
"@vueuse/core" "^9.12.0"
|
||||
"@vueuse/router" "^9.13.0"
|
||||
ant-design-vue "^3.2.15"
|
||||
colorpicker-v3 "^2.10.2"
|
||||
jetlinks-ui-components "^1.0.23"
|
||||
lodash-es "^4.17.21"
|
||||
monaco-editor "^0.40.0"
|
||||
onigasm "^2.2.5"
|
||||
sortablejs "^1.15.0"
|
||||
vuedraggable "^4.1.0"
|
||||
|
||||
|
@ -5101,6 +5086,13 @@ onetime@^6.0.0:
|
|||
dependencies:
|
||||
mimic-fn "^4.0.0"
|
||||
|
||||
onigasm@^2.2.5:
|
||||
version "2.2.5"
|
||||
resolved "http://registry.jetlinks.cn/onigasm/-/onigasm-2.2.5.tgz#cc4d2a79a0fa0b64caec1f4c7ea367585a676892"
|
||||
integrity sha512-F+th54mPc0l1lp1ZcFMyL/jTs2Tlq4SqIHKIXGZOR/VkHkF9A7Fr5rRr5+ZG/lWeRsyrClLYRq7s/yFQ/XhWCA==
|
||||
dependencies:
|
||||
lru-cache "^5.1.1"
|
||||
|
||||
only@0.0.2:
|
||||
version "0.0.2"
|
||||
resolved "https://registry.jetlinks.cn/only/-/only-0.0.2.tgz"
|
||||
|
|
Loading…
Reference in New Issue