Compare commits

..

No commits in common. "87d55dac02ebd13264a6d826d3bde8a7ec71a7fc" and "3e7991b1a7177672cd44ee842bd72a2facd93d38" have entirely different histories.

6 changed files with 12 additions and 77 deletions

View File

@ -1,6 +1,4 @@
<template> <template />
<div />
</template>
<script setup> <script setup>
import { isNullOrUndef } from '@/utils/is' import { isNullOrUndef } from '@/utils/is'

View File

@ -1,10 +1,9 @@
<template> <template>
<div> <div>
<n-upload <n-upload
action="#"
:default-file-list="fileList" :default-file-list="fileList"
v-bind="getImgOptions" list-type="image-card"
:on-change="handleChange"
:on-before-upload="handleBeforeUpload"
> >
点击上传 点击上传
</n-upload> </n-upload>
@ -12,6 +11,7 @@
v-model:show="showModal" v-model:show="showModal"
preset="card" preset="card"
style="width: 600px" style="width: 600px"
title="一张很酷的图片"
> >
<img :src="previewImageUrl" style="width: 100%"> <img :src="previewImageUrl" style="width: 100%">
</n-modal> </n-modal>
@ -19,64 +19,18 @@
</template> </template>
<script> <script>
import { defineComponent, reactive, toRefs, computed, unref } from 'vue' export default {
import { getToken } from '@/utils/token'
export default defineComponent({
name: 'ImgUpload', name: 'ImgUpload',
props: { props: {
options: { options: {
type: Object, type: Object,
default: null default: null
},
size: {
type: Number,
default: null
} }
}, },
setup(props, { emit }) { setup() {
const data = reactive({
fileList: []
})
const BaseURL = window.__APP__GLOB__CONF__?.VITE_APP_GLOB_BASE_API || import.meta.env.VITE_APP_GLOB_BASE_API
const getImgOptions = computed(() => {
return {
...unref(props.options),
listType: 'image-card',
defaultUpload: props.options.defaultUpload || false,
action: `${BaseURL}${props.options.action}`,
headers: {
'Authorization': getToken(),
...props.options.headers
}
}
})
function handleChange(file) {
console.log(222, file)
}
/**
* @description: 上传前判断文件是否符合条件
* @param {*} options
* @return {*}
*/
function handleBeforeUpload(options) {
const { file, fileList } = options
console.log(11, file, fileList)
if (props.size) {
const size = file.file.size
if (size < props.size * 1024 * 1024) {
fileList.splice(fileList.length - 1)
$message.error('选择的文件大小不满足条件!')
}
}
}
return {
...toRefs(data),
getImgOptions,
handleChange,
handleBeforeUpload
}
} }
}) }
</script> </script>
<style scoped lang='scss'> <style scoped lang='scss'>

View File

@ -1,6 +1,4 @@
<template> <template />
<div />
</template>
<script setup> <script setup>
import { useMessage } from 'naive-ui' import { useMessage } from 'naive-ui'

View File

@ -14,7 +14,6 @@
import { defineComponent, computed } from 'vue' import { defineComponent, computed } from 'vue'
export default defineComponent({ export default defineComponent({
name: 'CardDialogModal',
props: { props: {
options: { options: {
type: Object, type: Object,

View File

@ -9,10 +9,4 @@
.layout__content{ .layout__content{
height: calc(100vh - 48px); height: calc(100vh - 48px);
} }
}
.n-data-table .n-data-table-tr{
th{
white-space:nowrap;
}
} }

View File

@ -11,14 +11,7 @@
label="头像:" label="头像:"
path="avatar" path="avatar"
> >
<uploadImage <n-upload
:options="{
max:1,
action: '/upload/uploadImage/demo',
}"
size="2"
/>
<!-- <n-upload
action="https://www.mocky.io/v2/5e4bafc63100007100d8b70f" action="https://www.mocky.io/v2/5e4bafc63100007100d8b70f"
:default-file-list="previewFileList" :default-file-list="previewFileList"
list-type="image-card" list-type="image-card"
@ -31,7 +24,7 @@
title="头像" title="头像"
> >
<img :src="form.avatar" style="width: 100%"> <img :src="form.avatar" style="width: 100%">
</n-modal> --> </n-modal>
</n-form-item> </n-form-item>
<n-form-item label="用户编号:" path="code"> <n-form-item label="用户编号:" path="code">
<n-input <n-input
@ -145,13 +138,12 @@
<script> <script>
import { defineComponent, computed, onMounted, reactive } from 'vue' import { defineComponent, computed, onMounted, reactive } from 'vue'
import Modal from '@/components/Modal/index.vue' import Modal from '@/components/Modal/index.vue'
import uploadImage from '@/components/ImgUpload/index.vue'
import { getDeptAll } from '@/api/system/dept/index' import { getDeptAll } from '@/api/system/dept/index'
import { getRoleAll } from '@/api/system/role/index' import { getRoleAll } from '@/api/system/role/index'
import { dataToSelect } from '@/utils/handleData.js' import { dataToSelect } from '@/utils/handleData.js'
export default defineComponent({ export default defineComponent({
name: 'UserModal', name: 'UserModal',
components: { Modal, uploadImage }, components: { Modal },
props: { props: {
visible: { visible: {
type: Boolean, type: Boolean,