From b52018589bf6c7ec1d51ce8ad000a7aa993b0ab5 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期一, 13 四月 2026 16:06:15 +0800
Subject: [PATCH] 优化组盘表获取成品编号、流水号、供方代码
---
代码管理/WIDESEAWCS_Client/src/components/basic/VolUpload.vue | 248 ++++++++++++++++++++++++-------------------------
1 files changed, 121 insertions(+), 127 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WIDESEAWCS_Client/src/components/basic/VolUpload.vue" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WIDESEAWCS_Client/src/components/basic/VolUpload.vue"
index 4c7d696..87a2af7 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WIDESEAWCS_Client/src/components/basic/VolUpload.vue"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WIDESEAWCS_Client/src/components/basic/VolUpload.vue"
@@ -40,9 +40,7 @@
</div>
</div>
</div>
- <el-button v-else @click="handleClick"
- >閫夋嫨{{ img ? '鍥剧墖' : '鏂囦欢' }}</el-button
- >
+ <el-button v-else @click="handleClick">閫夋嫨{{ img ? "鍥剧墖" : "鏂囦欢" }}</el-button>
<el-button
v-if="!autoUpload && !img"
@@ -83,7 +81,7 @@
</div>
</template>
<script>
-let OSS = require('ali-oss');
+let OSS = require("ali-oss");
export default {
components: {},
props: {
@@ -91,62 +89,62 @@
//鏄惁鏄剧ず榛樿浠嬬粛
//鏄惁澶氶��
type: Boolean,
- default: false
+ default: false,
},
fileInfo: {
//鐢ㄤ簬鎺ユ敹涓婁紶鐨勬枃浠讹紝涔熷彲浠ュ姞浠ラ粯璁ゅ�硷紝鏄剧ず宸蹭笂浼犵殑鏂囦欢锛岀敤鎴蜂笂浼犲悗浼氳鐩栭粯璁ゅ��
type: Array,
default: () => {
return [];
- } //鏍煎紡[{name:'1.jpg',path:'127.0.01/1.jpg'}]
+ }, //鏍煎紡[{name:'1.jpg',path:'127.0.01/1.jpg'}]
},
downLoad: {
//鏄惁鍙互鐐瑰嚮鏂囦欢涓嬭浇
type: Boolean,
- default: true
+ default: true,
},
multiple: {
//鏄惁澶氶��
type: Boolean,
- default: false
+ default: false,
},
maxFile: {
//鏈�澶氬彲閫夋枃浠舵暟閲忥紝蹇呴』multiple=true锛屾墠浼氱敓鏁�
type: Number,
- default: 5
+ default: 5,
},
maxSize: {
//鏂囦欢闄愬埗澶у皬3M
type: Number,
- default: 50
+ default: 50,
},
autoUpload: {
//閫夋嫨鏂囦欢鍚庢槸鍚﹁嚜鍔ㄤ笂浼�
type: Boolean,
- default: true
+ default: true,
},
img: {
//鍥剧墖绫诲瀷 img>excel>fileTypes涓夌鏂囦欢绫诲瀷浼樺厛绾�
type: Boolean,
- default: false
+ default: false,
},
excel: {
//excel鏂囦欢
type: Boolean,
- default: false
+ default: false,
},
fileTypes: {
//鎸囧畾涓婁紶鏂囦欢鐨勭被鍨�
type: Array,
default: () => {
return [];
- }
+ },
},
url: {
//涓婁紶鐨剈rl
type: String,
- default: ''
+ default: "",
},
uploadBefore: {
//杩斿洖false浼氫腑姝㈡墽琛�
@@ -154,7 +152,7 @@
type: Function,
default: (files) => {
return true;
- }
+ },
},
uploadAfter: {
//杩斿洖false浼氫腑姝㈡墽琛�
@@ -162,14 +160,14 @@
type: Function,
default: (result, files) => {
return true;
- }
+ },
},
onChange: {
//閫夋嫨鏂囦欢鏃� //杩斿洖false浼氫腑姝㈡墽琛�
type: Function,
default: (files) => {
return true;
- }
+ },
},
// clear: {
// //涓婁紶瀹屾垚鍚庢槸鍚︽竻绌烘枃浠跺垪琛�
@@ -179,48 +177,48 @@
fileList: {
//鏄惁鏄剧ず閫夋嫨鐨勬枃浠跺垪琛�
type: Boolean,
- default: true
+ default: true,
},
fileClick: {
//鐐瑰嚮鏂囦欢浜嬩欢
type: Function,
default: (index, file, files) => {
return true;
- }
+ },
},
removeBefore: {
//绉婚櫎鏂囦欢浜嬩欢
type: Function,
default: (index, file, files) => {
return true;
- }
+ },
},
append: {
//姝ゅ睘鎬у凡搴熷純锛屽鏂囦欢涓婁紶锛岄粯璁よ拷鍔犳枃浠�
type: Boolean,
- default: false
+ default: false,
},
compress: {
//寮�鍚浘鐗囧帇缂�,鍚庨潰鏍规嵁闇�瑕佸啀瀹屽杽
type: Boolean,
- default: true
+ default: true,
},
compressMinSize: {
//鍘嬬缉鐨勬渶灏忔瘮渚�
type: Number,
- default: 0.1
- }
+ default: 0.1,
+ },
},
data() {
return {
- errorImg: 'this.src="' + require('@/assets/imgs/error-img.png') + '"',
+ errorImg: 'this.src="' + require("@/assets/imgs/error-img.png") + '"',
changed: false, //鎵嬪姩涓婁紶鎴愬姛鍚庣姝㈤噸澶嶄笂浼狅紝蹇呴』閲嶆柊閫夋嫨
model: true,
files: [],
- bigImg: '',
- imgTypes: ['gif', 'jpg', 'jpeg', 'png', 'bmp', 'webp', 'jfif'],
+ bigImg: "",
+ imgTypes: ["gif", "jpg", "jpeg", "png", "bmp", "webp", "jfif"],
loadingStatus: false,
- loadText: '涓婁紶鏂囦欢'
+ loadText: "涓婁紶鏂囦欢",
};
},
created() {
@@ -235,23 +233,23 @@
handler(files) {
this.cloneFile(files);
},
- deep: true
- }
+ deep: true,
+ },
},
methods: {
cloneFile(files) {
this.files = files.map((x) => {
return {
name: x.name || this.getFileName(x.path),
- path: x.path
+ path: x.path,
};
});
},
getFileName(path) {
if (!path) {
- return '鏈畾涔夋枃浠跺悕';
+ return "鏈畾涔夋枃浠跺悕";
}
- let _index = path.lastIndexOf('/');
+ let _index = path.lastIndexOf("/");
return path.substring(_index + 1);
},
previewImg(index) {
@@ -261,20 +259,20 @@
},
getSelector() {
if (this.autoUpload) {
- return 'auto-selector';
+ return "auto-selector";
}
- return 'submit-selector';
+ return "submit-selector";
},
getImgSrc(file, index) {
- if (file.hasOwnProperty('path')) {
+ if (file.hasOwnProperty("path")) {
if (this.base.isUrl(file.path)) {
return file.path;
}
//2020.12.27澧炲姞base64鍥剧墖鎿嶄綔
- if (file.path.indexOf('/9j/') != -1) {
- return 'data:image/jpeg;base64,' + file.path;
+ if (file.path.indexOf("/9j/") != -1) {
+ return "data:image/jpeg;base64," + file.path;
}
- if (file.path.substr(0, 1) == '/') {
+ if (file.path.substr(0, 1) == "/") {
file.path = file.path.substr(1);
}
return this.http.ipAddress + file.path;
@@ -290,23 +288,23 @@
return;
}
if (!file.path) {
- this.$message.error('璇峰厛涓婁紶鏂囦欢');
+ this.$message.error("璇峰厛涓婁紶鏂囦欢");
return;
}
this.base.dowloadFile(
file.path,
file.name,
{
- Authorization: this.$store.getters.getToken()
+ Authorization: this.$store.getters.getToken(),
},
this.http.ipAddress
);
},
getText() {
if (this.img) {
- return '鍙兘涓婁紶鍥剧墖,';
+ return "鍙兘涓婁紶鍥剧墖,";
} else if (this.excel) {
- return '鍙兘涓婁紶excel鏂囦欢,';
+ return "鍙兘涓婁紶excel鏂囦欢,";
}
},
handleClick() {
@@ -360,9 +358,9 @@
return this.files;
},
convertToFile(dataurl, filename) {
- let arr = dataurl.split(',');
+ let arr = dataurl.split(",");
let mime = arr[0].match(/:(.*?);/)[1];
- let suffix = mime.split('/')[1];
+ let suffix = mime.split("/")[1];
let bstr = atob(arr[1]);
let n = bstr.length;
let u8arr = new Uint8Array(n);
@@ -373,7 +371,7 @@
// 绗笁涓弬鏁版槸 瑕佹斁鍒版枃浠朵腑鐨勫唴瀹圭殑 MIME 绫诲瀷
return new File([u8arr], `${filename}.${suffix}`, {
type: mime,
- input: true
+ input: true,
});
},
async compressImg(file) {
@@ -385,14 +383,14 @@
let img = new Image();
img.src = e.target.result;
let _this = this;
- img.onload = function() {
+ img.onload = function () {
//榛樿鎸夋瘮渚嬪帇缂�
let w = this.width;
let h = this.height;
- let canvas = document.createElement('canvas');
- let ctx = canvas.getContext('2d');
- canvas.setAttribute('width', w);
- canvas.setAttribute('height', h);
+ let canvas = document.createElement("canvas");
+ let ctx = canvas.getContext("2d");
+ canvas.setAttribute("width", w);
+ canvas.setAttribute("height", h);
ctx.drawImage(this, 0, 0, w, h);
let rate = 0.3;
if (fileSize > 2) {
@@ -404,14 +402,14 @@
rate = _this.compressMinSize;
}
// rate=1;
- let base64 = canvas.toDataURL('image/jpeg', rate);
+ let base64 = canvas.toDataURL("image/jpeg", rate);
resolve(_this.convertToFile(base64, file.name));
};
};
});
},
async uploadOSS() {
- this.http.get('api/alioss/getAccessToken', {}, false).then(async (x) => {
+ this.http.get("api/alioss/getAccessToken", {}, false).then(async (x) => {
if (!x.status) return this.$Message.error(x.message);
let client = new OSS({
// yourRegion濉啓Bucket鎵�鍦ㄥ湴鍩熴�備互鍗庝笢1锛堟澀宸烇級涓轰緥锛孯egion濉啓涓簅ss-cn-hangzhou銆�
@@ -422,14 +420,14 @@
// 浠嶴TS鏈嶅姟鑾峰彇鐨勫畨鍏ㄤ护鐗岋紙SecurityToken锛夈��
stsToken: x.data.securityToken,
// 濉啓Bucket鍚嶇О銆�
- bucket: x.data.bucket
+ bucket: x.data.bucket,
});
console.log(this.files);
for (let index = 0; index < this.files.length; index++) {
const file = this.files[index];
if (file.input) {
let result = await client.put(
- x.data.bucketFolder + '/' + x.data.unique + file.name,
+ x.data.bucketFolder + "/" + x.data.unique + file.name,
file
);
file.path = result.url;
@@ -442,7 +440,7 @@
let _files = this.files.map((file) => {
return {
name: file.newName || file.name,
- path: file.path
+ path: file.path,
};
});
this.fileInfo.push(..._files);
@@ -454,41 +452,41 @@
async upload(vail) {
if (vail && !this.checkFile()) return false;
if (!this.url) {
- return this.$message.error('娌℃湁閰嶇疆濂経rl');
+ return this.$message.error("娌℃湁閰嶇疆濂経rl");
}
if (!this.files || this.files.length == 0) {
- return this.$message.error('璇烽�夋嫨鏂囦欢');
+ return this.$message.error("璇烽�夋嫨鏂囦欢");
}
//澧炲姞涓婁紶鏃惰嚜瀹氫箟鍙傛暟锛屽悗鍙颁娇鐢ㄨ幏鍙朥tilities.HttpContext.Current.Request.Query["瀛楁"]
- let params={};
- if (!this.uploadBefore(this.files,params)) {
+ let params = {};
+ if (!this.uploadBefore(this.files, params)) {
return;
}
- let paramText="";
+ let paramText = "";
if (Object.keys(params).length) {
- paramText="?1=1";
+ paramText = "?1=1";
for (const key in params) {
- let value=params[key];
- if(typeof(value)=='object'){
- value=JSON.stringify(value)
+ let value = params[key];
+ if (typeof value == "object") {
+ value = JSON.stringify(value);
}
- paramText+=`&${key}=${value}`
+ paramText += `&${key}=${value}`;
}
}
this.loadingStatus = true;
- this.loadText = '涓婁紶涓�..';
+ this.loadText = "涓婁紶涓�..";
if (window.oss && window.oss.ali.use) {
await this.uploadOSS();
this.loadingStatus = false;
- this.loadText = '涓婁紶鏂囦欢';
- if (!this.uploadAfter({status:true}, this.files)) {
+ this.loadText = "涓婁紶鏂囦欢";
+ if (!this.uploadAfter({ status: true }, this.files)) {
this.changed = false;
return;
} else {
this.changed = true;
}
- this.$message.success('涓婁紶鎴愬姛');
+ this.$message.success("涓婁紶鎴愬姛");
return;
}
@@ -496,32 +494,32 @@
for (let index = 0; index < this.files.length; index++) {
let file = this.files[index];
if (file.input) {
- let name = file.name.split('.');
+ let name = file.name.split(".");
name = name[name.length - 1].toLocaleLowerCase();
let isImg = this.imgTypes.indexOf(name) != -1;
- if (isImg && (name == 'jpg' || name == 'jpeg')) {
+ if (isImg && (name == "jpg" || name == "jpeg")) {
//>200KB鐨勫紑鍚帇缂�
if (isImg && file.size / 1024 / 1024 > 0.2) {
- console.log('鍘嬬缉鍓�' + file.size);
+ console.log("鍘嬬缉鍓�" + file.size);
file = await this.compressImg(file);
file.compress = true;
this.files[index] = file;
this.files[index].input = true;
- console.log('鍘嬬缉鍚�' + file.size);
+ console.log("鍘嬬缉鍚�" + file.size);
}
}
- forms.append('fileInput', file, file.name);
+ forms.append("fileInput", file, file.name);
}
}
// forms.append("fileInput", this.files);
this.http
- .post(this.url+paramText, forms, this.autoUpload ? '姝e湪涓婁紶鏂囦欢' : '')
+ .post(this.url + paramText, forms, this.autoUpload ? "姝e湪涓婁紶鏂囦欢" : "")
.then(
(x) => {
// this.$refs.uploadFile.clearFiles();
this.loadingStatus = false;
- this.loadText = '涓婁紶鏂囦欢';
+ this.loadText = "涓婁紶鏂囦欢";
if (!this.uploadAfter(x, this.files)) {
this.changed = false;
return;
@@ -541,7 +539,7 @@
let _files = this.files.map((file) => {
return {
name: file.name,
- path: file.path || x.data + file.name
+ path: file.path || x.data + file.name,
};
});
this.fileInfo.push(..._files);
@@ -549,18 +547,14 @@
this.files = _files;
},
(error) => {
- this.loadText = '涓婁紶鏂囦欢';
+ this.loadText = "涓婁紶鏂囦欢";
this.loadingStatus = false;
}
);
},
format(file, checkFileType) {
- const format =
- file.name
- .split('.')
- .pop()
- .toLocaleLowerCase() || '';
- let fileIcon = 'el-icon-document';
+ const format = file.name.split(".").pop().toLocaleLowerCase() || "";
+ let fileIcon = "el-icon-document";
if (this.fileTypes.length > 0 && checkFileType != undefined) {
if (this.fileTypes.indexOf(format) != -1) {
return true;
@@ -570,8 +564,8 @@
if (
checkFileType &&
!(checkFileType instanceof Array) &&
- checkFileType != 'img' &&
- checkFileType != 'excel'
+ checkFileType != "img" &&
+ checkFileType != "excel"
) {
if (checkFileType.indexOf(format) > -1) {
return true;
@@ -580,41 +574,39 @@
}
}
- if (checkFileType == 'img' || this.imgTypes.indexOf(format) > -1) {
- if (checkFileType == 'img') {
+ if (checkFileType == "img" || this.imgTypes.indexOf(format) > -1) {
+ if (checkFileType == "img") {
if (this.imgTypes.indexOf(format) > -1) {
return true;
} else {
return false;
}
}
- fileIcon = 'el-icon-picture-outline';
+ fileIcon = "el-icon-picture-outline";
}
if (
- ['mp4', 'm3u8', 'rmvb', 'avi', 'swf', '3gp', 'mkv', 'flv'].indexOf(
- format
- ) > -1
+ ["mp4", "m3u8", "rmvb", "avi", "swf", "3gp", "mkv", "flv"].indexOf(format) > -1
) {
- fileIcon = 'el-icon-document';
+ fileIcon = "el-icon-document";
}
- if (['mp3', 'wav', 'wma', 'ogg', 'aac', 'flac'].indexOf(format) > -1) {
- fileIcon = 'el-icon-document';
+ if (["mp3", "wav", "wma", "ogg", "aac", "flac"].indexOf(format) > -1) {
+ fileIcon = "el-icon-document";
}
- if (['doc', 'txt', 'docx', 'pages', 'epub', 'pdf'].indexOf(format) > -1) {
- fileIcon = 'el-icon-document';
+ if (["doc", "txt", "docx", "pages", "epub", "pdf"].indexOf(format) > -1) {
+ fileIcon = "el-icon-document";
}
if (
- checkFileType == 'excel' ||
- ['numbers', 'csv', 'xls', 'xlsx'].indexOf(format) > -1
+ checkFileType == "excel" ||
+ ["numbers", "csv", "xls", "xlsx"].indexOf(format) > -1
) {
- if (checkFileType == 'excel') {
- if (['numbers', 'csv', 'xls', 'xlsx'].indexOf(format) > -1) {
+ if (checkFileType == "excel") {
+ if (["numbers", "csv", "xls", "xlsx"].indexOf(format) > -1) {
return true;
} else {
return false;
}
}
- fileIcon = 'el-icon-document';
+ fileIcon = "el-icon-document";
}
return fileIcon;
},
@@ -627,11 +619,11 @@
files.length + (inputFiles || []).length > (this.maxFile || 5)
) {
this.$message.error(
- '鏈�澶氬彧鑳介�夈��' +
+ "鏈�澶氬彧鑳介�夈��" +
(this.maxFile || 5) +
- '銆�' +
- (this.img ? '寮犲浘鐗�' : '涓枃浠�') +
- ''
+ "銆�" +
+ (this.img ? "寮犲浘鐗�" : "涓枃浠�") +
+ ""
);
return false;
}
@@ -644,15 +636,15 @@
for (let index = 0; index < inputFiles.length; index++) {
const file = inputFiles[index];
if (names.indexOf(file.name) != -1) {
- file.name = '(' + index + ')' + file.name;
+ file.name = "(" + index + ")" + file.name;
}
names.push(file.name);
- if (this.img && !this.format(file, 'img')) {
- this.$message.error('閫夋嫨鐨勬枃浠躲��' + file.name + '銆戝彧鑳芥槸鍥剧墖鏍煎紡');
+ if (this.img && !this.format(file, "img")) {
+ this.$message.error("閫夋嫨鐨勬枃浠躲��" + file.name + "銆戝彧鑳芥槸鍥剧墖鏍煎紡");
return false;
}
- if (this.excel && !this.format(file, 'excel')) {
- this.$message.error('閫夋嫨鐨勬枃浠躲��' + file.name + '銆戝彧鑳芥槸excel鏂囦欢');
+ if (this.excel && !this.format(file, "excel")) {
+ this.$message.error("閫夋嫨鐨勬枃浠躲��" + file.name + "銆戝彧鑳芥槸excel鏂囦欢");
return false;
}
if (
@@ -661,28 +653,24 @@
!this.format(file, this.fileTypes)
) {
this.$message.error(
- '閫夋嫨鐨勬枃浠躲��' +
+ "閫夋嫨鐨勬枃浠躲��" +
file.name +
- '銆戝彧鑳芥槸銆�' +
- this.fileTypes.join(',') +
- '銆戞牸寮�'
+ "銆戝彧鑳芥槸銆�" +
+ this.fileTypes.join(",") +
+ "銆戞牸寮�"
);
return false;
}
if (file.size > (this.maxSize || 50) * 1024 * 1024) {
this.$message.error(
- '閫夋嫨鐨勬枃浠躲��' +
- file.name +
- '銆戜笉鑳借秴杩�:' +
- (this.maxSize || 50) +
- 'M'
+ "閫夋嫨鐨勬枃浠躲��" + file.name + "銆戜笉鑳借秴杩�:" + (this.maxSize || 50) + "M"
);
return false;
}
}
return true;
- }
- }
+ },
+ },
};
</script>
<style lang="less" scoped>
@@ -741,20 +729,26 @@
.img-selector {
position: relative;
cursor: pointer;
- margin: 0 10px 10px 0;
+ // margin: 0 10px 10px 0;
+ margin: 0px;
float: left;
- width: 65px;
- height: 65px;
+ width: 365px;
+ height: 365px;
border: 1px solid #c7c7c7;
overflow: hidden;
border-radius: 5px;
box-sizing: content-box;
+ background-image: url("~@/assets/test.png");
+ background-repeat: no-repeat;
+ background-position: center;
+ background-size: contain;
img {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
object-fit: cover;
+ // background-image: url("@/assets/logo.png");
}
.operation {
--
Gitblit v1.9.3