2026.1.22
1. 新增台账上传pdf,word,excel,ppt文件功能.
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | // component/filegrid/index.js |
| | | Component({ |
| | | options: { |
| | | addGlobalClass: true, |
| | | }, |
| | | /** |
| | | * ç»ä»¶ç屿§å表 |
| | | */ |
| | | properties: { |
| | | files: { |
| | | type: Array, |
| | | value: [], |
| | | observer(newVal) { |
| | | this.formatFiles(newVal); |
| | | }, |
| | | }, |
| | | gridHeight: { |
| | | type: String, |
| | | value: '29vw', |
| | | }, |
| | | gridWidth: { |
| | | type: String, |
| | | value: '29vw', |
| | | }, |
| | | }, |
| | | |
| | | /** |
| | | * ç»ä»¶çåå§æ°æ® |
| | | */ |
| | | data: { |
| | | currentFiles: [], |
| | | }, |
| | | |
| | | /** |
| | | * ç»ä»¶çæ¹æ³å表 |
| | | */ |
| | | methods: { |
| | | formatFiles(value) { |
| | | const currentFiles = value.map(f => { |
| | | // æ ¹æ®æä»¶ç±»åéæ©ä¸åæ ·å¼ |
| | | let extensionClass = ''; |
| | | switch (f.ext) { |
| | | case 'xls': |
| | | case 'xlsx': |
| | | case 'csv': |
| | | extensionClass = 'file_xlsx'; |
| | | break; |
| | | case 'doc': |
| | | case 'docx': |
| | | extensionClass = 'file_word'; |
| | | break; |
| | | case 'pdf': |
| | | extensionClass = 'file_pdf'; |
| | | break; |
| | | case 'ppt': |
| | | case 'pptx': |
| | | extensionClass = 'file_ppt'; |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | return { ...f, styleClass: extensionClass }; |
| | | }); |
| | | this.setData({ currentFiles }); |
| | | }, |
| | | //å¾çæ¾å¤§é¢è§ |
| | | previewImage(e) { |
| | | const { index } = e.currentTarget.dataset; |
| | | const f = this.data.currentFiles[index]; |
| | | const previewImageUrls = this.data.currentFiles |
| | | .filter(f => f.type == 'image') |
| | | .map(f => f.url); |
| | | const i = previewImageUrls.indexOf(f.url); |
| | | this.setData({ |
| | | previewImageUrls, |
| | | previewCurrent: i, |
| | | showPreview: true, |
| | | }); |
| | | }, |
| | | // æ¥çæä»¶ |
| | | previewFile(e) { |
| | | const { index } = e.currentTarget.dataset; |
| | | const file = this.data.currentFiles[index]; |
| | | if (file.url.indexOf('http') != -1) { |
| | | wx.showLoading({ |
| | | title: 'ä¸è½½æä»¶ä¸', |
| | | mask: true, |
| | | }); |
| | | wx.downloadFile({ |
| | | url: file.url, |
| | | success: res => { |
| | | wx.hideLoading(); |
| | | if (res.statusCode === 200) { |
| | | const filePath = res.tempFilePath; |
| | | wx.openDocument({ filePath: filePath }); |
| | | } else { |
| | | wx.showToast({ |
| | | title: 'æä»¶ä¸è½½å¤±è´¥', |
| | | icon: 'error', |
| | | }); |
| | | } |
| | | }, |
| | | fail(err) { |
| | | wx.showToast({ |
| | | title: 'æä»¶ä¸è½½å¤±è´¥', |
| | | icon: 'error', |
| | | }); |
| | | }, |
| | | }); |
| | | } else { |
| | | wx.openDocument({ filePath: file.url }); |
| | | } |
| | | }, |
| | | }, |
| | | }); |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | { |
| | | "component": true, |
| | | "usingComponents": { |
| | | "my-gallery": "/component/mygallery/mygallery" |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <!--component/filegrid/index.wxml--> |
| | | <view class="img-group"> |
| | | <block wx:for="{{currentFiles}}" wx:key="index"> |
| | | <!-- å¾ç --> |
| | | <image |
| | | wx:if="{{item.type == 'image'}}" |
| | | class="img-group_img" |
| | | style="{{'width:'+gridWidth+';height:'+gridHeight+';'}}" |
| | | src="{{item.url}}" |
| | | mode="aspectFill" |
| | | bindtap="previewImage" |
| | | data-index="{{index}}" |
| | | show-menu-by-longpress="{{true}}" |
| | | ></image> |
| | | <!-- 常è§officeæä»¶ --> |
| | | <view |
| | | wx:elif="{{item.type == 'file'}}" |
| | | data-index="{{index}}" |
| | | bindtap="previewFile" |
| | | class="img-group_img" |
| | | style="{{'width:'+gridWidth+';height:'+gridHeight+';'}}" |
| | | > |
| | | <view class="{{'uploader-preview__file ' + item.styleClass}}"> |
| | | <view class="wrap"> |
| | | <span class="{{'txt ' + item.styleClass}}">{{item.name}}</span> |
| | | </view> |
| | | <text class="unit" data-ext="{{item.ext}}">{{item.size}}</text> |
| | | </view> |
| | | </view> |
| | | <!-- å
¶ä» --> |
| | | <view |
| | | wx:else |
| | | data-index="{{index}}" |
| | | class="img-group_img uploader-preview__file" |
| | | > |
| | | <t-icon name="close-circle" size="36rpx" /> |
| | | </view> |
| | | </block> |
| | | </view> |
| | | <my-gallery |
| | | hide-on-click="{{true}}" |
| | | show-delete="{{false}}" |
| | | show="{{showPreview}}" |
| | | img-urls="{{previewImageUrls}}" |
| | | current="{{previewCurrent}}" |
| | | ></my-gallery> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | /* component/filegrid/index.wxss */ |
| | | .img-group { |
| | | display: flex; |
| | | flex-wrap: wrap; |
| | | } |
| | | |
| | | .img-group .img-group_img { |
| | | /* width: attr(data-width); |
| | | height: attr(data-height); */ |
| | | margin-bottom: 8px; |
| | | margin-right: 8px; |
| | | } |
| | | |
| | | .uploader-preview__file { |
| | | --default-bg-color: #888888; |
| | | position: relative; |
| | | display: flex; |
| | | flex-direction: column; |
| | | justify-content: space-between; |
| | | background-color: var(--default-bg-color); |
| | | color: white; |
| | | height: 100%; |
| | | font-size: 12px; |
| | | } |
| | | |
| | | .wrap { |
| | | height: 3em; |
| | | line-height: 1.5; |
| | | overflow: hidden; |
| | | /* background-color: rgb(0, 104, 104); */ |
| | | margin: 8rpx 8rpx 0 8rpx; |
| | | text-align: justify; |
| | | |
| | | } |
| | | |
| | | .wrap .txt { |
| | | max-height: 3em; |
| | | /* background-color: rgb(88, 104, 0); */ |
| | | /* margin: 8rpx 8rpx 0 8rpx; */ |
| | | display: -webkit-box; |
| | | -webkit-line-clamp: 2; |
| | | -webkit-box-orient: vertical; |
| | | overflow: hidden; |
| | | text-overflow: ellipsis; |
| | | } |
| | | |
| | | .unit { |
| | | margin: 0rpx 8rpx 8rpx 8rpx; |
| | | } |
| | | |
| | | .unit::after { |
| | | content: attr(data-ext); |
| | | position: absolute; |
| | | bottom: 0rpx; |
| | | right: 10rpx; |
| | | font-size: 30px; |
| | | color: #ffffff38; |
| | | } |
| | | |
| | | .file_xlsx { |
| | | background-color: #278553; |
| | | } |
| | | |
| | | .file_word { |
| | | background-color: #3980C0; |
| | | } |
| | | |
| | | .file_pdf { |
| | | background-color: #C84E39; |
| | | } |
| | | |
| | | .file_ppt { |
| | | background-color: #FF7A42; |
| | | } |
| | |
| | | module.exports = |
| | | /******/ |
| | | (function (modules) { // webpackBootstrap |
| | | (function (modules) { |
| | | // webpackBootstrap |
| | | /******/ // The module cache |
| | | /******/ |
| | | var installedModules = {}; |
| | | var installedModules = {}; /******/ // The require function |
| | | /******/ |
| | | /******/ // The require function |
| | | /******/ |
| | | function __webpack_require__(moduleId) { |
| | | /******/ function __webpack_require__(moduleId) { |
| | | /******/ |
| | | /******/ // Check if module is in cache |
| | | /******/ |
| | |
| | | /******/ |
| | | return installedModules[moduleId].exports; |
| | | /******/ |
| | | } |
| | | /******/ // Create a new module (and put it into the cache) |
| | | /******/ |
| | | var module = installedModules[moduleId] = { |
| | | } /******/ // Create a new module (and put it into the cache) |
| | | /******/ var module = (installedModules[moduleId] = { |
| | | /******/ |
| | | i: moduleId, |
| | | /******/ |
| | | l: false, |
| | | /******/ |
| | | exports: {} |
| | | exports: {}, |
| | | /******/ |
| | | }; |
| | | }); /******/ // Execute the module function |
| | | /******/ |
| | | /******/ // Execute the module function |
| | | /******/ modules[moduleId].call( |
| | | module.exports, |
| | | module, |
| | | module.exports, |
| | | __webpack_require__, |
| | | ); /******/ // Flag the module as loaded |
| | | /******/ |
| | | modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); |
| | | /******/ module.l = true; /******/ // Return the exports of the module |
| | | /******/ |
| | | /******/ // Flag the module as loaded |
| | | /******/ return module.exports; |
| | | /******/ |
| | | module.l = true; |
| | | /******/ |
| | | /******/ // Return the exports of the module |
| | | /******/ |
| | | return module.exports; |
| | | /******/ |
| | | } |
| | | } /******/ // expose the modules object (__webpack_modules__) |
| | | /******/ |
| | | /******/ |
| | | /******/ // expose the modules object (__webpack_modules__) |
| | | /******/ __webpack_require__.m = modules; /******/ // expose the module cache |
| | | /******/ |
| | | __webpack_require__.m = modules; |
| | | /******/ __webpack_require__.c = installedModules; /******/ // define getter function for harmony exports |
| | | /******/ |
| | | /******/ // expose the module cache |
| | | /******/ |
| | | __webpack_require__.c = installedModules; |
| | | /******/ |
| | | /******/ // define getter function for harmony exports |
| | | /******/ |
| | | __webpack_require__.d = function (exports, name, getter) { |
| | | /******/ __webpack_require__.d = function (exports, name, getter) { |
| | | /******/ |
| | | if (!__webpack_require__.o(exports, name)) { |
| | | /******/ |
| | | Object.defineProperty(exports, name, { |
| | | enumerable: true, |
| | | get: getter |
| | | get: getter, |
| | | }); |
| | | /******/ |
| | | } |
| | | /******/ |
| | | }; |
| | | }; /******/ // define __esModule on exports |
| | | /******/ |
| | | /******/ // define __esModule on exports |
| | | /******/ |
| | | __webpack_require__.r = function (exports) { |
| | | /******/ __webpack_require__.r = function (exports) { |
| | | /******/ |
| | | if (typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
| | | /******/ |
| | | Object.defineProperty(exports, Symbol.toStringTag, { |
| | | value: 'Module' |
| | | value: 'Module', |
| | | }); |
| | | /******/ |
| | | } |
| | | /******/ |
| | | Object.defineProperty(exports, '__esModule', { |
| | | value: true |
| | | value: true, |
| | | }); |
| | | /******/ |
| | | }; |
| | | }; /******/ /******/ /******/ /******/ /******/ // create a fake namespace object // mode & 1: value is a module id, require it // mode & 2: merge all properties of value into the ns // mode & 4: return value when already ns object // mode & 8|1: behave like require |
| | | /******/ |
| | | /******/ // create a fake namespace object |
| | | /******/ // mode & 1: value is a module id, require it |
| | | /******/ // mode & 2: merge all properties of value into the ns |
| | | /******/ // mode & 4: return value when already ns object |
| | | /******/ // mode & 8|1: behave like require |
| | | /******/ |
| | | __webpack_require__.t = function (value, mode) { |
| | | /******/ __webpack_require__.t = function (value, mode) { |
| | | /******/ |
| | | if (mode & 1) value = __webpack_require__(value); |
| | | /******/ |
| | | if (mode & 8) return value; |
| | | /******/ |
| | | if ((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; |
| | | if (mode & 4 && typeof value === 'object' && value && value.__esModule) |
| | | return value; |
| | | /******/ |
| | | var ns = Object.create(null); |
| | | /******/ |
| | |
| | | /******/ |
| | | Object.defineProperty(ns, 'default', { |
| | | enumerable: true, |
| | | value: value |
| | | value: value, |
| | | }); |
| | | /******/ |
| | | if (mode & 2 && typeof value != 'string') |
| | | for (var key in value) __webpack_require__.d(ns, key, function (key) { |
| | | return value[key]; |
| | | }.bind(null, key)); |
| | | for (var key in value) |
| | | __webpack_require__.d( |
| | | ns, |
| | | key, |
| | | function (key) { |
| | | return value[key]; |
| | | }.bind(null, key), |
| | | ); |
| | | /******/ |
| | | return ns; |
| | | /******/ |
| | | }; |
| | | }; /******/ // getDefaultExport function for compatibility with non-harmony modules |
| | | /******/ |
| | | /******/ // getDefaultExport function for compatibility with non-harmony modules |
| | | /******/ |
| | | __webpack_require__.n = function (module) { |
| | | /******/ __webpack_require__.n = function (module) { |
| | | /******/ |
| | | var getter = module && module.__esModule ? |
| | | /******/ |
| | | function getDefault() { |
| | | return module['default']; |
| | | } : |
| | | /******/ |
| | | function getModuleExports() { |
| | | return module; |
| | | }; |
| | | var getter = |
| | | module && module.__esModule |
| | | ? /******/ |
| | | function getDefault() { |
| | | return module['default']; |
| | | } |
| | | : /******/ |
| | | function getModuleExports() { |
| | | return module; |
| | | }; |
| | | /******/ |
| | | __webpack_require__.d(getter, 'a', getter); |
| | | /******/ |
| | | return getter; |
| | | /******/ |
| | | }; |
| | | }; /******/ // Object.prototype.hasOwnProperty.call |
| | | /******/ |
| | | /******/ // Object.prototype.hasOwnProperty.call |
| | | /******/ |
| | | __webpack_require__.o = function (object, property) { |
| | | /******/ __webpack_require__.o = function (object, property) { |
| | | return Object.prototype.hasOwnProperty.call(object, property); |
| | | }; |
| | | }; /******/ // __webpack_public_path__ |
| | | /******/ |
| | | /******/ // __webpack_public_path__ |
| | | /******/ |
| | | __webpack_require__.p = ""; |
| | | /******/ __webpack_require__.p = ''; /******/ // Load entry module and return exports |
| | | /******/ |
| | | /******/ |
| | | /******/ // Load entry module and return exports |
| | | /******/ return __webpack_require__((__webpack_require__.s = 22)); |
| | | /******/ |
| | | return __webpack_require__(__webpack_require__.s = 22); |
| | | })( |
| | | /************************************************************************/ |
| | | /******/ |
| | | }) |
| | | /************************************************************************/ |
| | | /******/ |
| | | ({ |
| | | |
| | | /***/ |
| | | 22: |
| | | /***/ |
| | | (function (module, exports, __webpack_require__) { |
| | | |
| | | "use strict"; |
| | | |
| | | |
| | | Component({ |
| | | options: { |
| | | addGlobalClass: true |
| | | }, |
| | | properties: { |
| | | title: { |
| | | type: String, |
| | | value: '' |
| | | }, |
| | | titleClass: { |
| | | type: "String", |
| | | value: "" |
| | | }, |
| | | |
| | | sizeType: { |
| | | type: Array, |
| | | value: ['original', 'compressed'] |
| | | }, |
| | | sourceType: { |
| | | type: Array, |
| | | value: ['album', 'camera'] |
| | | }, |
| | | maxSize: { |
| | | type: Number, |
| | | value: 5 * 1024 * 1024 |
| | | }, |
| | | maxCount: { |
| | | // æå¤ä¸ä¼ å¤å°ä¸ªæä»¶ |
| | | type: Number, |
| | | value: 1 |
| | | }, |
| | | countInfo: { |
| | | type: String, |
| | | value: "" |
| | | }, |
| | | files: { |
| | | // å½åçå¾çå表, {url, error, loading} |
| | | type: Array, |
| | | value: [], |
| | | |
| | | observer(newVal) { |
| | | this.setData({ |
| | | currentFiles: newVal |
| | | }); |
| | | } |
| | | |
| | | }, |
| | | select: { |
| | | // è¿æ»¤æä¸ªæä»¶ |
| | | type: null, |
| | | value: null |
| | | }, |
| | | upload: { |
| | | // è¿åPromiseçä¸ä¸ªæä»¶ä¸ä¼ ç彿° |
| | | type: null, |
| | | value: () => {} |
| | | }, |
| | | tips: { |
| | | type: String, |
| | | value: '' |
| | | }, |
| | | extClass: { |
| | | type: String, |
| | | value: '' |
| | | }, |
| | | showDelete: { |
| | | // æ¯å¦æ¾ç¤ºdeleteæé® |
| | | type: Boolean, |
| | | value: true |
| | | } |
| | | }, |
| | | data: { |
| | | currentFiles: [], |
| | | showPreview: false, |
| | | previewImageUrls: [], |
| | | groups: [{ |
| | | text: 'éæ©å¾ç', |
| | | value: 0 |
| | | }, { |
| | | text: 'ä»è天记å½éæ©æä»¶', |
| | | value: 1 |
| | | }], |
| | | }, |
| | | |
| | | ready() {}, |
| | | |
| | | methods: { |
| | | showActionSheet() { |
| | | this.setData({ |
| | | showSheet: true |
| | | }) |
| | | }, |
| | | previewImage(e) { |
| | | const { |
| | | index |
| | | } = e.currentTarget.dataset; |
| | | const previewImageUrls = []; |
| | | this.data.files.forEach(item => { |
| | | previewImageUrls.push(item.url); |
| | | }); |
| | | this.setData({ |
| | | previewImageUrls, |
| | | previewCurrent: index, |
| | | showPreview: true |
| | | }); |
| | | }, |
| | | previewFile(e) { |
| | | const { |
| | | index |
| | | } = e.currentTarget.dataset; |
| | | const file = this.data.files[index] |
| | | wx.openDocument({ |
| | | filePath: file.url, |
| | | }); |
| | | }, |
| | | actionClick(e) { |
| | | switch (e.detail.value) { |
| | | case 0: |
| | | this.chooseImage() |
| | | break; |
| | | case 1: |
| | | this.chooseMessageFile() |
| | | break; |
| | | default: |
| | | this.chooseImage() |
| | | break; |
| | | } |
| | | this.setData({ |
| | | showSheet: false |
| | | }) |
| | | }, |
| | | chooseImage() { |
| | | if (this.uploading) return; |
| | | wx.chooseMedia({ |
| | | count: this.data.maxCount - this.data.files.length, |
| | | sizeType: ['compressed'], |
| | | mediaType: ['image'], |
| | | success: res => { |
| | | console.log('chooseImage resp', res) |
| | | // é¦å
æ£æ¥æä»¶å¤§å° |
| | | let invalidIndex = -1; // @ts-ignore |
| | | res.tempFilePaths = res.tempFiles.map(item => item.tempFilePath) |
| | | res.tempFiles.forEach((item, index) => { |
| | | if (item.size > this.data.maxSize) { |
| | | invalidIndex = index; |
| | | } |
| | | }); |
| | | if (typeof this.data.select === 'function') { |
| | | const ret = this.data.select(res); |
| | | if (ret === false) { |
| | | return; |
| | | } |
| | | } |
| | | if (invalidIndex >= 0) { |
| | | this.triggerEvent('fail', { |
| | | type: 1, |
| | | errMsg: `chooseImage:fail size exceed ${this.data.maxSize}`, |
| | | total: res.tempFilePaths.length, |
| | | index: invalidIndex |
| | | }, {}); |
| | | return; |
| | | } // è·åæä»¶å
容 |
| | | |
| | | |
| | | const mgr = wx.getFileSystemManager(); |
| | | const contents = res.tempFilePaths.map(item => { |
| | | // @ts-ignore |
| | | const fileContent = mgr.readFileSync(item); |
| | | return fileContent; |
| | | }); |
| | | const obj = { |
| | | tempFilePaths: res.tempFilePaths, |
| | | tempFiles: res.tempFiles, |
| | | contents |
| | | }; // 触åéä¸çäºä»¶ï¼å¼åè
æ ¹æ®å
容æ¥ä¸ä¼ æä»¶ï¼ä¸ä¼ äºæä¸ä¼ çç»æåé¦å°files屿§éé¢ |
| | | |
| | | this.triggerEvent('select', obj, {}); |
| | | |
| | | let files = res.tempFiles.map((item, i) => ({ |
| | | loading: true, |
| | | url: item.tempFilePath, |
| | | type: item.fileType, |
| | | })) |
| | | //å缩å¾ç |
| | | wx.compressImage({ |
| | | src: files[0].url, |
| | | quality: 20, |
| | | success(data) { |
| | | console.log('compressImage', data) |
| | | }, |
| | | fail() { |
| | | |
| | | } |
| | | }) |
| | | |
| | | if (!files || !files.length) return; |
| | | const newFiles = this.data.files.concat(files); |
| | | this.setData({ |
| | | files: newFiles, |
| | | currentFiles: newFiles |
| | | }); |
| | | this.triggerEvent('uploadImg', { |
| | | newFiles |
| | | }, {}) |
| | | }, |
| | | fail: fail => { |
| | | if (fail.errMsg.indexOf('chooseImage:fail cancel') >= 0) { |
| | | this.triggerEvent('cancel', {}, {}); |
| | | return; |
| | | } |
| | | fail.type = 2; |
| | | this.triggerEvent('fail', fail, {}); |
| | | } |
| | | }); |
| | | }, |
| | | chooseMessageFile() { |
| | | if (this.uploading) return; |
| | | wx.chooseMessageFile({ |
| | | count: this.data.maxCount - this.data.files.length, |
| | | type: 'file', |
| | | extension: ['xls', 'xlsx', 'csv', 'doc', 'docx', 'pdf', 'ppt', 'pptx'], |
| | | success: res => { |
| | | console.log('chooseMessageFile', res) |
| | | // é¦å
æ£æ¥æä»¶å¤§å° |
| | | let invalidIndex = -1; // @ts-ignore |
| | | res.tempFilePaths = res.tempFiles.map(item => item.path) |
| | | res.tempFiles.forEach((item, index) => { |
| | | if (item.size > this.data.maxSize) { |
| | | invalidIndex = index; |
| | | } |
| | | }); |
| | | if (typeof this.data.select === 'function') { |
| | | const ret = this.data.select(res); |
| | | if (ret === false) { |
| | | return; |
| | | } |
| | | } |
| | | if (invalidIndex >= 0) { |
| | | this.triggerEvent('fail', { |
| | | type: 1, |
| | | errMsg: `chooseMessageFile:fail size exceed ${this.data.maxSize}`, |
| | | total: res.tempFilePaths.length, |
| | | index: invalidIndex |
| | | }, {}); |
| | | return; |
| | | } // è·åæä»¶å
容 |
| | | |
| | | |
| | | const mgr = wx.getFileSystemManager(); |
| | | const contents = res.tempFilePaths.map(item => { |
| | | // @ts-ignore |
| | | const fileContent = mgr.readFileSync(item); |
| | | return fileContent; |
| | | }); |
| | | const obj = { |
| | | tempFilePaths: res.tempFilePaths, |
| | | tempFiles: res.tempFiles, |
| | | contents |
| | | }; // 触åéä¸çäºä»¶ï¼å¼åè
æ ¹æ®å
容æ¥ä¸ä¼ æä»¶ï¼ä¸ä¼ äºæä¸ä¼ çç»æåé¦å°files屿§éé¢ |
| | | |
| | | this.triggerEvent('select', obj, {}); |
| | | |
| | | let files = res.tempFiles.map((item, i) => { |
| | | // 夿æä»¶ç±»åï¼å¯¹åºä¸åæ ·å¼ |
| | | let extensionClass = '' |
| | | switch (item.name.split('.')[1]) { |
| | | case 'xls': |
| | | case 'xlsx': |
| | | case 'csv': |
| | | extensionClass = 'file_xlsx' |
| | | break; |
| | | case 'doc': |
| | | case 'docx': |
| | | extensionClass = 'file_word' |
| | | break; |
| | | case 'pdf': |
| | | extensionClass = 'file_pdf' |
| | | break; |
| | | case 'ppt': |
| | | case 'pptx': |
| | | extensionClass = 'file_ppt' |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | // æåæä»¶åç§°ï¼å®ç°ææ¬è¿é¿æ¶ï¼ä¸é´çç¥ |
| | | const ellipsisName = { |
| | | start: item.name.slice(0, -5), |
| | | // 快尾5个åç¬¦å¸¸ææ¾ç¤º |
| | | end: item.name.substr(-5, 5) |
| | | } |
| | | // æä»¶å¤§å°æ ¼å¼å |
| | | let size = parseInt(item.size / 1024) |
| | | if (size > 1024) { |
| | | size = parseInt(size / 1024) + ' MB' |
| | | } else { |
| | | size += ' KB' |
| | | } |
| | | return { |
| | | loading: true, |
| | | url: item.path, |
| | | name: item.name, |
| | | ellipsisName, |
| | | styleClass: extensionClass, |
| | | type: item.type, |
| | | time: item.time, |
| | | size |
| | | } |
| | | }) |
| | | if (!files || !files.length) return; |
| | | const newFiles = this.data.files.concat(files); |
| | | this.setData({ |
| | | files: newFiles, |
| | | currentFiles: newFiles |
| | | }); |
| | | this.triggerEvent('uploadImg', { |
| | | newFiles |
| | | }, {}) |
| | | } |
| | | }) |
| | | }, |
| | | deletePic(e) { |
| | | const index = e.detail.index; |
| | | const files = this.data.files; |
| | | const file = files.splice(index, 1); |
| | | this.setData({ |
| | | files, |
| | | currentFiles: files |
| | | }); |
| | | this.triggerEvent('delete', { |
| | | index, |
| | | item: file[0] |
| | | }); |
| | | }, |
| | | |
| | | |
| | | } |
| | | }); |
| | | |
| | | { |
| | | /***/ |
| | | }) |
| | | 22: |
| | | /***/ |
| | | function (module, exports, __webpack_require__) { |
| | | 'use strict'; |
| | | |
| | | /******/ |
| | | }); |
| | | Component({ |
| | | options: { |
| | | addGlobalClass: true, |
| | | }, |
| | | properties: { |
| | | title: { |
| | | type: String, |
| | | value: '', |
| | | }, |
| | | titleClass: { |
| | | type: 'String', |
| | | value: '', |
| | | }, |
| | | |
| | | sizeType: { |
| | | type: Array, |
| | | value: ['original', 'compressed'], |
| | | }, |
| | | sourceType: { |
| | | type: Array, |
| | | value: ['album', 'camera'], |
| | | }, |
| | | maxSize: { |
| | | type: Number, |
| | | value: 5 * 1024 * 1024, |
| | | }, |
| | | maxCount: { |
| | | // æå¤ä¸ä¼ å¤å°ä¸ªæä»¶ |
| | | type: Number, |
| | | value: 1, |
| | | }, |
| | | countInfo: { |
| | | type: String, |
| | | value: '', |
| | | }, |
| | | files: { |
| | | // å½åçå¾çå表, {url, error, loading} |
| | | type: Array, |
| | | value: [], |
| | | |
| | | observer(newVal) { |
| | | this.setData({ |
| | | currentFiles: newVal, |
| | | }); |
| | | }, |
| | | }, |
| | | select: { |
| | | // è¿æ»¤æä¸ªæä»¶ |
| | | type: null, |
| | | value: null, |
| | | }, |
| | | upload: { |
| | | // è¿åPromiseçä¸ä¸ªæä»¶ä¸ä¼ ç彿° |
| | | type: null, |
| | | value: () => {}, |
| | | }, |
| | | tips: { |
| | | type: String, |
| | | value: '', |
| | | }, |
| | | extClass: { |
| | | type: String, |
| | | value: '', |
| | | }, |
| | | showDelete: { |
| | | // æ¯å¦æ¾ç¤ºdeleteæé® |
| | | type: Boolean, |
| | | value: true, |
| | | }, |
| | | allowFiles: { |
| | | // æ¯å¦å
è®¸éæ©å¾çä¹å¤çå
¶ä»æ ¼å¼æä»¶ |
| | | type: Boolean, |
| | | value: false, |
| | | }, |
| | | }, |
| | | data: { |
| | | currentFiles: [], |
| | | showPreview: false, |
| | | previewImageUrls: [], |
| | | groups: [ |
| | | { |
| | | text: 'éæ©å¾ç', |
| | | value: 0, |
| | | }, |
| | | { |
| | | text: 'ä»è天记å½éæ©æä»¶', |
| | | value: 1, |
| | | }, |
| | | ], |
| | | }, |
| | | |
| | | ready() {}, |
| | | |
| | | methods: { |
| | | showActionSheet() { |
| | | if (this.data.allowFiles) { |
| | | this.setData({ |
| | | showSheet: true, |
| | | }); |
| | | } else { |
| | | this.chooseImage(); |
| | | } |
| | | }, |
| | | previewImage(e) { |
| | | const { index } = e.currentTarget.dataset; |
| | | const f = this.data.files[index]; |
| | | const previewImageUrls = this.data.files |
| | | .filter(f => f.type == 'image') |
| | | .map(f => f.url); |
| | | const i = previewImageUrls.indexOf(f.url); |
| | | this.setData({ |
| | | previewImageUrls, |
| | | previewCurrent: i, |
| | | showPreview: true, |
| | | }); |
| | | }, |
| | | previewFile(e) { |
| | | const { index } = e.currentTarget.dataset; |
| | | const file = this.data.files[index]; |
| | | wx.openDocument({ |
| | | filePath: file.url, |
| | | }); |
| | | }, |
| | | actionClick(e) { |
| | | switch (e.detail.value) { |
| | | case 0: |
| | | this.chooseImage(); |
| | | break; |
| | | case 1: |
| | | this.chooseMessageFile(); |
| | | break; |
| | | default: |
| | | this.chooseImage(); |
| | | break; |
| | | } |
| | | this.setData({ |
| | | showSheet: false, |
| | | }); |
| | | }, |
| | | chooseImage() { |
| | | if (this.uploading) return; |
| | | wx.chooseMedia({ |
| | | count: this.data.maxCount - this.data.files.length, |
| | | sizeType: ['compressed'], |
| | | mediaType: ['image'], |
| | | success: res => { |
| | | console.log('chooseImage resp', res); |
| | | // é¦å
æ£æ¥æä»¶å¤§å° |
| | | let invalidIndex = -1; // @ts-ignore |
| | | res.tempFilePaths = res.tempFiles.map( |
| | | item => item.tempFilePath, |
| | | ); |
| | | res.tempFiles.forEach((item, index) => { |
| | | if (item.size > this.data.maxSize) { |
| | | invalidIndex = index; |
| | | } |
| | | }); |
| | | if (typeof this.data.select === 'function') { |
| | | const ret = this.data.select(res); |
| | | if (ret === false) { |
| | | return; |
| | | } |
| | | } |
| | | if (invalidIndex >= 0) { |
| | | this.triggerEvent( |
| | | 'fail', |
| | | { |
| | | type: 1, |
| | | errMsg: `chooseImage:fail size exceed ${this.data.maxSize}`, |
| | | total: res.tempFilePaths.length, |
| | | index: invalidIndex, |
| | | }, |
| | | {}, |
| | | ); |
| | | return; |
| | | } // è·åæä»¶å
容 |
| | | |
| | | const mgr = wx.getFileSystemManager(); |
| | | const contents = res.tempFilePaths.map(item => { |
| | | // @ts-ignore |
| | | const fileContent = mgr.readFileSync(item); |
| | | return fileContent; |
| | | }); |
| | | const obj = { |
| | | tempFilePaths: res.tempFilePaths, |
| | | tempFiles: res.tempFiles, |
| | | contents, |
| | | }; // 触åéä¸çäºä»¶ï¼å¼åè
æ ¹æ®å
容æ¥ä¸ä¼ æä»¶ï¼ä¸ä¼ äºæä¸ä¼ çç»æåé¦å°files屿§éé¢ |
| | | |
| | | this.triggerEvent('select', obj, {}); |
| | | |
| | | let files = res.tempFiles.map((item, i) => ({ |
| | | loading: true, |
| | | url: item.tempFilePath, |
| | | type: item.fileType, |
| | | })); |
| | | //å缩å¾ç |
| | | wx.compressImage({ |
| | | src: files[0].url, |
| | | quality: 20, |
| | | success(data) { |
| | | console.log('compressImage', data); |
| | | }, |
| | | fail() {}, |
| | | }); |
| | | |
| | | if (!files || !files.length) return; |
| | | const newFiles = this.data.files.concat(files); |
| | | this.setData({ |
| | | files: newFiles, |
| | | currentFiles: newFiles, |
| | | }); |
| | | this.triggerEvent( |
| | | 'uploadImg', |
| | | { |
| | | newFiles, |
| | | }, |
| | | {}, |
| | | ); |
| | | }, |
| | | fail: fail => { |
| | | if (fail.errMsg.indexOf('chooseImage:fail cancel') >= 0) { |
| | | this.triggerEvent('cancel', {}, {}); |
| | | return; |
| | | } |
| | | fail.type = 2; |
| | | this.triggerEvent('fail', fail, {}); |
| | | }, |
| | | }); |
| | | }, |
| | | chooseMessageFile() { |
| | | if (this.uploading) return; |
| | | wx.chooseMessageFile({ |
| | | count: this.data.maxCount - this.data.files.length, |
| | | type: 'file', |
| | | extension: [ |
| | | 'xls', |
| | | 'xlsx', |
| | | 'csv', |
| | | 'doc', |
| | | 'docx', |
| | | 'pdf', |
| | | 'ppt', |
| | | 'pptx', |
| | | ], |
| | | success: res => { |
| | | console.log('chooseMessageFile', res); |
| | | // é¦å
æ£æ¥æä»¶å¤§å° |
| | | let invalidIndex = -1; // @ts-ignore |
| | | res.tempFilePaths = res.tempFiles.map(item => item.path); |
| | | res.tempFiles.forEach((item, index) => { |
| | | if (item.size > this.data.maxSize) { |
| | | invalidIndex = index; |
| | | } |
| | | }); |
| | | if (typeof this.data.select === 'function') { |
| | | const ret = this.data.select(res); |
| | | if (ret === false) { |
| | | return; |
| | | } |
| | | } |
| | | if (invalidIndex >= 0) { |
| | | this.triggerEvent( |
| | | 'fail', |
| | | { |
| | | type: 1, |
| | | errMsg: `chooseMessageFile:fail size exceed ${this.data.maxSize}`, |
| | | total: res.tempFilePaths.length, |
| | | index: invalidIndex, |
| | | }, |
| | | {}, |
| | | ); |
| | | return; |
| | | } // è·åæä»¶å
容 |
| | | |
| | | const mgr = wx.getFileSystemManager(); |
| | | const contents = res.tempFilePaths.map(item => { |
| | | // @ts-ignore |
| | | const fileContent = mgr.readFileSync(item); |
| | | return fileContent; |
| | | }); |
| | | const obj = { |
| | | tempFilePaths: res.tempFilePaths, |
| | | tempFiles: res.tempFiles, |
| | | contents, |
| | | }; // 触åéä¸çäºä»¶ï¼å¼åè
æ ¹æ®å
容æ¥ä¸ä¼ æä»¶ï¼ä¸ä¼ äºæä¸ä¼ çç»æåé¦å°files屿§éé¢ |
| | | |
| | | this.triggerEvent('select', obj, {}); |
| | | |
| | | let files = res.tempFiles.map((item, i) => { |
| | | // 夿æä»¶ç±»åï¼å¯¹åºä¸åæ ·å¼ |
| | | const list = item.name.split('.'); |
| | | const ext = list[list.length - 1]; |
| | | let extensionClass = ''; |
| | | switch (ext) { |
| | | case 'xls': |
| | | case 'xlsx': |
| | | case 'csv': |
| | | extensionClass = 'file_xlsx'; |
| | | break; |
| | | case 'doc': |
| | | case 'docx': |
| | | extensionClass = 'file_word'; |
| | | break; |
| | | case 'pdf': |
| | | extensionClass = 'file_pdf'; |
| | | break; |
| | | case 'ppt': |
| | | case 'pptx': |
| | | extensionClass = 'file_ppt'; |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | // æä»¶å¤§å°æ ¼å¼å |
| | | let size = parseInt(item.size / 1024); |
| | | if (size > 1024) { |
| | | size = (size / 1024).toFixed(1) + ' MB'; |
| | | } else { |
| | | size += ' KB'; |
| | | } |
| | | return { |
| | | loading: true, |
| | | url: item.path, |
| | | name: item.name, |
| | | ext: ext ?? '', |
| | | styleClass: extensionClass, |
| | | type: item.type, |
| | | time: item.time, |
| | | size, |
| | | }; |
| | | }); |
| | | if (!files || !files.length) return; |
| | | const newFiles = this.data.files.concat(files); |
| | | this.setData({ |
| | | files: newFiles, |
| | | currentFiles: newFiles, |
| | | }); |
| | | this.triggerEvent( |
| | | 'uploadImg', |
| | | { |
| | | newFiles, |
| | | }, |
| | | {}, |
| | | ); |
| | | }, |
| | | }); |
| | | }, |
| | | deletePic(e) { |
| | | const index = e.detail.index; |
| | | this._delete(index); |
| | | }, |
| | | deleteFile(e) { |
| | | const { index } = e.currentTarget.dataset; |
| | | this._delete(index); |
| | | }, |
| | | _delete(index) { |
| | | const files = this.data.files; |
| | | const file = files.splice(index, 1); |
| | | this.setData({ |
| | | files, |
| | | currentFiles: files, |
| | | }); |
| | | this.triggerEvent('delete', { |
| | | index, |
| | | item: file[0], |
| | | }); |
| | | }, |
| | | }, |
| | | }); |
| | | |
| | | /***/ |
| | | }, |
| | | |
| | | /******/ |
| | | }, |
| | | ); |
| | |
| | | </view> |
| | | <view class="weui-uploader__bd"> |
| | | <view class="weui-uploader__files"> |
| | | <block wx:for="{{currentFiles}}" wx:key="*this"> |
| | | <block wx:for="{{currentFiles}}" wx:key="index"> |
| | | <!-- å¾ç --> |
| | | <block wx:if="{{item.type == 'image'}}"> |
| | | <view |
| | |
| | | src="{{item.url}}" |
| | | mode="aspectFill" |
| | | /> |
| | | <view class="close-btn"> |
| | | <t-icon |
| | | name="close" |
| | | size="36rpx" |
| | | data-index="{{index}}" |
| | | catch:tap="deleteFile" |
| | | ></t-icon> |
| | | </view> |
| | | </view> |
| | | </block> |
| | | <block wx:elif="{{item.type == 'file'}}"> |
| | |
| | | bindtap="previewFile" |
| | | class="weui-uploader__file" |
| | | > |
| | | <view class="{{'weui-uploader__img uploader-preview__file ' + styleClass}}"> |
| | | <view |
| | | class="{{'weui-uploader__img uploader-preview__file ' + item.styleClass}}" |
| | | > |
| | | <view class="wrap"> |
| | | <span class="{{'txt ' + styleClass}}">{{item.name}}</span> |
| | | <span class="{{'filename ' + styleClass}}" data-title="{{item.name}}" |
| | | <span class="{{'txt ' + item.styleClass}}">{{item.name}}</span> |
| | | <!-- <span class="{{'filename ' + item.styleClass}}" data-title="{{item.name}}" |
| | | >{{item.name}}</span |
| | | > |
| | | > --> |
| | | </view> |
| | | <text class="unit">{{item.size + ' KB'}}</text> |
| | | <text class="unit" data-ext="{{item.ext}}">{{item.size}}</text> |
| | | </view> |
| | | <view class="close-btn"> |
| | | <t-icon |
| | | name="close" |
| | | size="36rpx" |
| | | data-index="{{index}}" |
| | | catch:tap="deleteFile" |
| | | ></t-icon> |
| | | </view> |
| | | </view> |
| | | </block> |
| | |
| | | .close-btn { |
| | | position: absolute; |
| | | top: 0; |
| | | right: 0; |
| | | color: white; |
| | | background-color: rgba(0, 0, 0, 0.3); |
| | | padding: 2px; |
| | | border-bottom-left-radius: 8px; |
| | | border-top-left-radius: 2px; |
| | | border-bottom-right-radius: 2px; |
| | | } |
| | | |
| | | .weui-uploader__tips { |
| | | font-size: 12px; |
| | | color: #9c9c9c; |
| | | } |
| | | |
| | | .uploader-preview__file { |
| | | --default-bg-color: #888888; |
| | | position: relative; |
| | | display: flex; |
| | | flex-direction: column; |
| | | justify-content: space-between; |
| | |
| | | } |
| | | |
| | | .wrap { |
| | | /* background-color: rgb(109, 109, 4); */ |
| | | height: 3em; |
| | | line-height: 1.5; |
| | | overflow: hidden; |
| | | /* background-color: rgb(0, 104, 104); */ |
| | | margin: 8rpx 8rpx 0 8rpx; |
| | | text-align: justify; |
| | | |
| | | } |
| | | |
| | | .wrap .txt { |
| | | display: block; |
| | | max-height: 3em; |
| | | /* background-color: rgb(88, 104, 0); */ |
| | | /* margin: 8rpx 8rpx 0 8rpx; */ |
| | | display: -webkit-box; |
| | | -webkit-line-clamp: 2; |
| | | -webkit-box-orient: vertical; |
| | | overflow: hidden; |
| | | text-overflow: ellipsis; |
| | | } |
| | | |
| | | .wrap .filename { |
| | | position: relative; |
| | | /* display: flex; |
| | | text-align: justify; */ |
| | | /* display: -webkit-box; |
| | | -webkit-line-clamp: 2; |
| | | -webkit-box-orient: vertical; */ |
| | | /* display: none; */ |
| | | top: -3em; |
| | | background-color: rgb(115, 172, 118); |
| | | /* background-color: var(--default-bg-color); */ |
| | | /* background-color: rgb(115, 172, 118); */ |
| | | background-color: var(--default-bg-color); |
| | | overflow: hidden; |
| | | /* text-overflow: ellipsis; */ |
| | | text-align: justify; |
| | | /* white-space: nowrap; */ |
| | | text-overflow: ellipsis; |
| | | white-space: nowrap; |
| | | /* margin: 8rpx 8rpx 0 8rpx; */ |
| | | } |
| | | |
| | | .filename::before { |
| | | content: attr(data-title); |
| | | /* content: attr(data-title); */ |
| | | width: 100%; |
| | | float: right; |
| | | margin-top: 1.5em; |
| | |
| | | margin: 0rpx 8rpx 8rpx 8rpx; |
| | | } |
| | | |
| | | .file_xlsx {} |
| | | .unit::after { |
| | | content: attr(data-ext); |
| | | position: absolute; |
| | | bottom: 0rpx; |
| | | right: 10rpx; |
| | | font-size: 30px; |
| | | color: #ffffff38; |
| | | } |
| | | |
| | | .file_word {} |
| | | .file_xlsx { |
| | | background-color: #278553; |
| | | } |
| | | |
| | | .file_pdf {} |
| | | .file_word { |
| | | background-color: #3980C0; |
| | | } |
| | | |
| | | .file_ppt {} |
| | | .file_pdf { |
| | | background-color: #C84E39; |
| | | } |
| | | |
| | | .file_ppt { |
| | | background-color: #FF7A42; |
| | | } |
| | |
| | | padding-bottom: 16px; |
| | | -webkit-box-align: center; |
| | | -webkit-align-items: center; |
| | | align-items: center |
| | | align-items: center; |
| | | } |
| | | |
| | | .weui-uploader__title { |
| | |
| | | } |
| | | |
| | | .weui-uploader__file { |
| | | position: relative; |
| | | float: left; |
| | | margin-right: 8px; |
| | | margin-bottom: 8px; |
| | |
| | | </block> |
| | | <block wx:else> |
| | | <mp-upload |
| | | title="ä¸ä¼ å°è´¦å¾ç" |
| | | title="ä¸ä¼ æ´æ¹å¾ç" |
| | | titleClass="upload-title-class" |
| | | max-count="3" |
| | | files="{{imgFiles}}" |
| | |
| | | path.push(f.url); |
| | | }); |
| | | let ledger = this.data.ledger; |
| | | let namePairs = [] |
| | | this.data.imgFiles.forEach(f=>{ |
| | | // é¤äºå¾çå¤çææ¡£éè¦ä¼ è¾åå§åå |
| | | if (f.name) { |
| | | const ulist = f.url.split('/') |
| | | namePairs.push({ |
| | | first: ulist[ulist.length - 1], // ä¸ä¼ çä¸´æ¶æä»¶åå |
| | | second: f.name // æä»¶åå§åå |
| | | }) |
| | | } |
| | | }) |
| | | ledger.remark1 = this.data.remark; |
| | | if (this.data.detail) { |
| | | ledger.id = this.data.detail.id |
| | |
| | | |
| | | this.setData({ loading: true }); |
| | | ledgerservice.uploadLedger( |
| | | app.globalData.accessToken.userId, |
| | | ledger, |
| | | path, |
| | | app.globalData.accessToken.userId, ledger, |
| | | namePairs, path, |
| | | { |
| | | success(res) { |
| | | that.setData({ loading: false }); |
| | |
| | | if (this.data.imgFiles.length == 0) return; |
| | | |
| | | var that = this; |
| | | // æä»¶è·¯å¾ |
| | | let path = []; |
| | | this.data.imgFiles.forEach(f => { |
| | | path.push(f.url); |
| | | }); |
| | | // åºæ¥èªå·¡æ¥å°è´¦ä¿¡æ¯ |
| | | const { ledger, taskId } = this.data; |
| | | ledger.remark1 = this.data.remark; |
| | | if (this.data.detail) { |
| | | ledger.id = this.data.detail.id |
| | | } |
| | | // æä»¶ä¸´æ¶åç§°ååå§åç§°é
å¯¹ä¿¡æ¯ |
| | | let namePairs = [] |
| | | this.data.imgFiles.forEach(f=>{ |
| | | // é¤äºå¾çå¤çææ¡£éè¦ä¼ è¾åå§åå |
| | | if (f.name) { |
| | | const ulist = f.url.split('/') |
| | | namePairs.push({ |
| | | first: ulist[ulist.length - 1], // ä¸ä¼ çä¸´æ¶æä»¶åå |
| | | second: f.name // æä»¶åå§åå |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | this.setData({ loading: true }); |
| | | selfpatrolservice.uploadSelfPatrol( |
| | | app.globalData.accessToken.userId, |
| | | taskId, |
| | | ledger, |
| | | namePairs, |
| | | path, |
| | | { |
| | | success(res) { |
| | |
| | | onLoad(options) { |
| | | var that = this |
| | | this.initTime() |
| | | this.getRecord() |
| | | this.getOpenerEventChannel().on('acceptDataFromOpenerPage', function (data) { |
| | | let ledgerMap = new Map() |
| | | data.tabList.forEach(t => { |
| | |
| | | that.setData({ |
| | | ledgerMap |
| | | }) |
| | | that.getRecord() |
| | | }) |
| | | }, |
| | | |
| | |
| | | { |
| | | "navigationBarTitleText": "åå²å°è´¦", |
| | | "navigationBarBackgroundColor": "#57E4CB", |
| | | "navigationBarTextStyle": "white", |
| | | "usingComponents": { |
| | | "mp-icon": "/component/icon/icon", |
| | | "file-grid": "/component/filegrid/index", |
| | | "my-gallery": "/component/mygallery/mygallery" |
| | | } |
| | | } |
| | |
| | | <!--pages/mLedger/ledgerHistory/ledgerhistory.wxml--> |
| | | <wxs src="./utils.wxs" module="_" /> |
| | | |
| | | <import src="/template/nodata.wxml"></import> |
| | | <view class="page"> |
| | | <view class="page__hd"> |
| | |
| | | > |
| | | </view> |
| | | <view class="ledger-group"> |
| | | <view |
| | | <block |
| | | wx:for="{{item.ledgers}}" |
| | | wx:for-item="ledger" |
| | | wx:for-index="i2" |
| | | wx:key="i2" |
| | | class="ledger-group_item" |
| | | bindtap="previewImage" |
| | | data-index="{{i1}},{{i2}}" |
| | | > |
| | | <image class="" src="{{ledger.path1[0]}}" mode="aspectFill" show-menu-by-longpress="{{true}}"></image> |
| | | <view>{{ledger.ledgerName}}</view> |
| | | </view> |
| | | <view |
| | | wx:if="{{ledger._fileType == 'image'}}" |
| | | class="ledger-group_item" |
| | | bindtap="previewImage" |
| | | data-index="{{i1}},{{i2}}" |
| | | > |
| | | <image |
| | | class="ledger-group_item__file" |
| | | src="{{ledger.path1[0]}}" |
| | | mode="aspectFill" |
| | | show-menu-by-longpress="{{true}}" |
| | | ></image> |
| | | <view>{{ledger.ledgerName}}</view> |
| | | </view> |
| | | <view wx:else class="ledger-group_item" data-index="{{i1}},{{i2}}"> |
| | | <file-grid |
| | | class="ledger-group_item__file" |
| | | files="{{ledger._files}}" |
| | | gridHeight="{{_.styleByCount(ledger._files.length).height}}" |
| | | gridWidth="{{_.styleByCount(ledger._files.length).width}}" |
| | | ></file-grid> |
| | | <view>{{ledger.ledgerName}}</view> |
| | | </view> |
| | | </block> |
| | | </view> |
| | | </view> |
| | | </block> |
| | |
| | | |
| | | .ledger-group_item{ |
| | | width: 46vw; |
| | | display: flex; |
| | | flex-direction: column; |
| | | align-items: center; |
| | | text-align: center; |
| | | font-size: 14px; |
| | | |
| | | } |
| | | |
| | | .ledger-group_item>image{ |
| | | .ledger-group_item .ledger-group_item__file{ |
| | | width: 40vw; |
| | | height: 40vw; |
| | | border-radius: 8px; |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | /** |
| | | * æ ¹æ®å°è´¦æä»¶æ°é,å³å®æ¯ä¸ªæä»¶çå±ç¤ºå®½é« |
| | | * @param {Number} num |
| | | */ |
| | | function styleByCount(num) { |
| | | var width, height; |
| | | switch (num) { |
| | | case 1: |
| | | width = '40vw'; |
| | | height = '40vw'; |
| | | break; |
| | | case 2: |
| | | width = '40vw'; |
| | | height = '17vw'; |
| | | break; |
| | | case 3: |
| | | case 4: |
| | | width = '17vw'; |
| | | height = '17vw'; |
| | | break; |
| | | case 5: |
| | | case 6: |
| | | width = '17vw'; |
| | | height = '12vw'; |
| | | break; |
| | | default: |
| | | width = 0; |
| | | height = 0; |
| | | break; |
| | | } |
| | | |
| | | return { width, height }; |
| | | } |
| | | |
| | | module.exports = { |
| | | styleByCount: styleByCount, |
| | | }; |
| | |
| | | type: 0, |
| | | // å岿æ°è®°å½ |
| | | lastLedger: undefined, |
| | | |
| | | |
| | | }, |
| | | |
| | | /** |
| | |
| | | this.getOpenerEventChannel().on( |
| | | 'acceptDataFromOpenerPage', |
| | | function (data) { |
| | | data.ledger.description = data.ledger.description.replaceAll( |
| | | data.ledger.description = data.ledger.description?.replaceAll( |
| | | '\\n', |
| | | '\n', |
| | | ); |
| | | that.setData({ |
| | | ledger: data.ledger, |
| | | time: moment(data.ledger.updateDate).format('YYYYå¹´MMæDDæ¥'), |
| | | indexGroup: data.indexGroup, |
| | | type: data.type, |
| | | taskId: data.taskId, |
| | |
| | | |
| | | // 对äºå¯å¤å¶çå¹¶ä¸ä¸æ¯éä¼ ç¶æçå°è´¦ï¼è·åææ°çåå²è®°å½ç¨äºå¤å¶ |
| | | if (data.ledger.copy && !data.reUpload) { |
| | | that.getLatestLedger() |
| | | that.getLatestLedger(); |
| | | } |
| | | }, |
| | | ); |
| | | this.setData({ |
| | | loadingText: 'ä¸ä¼ ä¸', |
| | | loadCompleteText: 'ä¸ä¼ 宿', |
| | | timeoutText: 'ä¸ä¼ è¶
æ¶', |
| | | }); |
| | | }, |
| | | |
| | | /** |
| | |
| | | if (this.data.reUpload) { |
| | | //do nothing |
| | | return; |
| | | } else if (this.data.ledger.path1) { |
| | | let imgFiles = this.data.ledger.path1; |
| | | } else if (this.data.ledger._files) { |
| | | let imgFiles = this.data.ledger._files; |
| | | let remark = this.data.remark; |
| | | if (this.data.ledger.remark1) remark = this.data.ledger.remark1; |
| | | let remarkDisable = true; |
| | | this.setData({ |
| | | imgFiles, |
| | | remark, |
| | | remarkDisable |
| | | remarkDisable, |
| | | }); |
| | | } else if (this.data.ledger.upLoad) { |
| | | var that = this; |
| | |
| | | if (res.length > 0) { |
| | | let detail = res[0]; |
| | | if (detail.upLoad) { |
| | | let imgFiles = detail.path1; |
| | | let imgFiles = detail._files; |
| | | let remark = detail.remark1 ? detail.remark1 : ''; |
| | | let remarkDisable = true; |
| | | that.setData({ |
| | | imgFiles, |
| | | remark, |
| | | remarkDisable, |
| | | detail |
| | | detail, |
| | | }); |
| | | } |
| | | } |
| | |
| | | if (res.success) { |
| | | let detail = res.data; |
| | | if (detail.upLoad) { |
| | | let imgFiles = detail.path1; |
| | | let imgFiles = detail._files; |
| | | let remark = detail.remark1 ? detail.remark1 : ''; |
| | | let remarkDisable = true; |
| | | that.setData({ |
| | | imgFiles, |
| | | remark, |
| | | remarkDisable, |
| | | detail |
| | | detail, |
| | | }); |
| | | } |
| | | } |
| | |
| | | var typeId = this.data.ledger.ledgerSubTypeId; |
| | | var sceneType = app.globalData.userInfo.extension2; |
| | | this.setData({ |
| | | latestLedgerLoading: true |
| | | }) |
| | | latestLedgerLoading: true, |
| | | }); |
| | | ledgerservice.getLedgerDetail(userId, typeId, sceneType, null, { |
| | | success: (res) => { |
| | | success: res => { |
| | | if (res.length > 0) { |
| | | const ledger = res[0] |
| | | const ledger = res[0]; |
| | | this.setData({ |
| | | lastLedger: { |
| | | ...ledger, |
| | | _updateTimeStr: moment(ledger.updateDate).format('YYYYå¹´MMæDDæ¥') |
| | | } |
| | | }) |
| | | _updateTimeStr: moment(ledger.updateDate).format( |
| | | 'YYYYå¹´MMæDDæ¥', |
| | | ), |
| | | }, |
| | | }); |
| | | } |
| | | }, |
| | | complete: () => { |
| | | this.setData({ |
| | | latestLedgerLoading: false |
| | | }) |
| | | } |
| | | latestLedgerLoading: false, |
| | | }); |
| | | }, |
| | | }); |
| | | }, |
| | | |
| | | uploadFileFail(e) { |
| | | const { type, index } = e.detail; |
| | | if (type == 1) { |
| | | wx.showToast({ |
| | | title: `æä»¶è¿å¤§`, |
| | | icon: 'error', |
| | | }); |
| | | } |
| | | }, |
| | | |
| | | // ä¸ä¼ å°è´¦ |
| | | onSubmit: function () { |
| | | if (this.data.imgFiles.length == 0) { |
| | | wx.showToast({ |
| | | title: '请è³å°éæ©ä¸å¼ å¾ç', |
| | | title: '请è³å°éæ©ä¸ä¸ªæä»¶', |
| | | icon: 'none', |
| | | }); |
| | | } else { |
| | |
| | | // å»¶ç¨å¤å¶å°è´¦ |
| | | onCopyLedger() { |
| | | if (this.data.latestLedgerLoading) { |
| | | return |
| | | return; |
| | | } else if (this.data.lastLedger == undefined) { |
| | | wx.showToast({ |
| | | title: '没æå¯å»¶ç¨çè®°å½', |
| | |
| | | break; |
| | | case 2: |
| | | if (this.data.type == 0) { |
| | | const { |
| | | lastLedger |
| | | } = this.data |
| | | const copyLedgerList = [{ |
| | | subTypeId: lastLedger.ledgerSubTypeId, |
| | | time: `${lastLedger.year}-${lastLedger.month}` |
| | | }] |
| | | const { lastLedger } = this.data; |
| | | const copyLedgerList = [ |
| | | { |
| | | subTypeId: lastLedger.ledgerSubTypeId, |
| | | time: `${lastLedger.year}-${lastLedger.month}`, |
| | | }, |
| | | ]; |
| | | this._uploadCopyLedger(copyLedgerList); |
| | | } |
| | | break; |
| | |
| | | |
| | | //å¾çæ¾å¤§é¢è§ |
| | | previewImage(e) { |
| | | const { |
| | | index |
| | | } = e.currentTarget.dataset; |
| | | const previewImageUrls = this.data.imgFiles; |
| | | const { index } = e.currentTarget.dataset; |
| | | const previewImageUrls = this.data.imgFiles |
| | | .filter(f => f.type == 'image') |
| | | .map(f => f.url); |
| | | this.setData({ |
| | | previewImageUrls, |
| | | previewCurrent: index, |
| | |
| | | |
| | | // å°è´¦å¤æ³¨çå¬ |
| | | onRemarkChange(e) { |
| | | const { |
| | | value |
| | | } = e.detail; |
| | | const { value } = e.detail; |
| | | this.setData({ |
| | | remark: value |
| | | remark: value, |
| | | }); |
| | | }, |
| | | }); |
| | | }); |
| | |
| | | "usingComponents": { |
| | | "mp-upload":"/component/uploader/uploader", |
| | | "c-dialog": "/component/commondialog/commondialog", |
| | | "my-gallery": "/component/mygallery/mygallery", |
| | | "mp-gallery": "/component/gallery/gallery", |
| | | "file-grid": "/component/filegrid/index", |
| | | "mp-icon": "/component/icon/icon" |
| | | } |
| | | } |
| | |
| | | </view> |
| | | <view class="page__bd"> |
| | | <view wx:if="{{ledger.description}}" class="ledger-des"> |
| | | <view style="display: flex;align-items: center;height: 20px;margin-bottom: 10px;"> |
| | | <view class="ledger-tips"> |
| | | <mp-icon icon="info" color="" size="{{16}}"></mp-icon> |
| | | <text>{{ledger.ledgerTypeId == -1 ? 'æä½æç¤º' : 'å°è´¦æç¤º'}}</text> |
| | | </view> |
| | | <text>{{ledger.description}}</text> |
| | | </view> |
| | | <view wx:if="{{!ledger.upLoad || reUpload}}" class="weui-upload-view" style="margin-top: 16px"> |
| | | <mp-upload title="ä¸ä¼ å¾çï¼å¿
å¡«ï¼" titleClass="upload-title-class" max-count="6" files="{{imgFiles}}" binduploadImg="uploadFile" binddelete="delImg"></mp-upload> |
| | | <textarea disabled="{{remarkDisable}}" value="{{remark}}" class="text-area" auto-height="{{false}}" name="des" placeholder="æ·»å 夿³¨ï¼éå¡«ï¼" bindinput="onRemarkChange"></textarea> |
| | | <view |
| | | wx:if="{{!ledger.upLoad || reUpload}}" |
| | | class="weui-upload-view" |
| | | style="margin-top: 16px" |
| | | > |
| | | <mp-upload |
| | | title="ä¸ä¼ æä»¶ï¼å¿
å¡«ï¼" |
| | | tips="æä»¶æå¤§ä¸è½è¶
è¿5MB" |
| | | allowFiles="{{true}}" |
| | | titleClass="upload-title-class" |
| | | max-count="6" |
| | | files="{{imgFiles}}" |
| | | binduploadImg="uploadFile" |
| | | binddelete="delImg" |
| | | bindfail="uploadFileFail" |
| | | ></mp-upload> |
| | | <textarea |
| | | disabled="{{remarkDisable}}" |
| | | value="{{remark}}" |
| | | class="text-area" |
| | | auto-height="{{false}}" |
| | | name="des" |
| | | placeholder="æ·»å 夿³¨ï¼éå¡«ï¼" |
| | | bindinput="onRemarkChange" |
| | | ></textarea> |
| | | </view> |
| | | <block wx:else> |
| | | <view style="font-size: 14px; margin-top: 16px">å¾ç</view> |
| | | <view class="img-group"> |
| | | <image wx:for="{{imgFiles}}" wx:key="index" class="img-group_img" src="{{item}}" mode="aspectFill" bindtap="previewImage" data-index="{{index}}" show-menu-by-longpress="{{true}}"></image> |
| | | </view> |
| | | <view style="font-size: 14px; margin-top: 16px">å°è´¦æä»¶</view> |
| | | <file-grid files="{{imgFiles}}"></file-grid> |
| | | <view style="font-size: 14px; margin-top: 16px">夿³¨</view> |
| | | <textarea class="text-area text-area-read" placeholder="æ 夿³¨" value="{{remark}}"></textarea> |
| | | <textarea |
| | | disabled="{{true}}" |
| | | class="text-area text-area-read" |
| | | placeholder="æ 夿³¨" |
| | | value="{{remark}}" |
| | | ></textarea> |
| | | <view style="font-size: 12px; margin-top: 16px;color: rgb(160, 160, 160);">ä¸ä¼ æ¶é´: {{time}}</view> |
| | | </block> |
| | | </view> |
| | | <view class="page__ft"> |
| | | <view wx:if="{{!ledger.upLoad || reUpload}}" class="fix-bottom"> |
| | | <view wx:if="{{type == 0 && ledger.copy && !reUpload}}" class="submit submit-3 left" bindtap="onCopyLedger"> |
| | | <t-loading wx:if="{{latestLedgerLoading}}" theme="spinner" size="20rpx" class="wrapper" /> |
| | | <view |
| | | wx:if="{{type == 0 && ledger.copy && !reUpload}}" |
| | | class="submit submit-3 left" |
| | | bindtap="onCopyLedger" |
| | | > |
| | | <t-loading |
| | | wx:if="{{latestLedgerLoading}}" |
| | | theme="spinner" |
| | | size="20rpx" |
| | | class="wrapper" |
| | | /> |
| | | <text>å»¶ç¨</text> |
| | | <!-- <view class="small-tag-text"> |
| | | <text wx:if="{{lastLedger}}">䏿¬¡è®°å½ï¼{{lastLedger._updateTimeStr}}</text> |
| | | <text wx:else>æ ä¸ä¼ è®°å½</text> |
| | | </view> --> |
| | | </view> |
| | | <view wx:if="{{ledger.notRelated}}" class="submit submit-2 left" bindtap="onSubmitNoLedger">䏿¶å</view> |
| | | <view |
| | | wx:if="{{ledger.notRelated}}" |
| | | class="submit submit-2 left" |
| | | bindtap="onSubmitNoLedger" |
| | | >䏿¶å</view |
| | | > |
| | | <view class="submit right" bindtap="onSubmit">æäº¤</view> |
| | | </view> |
| | | <view wx:else class="fix-bottom"> |
| | |
| | | <view>确认延ç¨ï¼</view> |
| | | </view> |
| | | </c-dialog> |
| | | <my-gallery hide-on-click="{{true}}" show-delete="{{false}}" show="{{showPreview}}" img-urls="{{previewImageUrls}}" current="{{previewCurrent}}"></my-gallery> |
| | | </view> |
| | | </view> |
| | |
| | | } |
| | | |
| | | .fix-bottom .right { |
| | | flex: 2; |
| | | flex: 2; |
| | | } |
| | | |
| | | .upload-title-class { |
| | | font-size: small; |
| | | } |
| | | |
| | | .ledger-tips { |
| | | display: flex; |
| | | align-items: center; |
| | | height: 20px; |
| | | margin-bottom: 10px; |
| | | } |
| | | |
| | | .text-area { |
| | |
| | | color: var(--fyui-text-color_2); |
| | | } |
| | | |
| | | .img-group { |
| | | /* .img-group { |
| | | display: flex; |
| | | flex-wrap: wrap; |
| | | } |
| | |
| | | height: 29vw; |
| | | margin-bottom: 8px; |
| | | margin-right: 8px; |
| | | } |
| | | } */ |
| | | |
| | | .submit-2 { |
| | | background: white; |
| | |
| | | align-items: center; |
| | | } |
| | | |
| | | .custom-action__bg{ |
| | | .custom-action__bg { |
| | | position: absolute; |
| | | top: 0; |
| | | left: 0; |
| | | } |
| | | |
| | | .custom-action__tag{ |
| | | .custom-action__tag { |
| | | font-size: 14px; |
| | | color: var(--fyui-text-color_1); |
| | | font-weight: 600; |
| | |
| | | z-index: 2; |
| | | } |
| | | |
| | | .custom-action__tag>image{ |
| | | .custom-action__tag>image { |
| | | width: 64px; |
| | | height: 64px; |
| | | } |
| | |
| | | import { |
| | | parseSelfPatrol, |
| | | refreshLedgerStatus |
| | | } from '../../../../model/ledger'; |
| | | import { parseSelfPatrol, refreshLedgerStatus } from '../../../../model/ledger'; |
| | | import configservice from '../../../../service/configservice'; |
| | | const ledgerservice = require('../../../../service/ledgerservice'); |
| | | const moment = require('../../../../utils/moment.min'); |
| | |
| | | refresh: false, |
| | | thisMonth: '', |
| | | tags1: { |
| | | count: 0 |
| | | count: 0, |
| | | }, |
| | | pageList1: [], |
| | | // æ¯å¦ææéå¯ä»¥è¿è¡èªå·¡æ¥æ¿è¯º |
| | |
| | | const nowStr = now.format('YYYY-MM-DD'); |
| | | const thisMonth = now.format('YYYYå¹´MMæ'); |
| | | this.setData({ |
| | | thisMonth |
| | | thisMonth, |
| | | }); |
| | | this.getLedgerType(nowStr, r => { |
| | | this.setData({ |
| | |
| | | refresh: false, |
| | | }); |
| | | }); |
| | | this.getPromise() |
| | | this.getPromise(); |
| | | }, |
| | | |
| | | /** |
| | |
| | | */ |
| | | getPromise() { |
| | | if (this.data.promiseValid) { |
| | | configservice.fetchUserSettingRecord(app.globalData.accessToken.userId, { |
| | | success: res => { |
| | | const nowYear = moment().year() |
| | | const promiseYear = moment(res.data?.lastPromisedTime).year() |
| | | this.setData({ |
| | | promised: (res.data?.selfPatrolPromised == true) && (nowYear == promiseYear) |
| | | }) |
| | | configservice.fetchUserSettingRecord( |
| | | app.globalData.accessToken.userId, |
| | | { |
| | | success: res => { |
| | | const nowYear = moment().year(); |
| | | const promiseYear = moment(res.data?.lastPromisedTime).year(); |
| | | this.setData({ |
| | | promised: |
| | | res.data?.selfPatrolPromised == true && |
| | | nowYear == promiseYear, |
| | | }); |
| | | }, |
| | | }, |
| | | }) |
| | | ); |
| | | } |
| | | }, |
| | | |
| | |
| | | ledgerservice.getLedgerSummary( |
| | | app.globalData.accessToken.userId, |
| | | app.globalData.userInfo.extension2, |
| | | time, { |
| | | time, |
| | | { |
| | | success(res) { |
| | | let r = parseSelfPatrol(res); |
| | | success(r); |
| | |
| | | }, |
| | | |
| | | gotoLedgerDetail(e) { |
| | | const { |
| | | index |
| | | } = e.currentTarget.dataset; |
| | | const { index } = e.currentTarget.dataset; |
| | | const indexGroup = index; |
| | | var ledger = this.data.pageList1[index]; |
| | | var that = this; |
| | |
| | | wx.navigateTo({ |
| | | url: '/pages/mSelfPatrol/patrolpromise/index', |
| | | events: { |
| | | doPromiseDone: (data)=> { |
| | | doPromiseDone: data => { |
| | | this.setData({ |
| | | promised: data.promised |
| | | }) |
| | | promised: data.promised, |
| | | }); |
| | | }, |
| | | }, |
| | | success: (res)=> { |
| | | success: res => { |
| | | // éè¿ eventChannel å被æå¼é¡µé¢ä¼ éæ°æ® |
| | | // res.eventChannel.emit('acceptDataFromOpenerPage', { |
| | | |
| | | // }); |
| | | res.eventChannel.emit('acceptDataFromOpenerPage', { |
| | | review: false, |
| | | }); |
| | | }, |
| | | }); |
| | | }, |
| | |
| | | reviewPromise() { |
| | | wx.navigateTo({ |
| | | url: '/pages/mSelfPatrol/patrolpromise/index', |
| | | success: (res)=> { |
| | | success: res => { |
| | | // éè¿ eventChannel å被æå¼é¡µé¢ä¼ éæ°æ® |
| | | res.eventChannel.emit('acceptDataFromOpenerPage', { |
| | | review: true |
| | | review: true, |
| | | }); |
| | | }, |
| | | }); |
| | | } |
| | | }, |
| | | }, |
| | | }); |
| | | }); |
| | |
| | | this.getOpenerEventChannel().on( |
| | | 'acceptDataFromOpenerPage', |
| | | (data) => { |
| | | console.log('acceptDataFromOpenerPage', data); |
| | | this.setData({ |
| | | isReview: data.review |
| | | }) |
| | |
| | | </view> |
| | | </view> |
| | | <view class="page__ft"> |
| | | <template wx:if="{{!isReview}}"> |
| | | <block wx:if="{{!isReview}}"> |
| | | <view class="weui-agree"> |
| | | <label bindtap="checkboxChange"> |
| | | <checkbox |
| | |
| | | </label> |
| | | </view> |
| | | <view class="submit" bindtap="showCheckDialog">ç¾ç½²</view> |
| | | </template> |
| | | </block> |
| | | </view> |
| | | </view> |
| | | <t-dialog |
| | |
| | | const util = require('../utils/util.js'); |
| | | |
| | | // å°ç¨åºåå° |
| | | const baseUrl = "http://192.168.1.9:8082" |
| | | // const baseUrl = 'https://fyami.com.cn'; |
| | | // const baseUrl = "http://192.168.1.9:8082" |
| | | const baseUrl = 'https://fyami.com.cn'; |
| | | const bu = 'https://fyami.com.cn'; |
| | | const basePicUrl = `${bu}/images/`; |
| | | const baseIconUrl = `${bu}/images/weixin/eplaw/`; |
| | |
| | | const spBu = "https://fyami.com.cn:447" |
| | | const spPicUrl = `${spBu}/images/`; |
| | | |
| | | const mode = 'debug'; |
| | | // const mode = 'prod'; |
| | | // const mode = 'debug'; |
| | | const mode = 'prod'; |
| | | |
| | | function request(fun, hostUrl) { |
| | | const bUrl = hostUrl ? hostUrl : baseUrl; |
| | |
| | | import serviceutils from "./serviceutils"; |
| | | const Multipart = require('../utils/Multipart.min'); |
| | | const $f = require('./baserequest'); |
| | | const util = require('../utils/util'); |
| | |
| | | }, |
| | | |
| | | //ä¸ä¼ å°è´¦ |
| | | uploadLedger: function (userId, ledger, paths, fun) { |
| | | uploadLedger: function (userId, ledger, namePairs, paths, fun) { |
| | | const fields = [ |
| | | { |
| | | name: 'params', |
| | | value: JSON.stringify([ledger]), |
| | | }, |
| | | { |
| | | name: 'fileNames', |
| | | value: JSON.stringify(namePairs), |
| | | } |
| | | ]; |
| | | const files = []; |
| | | paths.forEach(p => { |
| | |
| | | r.path1 = r.path1.split(';').map((value, index) => { |
| | | return $f.basePicUrl + value; |
| | | }); |
| | | r._files = serviceutils.formatLedgerPath(r.path1) |
| | | r._fileType = serviceutils.judgeLedgerFileType(r._files) |
| | | }); |
| | | cb.success(res); |
| | | }; |
| | |
| | | import serviceutils from "./serviceutils"; |
| | | const Multipart = require('../utils/Multipart.min'); |
| | | const $f = require('./baserequest'); |
| | | const util = require('../utils/util'); |
| | | |
| | | |
| | | module.exports = { |
| | | /** |
| | |
| | | $f.get(fun1); |
| | | }, |
| | | |
| | | //ä¸ä¼ èªå·¡æ¥ |
| | | uploadSelfPatrol: function (userId, taskId, selfPatrol, paths, fun) { |
| | | //ä¸ä¼ åºæ¥èªå·¡æ¥ |
| | | uploadSelfPatrol: function (userId, taskId, selfPatrol,namePairs, paths, fun) { |
| | | const fields = [{ |
| | | name: 'params', |
| | | value: JSON.stringify([selfPatrol]), |
| | |
| | | name: 'taskId', |
| | | value: taskId, |
| | | }, |
| | | { |
| | | name: 'fileNames', |
| | | value: JSON.stringify(namePairs), |
| | | } |
| | | ]; |
| | | const files = []; |
| | | paths.forEach(p => { |
| | |
| | | r.path1 = r.path1.split(';').map((value, index) => { |
| | | return $f.basePicUrl + value; |
| | | }); |
| | | r._files = serviceutils.formatLedgerPath(r.path1) |
| | | r._fileType = serviceutils.judgeLedgerFileType(r._files) |
| | | } |
| | | cb.success(res); |
| | | }; |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | export default { |
| | | /** |
| | | * æ ¼å¼åå°è´¦æä»¶è·¯å¾æ°ç» |
| | | * @param {Array} pathList å°è´¦æä»¶çè·¯å¾æ°ç» |
| | | */ |
| | | formatLedgerPath(pathList) { |
| | | return pathList.map((value, index) => { |
| | | // æä»¶å |
| | | const plist = value.split('/'); |
| | | const fileName = plist[plist.length - 1]; |
| | | // æä»¶æ©å±å |
| | | const nList = fileName.split('.'); |
| | | const ext = nList[nList.length - 1]; |
| | | let fileType = 'file'; |
| | | if ( |
| | | ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg'].indexOf(ext) != -1 |
| | | ) { |
| | | fileType = 'image'; |
| | | } |
| | | return { |
| | | name: fileName, |
| | | type: fileType, |
| | | ext, |
| | | url: value, |
| | | }; |
| | | }); |
| | | }, |
| | | |
| | | /** |
| | | * ç¡®å®å°è´¦çæä»¶ç±»åç»æ,['image', 'file', 'mix'] |
| | | */ |
| | | judgeLedgerFileType(files) { |
| | | let type = ''; |
| | | for (let i = 0; i < files.length; i++) { |
| | | const f = files[i]; |
| | | if (f.type != type) { |
| | | if (type == '') { |
| | | type = f.type; |
| | | } else { |
| | | type = 'mix'; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | return type; |
| | | }, |
| | | }; |