From e2b651ce0abc30b1a12feb4a6188817f4bc570e0 Mon Sep 17 00:00:00 2001 From: Ledo Date: Sun, 12 Jan 2025 13:11:56 +0800 Subject: [PATCH] =?UTF-8?q?uniappp=E5=B0=91=E4=B8=9C=E8=A5=BF=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../processbom/ProcessBomDetailDO.java | 4 + .../plantaskbom/PlanTaskBomServiceImpl.java | 34 +- .../src/router/modules/remaining.ts | 24 +- .../views/heli/projectorder/startprint.vue | 16 +- .../src/views/heli/storage/StorageOut.vue | 40 +- .../src/views/heli/storage/StorageOutsp.vue | 78 +++- .../src/views/heli/storage/materials.vue | 4 +- mes-ui/mini-app/src/manifest.json | 9 +- .../productionReport-detail.vue | 7 +- mes-ui/mini-app/src/services/constants.ts | 3 +- .../mini-app/src/services/productionReport.ts | 2 +- .../src/uni_modules/l-upload/changelog.md | 8 - .../l-upload/components/l-upload/l-upload.vue | 425 ------------------ .../src/uni_modules/l-upload/package.json | 84 ---- .../src/uni_modules/l-upload/readme.md | 38 -- .../src/uni_modules/yt-upload/changelog.md | 12 - .../yt-upload/components/yt-upload/YtjFile.js | 396 ---------------- .../components/yt-upload/yt-upload.vue | 313 ------------- .../yt-upload/hybrid/html/js/vue.min.js | 8 - .../yt-upload/hybrid/html/uploadFile.html | 191 -------- .../src/uni_modules/yt-upload/package.json | 79 ---- .../src/uni_modules/yt-upload/readme.md | 347 -------------- 22 files changed, 145 insertions(+), 1977 deletions(-) delete mode 100644 mes-ui/mini-app/src/uni_modules/l-upload/changelog.md delete mode 100644 mes-ui/mini-app/src/uni_modules/l-upload/components/l-upload/l-upload.vue delete mode 100644 mes-ui/mini-app/src/uni_modules/l-upload/package.json delete mode 100644 mes-ui/mini-app/src/uni_modules/l-upload/readme.md delete mode 100644 mes-ui/mini-app/src/uni_modules/yt-upload/changelog.md delete mode 100644 mes-ui/mini-app/src/uni_modules/yt-upload/components/yt-upload/YtjFile.js delete mode 100644 mes-ui/mini-app/src/uni_modules/yt-upload/components/yt-upload/yt-upload.vue delete mode 100644 mes-ui/mini-app/src/uni_modules/yt-upload/hybrid/html/js/vue.min.js delete mode 100644 mes-ui/mini-app/src/uni_modules/yt-upload/hybrid/html/uploadFile.html delete mode 100644 mes-ui/mini-app/src/uni_modules/yt-upload/package.json delete mode 100644 mes-ui/mini-app/src/uni_modules/yt-upload/readme.md diff --git a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/dal/dataobject/processbom/ProcessBomDetailDO.java b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/dal/dataobject/processbom/ProcessBomDetailDO.java index 9ecc6e4..79048fc 100644 --- a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/dal/dataobject/processbom/ProcessBomDetailDO.java +++ b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/dal/dataobject/processbom/ProcessBomDetailDO.java @@ -83,6 +83,8 @@ public class ProcessBomDetailDO extends BaseDO { private Integer status; @TableField(exist = false) private Integer materialTypeId; + @TableField(exist = false) + private Integer materialType; /* * BOM状态 0:新增 1:取消 * */ @@ -142,4 +144,6 @@ public class ProcessBomDetailDO extends BaseDO { private Decimal boomAmount; @TableField(exist = false) private String sortAttr; + @TableField(exist = false) + private String matType; } diff --git a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/plantaskbom/PlanTaskBomServiceImpl.java b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/plantaskbom/PlanTaskBomServiceImpl.java index 05f2667..07d8dfa 100644 --- a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/plantaskbom/PlanTaskBomServiceImpl.java +++ b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/plantaskbom/PlanTaskBomServiceImpl.java @@ -1,5 +1,6 @@ package com.chanko.yunxi.mes.module.heli.service.plantaskbom; +import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.chanko.yunxi.mes.framework.common.pojo.PageResult; import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils; @@ -153,21 +154,24 @@ public class PlanTaskBomServiceImpl implements PlanTaskBomService { Map> groupedByMaterialId = list.stream() .collect(Collectors.groupingBy(ProcessBomDetailDO::getMaterialId)); List list1 = new ArrayList<>(); - groupedByMaterialId.forEach((matId,listTemp)->{ - ProcessBomDetailDO processBomDetailDO = listTemp.get(0); - int amount = 0; - for (ProcessBomDetailDO bo : listTemp) { - amount =amount+ bo.getProjectSubAmount() * bo.getAmount(); - } - processBomDetailDO.setAmount(amount); - if (listTemp.size() == 1){ - list1.add(processBomDetailDO); - }else { - processBomDetailDO.setProjectSubId(null); - processBomDetailDO.setProjectSubCode(null); - list1.add(processBomDetailDO); - } - }); + if(CollUtil.isNotEmpty(groupedByMaterialId)){ + + groupedByMaterialId.forEach((matId,listTemp)->{ + ProcessBomDetailDO processBomDetailDO = listTemp.get(0); + int amount = 0; + for (ProcessBomDetailDO bo : listTemp) { + amount =amount+ bo.getProjectSubAmount() * bo.getAmount(); + } + processBomDetailDO.setAmount(amount); + if (listTemp.size() == 1){ + list1.add(processBomDetailDO); + }else { + processBomDetailDO.setProjectSubId(null); + processBomDetailDO.setProjectSubCode(null); + list1.add(processBomDetailDO); + } + }); + } bomDetailDOPageResult.setList(list1); return bomDetailDOPageResult; } diff --git a/mes-ui/mes-ui-admin-vue3/src/router/modules/remaining.ts b/mes-ui/mes-ui-admin-vue3/src/router/modules/remaining.ts index ca3170f..4b57cc7 100644 --- a/mes-ui/mes-ui-admin-vue3/src/router/modules/remaining.ts +++ b/mes-ui/mes-ui-admin-vue3/src/router/modules/remaining.ts @@ -225,18 +225,18 @@ const remainingRouter: AppRouteRecordRaw[] = [ activeMenu: '/bpm/manager/form' } }, - { - path: '/manager/model/edit', - component: () => import('@/views/bpm/model/editor/index.vue'), - name: 'BpmModelEditor', - meta: { - noCache: true, - hidden: true, - canTo: true, - title: '设计流程', - activeMenu: '/bpm/manager/model' - } - }, + // { + // path: '/manager/model/edit', + // component: () => import('@/views/bpm/model/editor/index.vue'), + // name: 'BpmModelEditor', + // meta: { + // noCache: true, + // hidden: true, + // canTo: true, + // title: '设计流程', + // activeMenu: '/bpm/manager/model' + // } + // }, { path: '/manager/definition', component: () => import('@/views/bpm/definition/index.vue'), diff --git a/mes-ui/mes-ui-admin-vue3/src/views/heli/projectorder/startprint.vue b/mes-ui/mes-ui-admin-vue3/src/views/heli/projectorder/startprint.vue index 55c3894..f855c8a 100644 --- a/mes-ui/mes-ui-admin-vue3/src/views/heli/projectorder/startprint.vue +++ b/mes-ui/mes-ui-admin-vue3/src/views/heli/projectorder/startprint.vue @@ -792,14 +792,18 @@ const open = async (id: number,propertynew :number) => { businessType: 'PROJECT_ORDER' } formData.value.operateLogs = (await getOperateLogPage(logParams)).list - if (formData.value.operateLogs && formData.value.operateLogs.length >= 3) { - const approveLog = formData.value.operateLogs[2] - formData.value.approveTime = approveLog.startTime - formData.value.approveUserName = approveLog.userNickname - if(formData.value.operateLogs.length ==4){ - const auditLog = formData.value.operateLogs[3] + if (formData.value.operateLogs && formData.value.operateLogs.length >= 2) { + if(formData.value.operateLogs.length ==2){ + const approveLog = formData.value.operateLogs[0] + formData.value.approveTime = approveLog.startTime + formData.value.approveUserName = approveLog.userNickname + }else{ + const auditLog = formData.value.operateLogs[0] formData.value.auditTime = auditLog.startTime formData.value.auditUserName = auditLog.userNickname + const approveLog = formData.value.operateLogs[1] + formData.value.approveTime = approveLog.startTime + formData.value.approveUserName = approveLog.userNickname } // const auditLog = formData.value.operateLogs[3] // formData.value.auditTime = auditLog.startTime diff --git a/mes-ui/mes-ui-admin-vue3/src/views/heli/storage/StorageOut.vue b/mes-ui/mes-ui-admin-vue3/src/views/heli/storage/StorageOut.vue index 74c2ebd..7175cc9 100644 --- a/mes-ui/mes-ui-admin-vue3/src/views/heli/storage/StorageOut.vue +++ b/mes-ui/mes-ui-admin-vue3/src/views/heli/storage/StorageOut.vue @@ -368,6 +368,19 @@ link type="primary" size="small" :disabled="ctrView || ctrDelete" + + + 作废该单据后无法复原,请确认是否作废? + + + + + + 作废该单据后无法复原,请确认是否作废? + + + @@ -401,7 +415,7 @@ const { t } = useI18n() // 国际化 const message = useMessage() // 消息弹窗 const { query } = useRoute() const router = useRouter() - +const centerDialogVisible = ref(false) const dialogTitle = ref('') // 弹窗的标题 const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用 const formType = ref('') // 表单的类型:create - 新增;update - 修改 @@ -549,6 +563,22 @@ const handleStockType = async (typeid) => { enableHeadNo.value = true } } +const deleteData = ref(); + const deleteStorage = async() =>{ + await StorageApi.updateStorage(deleteData.value) + deleteData.value.cancel = useUserStore().getUser.id + commonResult = 'common.updateSuccess' + await StorageApi.updateStorageStatus(deleteData.value) + + message.success(t('common.updateSuccess')) + + query.id = formData.value.id + query.type = 'update' + if (sumbefore.value == 0) { + reload() + } + centerDialogVisible.value = false +} const handleStatus = async (num) => { formData.value.status = num const data = formData.value as unknown as StorageApi.StorageVO @@ -609,9 +639,8 @@ const handleStatus = async (num) => { data.outbound = useUserStore().getUser.id } else if(num ==3) { - await StorageApi.updateStorage(data) - data.cancel = useUserStore().getUser.id - commonResult = 'common.updateSuccess' + deleteData.value = data; + centerDialogVisible.value = true; }else{ await StorageApi.updateStorageok(data) if(formData.value.stockOutType == 1){ @@ -620,14 +649,16 @@ const handleStatus = async (num) => { } } - await StorageApi.updateStorageStatus(data) + if(num != 3){ + await StorageApi.updateStorageStatus(data) - message.success(t('common.updateSuccess')) +message.success(t('common.updateSuccess')) - query.id = formData.value.id - query.type = 'update' - if (sumbefore.value == 0) { - reload() +query.id = formData.value.id +query.type = 'update' +if (sumbefore.value == 0) { + reload() +} } } @@ -1050,7 +1081,7 @@ const initStatus = async (status) => { ctrCancel.value = true ctrDelete.value = false btnSave.value = false - btnCancel.value = true + btnCancel.value = false btnok.value=false break default: @@ -1065,11 +1096,11 @@ const initStatus = async (status) => { btnSave.value = false btnok.value=false console.log('ss'+formData.value.status) - if(formData.value.status == 4){ - btnCancel.value = true - }else{ - btnCancel.value = false - } + // if(formData.value.status == 4){ + // btnCancel.value = true + // }else{ + // btnCancel.value = false + // } } } @@ -1091,8 +1122,8 @@ onMounted(async () => { //获取状态为启用的物料信息 await getMatList('') - // 获取当前最新库存信息 - matLastData.value = await StorageMatApi.getStorageMatList(0) + // // 获取当前最新库存信息 + // matLastData.value = await StorageMatApi.getStorageMatList(0) // 编辑时获取入库单据信息,包括基础信息、物料信息、附件信息 if (query.id) { @@ -1139,10 +1170,11 @@ onMounted(async () => { item.matSpec = matEditList.value.find((record) => record.id === item.matId)?.spec item.matType = matTypes.find( op => op.value == matEditList.value.find((record) => record.id === item.matId)?.material_type)?.label item.matUnit = matUnits.find( op => op.value == matEditList.value.find((record) => record.id === item.matId)?.unit)?.label//matSimpList.value.find((record) => record.id === item.matId)?.unit - item.matRest = matLastData.value.find( - (row) => row.matId == item.matId && row.pnId == item.pnId - )?.matRest - item.matRest = item.matRest == undefined || item.matRest.length == 0 ? 0 : item.matRest + // item.matRest = matLastData.value.find( + // (row) => row.matId == item.matId && row.pnId == item.pnId + // )?.matRest + // console.log('ss'+item.matRest); + // item.matRest = item.matRest == undefined || item.matRest.length == 0 ? 0 : item.matRest item.pnlist = pnList.value.filter((pn) => pn.wh_id === item.whId) item.matList = matEditList.value.filter((record) => record.id === item.matId) }) diff --git a/mes-ui/mes-ui-admin-vue3/src/views/heli/storage/materials.vue b/mes-ui/mes-ui-admin-vue3/src/views/heli/storage/materials.vue index d0327e0..671106f 100644 --- a/mes-ui/mes-ui-admin-vue3/src/views/heli/storage/materials.vue +++ b/mes-ui/mes-ui-admin-vue3/src/views/heli/storage/materials.vue @@ -213,14 +213,12 @@ const submitForm = async () => { }else{ item.matId = item.id } - - - item.storageOkQty = '' item.whId= item.whId??'' item.rgId= item.rgId??'' item.pnId= item.pnId??'' }) + console.log(multipleSelection.value) // 发送操作成功的事件 emit('success', multipleSelection.value) } finally { diff --git a/mes-ui/mini-app/src/manifest.json b/mes-ui/mini-app/src/manifest.json index f655e5e..b77abb5 100644 --- a/mes-ui/mini-app/src/manifest.json +++ b/mes-ui/mini-app/src/manifest.json @@ -1,6 +1,6 @@ { "name" : "合力机械小程序", - "appid" : "__UNI__06FD60C", + "appid" : "__UNI__F93316F", "description" : "", "versionName" : "1.0.0", "versionCode" : "100", @@ -100,7 +100,7 @@ }, /* 小程序特有相关 */ "mp-weixin" : { - "appid" : "wx48fad418e2753b1c", + "appid" : "wxa29fe397274614b5", "setting" : { "minified" : true, "urlCheck" : true, @@ -112,8 +112,7 @@ "usingComponents" : true, "uniStatistics" : { "enable" : true - }, - "_usePrivacyCheck_" : true + } }, "mp-alipay" : { "usingComponents" : true @@ -127,6 +126,6 @@ "uniStatistics" : { "enable" : false }, - "vueVersion" : "2", + "vueVersion" : "3", "fallbackLocale" : "zh-Hans" } diff --git a/mes-ui/mini-app/src/pages/productionReport/productionReport-detail.vue b/mes-ui/mini-app/src/pages/productionReport/productionReport-detail.vue index dc74520..acf800f 100644 --- a/mes-ui/mini-app/src/pages/productionReport/productionReport-detail.vue +++ b/mes-ui/mini-app/src/pages/productionReport/productionReport-detail.vue @@ -36,7 +36,6 @@ const isShowEnd = computed(() => { } return flag }) -const productionTitle = ref('开始生产') const amount = ref('') const workTime = ref('') // 详情数据 @@ -99,7 +98,6 @@ const handleComplate = async () => { const params = { id: detailInfo.value?.id, active: 'FINISH', - ownerId: userId, } const data = await postOperateAPI(params) const url = `/pages/productionReport/productionReport-detail?id=${detailInfo.value.id}` @@ -126,14 +124,12 @@ const handleStart = async () => { const params = { id: detailInfo.value.id, active: 'START', - ownerId: userId, } const data = await postOperateAPI(params) const url = `/pages/productionReport/productionReport-detail?id=${detailInfo.value.id}` uni.redirectTo({ url, }) - productionTitle.value = '生产中' } // 结束生产 const handleStop = async () => { @@ -148,7 +144,6 @@ const handleStop = async () => { }) popup.value?.open() } - diff --git a/mes-ui/mini-app/src/services/constants.ts b/mes-ui/mini-app/src/services/constants.ts index c4e668d..175fabf 100644 --- a/mes-ui/mini-app/src/services/constants.ts +++ b/mes-ui/mini-app/src/services/constants.ts @@ -8,6 +8,5 @@ */ // export const serviceDomain = 'https://nxhs.cjyx.cc' // export const serviceDomain = 'https://star.hz-hl.com' -// export const serviceDomain = 'http://222.71.165.187:9010' +export const serviceDomain = 'http://222.71.165.187:9010' -export const serviceDomain = 'http://localhost:8080' \ No newline at end of file diff --git a/mes-ui/mini-app/src/services/productionReport.ts b/mes-ui/mini-app/src/services/productionReport.ts index 05bfc93..6814498 100644 --- a/mes-ui/mini-app/src/services/productionReport.ts +++ b/mes-ui/mini-app/src/services/productionReport.ts @@ -11,7 +11,7 @@ import { http } from '@/utils/http' export const getListAPI = (data: Object) => { return http({ method: 'GET', - url: '/heli/task-dispatch/task-dispatch-detail/pagewx', + url: '/heli/task-dispatch/task-dispatch-detail/page', data, }) } diff --git a/mes-ui/mini-app/src/uni_modules/l-upload/changelog.md b/mes-ui/mini-app/src/uni_modules/l-upload/changelog.md deleted file mode 100644 index 38efab9..0000000 --- a/mes-ui/mini-app/src/uni_modules/l-upload/changelog.md +++ /dev/null @@ -1,8 +0,0 @@ -## 1.0.3(2023-05-18) -1.0.3 -## 1.0.2(2023-05-18) -解决视频上传问题 -## 1.0.1(2023-05-15) -更细说明 -## 1.0.0(2023-05-12) -1.0.0 diff --git a/mes-ui/mini-app/src/uni_modules/l-upload/components/l-upload/l-upload.vue b/mes-ui/mini-app/src/uni_modules/l-upload/components/l-upload/l-upload.vue deleted file mode 100644 index bd26963..0000000 --- a/mes-ui/mini-app/src/uni_modules/l-upload/components/l-upload/l-upload.vue +++ /dev/null @@ -1,425 +0,0 @@ - - - - diff --git a/mes-ui/mini-app/src/uni_modules/l-upload/package.json b/mes-ui/mini-app/src/uni_modules/l-upload/package.json deleted file mode 100644 index 21698e2..0000000 --- a/mes-ui/mini-app/src/uni_modules/l-upload/package.json +++ /dev/null @@ -1,84 +0,0 @@ -{ - "id": "l-upload", - "displayName": "文件上传 图片上传预览 视频上传预览", - "version": "1.0.3", - "description": "l-upload 图片视频上传组件,自适应布局,可单独上传图片或视频,也可都能上传 仅测过小程序其他自测", - "keywords": [ - "文件上传", - "图片上传", - "视频上传", - "图片预览", - "视频预览" -], - "repository": "", -"engines": { - }, - "dcloudext": { - "type": "component-vue", - "sale": { - "regular": { - "price": "0.00" - }, - "sourcecode": { - "price": "0.00" - } - }, - "contact": { - "qq": "" - }, - "declaration": { - "ads": "无", - "data": "插件不采集任何数据", - "permissions": "无" - }, - "npmurl": "" - }, - "uni_modules": { - "dependencies": [], - "encrypt": [], - "platforms": { - "cloud": { - "tcb": "y", - "aliyun": "y" - }, - "client": { - "Vue": { - "vue2": "y", - "vue3": "y" - }, - "App": { - "app-vue": "y", - "app-nvue": "y" - }, - "H5-mobile": { - "Safari": "y", - "Android Browser": "y", - "微信浏览器(Android)": "y", - "QQ浏览器(Android)": "y" - }, - "H5-pc": { - "Chrome": "y", - "IE": "y", - "Edge": "y", - "Firefox": "y", - "Safari": "y" - }, - "小程序": { - "微信": "y", - "阿里": "y", - "百度": "y", - "字节跳动": "y", - "QQ": "y", - "钉钉": "y", - "快手": "y", - "飞书": "y", - "京东": "y" - }, - "快应用": { - "华为": "y", - "联盟": "y" - } - } - } - } -} \ No newline at end of file diff --git a/mes-ui/mini-app/src/uni_modules/l-upload/readme.md b/mes-ui/mini-app/src/uni_modules/l-upload/readme.md deleted file mode 100644 index 0965efd..0000000 --- a/mes-ui/mini-app/src/uni_modules/l-upload/readme.md +++ /dev/null @@ -1,38 +0,0 @@ -# l-upload -组件会根据图片大小自动调整每行图片数量图片之间的上下左右间距 -# 使用方法 -配置easycom规则后,自动按需引入,无需`import`组件,直接引用即可。 -# -注意 使用接口地址需要自己在组件中的uploadImage方法中根据自己组件返回数据进行修改 - -```html - -``` - - -## 组件属性 - -| 属性 | 类型 | 默认值 | 说明 | -|:---:|:---:|:---:|---| -| width | Number | 220 | 图片宽度,单位rpx | -| height | Number | 220 | 图片高度,单位rpx | -| uploadType | String | all | 上传类型 图片img 视频video 默认都可以 | -| 禁用添加 | Boolean | false | 禁用添加按钮,默认达到限制数量后禁用 | -| limit | Number | 9 | 图片视频限制数 | -| sizeType | Array | ['original', 'compressed'] | original 原图,compressed 压缩图,默认二者都有 | -| sourceType | Array | ['album', 'camera'] | album 从相册选图,camera 使用相机,默认二者都有。如需直接开相机或直接选相册,请只使用一个选项 | -| imageFormat | Array | [] | 可上传图片类型,默认为空,不限制 ['jpg','png','gif'] | -| images | Array | [] | 初始图片,如果是修改需要回显内容就能用到 | -| videos | Array | [] | 初始视频 | -| serverUrl | String | '' | 服务器接口地址。当接口地址为空时,直接返回本地图片地址 | -| fileKeyName | String | 'file' | 文件对应的key,默认为 file | -| header | Object | {} | HTTP 请求 Header, header 中不能设置 Referer。 | -| formData | Object | {} | HTTP 请求中其他额外的 form data | - - -## 组件事件 - -| 名称 | 触发时机 | -|:---:|---| -| complete | 上传完成事件 返回文件信息 | -| remove | 删除 返回index | \ No newline at end of file diff --git a/mes-ui/mini-app/src/uni_modules/yt-upload/changelog.md b/mes-ui/mini-app/src/uni_modules/yt-upload/changelog.md deleted file mode 100644 index 765239d..0000000 --- a/mes-ui/mini-app/src/uni_modules/yt-upload/changelog.md +++ /dev/null @@ -1,12 +0,0 @@ -## 2.3.1(2024-04-09) -修改第一次文件无法上传的bug -## 2.3.0(2023-11-06) -方法名修改 -## 2.2.9(2023-11-06) -修改bug -## 2.2.8(2023-11-06) -字段修改 -## 2.2.7(2023-11-06) -bug修改 -## 2.2.6(2023-03-16) -无 diff --git a/mes-ui/mini-app/src/uni_modules/yt-upload/components/yt-upload/YtjFile.js b/mes-ui/mini-app/src/uni_modules/yt-upload/components/yt-upload/YtjFile.js deleted file mode 100644 index 38c1568..0000000 --- a/mes-ui/mini-app/src/uni_modules/yt-upload/components/yt-upload/YtjFile.js +++ /dev/null @@ -1,396 +0,0 @@ -export class YtjFile { - constructor(data) { - this.dom = null; - // files.type = waiting(等待上传)|| loading(上传中)|| success(成功) || fail(失败) - this.files = new Map(); - this.debug = data.debug || false; - this.id = data.id; - this.width = data.width; - this.height = data.height; - this.option = data.option; - this.instantly = data.instantly; - this.prohibited = data.prohibited; - this.onchange = data.onchange; - this.onprogress = data.onprogress; - this.uploadHandle = this._uploadHandle; - // #ifdef MP-WEIXIN - this.uploadHandle = this._uploadHandleWX; - // #endif - } - - - /** - * 创建File节点 - * @param {string}path webview地址 - */ - create(path) { - if (!this.dom) { - // #ifdef H5 - let dom = document.createElement('input'); - dom.type = 'file' - dom.value = '' - dom.style.height = this.height - dom.style.width = this.width - dom.style.position = 'absolute' - dom.style.top = 0 - dom.style.left = 0 - dom.style.right = 0 - dom.style.bottom = 0 - dom.style.opacity = 0 - dom.style.zIndex = 999 - dom.accept = this.prohibited.accept; - if (this.prohibited.count > 1) { - dom.multiple = 'multiple'; - } - dom.onchange = event => { - for (let file of event.target.files) { - if (this.files.size >= this.prohibited.count) { - this.toast(`只允许上传${this.prohibited.count}个文件`); - this.dom.value = ''; - break; - } - this.addFile(file); - } - - this._uploadAfter(); - - this.dom.value = ''; - }; - this.dom = dom; - // #endif - - // #ifdef APP-PLUS - let styles = { - top: '-200px', - left: 0, - width: '1px', - height: '200px', - background: 'transparent' - }; - let extras = { - debug: this.debug, - instantly: this.instantly, - prohibited: this.prohibited, - } - this.dom = plus.webview.create(path, this.id, styles,extras); - this.setData(this.option); - this._overrideUrlLoading(); - // #endif - return this.dom; - } - } - - - /** - * 设置上传参数 - * @param {object|string}name 上传参数,支持a.b 和 a[b] - */ - setData() { - let [name,value = ''] = arguments; - if (typeof name === 'object') { - Object.assign(this.option,name); - } - else { - this._setValue(this.option,name,value); - } - - this.debug&&console.log(JSON.stringify(this.option)); - - // #ifdef APP-PLUS - this.dom.evalJS(`vm.setData('${JSON.stringify(this.option)}')`); - // #endif - } - - /** - * 上传 - * @param {string}name 文件名称 - */ - async upload(name='') { - if (!this.option.url) { - throw Error('未设置上传地址'); - } - - // #ifndef APP-PLUS - if (name && this.files.has(name)) { - await this.uploadHandle(this.files.get(name)); - } - else { - for (let item of this.files.values()) { - if (item.type === 'waiting' || item.type === 'fail') { - await this.uploadHandle(item); - } - } - } - // #endif - - // #ifdef APP-PLUS - this.dom&&this.dom.evalJS(`vm.upload('${name}')`); - // #endif - } - - // 选择文件change - addFile(file,isCallChange) { - - let name = file.name; - this.debug&&console.log('文件名称',name,'大小',file.size); - - if (file) { - // 限制文件格式 - let path = ''; - let suffix = name.substring(name.lastIndexOf(".")+1).toLowerCase(); - let formats = this.prohibited.formats.toLowerCase(); - // #ifndef MP-WEIXIN - path = URL.createObjectURL(file); - // #endif - // #ifdef MP-WEIXIN - path = file.path; - // #endif - if (formats&&!formats.includes(suffix)) { - this.toast(`不支持上传${suffix.toUpperCase()}格式文件`); - return false; - } - // 限制文件大小 - if (file.size > 1024 * 1024 * Math.abs(this.prohibited.size)) { - this.toast(`附件大小请勿超过${this.prohibited.size}M`) - return false; - } - this.files.set(file.name,{file,path,name: file.name,size: file.size,progress: 0,type: 'waiting'}); - return true; - } - } - - /** - * 移除文件 - * @param {string}name 不传name默认移除所有文件,传入name移除指定name的文件 - */ - clear(name='') { - // #ifdef APP-PLUS - this.dom&&this.dom.evalJS(`vm.clear('${name}')`); - // #endif - - if (!name) { - this.files.clear(); - } - else { - this.files.delete(name); - } - return this.onchange(this.files); - } - - /** - * 提示框 - * @param {string}msg 轻提示内容 - */ - toast(msg) { - uni.showToast({ - title: msg, - icon: 'none' - }); - } - - /** - * 微信小程序选择文件 - * @param {number}count 可选择文件数量 - */ - chooseMessageFile(type,count) { - wx.chooseMessageFile({ - count: count, - type: type, - success: ({ tempFiles }) => { - for (let file of tempFiles) { - this.addFile(file); - } - this._uploadAfter(); - }, - fail: () => { - this.toast(`打开失败`); - } - }) - } - - _copyObject(obj) { - if (typeof obj !== "undefined") { - return JSON.parse(JSON.stringify(obj)); - } else { - return obj; - } - } - - /** - * 自动根据字符串路径设置对象中的值 支持.和[] - * @param {Object} dataObj 数据源 - * @param {String} name 支持a.b 和 a[b] - * @param {String} value 值 - * setValue(dataObj, name, value); - */ - _setValue(dataObj, name, value) { - // 通过正则表达式 查找路径数据 - let dataValue; - if (typeof value === "object") { - dataValue = this._copyObject(value); - } else { - dataValue = value; - } - let regExp = new RegExp("([\\w$]+)|\\[(:\\d)\\]", "g"); - const patten = name.match(regExp); - // 遍历路径 逐级查找 最后一级用于直接赋值 - for (let i = 0; i < patten.length - 1; i++) { - let keyName = patten[i]; - if (typeof dataObj[keyName] !== "object") dataObj[keyName] = {}; - dataObj = dataObj[keyName]; - } - // 最后一级 - dataObj[patten[patten.length - 1]] = dataValue; - this.debug&&console.log('参数更新后',JSON.stringify(this.option)); - } - - _uploadAfter() { - this.onchange(this.files); - this.instantly&&this.upload(); - } - - _overrideUrlLoading() { - this.dom.overrideUrlLoading({ mode: 'reject' }, e => { - let {retype,item,files,end} = this._getRequest( - e.url - ); - let _this = this; - switch (retype) { - case 'updateOption': - this.dom.evalJS(`vm.setData('${JSON.stringify(_this.option)}')`); - break - case 'change': - try { - _this.files = new Map([..._this.files,...JSON.parse(unescape(files))]); - } catch (e) { - return console.error('出错了,请检查代码') - } - _this.onchange(_this.files); - break - case 'progress': - try { - item = JSON.parse(unescape(item)); - } catch (e) { - return console.error('出错了,请检查代码') - } - _this._changeFilesItem(item,end); - break - default: - break - } - }) - } - - _getRequest(url) { - let theRequest = new Object() - let index = url.indexOf('?') - if (index != -1) { - let str = url.substring(index + 1) - let strs = str.split('&') - for (let i = 0; i < strs.length; i++) { - theRequest[strs[i].split('=')[0]] = unescape(strs[i].split('=')[1]) - } - } - return theRequest - } - - _changeFilesItem(item,end=false) { - this.debug&&console.log('onprogress',JSON.stringify(item)); - this.onprogress(item,end); - this.files.set(item.name,item); - } - - _uploadHandle(item) { - item.type = 'loading'; - delete item.responseText; - return new Promise((resolve,reject)=>{ - this.debug&&console.log('option',JSON.stringify(this.option)); - let {url,name,method='POST',header,formData} = this.option; - let form = new FormData(); - for (let keys in formData) { - form.append(keys, formData[keys]) - } - form.append(name, item.file); - let xmlRequest = new XMLHttpRequest(); - xmlRequest.open(method, url, true); - for (let keys in header) { - xmlRequest.setRequestHeader(keys, header[keys]) - } - - xmlRequest.upload.addEventListener( - 'progress', - event => { - if (event.lengthComputable) { - let progress = Math.ceil((event.loaded * 100) / event.total) - if (progress <= 100) { - item.progress = progress; - this._changeFilesItem(item); - } - } - }, - false - ); - - xmlRequest.ontimeout = () => { - console.error('请求超时') - item.type = 'fail'; - this._changeFilesItem(item,true); - return resolve(false); - } - - xmlRequest.onreadystatechange = ev => { - if (xmlRequest.readyState == 4) { - if (xmlRequest.status == 200) { - this.debug&&console.log('上传完成:' + xmlRequest.responseText) - item['responseText'] = xmlRequest.responseText; - item.type = 'success'; - this._changeFilesItem(item,true); - return resolve(true); - } else if (xmlRequest.status == 0) { - console.error('status = 0 :请检查请求头Content-Type与服务端是否匹配,服务端已正确开启跨域,并且nginx未拦截阻止请求') - } - console.error('--ERROR--:status = ' + xmlRequest.status) - item.type = 'fail'; - this._changeFilesItem(item,true); - return resolve(false); - } - } - xmlRequest.send(form) - }); - } - - _uploadHandleWX(item) { - item.type = 'loading'; - delete item.responseText; - return new Promise((resolve,reject)=>{ - this.debug&&console.log('option',JSON.stringify(this.option)); - let form = {filePath: item.file.path,...this.option }; - form['fail'] = ({ errMsg = '' }) => { - console.error('--ERROR--:' + errMsg) - item.type = 'fail'; - this._changeFilesItem(item,true); - return resolve(false); - } - form['success'] = res => { - if (res.statusCode == 200) { - this.debug&&console.log('上传完成,微信端返回不一定是字符串,根据接口返回格式判断是否需要JSON.parse:' + res.data) - item['responseText'] = res.data; - item.type = 'success'; - this._changeFilesItem(item,true); - return resolve(true); - } - item.type = 'fail'; - this._changeFilesItem(item,true); - return resolve(false); - } - - let xmlRequest = uni.uploadFile(form); - xmlRequest.onProgressUpdate(({ progress = 0 }) => { - if (progress <= 100) { - item.progress = progress; - this._changeFilesItem(item); - } - }) - }); - } -} \ No newline at end of file diff --git a/mes-ui/mini-app/src/uni_modules/yt-upload/components/yt-upload/yt-upload.vue b/mes-ui/mini-app/src/uni_modules/yt-upload/components/yt-upload/yt-upload.vue deleted file mode 100644 index 44aca31..0000000 --- a/mes-ui/mini-app/src/uni_modules/yt-upload/components/yt-upload/yt-upload.vue +++ /dev/null @@ -1,313 +0,0 @@ - - - - - diff --git a/mes-ui/mini-app/src/uni_modules/yt-upload/hybrid/html/js/vue.min.js b/mes-ui/mini-app/src/uni_modules/yt-upload/hybrid/html/js/vue.min.js deleted file mode 100644 index 97ac4cf..0000000 --- a/mes-ui/mini-app/src/uni_modules/yt-upload/hybrid/html/js/vue.min.js +++ /dev/null @@ -1,8 +0,0 @@ -/*! - * Vue.js v2.3.0 - * (c) 2014-2017 Evan You - * Released under the MIT License. - */ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.Vue=t()}(this,function(){"use strict";function e(e){return void 0===e||null===e}function t(e){return void 0!==e&&null!==e}function n(e){return!0===e}function r(e){return"string"==typeof e||"number"==typeof e}function i(e){return null!==e&&"object"==typeof e}function o(e){return"[object Object]"===Ai.call(e)}function a(e){return"[object RegExp]"===Ai.call(e)}function s(e){return null==e?"":"object"==typeof e?JSON.stringify(e,null,2):String(e)}function c(e){var t=parseFloat(e);return isNaN(t)?e:t}function u(e,t){for(var n=Object.create(null),r=e.split(","),i=0;i-1)return e.splice(n,1)}}function f(e,t){return Si.call(e,t)}function p(e){var t=Object.create(null);return function(n){return t[n]||(t[n]=e(n))}}function d(e,t){function n(n){var r=arguments.length;return r?r>1?e.apply(t,arguments):e.call(t,n):e.call(t)}return n._length=e.length,n}function v(e,t){t=t||0;for(var n=e.length-t,r=new Array(n);n--;)r[n]=e[n+t];return r}function h(e,t){for(var n in t)e[n]=t[n];return e}function m(e){for(var t={},n=0;n=0&&$o[n].id>e.id;)n--;$o.splice(Math.max(n,Ao)+1,0,e)}else $o.push(e);Co||(Co=!0,ro($e))}}function Ae(e){To.clear(),Oe(e,To)}function Oe(e,t){var n,r,o=Array.isArray(e);if((o||i(e))&&Object.isExtensible(e)){if(e.__ob__){var a=e.__ob__.dep.id;if(t.has(a))return;t.add(a)}if(o)for(n=e.length;n--;)Oe(e[n],t);else for(r=Object.keys(e),n=r.length;n--;)Oe(e[r[n]],t)}}function Se(e,t,n){Eo.get=function(){return this[t][n]},Eo.set=function(e){this[t][n]=e},Object.defineProperty(e,n,Eo)}function Te(e){e._watchers=[];var t=e.$options;t.props&&Ee(e,t.props),t.methods&&Me(e,t.methods),t.data?je(e):E(e._data={},!0),t.computed&&Le(e,t.computed),t.watch&&Pe(e,t.watch)}function Ee(e,t){var n=e.$options.propsData||{},r=e._props={},i=e.$options._propKeys=[],o=!e.$parent;lo.shouldConvert=o;for(var a in t)!function(o){i.push(o);var a=U(o,t,n,e);j(r,o,a),o in e||Se(e,"_props",o)}(a);lo.shouldConvert=!0}function je(e){var t=e.$options.data;t=e._data="function"==typeof t?Ne(t,e):t||{},o(t)||(t={});for(var n=Object.keys(t),r=e.$options.props,i=n.length;i--;)r&&f(r,n[i])||$(n[i])||Se(e,"_data",n[i]);E(t,!0)}function Ne(e,t){try{return e.call(t)}catch(e){return C(e,t,"data()"),{}}}function Le(e,t){var n=e._computedWatchers=Object.create(null);for(var r in t){var i=t[r],o="function"==typeof i?i:i.get;n[r]=new So(e,o,g,jo),r in e||Ie(e,r,i)}}function Ie(e,t,n){"function"==typeof n?(Eo.get=De(t),Eo.set=g):(Eo.get=n.get?!1!==n.cache?De(t):n.get:g,Eo.set=n.set?n.set:g),Object.defineProperty(e,t,Eo)}function De(e){return function(){var t=this._computedWatchers&&this._computedWatchers[e];if(t)return t.dirty&&t.evaluate(),oo.target&&t.depend(),t.value}}function Me(e,t){e.$options.props;for(var n in t)e[n]=null==t[n]?g:d(t[n],e)}function Pe(e,t){for(var n in t){var r=t[n];if(Array.isArray(r))for(var i=0;i=0||n.indexOf(e[i])<0)&&r.push(e[i]);return r}return e}function pt(e){this._init(e)}function dt(e){e.use=function(e){if(!e.installed){var t=v(arguments,1);return t.unshift(this),"function"==typeof e.install?e.install.apply(e,t):"function"==typeof e&&e.apply(null,t),e.installed=!0,this}}}function vt(e){e.mixin=function(e){this.options=B(this.options,e)}}function ht(e){e.cid=0;var t=1;e.extend=function(e){e=e||{};var n=this,r=n.cid,i=e._Ctor||(e._Ctor={});if(i[r])return i[r];var o=e.name||n.options.name,a=function(e){this._init(e)};return a.prototype=Object.create(n.prototype),a.prototype.constructor=a,a.cid=t++,a.options=B(n.options,e),a.super=n,a.options.props&&mt(a),a.options.computed&>(a),a.extend=n.extend,a.mixin=n.mixin,a.use=n.use,Di.forEach(function(e){a[e]=n[e]}),o&&(a.options.components[o]=a),a.superOptions=n.options,a.extendOptions=e,a.sealedOptions=h({},a.options),i[r]=a,a}}function mt(e){var t=e.options.props;for(var n in t)Se(e.prototype,"_props",n)}function gt(e){var t=e.options.computed;for(var n in t)Ie(e.prototype,n,t[n])}function yt(e){Di.forEach(function(t){e[t]=function(e,n){return n?("component"===t&&o(n)&&(n.name=n.name||e,n=this.options._base.extend(n)),"directive"===t&&"function"==typeof n&&(n={bind:n,update:n}),this.options[t+"s"][e]=n,n):this.options[t+"s"][e]}})}function _t(e){return e&&(e.Ctor.options.name||e.tag)}function bt(e,t){return"string"==typeof e?e.split(",").indexOf(t)>-1:!!a(e)&&e.test(t)}function $t(e,t,n){for(var r in e){var i=e[r];if(i){var o=_t(i.componentOptions);o&&!n(o)&&(i!==t&&xt(i),e[r]=null)}}}function xt(e){e&&e.componentInstance.$destroy()}function wt(e){for(var n=e.data,r=e,i=e;t(i.componentInstance);)i=i.componentInstance._vnode,i.data&&(n=Ct(i.data,n));for(;t(r=r.parent);)r.data&&(n=Ct(n,r.data));return kt(n)}function Ct(e,n){return{staticClass:At(e.staticClass,n.staticClass),class:t(e.class)?[e.class,n.class]:n.class}}function kt(e){var n=e.class,r=e.staticClass;return t(r)||t(n)?At(r,Ot(n)):""}function At(e,t){return e?t?e+" "+t:e:t||""}function Ot(n){if(e(n))return"";if("string"==typeof n)return n;var r="";if(Array.isArray(n)){for(var o,a=0,s=n.length;a-1?ua[e]=t.constructor===window.HTMLUnknownElement||t.constructor===window.HTMLElement:ua[e]=/HTMLUnknownElement/.test(t.toString())}function Et(e){if("string"==typeof e){var t=document.querySelector(e);return t||document.createElement("div")}return e}function jt(e,t){var n=document.createElement(e);return"select"!==e?n:(t.data&&t.data.attrs&&void 0!==t.data.attrs.multiple&&n.setAttribute("multiple","multiple"),n)}function Nt(e,t){return document.createElementNS(ia[e],t)}function Lt(e){return document.createTextNode(e)}function It(e){return document.createComment(e)}function Dt(e,t,n){e.insertBefore(t,n)}function Mt(e,t){e.removeChild(t)}function Pt(e,t){e.appendChild(t)}function Rt(e){return e.parentNode}function Ft(e){return e.nextSibling}function Bt(e){return e.tagName}function Ht(e,t){e.textContent=t}function Ut(e,t,n){e.setAttribute(t,n)}function Vt(e,t){var n=e.data.ref;if(n){var r=e.context,i=e.componentInstance||e.elm,o=r.$refs;t?Array.isArray(o[n])?l(o[n],i):o[n]===i&&(o[n]=void 0):e.data.refInFor?Array.isArray(o[n])&&o[n].indexOf(i)<0?o[n].push(i):o[n]=[i]:o[n]=i}}function zt(e,n){return e.key===n.key&&e.tag===n.tag&&e.isComment===n.isComment&&t(e.data)===t(n.data)&&Jt(e,n)}function Jt(e,n){if("input"!==e.tag)return!0;var r;return(t(r=e.data)&&t(r=r.attrs)&&r.type)===(t(r=n.data)&&t(r=r.attrs)&&r.type)}function Kt(e,n,r){var i,o,a={};for(i=n;i<=r;++i)o=e[i].key,t(o)&&(a[o]=i);return a}function qt(e,t){(e.data.directives||t.data.directives)&&Wt(e,t)}function Wt(e,t){var n,r,i,o=e===pa,a=t===pa,s=Zt(e.data.directives,e.context),c=Zt(t.data.directives,t.context),u=[],l=[];for(n in c)r=s[n],i=c[n],r?(i.oldValue=r.value,Yt(i,"update",t,e),i.def&&i.def.componentUpdated&&l.push(i)):(Yt(i,"bind",t,e),i.def&&i.def.inserted&&u.push(i));if(u.length){var f=function(){for(var n=0;n=0&&" "===(m=e.charAt(h));h--);m&&_a.test(m)||(l=!0)}}else void 0===o?(v=i+1,o=e.slice(0,i).trim()):t();if(void 0===o?o=e.slice(0,i).trim():0!==v&&t(),a)for(i=0;i=Bo}function gn(e){return 34===e||39===e}function yn(e){var t=1;for(zo=Vo;!mn();)if(e=hn(),gn(e))_n(e);else if(91===e&&t++,93===e&&t--,0===t){Jo=Vo;break}}function _n(e){for(var t=e;!mn()&&(e=hn())!==t;);}function bn(e,t,n){Ko=n;var r=t.value,i=t.modifiers,o=e.tag,a=e.attrsMap.type;if("select"===o)wn(e,r,i);else if("input"===o&&"checkbox"===a)$n(e,r,i);else if("input"===o&&"radio"===a)xn(e,r,i);else if("input"===o||"textarea"===o)Cn(e,r,i);else if(!Pi.isReservedTag(o))return pn(e,r,i),!1;return!0}function $n(e,t,n){var r=n&&n.number,i=ln(e,"value")||"null",o=ln(e,"true-value")||"true",a=ln(e,"false-value")||"false";an(e,"checked","Array.isArray("+t+")?_i("+t+","+i+")>-1"+("true"===o?":("+t+")":":_q("+t+","+o+")")),un(e,$a,"var $$a="+t+",$$el=$event.target,$$c=$$el.checked?("+o+"):("+a+");if(Array.isArray($$a)){var $$v="+(r?"_n("+i+")":i)+",$$i=_i($$a,$$v);if($$c){$$i<0&&("+t+"=$$a.concat($$v))}else{$$i>-1&&("+t+"=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}}else{"+dn(t,"$$c")+"}",null,!0)}function xn(e,t,n){var r=n&&n.number,i=ln(e,"value")||"null";i=r?"_n("+i+")":i,an(e,"checked","_q("+t+","+i+")"),un(e,$a,dn(t,i),null,!0)}function wn(e,t,n){var r=n&&n.number,i='Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = "_value" in o ? o._value : o.value;return '+(r?"_n(val)":"val")+"})",o="var $$selectedVal = "+i+";";o=o+" "+dn(t,"$event.target.multiple ? $$selectedVal : $$selectedVal[0]"),un(e,"change",o,null,!0)}function Cn(e,t,n){var r=e.attrsMap.type,i=n||{},o=i.lazy,a=i.number,s=i.trim,c=!o&&"range"!==r,u=o?"change":"range"===r?ba:"input",l="$event.target.value";s&&(l="$event.target.value.trim()"),a&&(l="_n("+l+")");var f=dn(t,l);c&&(f="if($event.target.composing)return;"+f),an(e,"value","("+t+")"),un(e,u,f,null,!0),(s||a||"number"===r)&&un(e,"blur","$forceUpdate()")}function kn(e){var n;t(e[ba])&&(n=zi?"change":"input",e[n]=[].concat(e[ba],e[n]||[]),delete e[ba]),t(e[$a])&&(n=Zi?"click":"change",e[n]=[].concat(e[$a],e[n]||[]),delete e[$a])}function An(e,t,n,r,i){if(n){var o=t,a=qo;t=function(n){null!==(1===arguments.length?o(n):o.apply(null,arguments))&&On(e,t,r,a)}}qo.addEventListener(e,t,Gi?{capture:r,passive:i}:r)}function On(e,t,n,r){(r||qo).removeEventListener(e,t,n)}function Sn(t,n){if(!e(t.data.on)||!e(n.data.on)){var r=n.data.on||{},i=t.data.on||{};qo=n.elm,kn(r),G(r,i,An,On,n.context)}}function Tn(n,r){if(!e(n.data.domProps)||!e(r.data.domProps)){var i,o,a=r.elm,s=n.data.domProps||{},c=r.data.domProps||{};t(c.__ob__)&&(c=r.data.domProps=h({},c));for(i in s)e(c[i])&&(a[i]="");for(i in c)if(o=c[i],"textContent"!==i&&"innerHTML"!==i||(r.children&&(r.children.length=0),o!==s[i]))if("value"===i){a._value=o;var u=null==o?"":String(o);En(a,r,u)&&(a.value=u)}else a[i]=o}}function En(e,t,n){return!e.composing&&("option"===t.tag||jn(e,n)||Nn(e,n))}function jn(e,t){return document.activeElement!==e&&e.value!==t}function Nn(e,n){var r=e.value,i=e._vModifiers;return t(i)&&i.number||"number"===e.type?c(r)!==c(n):t(i)&&i.trim?r.trim()!==n.trim():r!==n}function Ln(e){var t=In(e.style);return e.staticStyle?h(e.staticStyle,t):t}function In(e){return Array.isArray(e)?m(e):"string"==typeof e?Ca(e):e}function Dn(e,t){var n,r={};if(t)for(var i=e;i.componentInstance;)i=i.componentInstance._vnode,i.data&&(n=Ln(i.data))&&h(r,n);(n=Ln(e.data))&&h(r,n);for(var o=e;o=o.parent;)o.data&&(n=Ln(o.data))&&h(r,n);return r}function Mn(n,r){var i=r.data,o=n.data;if(!(e(i.staticStyle)&&e(i.style)&&e(o.staticStyle)&&e(o.style))){var a,s,c=r.elm,u=o.staticStyle,l=o.normalizedStyle||o.style||{},f=u||l,p=In(r.data.style)||{};r.data.normalizedStyle=t(p.__ob__)?h({},p):p;var d=Dn(r,!0);for(s in f)e(d[s])&&Oa(c,s,"");for(s in d)(a=d[s])!==f[s]&&Oa(c,s,null==a?"":a)}}function Pn(e,t){if(t&&(t=t.trim()))if(e.classList)t.indexOf(" ")>-1?t.split(/\s+/).forEach(function(t){return e.classList.add(t)}):e.classList.add(t);else{var n=" "+(e.getAttribute("class")||"")+" ";n.indexOf(" "+t+" ")<0&&e.setAttribute("class",(n+t).trim())}}function Rn(e,t){if(t&&(t=t.trim()))if(e.classList)t.indexOf(" ")>-1?t.split(/\s+/).forEach(function(t){return e.classList.remove(t)}):e.classList.remove(t);else{for(var n=" "+(e.getAttribute("class")||"")+" ",r=" "+t+" ";n.indexOf(r)>=0;)n=n.replace(r," ");e.setAttribute("class",n.trim())}}function Fn(e){if(e){if("object"==typeof e){var t={};return!1!==e.css&&h(t,ja(e.name||"v")),h(t,e),t}return"string"==typeof e?ja(e):void 0}}function Bn(e){Fa(function(){Fa(e)})}function Hn(e,t){(e._transitionClasses||(e._transitionClasses=[])).push(t),Pn(e,t)}function Un(e,t){e._transitionClasses&&l(e._transitionClasses,t),Rn(e,t)}function Vn(e,t,n){var r=zn(e,t),i=r.type,o=r.timeout,a=r.propCount;if(!i)return n();var s=i===La?Ma:Ra,c=0,u=function(){e.removeEventListener(s,l),n()},l=function(t){t.target===e&&++c>=a&&u()};setTimeout(function(){c0&&(n=La,l=a,f=o.length):t===Ia?u>0&&(n=Ia,l=u,f=c.length):(l=Math.max(a,u),n=l>0?a>u?La:Ia:null,f=n?n===La?o.length:c.length:0),{type:n,timeout:l,propCount:f,hasTransform:n===La&&Ba.test(r[Da+"Property"])}}function Jn(e,t){for(;e.length1}function Yn(e,t){!0!==t.data.show&&qn(t)}function Qn(e,t,n){var r=t.value,i=e.multiple;if(!i||Array.isArray(r)){for(var o,a,s=0,c=e.options.length;s-1,a.selected!==o&&(a.selected=o);else if(y(er(a),r))return void(e.selectedIndex!==s&&(e.selectedIndex=s));i||(e.selectedIndex=-1)}}function Xn(e,t){for(var n=0,r=t.length;n=0&&a[i].lowerCasedTag!==s;i--);else i=0;if(i>=0){for(var c=a.length-1;c>=i;c--)t.end&&t.end(a[c].tag,n,r);a.length=i,o=i&&a[i-1].tag}else"br"===s?t.start&&t.start(e,[],!0,n,r):"p"===s&&(t.start&&t.start(e,[],!1,n,r),t.end&&t.end(e,n,r))}for(var i,o,a=[],s=t.expectHTML,c=t.isUnaryTag||Ni,u=t.canBeLeftOpenTag||Ni,l=0;e;){if(i=e,o&&Ns(o)){var f=o.toLowerCase(),p=Ls[f]||(Ls[f]=new RegExp("([\\s\\S]*?)(]*>)","i")),d=0,v=e.replace(p,function(e,n,r){return d=r.length,Ns(f)||"noscript"===f||(n=n.replace(//g,"$1").replace(//g,"$1")),t.chars&&t.chars(n),""});l+=e.length-v.length,e=v,r(f,l-d,l)}else{var h=e.indexOf("<");if(0===h){if(fs.test(e)){var m=e.indexOf("--\x3e");if(m>=0){n(m+3);continue}}if(ps.test(e)){var g=e.indexOf("]>");if(g>=0){n(g+2);continue}}var y=e.match(ls);if(y){n(y[0].length);continue}var _=e.match(us);if(_){var b=l;n(_[0].length),r(_[1],b,l);continue}var $=function(){var t=e.match(ss);if(t){var r={tagName:t[1],attrs:[],start:l};n(t[0].length);for(var i,o;!(i=e.match(cs))&&(o=e.match(os));)n(o[0].length),r.attrs.push(o);if(i)return r.unarySlash=i[1],n(i[0].length),r.end=l,r}}();if($){!function(e){var n=e.tagName,i=e.unarySlash;s&&("p"===o&&rs(n)&&r(o),u(n)&&o===n&&r(n));for(var l=c(n)||"html"===n&&"head"===o||!!i,f=e.attrs.length,p=new Array(f),d=0;d=0){for(w=e.slice(h);!(us.test(w)||ss.test(w)||fs.test(w)||ps.test(w)||(C=w.indexOf("<",1))<0);)h+=C,w=e.slice(h);x=e.substring(0,h),n(h)}h<0&&(x=e,e=""),t.chars&&x&&t.chars(x)}if(e===i){t.chars&&t.chars(e);break}}r()}function mr(e,t){var n=t?Rs(t):Ps;if(n.test(e)){for(var r,i,o=[],a=n.lastIndex=0;r=n.exec(e);){i=r.index,i>a&&o.push(JSON.stringify(e.slice(a,i)));var s=tn(r[1].trim());o.push("_s("+s+")"),a=i+r[0].length}return a0,Ki=Vi&&Vi.indexOf("edge/")>0,qi=Vi&&Vi.indexOf("android")>0,Wi=Vi&&/iphone|ipad|ipod|ios/.test(Vi),Zi=Vi&&/chrome\/\d+/.test(Vi)&&!Ki,Gi=!1;if(Ui)try{var Yi={};Object.defineProperty(Yi,"passive",{get:function(){Gi=!0}}),window.addEventListener("test-passive",null,Yi)}catch(e){}var Qi,Xi,eo=function(){return void 0===Qi&&(Qi=!Ui&&"undefined"!=typeof global&&"server"===global.process.env.VUE_ENV),Qi},to=Ui&&window.__VUE_DEVTOOLS_GLOBAL_HOOK__,no="undefined"!=typeof Symbol&&k(Symbol)&&"undefined"!=typeof Reflect&&k(Reflect.ownKeys),ro=function(){function e(){r=!1;var e=n.slice(0);n.length=0;for(var t=0;t1?v(n):n;for(var r=v(arguments,1),i=0,o=n.length;i1&&(t[n[0].trim()]=n[1].trim())}}),t}),ka=/^--/,Aa=/\s*!important$/,Oa=function(e,t,n){if(ka.test(t))e.style.setProperty(t,n);else if(Aa.test(n))e.style.setProperty(t,n.replace(Aa,""),"important");else{var r=Ta(t);if(Array.isArray(n))for(var i=0,o=n.length;iv?(f=e(i[g+1])?null:i[g+1].elm,y(n,f,i,d,g,o)):d>g&&b(n,r,p,v)}function w(r,i,o,a){if(r!==i){if(n(i.isStatic)&&n(r.isStatic)&&i.key===r.key&&(n(i.isCloned)||n(i.isOnce)))return i.elm=r.elm,void(i.componentInstance=r.componentInstance);var s,c=i.data;t(c)&&t(s=c.hook)&&t(s=s.prepatch)&&s(r,i);var u=i.elm=r.elm,l=r.children,f=i.children;if(t(c)&&h(i)){for(s=0;s',n.innerHTML.indexOf(t)>0}("\n"," "),ts=u("area,base,br,col,embed,frame,hr,img,input,isindex,keygen,link,meta,param,source,track,wbr"),ns=u("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source"),rs=u("address,article,aside,base,blockquote,body,caption,col,colgroup,dd,details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,title,tr,track"),is=[/"([^"]*)"+/.source,/'([^']*)'+/.source,/([^\s"'=<>`]+)/.source],os=new RegExp("^\\s*"+/([^\s"'<>\/=]+)/.source+"(?:\\s*("+/(?:=)/.source+")\\s*(?:"+is.join("|")+"))?"),as="[a-zA-Z_][\\w\\-\\.]*",ss=new RegExp("^<((?:"+as+"\\:)?"+as+")"),cs=/^\s*(\/?)>/,us=new RegExp("^<\\/((?:"+as+"\\:)?"+as+")[^>]*>"),ls=/^]+>/i,fs=/^ - - - 提示:【path主要用于图片视频类文件回显,他用自行处理】:{{item.path}} - {{item.name}} - 大小:{{item.size}} - 状态:{{item.type}} - 进度:{{item.progress}} - 服务端返回演示:{{item.responseText}} - 重新上传 - 删除 - - - - - - {{item.name}} - 大小:{{item.size}} - 状态:{{item.type}} - 进度:{{item.progress}} - - - - - - - - - - -``` - ---- -* 函数说明 - - -``` javascript -export default { - data() { - return { - // 上传接口参数 - option: { - // 上传服务器地址,需要替换为你的接口地址 - url: 'http://xxxxxxx/dropbox/document/upload', // 该地址非真实路径,需替换为你项目自己的接口地址 - // 上传附件的key - name: 'file', - // 根据你接口需求自定义请求头,默认不要写content-type,让浏览器自适配 - header: { - // 示例参数可删除 - 'Authorization': 'bearer eyJhbGciOiJSUzI1NiIsI', - 'uid': '99', - 'client': 'app', - 'accountid': 'DP', - }, - // 根据你接口需求自定义body参数 - formData: { - // 'orderId': 1000 - } - }, - // 选择文件后是否立即自动上传,true=选择后立即上传 - instantly: true, - // 必传宽高且宽高应与slot宽高保持一致 - width: '180rpx', - height: '180rpx', - // 限制允许上传的格式,空串=不限制,默认为空 - formats: '', - // 文件上传大小限制 - size: 30, - // 文件数量限制 - count: 2, - // 文件回显列表 - files: new Map(), - // 微信小程序Map对象for循环不显示,所以转成普通数组,不要问为什么,我也不知道 - wxFiles: [], - // 是否打印日志 - debug: true, - - - // 演示用 - tabIndex: 0, - list:[], - } - }, - onReady() { - setTimeout(()=>{ - console.log('----演示动态更新参数-----'); - this.$refs['ytUpload'+this.tabIndex].setData('formData.orderId','动态设置的参数'); - - console.log('以下注释内容为-动态更新参数更多演示,放开后可查看演示效果'); - // 修改option对象的name属性 - // this.$refs.ytUpload.setData('name','myFile'); - - // 修改option对象的formData内的属性 - // this.$refs.ytUpload.setData('formData.appid','1111'); - - // 替换option对象的formData - // this.$refs.ytUpload.setData('formData',{appid:'222'}); - - // option对象的formData新增属性 - // this.$refs.ytUpload.setData('formData.newkey','新插入到formData的属性'); - - - // ---------演示初始化值,用于已提交后再次编辑时需带入已上传文件------- - // 方式1=传入数组 - // let files1 = [{name: '1.png'},{name: '2.png',}]; - - // 方式2=传入Map对象 - // let files2 = new Map(); - // files2.set('1.png',{name: '1.png'}) - - // 此处调用setFiles设置初始files - // this.$refs.ytUpload.setFiles(files1); - - // 初始化tab - this.onTab(0); - },2000) - }, - methods: { - // 某文件上传结束回调(成功失败都回调) - onuploadEnd(item) { - console.log(`${item.name}已上传结束,上传状态=${item.type}`); - - // 更新当前窗口状态变化的文件 - this.files.set(item.name,item); - - // ---可删除--演示上传完成后取服务端数据 - if (item['responseText']) { - console.log('演示服务器返回的字符串JSON转Object对象'); - this.files.get(item.name).responseText = JSON.parse(item.responseText); - } - - // 微信小程序Map对象for循环不显示,所以转成普通数组, - // 如果你用不惯Map对象,也可以像这样转普通数组,组件使用Map主要是避免反复文件去重操作 - // #ifdef MP-WEIXIN - this.wxFiles = [...this.files.values()]; - // #endif - - // 强制更新视图 - this.$forceUpdate(); - - - // ---可删除--演示判断是否所有文件均已上传成功 - let isAll = [...this.files.values()].find(item=>item.type!=='success'); - if (!isAll) { - console.log('已全部上传完毕'); - } - else { - console.log(isAll.name+'待上传'); - } - - }, - // 上传进度回调 - onprogress(item) { - // 更新当前状态变化的文件 - this.files.set(item.name,item); - - console.log('打印对象',JSON.stringify(this.files.get(item.name))); - // 微信小程序Map对象for循环不显示,所以转成普通数组,不要问为什么,我也不知道 - // #ifdef MP-WEIXIN - this.wxFiles = [...this.files.values()]; - // #endif - - // 强制更新视图 - this.$forceUpdate(); - - }, - // 文件选择回调 - onChange(files) { - console.log('当前选择的文件列表:',JSON.stringify([...files.values()])); - // 更新选择的文件 - this.files = files; - // 强制更新视图 - this.$forceUpdate(); - - // 微信小程序Map对象for循环不显示,所以转成普通数组,不要问为什么,我也不知道 - // #ifdef MP-WEIXIN - this.wxFiles = [...this.files.values()]; - // #endif - - // ---可删除--演示重新定位覆盖层控件 - this.$nextTick(()=>{ - console.log('演示重新定位'); - this.$refs.ytUpload0.show(); - this.$refs.ytUpload1.show(); - this.$refs.ytUpload2.show(); - }); - - }, - // 手动上传 - upload() { - // name=指定文件名,不指定则上传所有type等于waiting和fail的文件 - this.$refs['ytUpload'+this.tabIndex].upload(); - }, - // 指定上传某个文件 - resetUpload(name) { - this.$refs['ytUpload'+this.tabIndex].upload(name); - }, - // 移除某个文件 - clear(name) { - // name=指定文件名,不传name默认移除所有文件 - this.$refs['ytUpload'+this.tabIndex].clear(name); - }, - /** - * ---可删除--演示在组件上方添加新内容DOM变化 - * DOM重排演示,重排后组件内部updated默认会触发show方法,若特殊情况未能触发updated也可以手动调用一次show() - * 什么是DOM重排?自行百度去 - */ - add() { - this.list.push('DOM重排测试'); - }, - /** - * ---可删除--演示Tab切换时覆盖层是否能被点击 - * APP端因为是webview,层级比view高,此时若不希望点击触发选择文件,需要手动调用hide() - * 手动调用hide后,需要调用show()才能恢复覆盖层的点击 - */ - onTab(tabIndex) { - this.$refs.ytUpload0.hide(); - this.$refs.ytUpload1.hide(); - - this.tabIndex = tabIndex; - - this.$nextTick(()=>{ - this.$refs['ytUpload'+this.tabIndex].show(); - }) - - }, - /** - * 打开nvue窗口查看非跟随窗口滚动效果 - */ - open() { - uni.navigateTo({ - url: '/pages/nvue-demo/nvue-demo' - }); - } - } -} - -``` -| `QQ交流群(906392632)` | -| ----------------------| -|![QQ交流群](https://7072-prod-4gapv4gl33a8a0ff-1305990777.tcb.qcloud.la/%E9%87%8D%E8%A6%81%E5%9B%BE%E7%89%87%E5%AD%98%E5%82%A8/Snipaste_2023-11-06_16-50-56.png?sign=ed27f09cfeabb33e24835fecdd4108db&t=1699260686)| -| QQ群号:906392632 | - -## 温馨提示 - -* 文件上传 -0. 如说明表达还不够清楚,不清楚怎么使用可导入完整示例项目运行体验和查看 -1. APP端请优先联调Android,上传成功后再运行iOS端,如iOS返回status=0则需要后端开启允许跨域; -2. header的Content-Type类型需要与服务端要求一致,否则收不到附件(服务端若没有明文规定则可不写,使用默认匹配) -3. 服务端不清楚怎么配置跨域可加群咨询,具体百度~ -4. 若能帮到你还请点亮5颗小星星以作鼓励哈~ -5. 若能帮到你还请点亮5颗小星星以作鼓励哈~ -6. 若能帮到你还请点亮5颗小星星以作鼓励哈~ \ No newline at end of file