| | |
| | | <view class="box1"> |
| | | <!-- 设备+日期 --> |
| | | <view class="box_list"> |
| | | <view class="box_list_item" @click="open"> |
| | | <view class="box_list_item" @click="show = true"> |
| | | <view class="box_list_item_left"> |
| | | <text>检验设备</text><text>*</text> |
| | | </view> |
| | |
| | | <view class="box_footer"> |
| | | <button class="box_footer_submit" v-preventReClick @click="submit">提交</button> |
| | | </view> |
| | | <!-- 查看大图 --> |
| | | <Preview :list="form.files" :current="current" v-if="isOpen" /> |
| | | <!-- 选择设备 --> |
| | | <ytyDataPicker :show="show" :dataList="columns" @select="handleSelect" @search="handleSearch" @close="show = false" /> |
| | | <!-- 选择时间 --> |
| | | <u-datetime-picker :show="showTime" v-model="currentDate" @cancel="showTime = false" @confirm="queding" mode="datetime"></u-datetime-picker> |
| | | </view> |
| | |
| | | import { getBarcodeContent } from '@/util/api/WorkOrderAPI' |
| | | import { saveBean, getDeviceByCondition, getsbInfo } from '@/util/api/QualityAPI' |
| | | import { queryListByCode, uploadFiles } from '@/util/api/index' |
| | | import { QRCodeType, baseUrl } from '@/common/config.js' |
| | | import { QRCodeType, baseUrl, fileType } from '@/common/config.js' |
| | | import { setTime, judgmentType } from '@/util/utils.js' |
| | | import { mapState } from 'vuex' |
| | | import ytyDataPicker from '@/components/yty-data-picker/yty-data-picker.vue' |
| | | import Preview from '@/components/Preview/Preview.vue' |
| | | |
| | | export default { |
| | | data() { |
| | | return { |
| | | list1: [ |
| | | 'https://cloudfactory.oss-cn-hangzhou.aliyuncs.com/deviceCheck/20230911/e228a809-0a6b-443c-9a2c-78d5c1b1b633.mp4', |
| | | 'https://cdn.uviewui.com/uview/swiper/swiper2.png', |
| | | 'https://cdn.uviewui.com/uview/swiper/swiper3.png', |
| | | ], |
| | | status: [{ |
| | | name: '正常', |
| | | active: true, |
| | |
| | | ], |
| | | columns: [], |
| | | path: '', |
| | | show: false, |
| | | showTime: false, |
| | | currentDate: new Date(), |
| | | current: 0, |
| | | form: { |
| | | equipmentId: '', // 设备id |
| | | equipmentName: '', //设备名称 |
| | |
| | | } |
| | | }; |
| | | }, |
| | | components:{ |
| | | ytyDataPicker, |
| | | Preview |
| | | }, |
| | | onLoad() { |
| | | this.form.time = setTime(new Date(), '-') |
| | | this.getqueryListByCode() |
| | | this.getSB('') |
| | | }, |
| | | computed: { |
| | | ...mapState(['session']) |
| | | }, |
| | | methods: { |
| | | // 删除指定文件 |
| | | dele(i) { |
| | | this.form.files.splice(i, 1) |
| | | }, |
| | | // 选择设备 |
| | | handleSelect(e) { |
| | | this.form.equipmentId = e.code |
| | | this.form.equipmentName = e.name |
| | | this.show = false |
| | | }, |
| | | // 搜索设备 |
| | | handleSearch(e) { |
| | | this.getSB(e) |
| | | }, |
| | | // 确认选择日期 |
| | | queding(val) { |
| | | this.form.time = uni.$u.timeFormat(val.value, 'yyyy-mm-dd hh:MM:ss') |
| | |
| | | }, |
| | | // 扫码 |
| | | openCode() { |
| | | var that = this |
| | | uni.scanCode({ |
| | | onlyFromCamera: true, |
| | | success: function (result) { |
| | |
| | | getsbInfo(res.data.id) |
| | | .then(res1 => { |
| | | if (res1.code === 200) { |
| | | this.form.equipmentId = res1.data.id |
| | | this.form.equipmentName = res1.data.name |
| | | that.form.equipmentId = res1.data.id |
| | | that.form.equipmentName = res1.data.name |
| | | } |
| | | }) |
| | | } else { |
| | |
| | | }) |
| | | }, |
| | | // 获取当前用户下所有设备 |
| | | getSB() { |
| | | getDeviceByCondition({}) |
| | | getSB(name) { |
| | | getDeviceByCondition({ name }) |
| | | .then(res => { |
| | | if (res.code === 200 && res.data && res.data.length > 0) { |
| | | this.columns = [] |
| | | let arr = [] |
| | | res.data.forEach(item => { |
| | | this.columns.push({ text: item.name, id: item.id }) |
| | | arr.push({ name: item.name, code: item.id }) |
| | | }) |
| | | this.columns = arr |
| | | } else { |
| | | this.columns = [] |
| | | } |
| | | }) |
| | | }, |
| | | // 获取文件 |
| | | async upFile(e) { |
| | | if (this.form.files.length + e.target.files.length > 9) { |
| | | uni.showToast({ |
| | | title: '最多只能上传9个图片/视频', |
| | | icon: 'none', |
| | | duration: 2000 |
| | | }); |
| | | return |
| | | } |
| | | for (let i = 0; i < e.target.files.length; i++) { |
| | | let type = e.target.files[i].type |
| | | let index = type.indexOf('/') |
| | | let data = type.substring(index + 1, type.length) |
| | | const format = new FormData() |
| | | format.append('file', e.target.files[i]) |
| | | format.append('folder', this.path) |
| | | let res = await uploadFiles(format) |
| | | if (res.code === 200) { |
| | | form.files.push({ |
| | | fileUrl: res.data.imgaddr, |
| | | filename: res.data.imgname, |
| | | filesize: e.target.files[i].size, |
| | | type: judgmentType(data.toLowerCase()) ? 0 : 1, |
| | | url: res.data.url |
| | | }) |
| | | } |
| | | } |
| | | // upload.value.value = '' |
| | | }, |
| | | // 点击上传 |
| | | uploadFile() { |
| | | var that = this |
| | | uni.chooseImage({ |
| | | success: (chooseImageRes) => { |
| | | const tempFilePaths = chooseImageRes.tempFilePaths; |
| | |
| | | filePath: tempFilePaths[0], |
| | | name: 'file', |
| | | header: { |
| | | 'Cookie': 'eva-auth-token=' + this.session |
| | | 'Cookie': 'eva-auth-token=' + that.session |
| | | }, |
| | | formData: { |
| | | 'folder': this.path |
| | | 'folder': that.path |
| | | }, |
| | | success: (uploadFileRes) => { |
| | | console.log(JSON.parse(uploadFileRes.data)); |
| | | let res = JSON.parse(uploadFileRes.data) |
| | | this.form.files.push({ |
| | | let type = '' |
| | | for (let i = 0; i < fileType.length; i++) { |
| | | if (tempFilePaths[0].indexOf(fileType[i].name) !== -1) { |
| | | type = fileType[i].type |
| | | } |
| | | } |
| | | that.form.files.push({ |
| | | fileUrl: res.data.imgaddr, |
| | | filename: res.data.imgname, |
| | | // filesize: e.target.files[i].size, |
| | | type: judgmentType(tempFilePaths[0]) ? 0 : 1, |
| | | type, |
| | | url: res.data.url |
| | | }) |
| | | } |
| | |
| | | height: 100%; |
| | | position: absolute; |
| | | background: #F7F7F7; |
| | | |
| | | .sb { |
| | | width: 100%; |
| | | height: 800rpx; |
| | | padding: 30rpx; |
| | | box-sizing: border-box; |
| | | } |
| | | |
| | | .box_list { |
| | | padding: 0 30rpx 0 30rpx; |