|
@@ -1,257 +1,221 @@
|
|
|
<template>
|
|
|
<view>
|
|
|
+ <!-- 单据明细 -->
|
|
|
<view class="margin-top">
|
|
|
<scroll-view :scroll-y="true" :show-scrollbar="true">
|
|
|
<view class="scroll-list">
|
|
|
<view class="list-item">
|
|
|
<text class="text-gray item-title">工作中心</text>
|
|
|
- <text class="item-content">{{workCenterGuid}}</text>
|
|
|
+ <text class="item-content">{{billDetail.workCenterGuid||''}}</text>
|
|
|
</view>
|
|
|
<view class="list-item">
|
|
|
<text class="text-gray item-title">客户合同号</text>
|
|
|
- <text class="item-content">{{khhth}}</text>
|
|
|
+ <text class="item-content">{{billDetail.khhth}}</text>
|
|
|
</view>
|
|
|
<view class="list-item">
|
|
|
<text class="text-gray item-title">客户名称</text>
|
|
|
- <text class="item-content">{{khmc}}</text>
|
|
|
+ <text class="item-content">{{billDetail.khmc}}</text>
|
|
|
</view>
|
|
|
<view class="list-item">
|
|
|
<text class="text-gray item-title">加工指导书编号</text>
|
|
|
- <text class="item-content">{{jgzdsbh}}</text>
|
|
|
+ <text class="item-content">{{billDetail.jgzdsbh}}</text>
|
|
|
</view>
|
|
|
<view class="list-item">
|
|
|
<text class="text-gray item-title">销售物流号</text>
|
|
|
- <text class="item-content">{{xswlh}}</text>
|
|
|
+ <text class="item-content">{{billDetail.xswlh}}</text>
|
|
|
</view>
|
|
|
<view class="list-item">
|
|
|
<text class="text-gray item-title">面料编码</text>
|
|
|
- <text class="item-content">{{ynDyeFabCode}}</text>
|
|
|
+ <text class="item-content">{{billDetail.ynDyeFabCode}}</text>
|
|
|
</view>
|
|
|
<view class="list-item">
|
|
|
<text class="text-gray item-title">合同交期</text>
|
|
|
- <text class="item-content">{{htjq}}</text>
|
|
|
+ <text class="item-content">{{billDetail.htjq}}</text>
|
|
|
</view>
|
|
|
<view class="list-item">
|
|
|
<text class="text-gray item-title">合同数量</text>
|
|
|
- <text class="item-content">{{htsl}}</text>
|
|
|
+ <text class="item-content">{{billDetail.htsl}}</text>
|
|
|
</view>
|
|
|
<view class="list-item">
|
|
|
<text class="text-gray item-title">计量单位</text>
|
|
|
- <text class="item-content">{{jldw}}</text>
|
|
|
+ <text class="item-content">{{billDetail.jldw}}</text>
|
|
|
</view>
|
|
|
<view class="list-item">
|
|
|
<text class="text-gray item-title">反馈初始结论</text>
|
|
|
- <text class="item-content">{{fkcsjl}}</text>
|
|
|
+ <text class="item-content">{{billDetail.fkcsjl||''}}</text>
|
|
|
</view>
|
|
|
<view class="list-item">
|
|
|
<text class="text-gray item-title">反馈人</text>
|
|
|
- <text class="item-content">{{fkr}}</text>
|
|
|
+ <text class="item-content">{{billDetail.fkr}}</text>
|
|
|
</view>
|
|
|
<view class="list-item">
|
|
|
<text class="text-gray item-title">反馈时间</text>
|
|
|
- <text class="item-content">{{fksj}}</text>
|
|
|
+ <text class="item-content">{{billDetail.fksj}}</text>
|
|
|
</view>
|
|
|
<view class="list-item">
|
|
|
<text class="text-gray item-title">反馈次数</text>
|
|
|
- <text class="item-content">{{fkcs}}</text>
|
|
|
+ <text class="item-content">{{billDetail.fkcs}}</text>
|
|
|
</view>
|
|
|
<view class="list-item">
|
|
|
<text class="text-gray item-title">反馈原因</text>
|
|
|
- <text class="item-content">{{fkyy}}</text>
|
|
|
+ <text class="item-content">{{billDetail.fkyy}}</text>
|
|
|
</view>
|
|
|
<view class="list-item">
|
|
|
<text class="text-gray item-title">验装工厂处理结论</text>
|
|
|
- <text class="item-content">{{yzgccljl}}</text>
|
|
|
+ <text class="item-content">{{billDetail.yzgccljl||''}}</text>
|
|
|
</view>
|
|
|
<view class="list-item">
|
|
|
<text class="text-gray item-title">验装工厂处理意见</text>
|
|
|
- <text class="item-content">{{yzgcclyj}}</text>
|
|
|
+ <text class="item-content">{{billDetail.yzgcclyj||''}}</text>
|
|
|
</view>
|
|
|
<view class="list-item">
|
|
|
<text class="text-gray item-title">验装工厂处理人</text>
|
|
|
- <text class="item-content">{{yzgcclr}}</text>
|
|
|
+ <text class="item-content">{{billDetail.yzgcclr||''}}</text>
|
|
|
</view>
|
|
|
<view class="list-item">
|
|
|
<text class="text-gray item-title">验装工厂处理时间</text>
|
|
|
- <text class="item-content">{{yzgcclsj}}</text>
|
|
|
+ <text class="item-content">{{billDetail.yzgcclsj||''}}</text>
|
|
|
</view>
|
|
|
<view class="list-item">
|
|
|
<text class="text-gray item-title">验装工厂备注</text>
|
|
|
- <text class="item-content">{{yzgcbz}}</text>
|
|
|
+ <text class="item-content">{{billDetail.yzgcbz||''}}</text>
|
|
|
</view>
|
|
|
<view class="list-item">
|
|
|
<text class="text-gray item-title">品管部最终处理结论</text>
|
|
|
- <text class="item-content">{{pgbzzcljl}}</text>
|
|
|
+ <text class="item-content">{{billDetail.pgbzzcljl||''}}</text>
|
|
|
</view>
|
|
|
<view class="list-item">
|
|
|
<text class="text-gray item-title">品管部最终处理意见</text>
|
|
|
- <text class="item-content">{{pgbzzclyj}}</text>
|
|
|
+ <text class="item-content">{{billDetail.pgbzzclyj||''}}</text>
|
|
|
</view>
|
|
|
<view class="list-item">
|
|
|
<text class="text-gray item-title">品管部最终处理人</text>
|
|
|
- <text class="item-content">{{pgbzzclr}}</text>
|
|
|
+ <text class="item-content">{{billDetail.pgbzzclr||''}}</text>
|
|
|
</view>
|
|
|
<view class="list-item">
|
|
|
<text class="text-gray item-title">品管部最终处理时间</text>
|
|
|
- <text class="item-content">{{pgbzzclsj}}</text>
|
|
|
+ <text class="item-content">{{billDetail.pgbzzclsj||''}}</text>
|
|
|
</view>
|
|
|
<view class="list-item">
|
|
|
<text class="text-gray item-title">返工部门</text>
|
|
|
- <text class="item-content">{{fgbm}}</text>
|
|
|
+ <text class="item-content">{{billDetail.fgbm||''}}</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
</scroll-view>
|
|
|
</view>
|
|
|
-
|
|
|
+ <!-- 图片上传 -->
|
|
|
<view class="margin-top">
|
|
|
<view class="cu-bar bg-white">
|
|
|
<view class="action">
|
|
|
图片上传
|
|
|
</view>
|
|
|
- <view class="action">
|
|
|
- {{imgLinks.length}}/9
|
|
|
- </view>
|
|
|
</view>
|
|
|
<view class="cu-form-group">
|
|
|
<view class="grid col-4 grid-square flex-sub">
|
|
|
- <view class="bg-img" v-for="(item,index) in imgLinks" :key="index" @tap="ViewImage"
|
|
|
- :data-url="imgLinks[index]">
|
|
|
- <image :src="imgLinks[index]" mode="aspectFill"></image>
|
|
|
+ <view class="bg-img" v-for="(item,index) in imgList" @tap="ViewImage" :data-url="item.url">
|
|
|
+ <image :src="item.url" mode="aspectFill"></image>
|
|
|
<view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="index">
|
|
|
<text class='cuIcon-close'></text>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view class="solids" @tap="ChooseImage" v-if="imgLinks.length<9">
|
|
|
+ <view class="solids" @tap="ChooseImage" v-if="imgList.length<9">
|
|
|
<text class='cuIcon-cameraadd'></text>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
-
|
|
|
- <view>
|
|
|
- <view class="padding margin-tb-sm text-center">
|
|
|
- <button class="cu-btn block round bg-blue lg" @click="upload">提交</button>
|
|
|
- </view>
|
|
|
+ <!-- 保存 -->
|
|
|
+ <view class="padding margin-tb-sm text-center" v-show="isAllowEdit=='true'">
|
|
|
+ <button class="cu-btn block round bg-blue lg" @click="upload">保存</button>
|
|
|
</view>
|
|
|
+
|
|
|
+ <mx-compress ref="mxCompress" />
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- //引入已经定义的公共模块,用来获取和设置userkey/token
|
|
|
- import token from '../../common/token.js'
|
|
|
+ //导入图片压缩组件
|
|
|
+ import mxCompress from '../../components/mx-compress/mx-compress.vue';
|
|
|
|
|
|
export default {
|
|
|
+ components: {
|
|
|
+ mxCompress //注册组件
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
- orgFrameGuid: '',
|
|
|
- workCenterGuid: '',
|
|
|
- khhth: '',
|
|
|
- khmc: '',
|
|
|
- jgzdsbh: '',
|
|
|
- xswlh: '',
|
|
|
- ynDyeFabCode: '',
|
|
|
- htjq: '',
|
|
|
- htsl: '',
|
|
|
- jldw: '',
|
|
|
- fkcsjl: '',
|
|
|
- fkr: '',
|
|
|
- fksj: '',
|
|
|
- fkcs: '',
|
|
|
- fkyy: '',
|
|
|
- yzgccljl: '',
|
|
|
- yzgcclyj: '',
|
|
|
- yzgcclr: '',
|
|
|
- yzgcclsj: '',
|
|
|
- yzgcbz: '',
|
|
|
- pgbzzcljl: '',
|
|
|
- pgbzzclyj: '',
|
|
|
- pgbzzclr: '',
|
|
|
- pgbzzclsj: '',
|
|
|
- fgbm: '',
|
|
|
- imgLinks: [],
|
|
|
- imgNames: [],
|
|
|
- toUploadNames: [],
|
|
|
- uploadedImgNames: [],
|
|
|
+ billDetail: {}, //单据明细
|
|
|
+ isAllowEdit: '', //是否允许保存
|
|
|
+ paramData: '', //单据列表页面获取数据参数
|
|
|
+ imgList: [] //反馈图片列表
|
|
|
}
|
|
|
},
|
|
|
- mounted() {
|
|
|
- //隐藏导航栏自带的返回按钮
|
|
|
- var a = document.getElementsByClassName('uni-page-head-hd')[0];
|
|
|
- console.log(a);
|
|
|
- a.style.display = "none";
|
|
|
- },
|
|
|
onLoad(param) {
|
|
|
- console.log('明细页面获取全局token:' + token.globalToken);
|
|
|
- console.log('onLoad:传递的单据' + param.billJson);
|
|
|
- let bill = JSON.parse(param.billJson);
|
|
|
-
|
|
|
- //给明细界面赋值
|
|
|
- this.orgFrameGuid = bill.orgFrameGuid;
|
|
|
- this.workCenterGuid = bill.workCenterGuid;
|
|
|
- this.khhth = bill.khhth;
|
|
|
- this.khmc = bill.khmc;
|
|
|
- this.jgzdsbh = bill.jgzdsbh;
|
|
|
- this.xswlh = bill.xswlh;
|
|
|
- this.ynDyeFabCode = bill.ynDyeFabCode;
|
|
|
- this.htjq = bill.htjq;
|
|
|
- this.htsl = bill.htsl;
|
|
|
- this.jldw = bill.jldw;
|
|
|
- this.fkcsjl = bill.fkcsjl;
|
|
|
- this.fkr = bill.fkr;
|
|
|
- this.fksj = bill.fksj;
|
|
|
- this.fkcs = bill.fkcs;
|
|
|
- this.fkyy = bill.fkyy;
|
|
|
- this.yzgccljl = bill.yzgccljl;
|
|
|
- this.yzgcclyj = bill.yzgcclyj;
|
|
|
- this.yzgcclr = bill.yzgcclr;
|
|
|
- this.yzgcclsj = bill.yzgcclsj;
|
|
|
- this.yzgcbz = bill.yzgcbz;
|
|
|
- this.pgbzzcljl = bill.pgbzzcljl;
|
|
|
- this.pgbzzclyj = bill.pgbzzclyj;
|
|
|
- this.pgbzzclr = bill.pgbzzclr;
|
|
|
- this.pgbzzclsj = bill.pgbzzclsj;
|
|
|
- this.fgbm = bill.fgbm;
|
|
|
+ //若加载页面时未提供参数值,则直接返回
|
|
|
+ if (Object.keys(param).length == 0) return
|
|
|
+
|
|
|
+ //给明细界面赋值、设置提交按钮是否可用以及记录单据列表页面是否查询全部单据
|
|
|
+ this.billDetail = JSON.parse(param.billData)
|
|
|
+ this.isAllowEdit = param.isAllowEdit
|
|
|
+ this.paramData=param.paramData
|
|
|
+
|
|
|
+ //添加请求拦截器
|
|
|
+ var vm = this
|
|
|
+ uni.getStorage({
|
|
|
+ key: 'token',
|
|
|
+ success: function(res) {
|
|
|
+ //请求拦截器
|
|
|
+ uni.addInterceptor('request', {
|
|
|
+ invoke(args) {
|
|
|
+ args.header = {
|
|
|
+ 'token': res.data
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
|
|
|
- //获取已经上传的图片
|
|
|
- uni.request({
|
|
|
- url: 'http://10.20.71.214:9090/yzcj/zlfkcl/getImage',
|
|
|
- data: {
|
|
|
- orgFrameGuid: this.orgFrameGuid,
|
|
|
- jgzdsbh: this.jgzdsbh,
|
|
|
- xswlh: this.xswlh,
|
|
|
- fkcs: this.fkcs,
|
|
|
- },
|
|
|
+ //获取已经上传的图片
|
|
|
+ uni.request({
|
|
|
+ url: 'https://api.lttc.cn/mes/yzcj/qualityFeedback/getImgList',
|
|
|
+ data: {
|
|
|
+ orgFrameGuid: vm.billDetail.orgFrameGuid,
|
|
|
+ jgzdsbh: vm.billDetail.jgzdsbh,
|
|
|
+ xswlh: vm.billDetail.xswlh,
|
|
|
+ fkcs: vm.billDetail.fkcs,
|
|
|
+ },
|
|
|
|
|
|
- success: (res) => {
|
|
|
- console.log('获取已上传图片成功' );
|
|
|
- console.log('返回的已上传的图片信息'+JSON.stringify(res));
|
|
|
-
|
|
|
- //显示已上传的图片
|
|
|
- this.imgLinks = res.data.imgUrls;
|
|
|
- this.imgNames = res.data.imgNames;
|
|
|
-
|
|
|
- //记录已上传的图片
|
|
|
- this.uploadedImgNames =JSON.stringify(res.data.imgNames) ;
|
|
|
- console.log('获取服务器图片后:已上传的文件链接:' + JSON.stringify(this.imgLinks) + '//已上传的文件名:' + JSON.stringify(this.uploadedImgNames));
|
|
|
- },
|
|
|
- fail: (res) => {
|
|
|
- console.log('获取已上传的图片失败:' + res.errMsg);
|
|
|
- uni.showToast({
|
|
|
- title: '获取已上传的图片失败:' + res.errMsg,
|
|
|
- icon: 'none'
|
|
|
+ success: (res) => {
|
|
|
+ if (res.data.code == 0) {
|
|
|
+ //根据图片src链接显示已上传的图片
|
|
|
+ vm.imgList = res.data.data;
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: '获取反馈图片列表失败!原因是:' + res.data.msg,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail: (res) => {
|
|
|
+ uni.showToast({
|
|
|
+ title: '访问网络获取反馈图片列表失败!原因是:' + res.errMsg,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
})
|
|
|
},
|
|
|
- complete: (res) => {
|
|
|
- console.log('访问网络获取图片结束');
|
|
|
+ fail() {
|
|
|
+ //从缓存中未获取到token失败时跳转登录界面
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '../login/login?isback=1'
|
|
|
+ })
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
},
|
|
|
- onNavigationBarButtonTap(e) {
|
|
|
- console.log("返回按钮!!!!!" + e);
|
|
|
- console.log("跳转到单据列表");
|
|
|
+ onBackPress(e) {
|
|
|
+ //返回上一页面,即单据列表页
|
|
|
uni.navigateTo({
|
|
|
- url: "/pages/billlist/billlist"
|
|
|
- });
|
|
|
+ url: '../billlist/billlist?paramData=' + this.paramData
|
|
|
+ })
|
|
|
+ //返回值为 true 时,才表示不执行默认的返回,自行处理此时的业务逻辑
|
|
|
+ return true
|
|
|
},
|
|
|
methods: {
|
|
|
ChooseImage() {
|
|
@@ -259,277 +223,155 @@
|
|
|
count: 9,
|
|
|
sizeType: ['original', 'compressed'],
|
|
|
sourceType: ['camera', 'album'],
|
|
|
+ success: async (res) => {
|
|
|
+ try {
|
|
|
+ // 调用组件的compress方法开始压缩,返回值是压缩的结果,结果为数组,每一项是一个对象
|
|
|
+ // {
|
|
|
+ // file:'在H5中为File格式的图片数据,在小程序中为图片临时路径',
|
|
|
+ // base64:'在H5和小程序中都是base64格式数据,只有当指定base64为true时才有'
|
|
|
+ // }
|
|
|
+ let result = await this.$refs.mxCompress.compress(res, {
|
|
|
+ base64: true, // 是否也返回base64格式,默认false,既不返回base64格式图片数据,反之亦然
|
|
|
+ maxLongSize: 1920, //最长尺寸
|
|
|
+ quality: 0.8, // 压缩质量(0-1),默认为0.8,值越小压缩质量越大
|
|
|
+ showLoading: true, // 是否显示loading提示,也可以传入一个字符串(相当于loading时的title),默认为true,
|
|
|
+ mask: true // 当showLoading为true时,是否显示遮罩层,默认为true
|
|
|
+ });
|
|
|
|
|
|
- success: (res) => {
|
|
|
- //选择图片后:res.tempFilePaths 存放图片的blob网址
|
|
|
- console.log('选择图片后:' + res.tempFiles[0].size + 'Byte//文件名:' + res.tempFiles[0].name + '//' + res.tempFiles[0].type + '//' + res.tempFiles[0].path);
|
|
|
-
|
|
|
- //选择图片后,添加到 imgLinks 中
|
|
|
- if (this.imgLinks.length != 0) {
|
|
|
- //如果存在上传过的图片,则保留已上传图片,添加新选择的图片
|
|
|
- console.log('imgLinks有图片');
|
|
|
- this.imgLinks = this.imgLinks.concat(res.tempFilePaths);
|
|
|
- } else {
|
|
|
- this.imgLinks = res.tempFilePaths;
|
|
|
- }
|
|
|
- console.log('显示的图片:已上传的和已选择的链接:' + this.imgLinks);
|
|
|
+ //循环添加压缩后的图片
|
|
|
+ for (let item of result) {
|
|
|
+ //H5端:根据压缩后图片的base64格式数据来上传图片
|
|
|
+ //#ifdef H5
|
|
|
+ let imgSrc = item.base64;
|
|
|
+ //#endif
|
|
|
+ //小程序端:根据压缩后图片的临时路径来上传图片
|
|
|
+ //#ifdef MP-WEIXIN
|
|
|
+ let imgSrc = item.file;
|
|
|
+ //#endif
|
|
|
+
|
|
|
+ this.imgList.push({
|
|
|
+ "url": imgSrc,
|
|
|
+ "status": 0
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
- //选择图片后,添加到 imgNames 中
|
|
|
- for (var i = 0; i < res.tempFiles.length; i++) {
|
|
|
- this.imgNames.push(res.tempFiles[i].name); //已上传到服务器的文件名和新选择的文件名
|
|
|
+ } catch (error) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '图片压缩出现异常!原因是:' + error,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
}
|
|
|
- console.log('已选择图片的名称:' + this.imgNames);
|
|
|
- console.log('选择图片后已上传文件:'+this.uploadedImgNames);
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
ViewImage(e) {
|
|
|
+ //获取当前单据上传的所有图片的url地址
|
|
|
+ var imgUrls = []
|
|
|
+ for (let item of this.imgList) {
|
|
|
+ imgUrls.push(item.url)
|
|
|
+ }
|
|
|
+
|
|
|
//预览图片
|
|
|
uni.previewImage({
|
|
|
- urls: this.imgLinks,
|
|
|
+ urls: imgUrls,
|
|
|
current: e.currentTarget.dataset.url,
|
|
|
});
|
|
|
},
|
|
|
DelImg(e) {
|
|
|
- uni.showModal({
|
|
|
- title: '提示',
|
|
|
- content: '确定要删除这张面料图片吗?',
|
|
|
- cancelText: '保留',
|
|
|
- confirmText: '删除',
|
|
|
-
|
|
|
- success: res => {
|
|
|
- if (res.confirm) {
|
|
|
- //要删除的文件名
|
|
|
- console.log('询问删除时索引'+e.currentTarget.dataset.index);
|
|
|
- console.log('文件名:'+this.imgNames);
|
|
|
- console.log('文件链接'+this.imgLinks);
|
|
|
- let deleteName = this.imgNames[e.currentTarget.dataset.index];
|
|
|
- console.log('要删除的图片名' + deleteName);
|
|
|
- console.log('删除前临时网址数组' + this.imgLinks);
|
|
|
- console.log('删除前图片名数组' + this.imgNames);
|
|
|
-
|
|
|
- //判断是否是服务器已经上穿过的图片
|
|
|
- if (this.uploadedImgNames.indexOf(deleteName) > 0) {
|
|
|
- //已上传的图片不允许删除并提示
|
|
|
- uni.showToast({
|
|
|
- title: '图片\"' + deleteName + '\"已上传到服务器,不允许删除!',
|
|
|
- icon: 'none'
|
|
|
- });
|
|
|
- return;
|
|
|
- }
|
|
|
- else {
|
|
|
- //没上传的图片直接删除
|
|
|
- this.imgLinks.splice(e.currentTarget.dataset.index, 1)
|
|
|
- console.log('删除后图片临时网址数组' + this.imgLinks);
|
|
|
- this.imgNames.splice(e.currentTarget.dataset.index, 1)
|
|
|
- console.log('删除后的图片名数组' + JSON.stringify(this.imgNames));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- upload() {
|
|
|
- //当前没有图片,直接返回
|
|
|
- if (this.imgLinks.length == 0) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- //检查文件是否为图片
|
|
|
- var illegalFiles = ''; //未知类型的
|
|
|
- var otherFiles = ''; //非图片的
|
|
|
- var uploadedFiles = ''; //已上传的
|
|
|
- var uploadedList = [];
|
|
|
- var sameNames = '';
|
|
|
- var sameNameList = [];
|
|
|
- console.log('提交后,开始检查文件之前,已上传的文件名:'+this.uploadedImgNames);
|
|
|
- for (var i = 0; i < this.imgNames.length; i++) {
|
|
|
- console.log('循环' + i);
|
|
|
-
|
|
|
- //检查文件是否合法
|
|
|
- var fileName = this.imgNames[i];
|
|
|
- var dotIndex = fileName.lastIndexOf('.');
|
|
|
- if (dotIndex == -1) {
|
|
|
- illegalFiles += fileName + ','
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- //检查是否为图片文件
|
|
|
- var extension = fileName.substring(dotIndex + 1, fileName.length);
|
|
|
- var fileTypes = ['jpg', 'jpeg', 'png', 'bmp'];
|
|
|
- if (fileTypes.indexOf(extension) == -1) {
|
|
|
- otherFiles += fileName + ','
|
|
|
- console.log('非图片文件' + otherFiles);
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- //判断是否已经上传过
|
|
|
- if (this.uploadedImgNames.indexOf(fileName) != -1) {
|
|
|
- console.log('已上传图片' + this.uploadedImgNames+'//文件名'+fileName);
|
|
|
- uploadedFiles += fileName + ',';
|
|
|
-
|
|
|
- if(uploadedList.indexOf(fileName) == -1){
|
|
|
- uploadedList.push(fileName);
|
|
|
- }
|
|
|
- else{
|
|
|
- sameNames += fileName + ',';
|
|
|
- sameNameList.push(fileName);
|
|
|
- }
|
|
|
-
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- //要上传的图片名
|
|
|
- this.toUploadNames.push(fileName);
|
|
|
- console.log('添加文件'+fileName);
|
|
|
- }
|
|
|
-
|
|
|
- //如果文件不符合要求,显示提示
|
|
|
- let hint = ''
|
|
|
- if (illegalFiles.length > 0) {
|
|
|
- illegalFiles = illegalFiles.substring(0, illegalFiles.length - 1); //删除最后一个逗号
|
|
|
- hint += '文件[' + illegalFiles + ']类型未知,不允许上传!\n'
|
|
|
- }
|
|
|
- if (otherFiles.length > 0) {
|
|
|
- otherFiles = otherFiles.substring(0, otherFiles.length - 1); //删除最后一个逗号
|
|
|
- hint += '文件[' + otherFiles + ']不是常见的图片文件,不允许上传!\n'
|
|
|
- }
|
|
|
-
|
|
|
- //如果存在不合法文件,提示并返回
|
|
|
- console.log('提示' + hint);
|
|
|
- if (hint.length > 0) {
|
|
|
- uni.showToast({
|
|
|
- title: hint
|
|
|
- });
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- //若存在与已上传图片同名的图片
|
|
|
- if (sameNameList.length > 0) {
|
|
|
- sameNames = sameNames.substring(0, sameNames.length - 1); //删除最后一个逗号
|
|
|
-
|
|
|
- //询问后做不同处理
|
|
|
+ //根据图片状态删除图片,若未上传至服务器,则直接删除,否则需删除服务器的图片
|
|
|
+ var img = this.imgList[e.currentTarget.dataset.index]
|
|
|
+ if (img.status == 0) {
|
|
|
+ //界面删除图片
|
|
|
+ this.imgList.splice(e.currentTarget.dataset.index, 1)
|
|
|
+ } else {
|
|
|
+ //图片已上传至服务器,询问用户是否确定删除
|
|
|
uni.showModal({
|
|
|
title: '提示',
|
|
|
- content: '已上传过同名文件[' + sameNames + '],是否重命名并上传?',
|
|
|
- confirmText: '重命名',
|
|
|
- cancelText: '取消',
|
|
|
-
|
|
|
- success: res => {
|
|
|
- //根据选择的是重命名还是取消,处理 this.toUploadNames
|
|
|
- if (res.confirm) {
|
|
|
- //将重复的文件区分开
|
|
|
- for (let j = 0; j < sameNameList.length; j++) {
|
|
|
- //文件名后面加“_1”
|
|
|
- fileName = sameNameList[j];
|
|
|
- console.log('原重复文件名' + fileName);
|
|
|
- fileName = fileName.substring(0, dotIndex) + '_1' + fileName.substring(dotIndex, fileName.length);
|
|
|
- console.log('重命名之后的文件名' + fileName);
|
|
|
- //拼接到 pathStr 中
|
|
|
- this.toUploadNames.push(fileName);
|
|
|
- }
|
|
|
- }
|
|
|
- else if (res.cancel) {
|
|
|
- //如果不重命名,则直接返回
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- else {
|
|
|
- //没有重复文件,直接进行后续操作
|
|
|
- console.log('没有重复文件');
|
|
|
- }
|
|
|
-
|
|
|
- //判断有没有等待上传的图片
|
|
|
- if (this.toUploadNames.length == 0) {
|
|
|
- uni.showToast({
|
|
|
- title: '没有选择图片或选择的图片均已上传,请重新选择图片!',
|
|
|
- icon:'none'
|
|
|
- });
|
|
|
- return;
|
|
|
- }
|
|
|
- console.log('等待上传的图片名:' + this.toUploadNames);
|
|
|
-
|
|
|
- //选择之后,访问网络上传图片
|
|
|
- this.uploadFile();
|
|
|
- },
|
|
|
- uploadFile() {
|
|
|
- //上传文件到服务器
|
|
|
- console.log('要上传的文件名:' + this.toUploadNames);
|
|
|
- console.log('要上传的文件链接:' + this.imgLinks);
|
|
|
-
|
|
|
- //一次性上传多个文件不适用于网页和小程序,所以还是采用循环+每次上传一个文件
|
|
|
- let uploadNames = this.toUploadNames;
|
|
|
- uploadNames.forEach((filename) => {
|
|
|
- uni.uploadFile({
|
|
|
- url: 'http://10.20.71.214:9090/yzcj/zlfkcl/uploadFile',
|
|
|
- fileType: 'image',
|
|
|
- filePath: filename, //文件名
|
|
|
-
|
|
|
- success: (res) => {
|
|
|
- if (res.statusCode == 200) {
|
|
|
- console.log('访问网络上传文件成功:');
|
|
|
- //this.uploadRes = true;
|
|
|
- console.log('准备插入的图片信息:' + filename + '//' + this.orgFrameGuid);
|
|
|
+ content: '此图片已上传至服务器,确定要删除这张面料图片吗?',
|
|
|
+ cancelText: '保留',
|
|
|
+ confirmText: '删除',
|
|
|
+ success: result => {
|
|
|
+ if (result.confirm) {
|
|
|
+ //访问网络删除已上传的图片
|
|
|
uni.request({
|
|
|
- url: 'http://10.20.71.214:9090/yzcj/zlfkcl/uploadData',
|
|
|
+ url: 'https://api.lttc.cn/mes/yzcj/qualityFeedback/deleteImg',
|
|
|
data: {
|
|
|
- orgFrameGuid: this.orgFrameGuid,
|
|
|
- jgzdsbh: this.jgzdsbh,
|
|
|
- xswlh: this.xswlh,
|
|
|
- fkcs: this.fkcs,
|
|
|
- path: filename,
|
|
|
+ "imgId": img.id
|
|
|
},
|
|
|
-
|
|
|
success: (res) => {
|
|
|
- console.log('插入图片路径结果' + JSON.stringify(res.data));
|
|
|
-
|
|
|
- if (res.data.code != -1) {
|
|
|
- //输出信息
|
|
|
- var uploadedBills = res.data;
|
|
|
- for (var i = 0; i < res.data.length; i++) {
|
|
|
- this.uploadedImgs.push(res.data[i].path);
|
|
|
- }
|
|
|
- console.log('uploadedImgs:' + JSON.stringify(
|
|
|
- this.uploadedImgs));
|
|
|
+ if (res.data.code == 0) {
|
|
|
+ //数据库删除图片记录成功后,界面删除图片
|
|
|
+ this.imgList.splice(e.currentTarget.dataset.index, 1);
|
|
|
} else {
|
|
|
uni.showToast({
|
|
|
- title: '上传图片失败!',
|
|
|
+ title: '删除反馈图片失败!原因是:' + res.data.msg,
|
|
|
icon: 'none'
|
|
|
- });
|
|
|
+ })
|
|
|
}
|
|
|
},
|
|
|
fail: (res) => {
|
|
|
- console.log('访问网络插入图片路径失败:' + res.errMsg);
|
|
|
uni.showToast({
|
|
|
- title: '访问网络插入图片路径失败:' +
|
|
|
- res.errMsg,
|
|
|
+ title: '访问网络删除图片失败!原因是:' + res.errMsg,
|
|
|
icon: 'none'
|
|
|
- });
|
|
|
- },
|
|
|
- complete() {
|
|
|
- console.log('访问网络插入图片路径结束');
|
|
|
+ })
|
|
|
}
|
|
|
})
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ upload() {
|
|
|
+ //获取需要上传到服务器的图片列表
|
|
|
+ var uploadImgs = this.imgList.filter(function(item) {
|
|
|
+ return item.status == 0
|
|
|
+ })
|
|
|
+
|
|
|
+ //若没有需要上传的图片,则直接返回
|
|
|
+ if (uploadImgs.length == 0) return
|
|
|
+
|
|
|
+ //循环上传图片
|
|
|
+ for (let file of uploadImgs) {
|
|
|
+ //访问网络上传图片
|
|
|
+ uni.uploadFile({
|
|
|
+ url: 'https://api.lttc.cn/mes/yzcj/qualityFeedback/uploadFile',
|
|
|
+ name: "file",
|
|
|
+ filePath: file.url,
|
|
|
+ formData: {
|
|
|
+ "orgFrameGuid": this.billDetail.orgFrameGuid,
|
|
|
+ "jgzdsbh": this.billDetail.jgzdsbh,
|
|
|
+ "xswlh": this.billDetail.xswlh,
|
|
|
+ "fkcs": this.billDetail.fkcs
|
|
|
+ },
|
|
|
+ success: (res) => {
|
|
|
+ let jsonData = JSON.parse(res.data);
|
|
|
+ if (jsonData.code == 0) {
|
|
|
+ //上传图片成功后,更新图片Id和状态
|
|
|
+ file.id = jsonData.data.guid;
|
|
|
+ file.status = 1;
|
|
|
|
|
|
+ //提示保存成功
|
|
|
+ uni.showToast({
|
|
|
+ title: '保存成功',
|
|
|
+ icon: 'success'
|
|
|
+ })
|
|
|
} else {
|
|
|
- console.log('访问网络上传文件失败:' + res.errMsg);
|
|
|
+ //上传图片失败,弹框提示
|
|
|
+ uni.showToast({
|
|
|
+ title: '上传反馈图片失败!原因是:' + jsonData.msg,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
}
|
|
|
},
|
|
|
fail: (res) => {
|
|
|
- console.log('访问网络上传图片失败:' + JSON.stringify(res));
|
|
|
- this.uploadRes = false;
|
|
|
uni.showToast({
|
|
|
- title: '访问网络上传图片失败:' + res.errMsg,
|
|
|
+ title: '访问网络上传反馈图片失败!原因是:' + res.errMsg,
|
|
|
icon: 'none'
|
|
|
- });
|
|
|
- },
|
|
|
- complete: (res) => {
|
|
|
- console.log('上传图片文件结束');
|
|
|
-
|
|
|
+ })
|
|
|
}
|
|
|
- })
|
|
|
- });
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -542,7 +384,6 @@
|
|
|
flex-wrap: nowrap;
|
|
|
justify-content: space-between;
|
|
|
align-items: stretch;
|
|
|
-
|
|
|
height: 750rpx;
|
|
|
}
|
|
|
|
|
@@ -574,4 +415,4 @@
|
|
|
width: 60%;
|
|
|
line-height: 50upx;
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|