Commit 5df94802 authored by xiangzj's avatar xiangzj

下配额,非配额,公关订单上传图片处理

parent d76d43e7
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
// "appid" : "__UNI__EDB6A1F", // "appid" : "__UNI__EDB6A1F",
"appid" : "__UNI__EDB6A1F", "appid" : "__UNI__EDB6A1F",
"description" : "订货系统", "description" : "订货系统",
"versionName" : "1.1.20", "versionName" : "1.1.40",
"versionCode" : "10120", "versionCode" : "10140",
"transformPx" : false, "transformPx" : false,
"app-plus" : { "app-plus" : {
/* 5+App特有相关 */ /* 5+App特有相关 */
......
{ {
"name": "wly", "name": "upload实用上传组件",
"version": "1.0.0", "version": "1.0.3",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
...@@ -46,6 +46,11 @@ ...@@ -46,6 +46,11 @@
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz",
"integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==" "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A=="
}, },
"image-tools": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/image-tools/-/image-tools-1.4.0.tgz",
"integrity": "sha512-TKtvJ6iUwM0mfaD4keMnk1ENHFC470QEjBfA3IlvKdEOufzvWbjbaoNcoyYq6HlViF8+d5tOS1ooE6j7CHf1lQ=="
},
"js-base64": { "js-base64": {
"version": "2.6.4", "version": "2.6.4",
"resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.6.4.tgz", "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.6.4.tgz",
......
...@@ -9,5 +9,8 @@ ...@@ -9,5 +9,8 @@
"图片上传", "图片上传",
"多图上传", "多图上传",
"多图选择" "多图选择"
] ],
"dependencies": {
"image-tools": "^1.4.0"
}
} }
...@@ -910,22 +910,22 @@ ...@@ -910,22 +910,22 @@
} }
} }
}, },
{ // {
"path": "pages/breakwords-clue/breakwords-clue", // "path": "pages/breakwords-clue/breakwords-clue",
"style": { // "style": {
"app-plus": { // "app-plus": {
"titleNView": { // "titleNView": {
"titleAlign": "left", // "titleAlign": "left",
"titleColor": "#333", // "titleColor": "#333",
"titleSize": "17px", // "titleSize": "17px",
"backgroundColor": "transparent", // "backgroundColor": "transparent",
"titleText": "提报市场违约线索", // "titleText": "提报市场违约线索",
"autoBackButton": true // "autoBackButton": true
}, // },
"bounce": "none" // "bounce": "none"
} // }
} // }
}, // },
{ {
"path": "pages/breakwords-clue-detail/breakwords-clue-detail", "path": "pages/breakwords-clue-detail/breakwords-clue-detail",
"style": { "style": {
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
</view> </view>
<view class="upload-block"> <view class="upload-block">
<uni-file-picker ref='files' limit="4" :auto-upload='false' v-model="fileList" file-mediatype="image" <uni-file-picker ref='files' limit="4" :auto-upload='false' v-model="fileList" file-mediatype="image"
:imageStyles="imageStyles" @select="select" @progress="progress" @success="success" @fail='fail'> :imageStyles="imageStyles" @select="select" @progress="progress" @success="success" @fail='fail' @delete='deletes'>
<text>+</text> <text>+</text>
</uni-file-picker> </uni-file-picker>
</view> </view>
...@@ -95,11 +95,15 @@ ...@@ -95,11 +95,15 @@
apiUpdateGroupOrder apiUpdateGroupOrder
} from '@/servers/groupOrder.js' } from '@/servers/groupOrder.js'
import {
base64ToHex
} from '@/utils/index.js'
import { import {
mapMutations, mapMutations,
mapState mapState
} from 'vuex' } from 'vuex'
import { pathToBase64, base64ToPath } from 'image-tools'
export default { export default {
data() { data() {
return { return {
...@@ -108,6 +112,7 @@ ...@@ -108,6 +112,7 @@
OBJECT_ID: '' OBJECT_ID: ''
}, },
fileList: [], fileList: [],
imgFileBase64: [],
flag: false flag: false
} }
}, },
...@@ -142,9 +147,10 @@ ...@@ -142,9 +147,10 @@
baseinfo, baseinfo,
INFO, INFO,
ITEM, ITEM,
ATTACHMENT
} = this.groupOrder } = this.groupOrder
let ATTACHMENT = this.groupOrder.ATTACHMENT
ATTACHMENT = [...ATTACHMENT, ...this.imgFileBase64]
const params = { const params = {
"MODE": "SAVE", "MODE": "SAVE",
INFO: { INFO: {
...@@ -234,9 +240,38 @@ ...@@ -234,9 +240,38 @@
progress(e) { progress(e) {
console.log('上传进度:', e) console.log('上传进度:', e)
}, },
deletes(e){
if(e.tempFile.uuid){
const arr = this.imgFileBase64.filter(item => item.uuid !== e.tempFile.uuid )
this.imgFileBase64 = [ ...arr ]
}else{
this.imgFileBase64 = []
}
},
// 选择文件 // 选择文件
select(e) { select(e) {
let _this = this
let fileObj = null
console.log('选择文件:', e) console.log('选择文件:', e)
e.tempFilePaths.forEach((url,idx)=>{
pathToBase64(url).then(base64 => {
fileObj = {
uuid: e.tempFiles[idx].uuid,
FILENAME: e.tempFiles[idx].name,
MIMETYPE: '',
DOC_TYPE: e.tempFiles[idx].fileType,
XCONTENT: base64ToHex(base64),
FILELENGTH: e.tempFiles[idx].size,
ZZFLD00002D: _this.userInfo.code,
ZZFLD00002D_DSCR: _this.userInfo.name,
}
_this.imgFileBase64.push(fileObj);
console.log('_this.imgFileBase64', _this.imgFileBase64)
})
.catch(error => {
console.error(error)
})
})
}, },
// 上传成功 // 上传成功
success(e) { success(e) {
......
...@@ -3,14 +3,15 @@ ...@@ -3,14 +3,15 @@
<view class="status_bar" :style="navHeight"></view> <view class="status_bar" :style="navHeight"></view>
<view class="listview"> <view class="listview">
<view class="cell-list"> <view class="cell-list">
<view class="cell-list-block" @click="goOrder('breakwords-clue')"> <!-- <view class="cell-list-block" @click="goOrder('breakwords-clue')">
<image class="icon-address" src="@/static/image/home_report@3x.png" mode="aspectFit"></image> <image class="icon-address" src="@/static/image/home_report@3x.png" mode="aspectFit"></image>
<view class="cell-list-block__content"> <view class="cell-list-block__content">
<text class="cell-list-block__title">提报线索</text> <text class="cell-list-block__title">提报线索</text>
<!-- <text class="cell-list-block__desc">Account inquiry</text> --> <text class="cell-list-block__desc">Account inquiry</text>
</view> </view>
<image class="icon-arrow" src="@/static/image/arrow_r@3x.png" mode="aspectFit"></image> <image class="icon-arrow" src="@/static/image/arrow_r@3x.png" mode="aspectFit"></image>
</view> 上传图片功能不能使用,上传图片是上传什么格式?支持base64,16进制
</view> -->
<view class="cell-list-block" @click="goOrder('breakwords-market')"> <view class="cell-list-block" @click="goOrder('breakwords-market')">
<image class="icon-address" src="@/static/image/home_marketclue@3x.png" mode="aspectFit"></image> <image class="icon-address" src="@/static/image/home_marketclue@3x.png" mode="aspectFit"></image>
<view class="cell-list-block__content"> <view class="cell-list-block__content">
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
</view> </view>
<view class="upload-block"> <view class="upload-block">
<uni-file-picker ref='files' limit="4" :auto-upload='false' v-model="fileList" file-mediatype="image" <uni-file-picker ref='files' limit="4" :auto-upload='false' v-model="fileList" file-mediatype="image"
:imageStyles="imageStyles" @select="select" @progress="progress" @success="success" @fail='fail'> :imageStyles="imageStyles" @select="select" @progress="progress" @success="success" @fail='fail' @delete='deletes' >
<text>+</text> <text>+</text>
</uni-file-picker> </uni-file-picker>
</view> </view>
...@@ -96,13 +96,15 @@ ...@@ -96,13 +96,15 @@
} from '@/servers/noQuotaOrder.js' } from '@/servers/noQuotaOrder.js'
import { import {
formatToUnit16Array formatToUnit16Array,
base64ToHex
} from '@/utils/index.js' } from '@/utils/index.js'
import { import {
mapMutations, mapMutations,
mapState mapState
} from 'vuex' } from 'vuex'
import { pathToBase64, base64ToPath } from 'image-tools'
export default { export default {
data() { data() {
...@@ -235,28 +237,62 @@ ...@@ -235,28 +237,62 @@
progress(e) { progress(e) {
console.log('上传进度:', e) console.log('上传进度:', e)
}, },
deletes(e){
if(e.tempFile.uuid){
const arr = this.imgFileBase64.filter(item => item.uuid !== e.tempFile.uuid )
this.imgFileBase64 = [ ...arr ]
}else{
this.imgFileBase64 = []
}
},
// 选择文件 // 选择文件
async select(e) { async select(e) {
console.log('选择文件:', e, this.fileList)
let _this = this let _this = this
const unit16Array = await formatToUnit16Array(e.tempFiles[0].file) let fileObj = null
let reader = new FileReader(); console.log('选择文件:', e)
let fileObj = { e.tempFilePaths.forEach((url,idx)=>{
FILENAME: e.tempFiles[0].name, pathToBase64(url).then(base64 => {
fileObj = {
uuid: e.tempFiles[idx].uuid,
FILENAME: e.tempFiles[idx].name,
MIMETYPE: '', MIMETYPE: '',
DOC_TYPE: e.tempFiles[0].fileType, DOC_TYPE: e.tempFiles[idx].fileType,
XCONTENT: unit16Array, XCONTENT: base64ToHex(base64),
FILELENGTH: e.tempFiles[0].size, FILELENGTH: e.tempFiles[idx].size,
ZZFLD00002D: this.userInfo.code, ZZFLD00002D: _this.userInfo.code,
ZZFLD00002D_DSCR: this.userInfo.name, ZZFLD00002D_DSCR: _this.userInfo.name,
}
reader.readAsDataURL(e.tempFiles[0].file);
reader.onload = function(e) {
// fileObj.XCONTENT = e.target.result;
_this.imgFileBase64.push(fileObj);
console.log('2222', e)
} }
_this.imgFileBase64.push(fileObj);
console.log('_this.imgFileBase64', _this.imgFileBase64)
})
.catch(error => {
console.error(error)
})
})
}, },
// async select(e) {
// console.log('选择文件:', e, this.fileList)
// let _this = this
// const unit16Array = await formatToUnit16Array(e.tempFiles[0].file)
// let reader = new FileReader();
// let fileObj = {
// FILENAME: e.tempFiles[0].name,
// MIMETYPE: '',
// DOC_TYPE: e.tempFiles[0].fileType,
// XCONTENT: unit16Array,
// FILELENGTH: e.tempFiles[0].size,
// ZZFLD00002D: this.userInfo.code,
// ZZFLD00002D_DSCR: this.userInfo.name,
// }
// reader.readAsDataURL(e.tempFiles[0].file);
// reader.onload = function(e) {
// // fileObj.XCONTENT = e.target.result;
// _this.imgFileBase64.push(fileObj);
// console.log('2222', e)
// }
// },
// 上传成功 // 上传成功
success(e) { success(e) {
console.log('上传成功', e) console.log('上传成功', e)
......
...@@ -256,7 +256,7 @@ ...@@ -256,7 +256,7 @@
_this.orderItem.contactNumber = data.selectShuntAdressAccountInfo.TEL_NUMBER _this.orderItem.contactNumber = data.selectShuntAdressAccountInfo.TEL_NUMBER
_this.orderItem.contacPerson = data.selectShuntAdressAccountInfo.C_O_NAME _this.orderItem.contacPerson = data.selectShuntAdressAccountInfo.C_O_NAME
_this.orderItem.spurtCodeUnitName = data.selectShuntAdressAccountInfo.PARTNER_NAME _this.orderItem.spurtCodeUnitName = data.selectShuntAdressAccountInfo.PARTNER_NAME
_this.getReceipt(_this.orderItem.shuntDealer) _this.getReceipt(_this.orderItem.shuntDealer, true)
}) })
uni.$on('selectShuntCode', function(data) { uni.$on('selectShuntCode', function(data) {
console.log('监听到事件来自 selectShuntCode ,携带参数 msg 为:', data); console.log('监听到事件来自 selectShuntCode ,携带参数 msg 为:', data);
...@@ -334,13 +334,14 @@ ...@@ -334,13 +334,14 @@
} }
const { data } = await findByCustomer(params) const { data } = await findByCustomer(params)
}, },
async getReceipt(partner = this.orderItem.customerCode){ async getReceipt(partner = this.orderItem.customerCode, flag=false){
const params = { const params = {
partner, partner,
'role': "WLY001" 'role': "WLY001"
} }
const res = await getReceipt(params) const res = await getReceipt(params)
this.receiveUnitArr = res.DATA this.receiveUnitArr = res.DATA
if(flag)return
this.orderItem.receiveUnitName = this.receiveUnitArr[0].PARTNER_NAME this.orderItem.receiveUnitName = this.receiveUnitArr[0].PARTNER_NAME
this.orderItem.receiveUnitCode = this.receiveUnitArr[0].PARTNER this.orderItem.receiveUnitCode = this.receiveUnitArr[0].PARTNER
this.orderItem.spurtCodeUnitName = this.receiveUnitArr[0].PARTNER_NAME this.orderItem.spurtCodeUnitName = this.receiveUnitArr[0].PARTNER_NAME
......
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
</view> </view>
<view class="upload-block"> <view class="upload-block">
<uni-file-picker ref='files' limit="4" :auto-upload='false' v-model="fileList" file-mediatype="image" <uni-file-picker ref='files' limit="4" :auto-upload='false' v-model="fileList" file-mediatype="image"
:imageStyles="imageStyles" @select="select" @progress="progress" @success="success" @fail='fail'> :imageStyles="imageStyles" @select="select" @progress="progress" @success="success" @fail='fail' @delete='deletes'>
<text>+</text> <text>+</text>
</uni-file-picker> </uni-file-picker>
</view> </view>
...@@ -145,11 +145,15 @@ ...@@ -145,11 +145,15 @@
apiUpdateQuotaOrder apiUpdateQuotaOrder
} from '@/servers/quotaOrder.js' } from '@/servers/quotaOrder.js'
import {
base64ToHex
} from '@/utils/index.js'
import { import {
mapMutations, mapMutations,
mapState mapState
} from 'vuex' } from 'vuex'
import { pathToBase64, base64ToPath } from 'image-tools'
export default { export default {
data() { data() {
return { return {
...@@ -157,6 +161,7 @@ ...@@ -157,6 +161,7 @@
orderInfo: { orderInfo: {
OBJECT_ID: '' OBJECT_ID: ''
}, },
imgFileBase64: [],
fileList: [], fileList: [],
flag: false flag: false
} }
...@@ -195,8 +200,10 @@ ...@@ -195,8 +200,10 @@
INFO, INFO,
ITEM_INNER, ITEM_INNER,
ITEM_OUTER, ITEM_OUTER,
ATTACHMENT
} = this.quotaOrder } = this.quotaOrder
let ATTACHMENT = this.quotaOrder.ATTACHMENT
ATTACHMENT = [...ATTACHMENT, ...this.imgFileBase64]
const params = { const params = {
"USER_BP": this.userInfo.code, "USER_BP": this.userInfo.code,
"ROLE": 'WLY001', "ROLE": 'WLY001',
...@@ -290,9 +297,38 @@ ...@@ -290,9 +297,38 @@
progress(e) { progress(e) {
console.log('上传进度:', e) console.log('上传进度:', e)
}, },
deletes(e){
if(e.tempFile.uuid){
const arr = this.imgFileBase64.filter(item => item.uuid !== e.tempFile.uuid )
this.imgFileBase64 = [ ...arr ]
}else{
this.imgFileBase64 = []
}
},
// 选择文件 // 选择文件
select(e) { select(e) {
console.log('选择文件:', e, this.fileList) let _this = this
let fileObj = null
console.log('选择文件:', e)
e.tempFilePaths.forEach((url,idx)=>{
pathToBase64(url).then(base64 => {
fileObj = {
uuid: e.tempFiles[idx].uuid,
FILENAME: e.tempFiles[idx].name,
MIMETYPE: '',
DOC_TYPE: e.tempFiles[idx].fileType,
XCONTENT: base64ToHex(base64),
FILELENGTH: e.tempFiles[idx].size,
ZZFLD00002D: _this.userInfo.code,
ZZFLD00002D_DSCR: _this.userInfo.name,
}
_this.imgFileBase64.push(fileObj);
console.log('_this.imgFileBase64', _this.imgFileBase64)
})
.catch(error => {
console.error(error)
})
})
}, },
// 上传成功 // 上传成功
success(e) { success(e) {
......
...@@ -46,6 +46,17 @@ function deepMerge(target = {}, source = {}) { ...@@ -46,6 +46,17 @@ function deepMerge(target = {}, source = {}) {
} }
return target; return target;
} }
// base64转成16进制
function base64ToHex(str) {
const str1 = str.replace(/^data:image\/\w+;base64,/, "")
const raw = atob(str1);
let result = '';
for (let i = 0; i < raw.length; i++) {
const hex = raw.charCodeAt(i).toString(16);
result += (hex.length === 2 ? hex : '0' + hex);
}
return result.toUpperCase();
}
// 转成十六进制 // 转成十六进制
function formatToUnit16Array(file) { function formatToUnit16Array(file) {
...@@ -90,5 +101,6 @@ export { ...@@ -90,5 +101,6 @@ export {
deepClone, deepClone,
deepMerge, deepMerge,
formatToUnit16Array, formatToUnit16Array,
sapDownloadFile sapDownloadFile,
base64ToHex
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment