|  | @@ -0,0 +1,86 @@
 | 
	
		
			
				|  |  | +<template>
 | 
	
		
			
				|  |  | +  <CyDialog
 | 
	
		
			
				|  |  | +      :title
 | 
	
		
			
				|  |  | +      ignore-error
 | 
	
		
			
				|  |  | +      body-width="60%"
 | 
	
		
			
				|  |  | +      :body-height="windowSize"
 | 
	
		
			
				|  |  | +  >
 | 
	
		
			
				|  |  | +    <el-upload
 | 
	
		
			
				|  |  | +        v-model:fileList="fileList"
 | 
	
		
			
				|  |  | +        accept="image/png"
 | 
	
		
			
				|  |  | +        drag
 | 
	
		
			
				|  |  | +        :onSuccess
 | 
	
		
			
				|  |  | +        :headers
 | 
	
		
			
				|  |  | +        :action
 | 
	
		
			
				|  |  | +        list-type="picture"
 | 
	
		
			
				|  |  | +        :multiple
 | 
	
		
			
				|  |  | +    >
 | 
	
		
			
				|  |  | +      <el-icon class="el-icon--upload">
 | 
	
		
			
				|  |  | +        <UploadFilled/>
 | 
	
		
			
				|  |  | +      </el-icon>
 | 
	
		
			
				|  |  | +      <div class="el-upload__text">
 | 
	
		
			
				|  |  | +        拖拽上传 或 <em>点击上传</em>
 | 
	
		
			
				|  |  | +      </div>
 | 
	
		
			
				|  |  | +      <template #tip>
 | 
	
		
			
				|  |  | +        <div class="el-upload__tip">
 | 
	
		
			
				|  |  | +          尺寸小于500KB的 PNG 文件
 | 
	
		
			
				|  |  | +        </div>
 | 
	
		
			
				|  |  | +      </template>
 | 
	
		
			
				|  |  | +    </el-upload>
 | 
	
		
			
				|  |  | +  </CyDialog>
 | 
	
		
			
				|  |  | +</template>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +<script setup lang="ts">
 | 
	
		
			
				|  |  | +import {UploadFilled} from '@element-plus/icons-vue'
 | 
	
		
			
				|  |  | +import {isDev} from "@/utils/public";
 | 
	
		
			
				|  |  | +import {UploadFile, UploadFiles, UploadUserFile} from "element-plus";
 | 
	
		
			
				|  |  | +import {stringIsBlank} from "@/utils/blank-utils";
 | 
	
		
			
				|  |  | +import XEUtils from "xe-utils";
 | 
	
		
			
				|  |  | +import CyDialog from "@/components/cy/dialog/src/CyDialog.vue";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +const props = withDefaults(defineProps<{
 | 
	
		
			
				|  |  | +  code?: string,
 | 
	
		
			
				|  |  | +  name?: string
 | 
	
		
			
				|  |  | +}>(), {
 | 
	
		
			
				|  |  | +  code: null,
 | 
	
		
			
				|  |  | +  name: ''
 | 
	
		
			
				|  |  | +})
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +const windowSize = `calc(${window.innerHeight}px - 500px)`
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +const multiple = computed(() => {
 | 
	
		
			
				|  |  | +  return stringIsBlank(props.code)
 | 
	
		
			
				|  |  | +})
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +const title = multiple.value ? "批量上传,根据图片的名称上传,如(3891.png),格式为 工号.png" : props.name + ":上传签名"
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +const fileList = ref<UploadUserFile[]>([])
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +const url = isDev ? 'http://172.16.30.66:8706/' : 'http://172.16.32.167:8706'
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +const action = computed(() => {
 | 
	
		
			
				|  |  | +  if (multiple.value) {
 | 
	
		
			
				|  |  | +    return url + `/settings/putAutographImage`;
 | 
	
		
			
				|  |  | +  } else {
 | 
	
		
			
				|  |  | +    return url + `/settings/putAutographImage?code=${props.code}`;
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +})
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +const headers = {
 | 
	
		
			
				|  |  | +  token: localStorage.token
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +function onSuccess(response: any, uploadFile: UploadFile, uploadFiles: UploadFiles) {
 | 
	
		
			
				|  |  | +  const index = XEUtils.findLastIndexOf(fileList.value, (item: UploadUserFile) => {
 | 
	
		
			
				|  |  | +    return item.uid === uploadFile.uid;
 | 
	
		
			
				|  |  | +  })
 | 
	
		
			
				|  |  | +  if (response.code === 200) {
 | 
	
		
			
				|  |  | +    fileList.value[index] = {
 | 
	
		
			
				|  |  | +      ...fileList.value[index],
 | 
	
		
			
				|  |  | +      ...response.data
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  } else {
 | 
	
		
			
				|  |  | +    fileList.value[index].status = 'fail'
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +</script>
 |