Merge branch 'master' of http://gitea.zianxin.com/zianxin-tec/biz-pc-cloud
This commit is contained in:
commit
5ee54bc7d8
16 files changed
+562
-77
No files matched your search
@@ -0,0 +1,55 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-button :style="jsonViewStyle" type="text" link @click="jsonViewVisible = true">
|
||||
<div :style="jsonViewStyle" class="json-view">{{ jsonView }}</div>
|
||||
</el-button>
|
||||
<el-dialog append-to-body v-model="jsonViewVisible">
|
||||
<vue-json-pretty :data="jsonData" showLength showLineNumber showIcon :collapsedOnClickBrackets="false" />
|
||||
<template #footer>
|
||||
<el-button @click="jsonViewVisible = false">关闭</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup name="preview-json">
|
||||
import VueJsonPretty from "vue-json-pretty"
|
||||
import "vue-json-pretty/lib/styles.css"
|
||||
|
||||
type Props = {
|
||||
width?: number
|
||||
json?: string
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
width: 0,
|
||||
json: "",
|
||||
})
|
||||
|
||||
const jsonViewVisible = ref<boolean>(false)
|
||||
|
||||
const jsonData = computed(() => {
|
||||
if (!props.json) return ""
|
||||
if (typeof props.json == "string") return JSON.parse(props.json)
|
||||
return props.json
|
||||
})
|
||||
|
||||
const jsonView = computed(() => {
|
||||
if (!props.json) return ""
|
||||
if (typeof props.json != "string") return JSON.stringify(props.json)
|
||||
return props.json
|
||||
})
|
||||
|
||||
const jsonViewStyle = computed(() => {
|
||||
if (!props.width) return { width: "160px !important" }
|
||||
return { width: `${props.width}px !important` }
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.json-view {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,115 @@
|
||||
<template>
|
||||
<el-select
|
||||
style="width: 100%"
|
||||
v-model="state.selectId"
|
||||
:placeholder="props.placeholder"
|
||||
:clearable="props.clearable"
|
||||
remote-show-suffix
|
||||
filterable
|
||||
remote
|
||||
:disabled="props.disabled"
|
||||
:remote-method="remoteSearch"
|
||||
:loading="state.loading"
|
||||
@visible-change="(e: boolean) => e && getOptions()"
|
||||
@change="change"
|
||||
>
|
||||
<el-option v-for="v in state.options" :key="v.id" :label="`${v.deviceCode}-${v.cabinetNo}`" :value="v.id">
|
||||
<div class="flex items-center">
|
||||
<div class="color-primary">{{ v.deviceCode }}-{{ v.cabinetNo }}</div>
|
||||
<div class="flex items-center justify-center ml5">
|
||||
<el-tag size="small"> {{ v.hardName }} </el-tag>
|
||||
</div>
|
||||
</div>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="select-wallet-type">
|
||||
import { reactive } from "vue"
|
||||
import { useDict } from "/@/hooks/dict"
|
||||
import * as hardDoorManagerApi from "/@/api/hard/hard-door-manager"
|
||||
|
||||
const emit = defineEmits(["change"])
|
||||
|
||||
const selectId = defineModel()
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
placeholder?: string
|
||||
disabled?: boolean
|
||||
clearable?: boolean
|
||||
autoFirst?: boolean
|
||||
apiParams?: any
|
||||
}>(),
|
||||
{
|
||||
placeholder: "请选择",
|
||||
disabled: false,
|
||||
clearable: true,
|
||||
autoFirst: false,
|
||||
apiParams: {},
|
||||
},
|
||||
)
|
||||
|
||||
const queryForm = reactive<any>({
|
||||
cabinetNo: "",
|
||||
current: 1,
|
||||
size: 10,
|
||||
})
|
||||
|
||||
const state = reactive<any>({
|
||||
loading: true,
|
||||
selectId: selectId,
|
||||
options: [],
|
||||
walletType: [],
|
||||
})
|
||||
|
||||
watch(
|
||||
selectId,
|
||||
(newVal, oldValue) => {
|
||||
if (newVal == oldValue) return
|
||||
state.selectId = newVal
|
||||
getOptions()
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
async function getOptions() {
|
||||
try {
|
||||
state.loading = true
|
||||
const _pa = {
|
||||
...queryForm,
|
||||
...props.apiParams,
|
||||
}
|
||||
const { data } = await hardDoorManagerApi.selectCabinet(_pa)
|
||||
state.options = data.records ?? []
|
||||
if (props.autoFirst && state.options.length != 0) {
|
||||
state.selectId = state.options[0].id
|
||||
emit("change", selectId)
|
||||
}
|
||||
const { wallet_type } = useDict("wallet_type")
|
||||
state.walletType = wallet_type
|
||||
} finally {
|
||||
setTimeout(() => (state.loading = false), 500)
|
||||
}
|
||||
}
|
||||
|
||||
function remoteSearch(params: string) {
|
||||
if (params != queryForm.cabinetNo) {
|
||||
queryForm.cabinetNo = params
|
||||
getOptions()
|
||||
}
|
||||
}
|
||||
|
||||
function clear() {
|
||||
state.selectId = null
|
||||
getOptions()
|
||||
}
|
||||
|
||||
function change() {
|
||||
emit("change", selectId)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
props.autoFirst && getOptions()
|
||||
})
|
||||
</script>
|
||||
@@ -12,6 +12,7 @@ import Tip from "/@/components/Tip/index.vue"
|
||||
import TagList from "/@/components/TagList/index.vue"
|
||||
import SvgIcon from "/@/components/SvgIcon/index.vue"
|
||||
import PreviewImage from "/@/components/PreviewImage/index.vue"
|
||||
import PreviewJson from "/@/components/PreviewJson/index.vue"
|
||||
import DraggableDepTree from "/@/components/DraggableDepTree/index.vue"
|
||||
|
||||
// 业务组件
|
||||
@@ -31,6 +32,7 @@ import SelectHard from "/@/components/Select/SelectHard.vue"
|
||||
import SelectHardSpu from "/@/components/Select/SelectHardSpu.vue"
|
||||
import SelectHardGroup from "/@/components/Select/selectHardGroup.vue"
|
||||
import SelectRole from "/@/components/Select/SelectRole.vue"
|
||||
import SelectCabinet from "/@/components/Select/SelectCabinet.vue"
|
||||
|
||||
// 第三方组件
|
||||
import ElementPlus from "element-plus"
|
||||
@@ -66,6 +68,7 @@ export default {
|
||||
app.component("TagList", TagList)
|
||||
app.component("SvgIcon", SvgIcon)
|
||||
app.component("PreviewImage", PreviewImage)
|
||||
app.component("PreviewJson", PreviewJson)
|
||||
app.component("DraggableDepTree", DraggableDepTree)
|
||||
app.component("TreeMultipleSelect", TreeMultipleSelect)
|
||||
app.component("SelectHard", SelectHard)
|
||||
@@ -83,6 +86,7 @@ export default {
|
||||
app.component("SelectSupplier", SelectSupplier)
|
||||
app.component("SelectMchRule", SelectMchRule)
|
||||
app.component("SelectRole", SelectRole)
|
||||
app.component("SelectCabinet", SelectCabinet)
|
||||
|
||||
// 导入全部的elmenet-plus的图标
|
||||
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
||||
|
||||
Reference in new issue
Block a user