Commit 5df94802 authored by xiangzj's avatar xiangzj

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

parent d76d43e7
......@@ -3,8 +3,8 @@
// "appid" : "__UNI__EDB6A1F",
"appid" : "__UNI__EDB6A1F",
"description" : "订货系统",
"versionName" : "1.1.20",
"versionCode" : "10120",
"versionName" : "1.1.40",
"versionCode" : "10140",
"transformPx" : false,
"app-plus" : {
/* 5+App特有相关 */
......
{
"name": "wly",
"version": "1.0.0",
"name": "upload实用上传组件",
"version": "1.0.3",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......@@ -46,6 +46,11 @@
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz",
"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": {
"version": "2.6.4",
"resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.6.4.tgz",
......
......@@ -9,5 +9,8 @@
"图片上传",
"多图上传",
"多图选择"
]
}
\ No newline at end of file
],
"dependencies": {
"image-tools": "^1.4.0"
}
}
......@@ -910,22 +910,22 @@
}
}
},
{
"path": "pages/breakwords-clue/breakwords-clue",
"style": {
"app-plus": {
"titleNView": {
"titleAlign": "left",
"titleColor": "#333",
"titleSize": "17px",
"backgroundColor": "transparent",
"titleText": "提报市场违约线索",
"autoBackButton": true
},
"bounce": "none"
}
}
},
// {
// "path": "pages/breakwords-clue/breakwords-clue",
// "style": {
// "app-plus": {
// "titleNView": {
// "titleAlign": "left",
// "titleColor": "#333",
// "titleSize": "17px",
// "backgroundColor": "transparent",
// "titleText": "提报市场违约线索",
// "autoBackButton": true
// },
// "bounce": "none"
// }
// }
// },
{
"path": "pages/breakwords-clue-detail/breakwords-clue-detail",
"style": {
......
......@@ -53,7 +53,7 @@
</view>
<view class="upload-block">
<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>
</uni-file-picker>
</view>
......@@ -95,11 +95,15 @@
apiUpdateGroupOrder
} from '@/servers/groupOrder.js'
import {
base64ToHex
} from '@/utils/index.js'
import {
mapMutations,
mapState
} from 'vuex'
import { pathToBase64, base64ToPath } from 'image-tools'
export default {
data() {
return {
......@@ -108,6 +112,7 @@
OBJECT_ID: ''
},
fileList: [],
imgFileBase64: [],
flag: false
}
},
......@@ -142,9 +147,10 @@
baseinfo,
INFO,
ITEM,
ATTACHMENT
} = this.groupOrder
let ATTACHMENT = this.groupOrder.ATTACHMENT
ATTACHMENT = [...ATTACHMENT, ...this.imgFileBase64]
const params = {
"MODE": "SAVE",
INFO: {
......@@ -234,9 +240,38 @@
progress(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) {
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) {
......
......@@ -3,14 +3,15 @@
<view class="status_bar" :style="navHeight"></view>
<view class="listview">
<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>
<view class="cell-list-block__content">
<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>
<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')">
<image class="icon-address" src="@/static/image/home_marketclue@3x.png" mode="aspectFit"></image>
<view class="cell-list-block__content">
......
......@@ -53,7 +53,7 @@
</view>
<view class="upload-block">
<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>
</uni-file-picker>
</view>
......@@ -96,13 +96,15 @@
} from '@/servers/noQuotaOrder.js'
import {
formatToUnit16Array
formatToUnit16Array,
base64ToHex
} from '@/utils/index.js'
import {
mapMutations,
mapState
} from 'vuex'
import { pathToBase64, base64ToPath } from 'image-tools'
export default {
data() {
......@@ -235,28 +237,62 @@
progress(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) {
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)
}
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)
})
})
},
// 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) {
console.log('上传成功', e)
......
......@@ -256,7 +256,7 @@
_this.orderItem.contactNumber = data.selectShuntAdressAccountInfo.TEL_NUMBER
_this.orderItem.contacPerson = data.selectShuntAdressAccountInfo.C_O_NAME
_this.orderItem.spurtCodeUnitName = data.selectShuntAdressAccountInfo.PARTNER_NAME
_this.getReceipt(_this.orderItem.shuntDealer)
_this.getReceipt(_this.orderItem.shuntDealer, true)
})
uni.$on('selectShuntCode', function(data) {
console.log('监听到事件来自 selectShuntCode ,携带参数 msg 为:', data);
......@@ -334,13 +334,14 @@
}
const { data } = await findByCustomer(params)
},
async getReceipt(partner = this.orderItem.customerCode){
async getReceipt(partner = this.orderItem.customerCode, flag=false){
const params = {
partner,
'role': "WLY001"
}
const res = await getReceipt(params)
this.receiveUnitArr = res.DATA
if(flag)return
this.orderItem.receiveUnitName = this.receiveUnitArr[0].PARTNER_NAME
this.orderItem.receiveUnitCode = this.receiveUnitArr[0].PARTNER
this.orderItem.spurtCodeUnitName = this.receiveUnitArr[0].PARTNER_NAME
......
......@@ -103,7 +103,7 @@
</view>
<view class="upload-block">
<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>
</uni-file-picker>
</view>
......@@ -144,12 +144,16 @@
import {
apiUpdateQuotaOrder
} from '@/servers/quotaOrder.js'
import {
base64ToHex
} from '@/utils/index.js'
import {
mapMutations,
mapState
} from 'vuex'
import { pathToBase64, base64ToPath } from 'image-tools'
export default {
data() {
return {
......@@ -157,6 +161,7 @@
orderInfo: {
OBJECT_ID: ''
},
imgFileBase64: [],
fileList: [],
flag: false
}
......@@ -195,8 +200,10 @@
INFO,
ITEM_INNER,
ITEM_OUTER,
ATTACHMENT
} = this.quotaOrder
let ATTACHMENT = this.quotaOrder.ATTACHMENT
ATTACHMENT = [...ATTACHMENT, ...this.imgFileBase64]
const params = {
"USER_BP": this.userInfo.code,
"ROLE": 'WLY001',
......@@ -290,9 +297,38 @@
progress(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) {
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) {
......
......@@ -46,6 +46,17 @@ function deepMerge(target = {}, source = {}) {
}
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) {
......@@ -90,5 +101,6 @@ export {
deepClone,
deepMerge,
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