| | |
| | | <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_list1_club_list_item" v-for="(item, index) in form.files" :key="index" |
| | | @click="seeBigFile(index)"> |
| | | <image class="close" src="@/static/ic_delete@2x.png" @click.stop="dele(index)" /> |
| | | <image class="play" src="@/static/ic_play@2x.png" v-if="item.type === 1" /> |
| | | <image class="play" src="@/static/ic_play@2x.png" v-if="item.typec === 1" /> |
| | | <view class="type"> |
| | | <video :src="item.url" v-if="item.type === 1"></video> |
| | | <video :src="item.url" v-if="item.typec === 1"></video> |
| | | <image v-else class="type_img" :src="item.url" mode="widthFix" /> |
| | | </view> |
| | | </view> |
| | |
| | | </view> |
| | | <view class="box_list2"> |
| | | <view class="box_list2_label">备注</view> |
| | | <textarea name="" id="" v-model="form.remarks" cols="20" rows="5" maxlength="300" |
| | | placeholder="请详细描述巡检情况"></textarea> |
| | | <textarea v-model="form.remarks" cols="20" rows="5" maxlength="300" placeholder="请详细描述巡检情况"></textarea> |
| | | </view> |
| | | <view class="box_footer"> |
| | | <button class="box_footer_submit" v-preventReClick @click="submit">提交</button> |
| | | </view> |
| | | <!-- 查看大图 --> |
| | | <Preview :list="form.files.map(item => item.url)" :current="current" @close="isOpen = false" 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.vue' |
| | | |
| | | export default { |
| | | data() { |
| | |
| | | } |
| | | ], |
| | | columns: [], |
| | | isOpen: false, |
| | | 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: { |
| | | // 查看大图/视频 |
| | | seeBigFile(i) { |
| | | this.current = i |
| | | this.isOpen = true |
| | | }, |
| | | // 删除指定文件 |
| | | 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() { |
| | | uni.chooseImage({ |
| | | var that = this |
| | | uni.chooseMedia({ |
| | | mediaType: ['image', 'video'], |
| | | sourceType: ['album', 'camera'], |
| | | success: (chooseImageRes) => { |
| | | const tempFilePaths = chooseImageRes.tempFilePaths; |
| | | console.log(tempFilePaths) |
| | | uni.uploadFile({ |
| | | url: baseUrl + '/ext/routeCardExt/upload', |
| | | filePath: tempFilePaths[0], |
| | | name: 'file', |
| | | header: { |
| | | 'Cookie': 'eva-auth-token=' + this.session |
| | | }, |
| | | formData: { |
| | | 'folder': this.path |
| | | }, |
| | | success: (uploadFileRes) => { |
| | | console.log(JSON.parse(uploadFileRes.data)); |
| | | let res = JSON.parse(uploadFileRes.data) |
| | | this.form.files.push({ |
| | | fileUrl: res.data.imgaddr, |
| | | filename: res.data.imgname, |
| | | // filesize: e.target.files[i].size, |
| | | type: judgmentType(tempFilePaths[0]) ? 0 : 1, |
| | | url: res.data.url |
| | | }) |
| | | } |
| | | }); |
| | | uni.showLoading({ title: '上传中' }); |
| | | const tempFilePaths = chooseImageRes.tempFiles; |
| | | for (let i = 0; i < tempFilePaths.length; i++) { |
| | | uni.uploadFile({ |
| | | url: baseUrl + '/ext/routeCardExt/upload', |
| | | filePath: tempFilePaths[i].tempFilePath, |
| | | name: 'file', |
| | | header: { |
| | | 'Cookie': 'eva-auth-token=' + that.session |
| | | }, |
| | | formData: { |
| | | 'folder': that.path |
| | | }, |
| | | success: (uploadFileRes) => { |
| | | let res = JSON.parse(uploadFileRes.data) |
| | | let typec = '' |
| | | for (let s = 0; s < fileType.length; s++) { |
| | | if (tempFilePaths[i].tempFilePath.indexOf(fileType[s].name) !== -1) { |
| | | typec = fileType[s].type |
| | | } |
| | | } |
| | | that.form.files.push({ |
| | | fileUrl: res.data.imgaddr, |
| | | filename: res.data.imgname, |
| | | typec, |
| | | url: res.data.url |
| | | }) |
| | | uni.hideLoading(); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | }, |
| | |
| | | height: 100%; |
| | | position: absolute; |
| | | background: #F7F7F7; |
| | | |
| | | .sb { |
| | | width: 100%; |
| | | height: 800rpx; |
| | | padding: 30rpx; |
| | | box-sizing: border-box; |
| | | } |
| | | |
| | | .box_list { |
| | | padding: 0 30rpx 0 30rpx; |