| | |
| | | <uni-data-select v-model="formData.num" :localdata="equipmentList" @change="changeEquipmentList" |
| | | placeholder="请选择" /> |
| | | </uni-forms-item> --> |
| | | <uni-forms-item required name="num" label="设备编号:"> |
| | | <uni-forms-item required :label-width="100" name="num" label="设备编号:"> |
| | | <uni-easyinput v-model=" formData.numSear" placeholder="请选择" :disabled="true" suffixIcon="search" |
| | | @iconClick="OnenterpriseId()" /> |
| | | </uni-forms-item> |
| | | <uni-forms-item required name="name" label="故障简称:"> |
| | | <uni-forms-item required :label-width="100" name="name" label="故障简称:"> |
| | | <uni-data-select v-model="formData.faultName" :localdata="formData.faultNameList" |
| | | @change="changefaultNameList" placeholder="请选择" /> |
| | | </uni-forms-item> |
| | | <uni-forms-item required name="faultType" label="故障分类:"> |
| | | <uni-forms-item required :label-width="100" name="faultType" label="故障分类:"> |
| | | <uni-easyinput v-model="formData.faultType" :disabled='true' /> |
| | | </uni-forms-item> |
| | | <uni-forms-item required name="faultDescription" label="故障描述:"> |
| | | <uni-forms-item required :label-width="100" name="faultDescription" label="故障描述:"> |
| | | <uni-easyinput v-model="formData.faultDescription" :disabled='true' /> |
| | | </uni-forms-item> |
| | | |
| | | <uni-forms-item required name="desc" label="故障开始时间:"> |
| | | <uni-datetime-picker type="datetime" v-model="formData.loadTime" /> |
| | | </uni-forms-item> |
| | | <uni-forms-item required name="name" label="是否停机:"> |
| | | <uni-forms-item required name="name" :label-width="100" label="是否停机:"> |
| | | <uni-data-select v-model="formData.breakdownFlag" :localdata="isTrueList" @change="changeisTrueList" |
| | | placeholder="请选择" /> |
| | | </uni-forms-item> |
| | | <uni-forms-item name="outNum" label="报修图片:"> |
| | | <view class="grid col-4 grid-square flex-sub"> |
| | | <view class="bg-img" v-for="(item,index) in imgList" :key="index" @tap="ViewImage" |
| | | :data-url="imgList[index]"> |
| | | <image :src="imgList[index]" mode="aspectFill"></image> |
| | | <view class="cu-tag bg-red radius" @tap.stop="DelImg" :data-index="index"> |
| | | <text class='cuIcon-close'></text> |
| | | </view> |
| | | </view> |
| | | <view class="solids" @tap="ChooseImage" v-if="imgList.length<1"> |
| | | <text class='cuIcon-cameraadd'></text> |
| | | </view> |
| | | </view> |
| | | <uni-forms-item required :label-width="110" name="desc" label="故障开始时间:"> |
| | | <uni-datetime-picker type="datetime" v-model="formData.loadTime" /> |
| | | </uni-forms-item> |
| | | |
| | | <uni-forms-item name="outNum" label="报修图片:"> |
| | | <uni-file-picker limit="9" :value="fileLists" :image-styles="imageStyles" :sourceType="sourceType" |
| | | @select="select" @progress="progress" @success="success" @fail="fail" @delete="deletea" /> |
| | | </uni-forms-item> |
| | | |
| | | <uni-forms-item name="faultDescription" label="备注:"> |
| | |
| | | mixins: [MescrollMixin], // 使用mixin |
| | | data() { |
| | | return { |
| | | // 图片回显 |
| | | fileLists: [], |
| | | // 上传图片的样式 |
| | | imageStyles: { |
| | | width: 90, |
| | | height: 90, |
| | | }, |
| | | // uni.chooseImage值,从相册选择,拍摄 |
| | | sourceType: ['album', 'camera'], |
| | | id: '', |
| | | equipmentList: [], |
| | | isTrueList: [{ |
| | |
| | | }, |
| | | changefaultNameList(e) { |
| | | this.formData.faultName = e; |
| | | if (e == '1902250920983339009') { |
| | | this.formData.faultType = this.formData.faultNameList[0].faultCategory_dictText; |
| | | this.formData.faultDescription = this.formData.faultNameList[0].faultDescription; |
| | | } else if (e == '1909114668383875074') { |
| | | this.formData.faultType = this.formData.faultNameList[1].faultCategory_dictText; |
| | | this.formData.faultDescription = this.formData.faultNameList[1].faultDescription; |
| | | } else if (e == '1909877534952710145') { |
| | | this.formData.faultType = this.formData.faultNameList[2].faultCategory_dictText; |
| | | this.formData.faultDescription = this.formData.faultNameList[2].faultDescription; |
| | | |
| | | this.setFaultReason(this.formData.faultName) |
| | | |
| | | }, |
| | | setFaultReason(value) { |
| | | for (let i = 0; i < this.formData.faultNameList.length; i++) { |
| | | if (this.formData.faultNameList[i].id === value) { |
| | | this.formData.faultType = this.formData.faultNameList[i].faultCategory_dictText |
| | | this.formData.faultDescription = this.formData.faultNameList[i].faultDescription |
| | | } |
| | | |
| | | } |
| | | }, |
| | | |
| | | |
| | | getfaultReasonList() { |
| | | this.$http.get(this.url.faultReasonList).then(res => { |
| | | //设置列表数据 |
| | |
| | | this.$tip.error("联网失败") |
| | | }) |
| | | }, |
| | | // getEquipment() { |
| | | // this.$http.get(this.url.getEquipmentList).then(res => { |
| | | // //设置列表数据 |
| | | // if (res.data.success) { |
| | | // this.equipmentList = res.data.result |
| | | // } else { |
| | | // uni.showToast({ |
| | | // icon: "error", |
| | | // title: res.data.message, |
| | | // duration: 2000 |
| | | // }); |
| | | |
| | | // } |
| | | // }).catch(() => { |
| | | // this.$tip.error("联网失败") |
| | | // }) |
| | | // }, |
| | | // changeEquipmentList(e) { |
| | | // this.formData.num = e; |
| | | // }, |
| | | changeisTrueList(e) { |
| | | this.formData.breakdownFlag = e; |
| | | }, |
| | | select(e) { |
| | | const tempFilePaths = e.tempFilePaths; |
| | | |
| | | ChooseImage() { |
| | | var that = this; |
| | | uni.chooseImage({ |
| | | count: 4, |
| | | sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有 |
| | | sourceType: ['album'], // 从相册选择 |
| | | success: (res) => { |
| | | // 存储选择的图片路径 |
| | | that.imgList = res.tempFilePaths; |
| | | // if (!Array.isArray(tempFilePaths) || tempFilePaths.length === 0) { |
| | | // uni.showToast({ |
| | | // title: '请选择文件', |
| | | // icon: 'none' |
| | | // }); |
| | | // return; |
| | | // } |
| | | |
| | | // 初始化 formData.avatar 为空字符串 |
| | | that.formData.avatar = []; |
| | | uni.showLoading({ |
| | | title: '上传中...' |
| | | }); |
| | | |
| | | // 创建上传任务的 Promise 数组 |
| | | const uploadPromises = res.tempFilePaths.map((filePath, index) => { |
| | | return new Promise((resolve, reject) => { |
| | | that.$http.upload(that.url.upload, { |
| | | filePath: filePath, |
| | | name: 'file' |
| | | }) |
| | | .then(uploadRes => { |
| | | // 假设服务器返回的结果中包含文件路径 |
| | | const filePath = uploadRes.data.result[0]; |
| | | this.formData.avatar.push(filePath) |
| | | resolve(filePath); |
| | | }) |
| | | .catch(err => { |
| | | console.error('图片' + index + '上传失败:', err); |
| | | reject(err); |
| | | }); |
| | | }); |
| | | }); |
| | | |
| | | // 并发执行所有上传任务 |
| | | Promise.all(uploadPromises) |
| | | .then((uploadedFilePaths) => { |
| | | console.log('所有图片上传成功:', that.formData.avatar); |
| | | const uploadPromises = tempFilePaths.map((filePath, index) => { |
| | | return new Promise((resolve, reject) => { |
| | | this.$http.upload(this.url.upload, { |
| | | filePath: filePath, |
| | | name: 'file' |
| | | }) |
| | | .catch((err) => { |
| | | console.error('图片上传失败:', err); |
| | | that.$tip.error('图片上传失败'); |
| | | .then(uploadRes => { |
| | | // 假设服务器返回的结果中包含文件路径 |
| | | const serverFilePath = uploadRes.data.result[0]; |
| | | this.formData.avatar.push(serverFilePath); |
| | | resolve(uploadRes); // 返回结果给 Promise.all |
| | | }) |
| | | .catch(err => { |
| | | console.error(`图片 ${index + 1} 上传失败:`, err); |
| | | reject(err); |
| | | }); |
| | | } |
| | | }); |
| | | }); |
| | | }, |
| | | ViewImage(e) { |
| | | uni.previewImage({ |
| | | urls: this.imgList, |
| | | current: e.currentTarget.dataset.url |
| | | }); |
| | | }, |
| | | DelImg(e) { |
| | | uni.showModal({ |
| | | title: '提示', |
| | | content: '确定要删除这段回忆吗?', |
| | | cancelText: '再看看', |
| | | confirmText: '再见', |
| | | success: res => { |
| | | if (res.confirm) { |
| | | this.imgList.splice(e.currentTarget.dataset.index, 1) |
| | | } |
| | | } |
| | | }) |
| | | |
| | | Promise.all(uploadPromises) |
| | | .then(() => { |
| | | uni.hideLoading(); |
| | | uni.showToast({ |
| | | title: '全部上传成功' |
| | | }); |
| | | }) |
| | | .catch(err => { |
| | | uni.hideLoading(); |
| | | uni.showToast({ |
| | | title: '部分上传失败', |
| | | icon: 'none' |
| | | }); |
| | | console.error('上传异常:', err); |
| | | }); |
| | | }, |
| | | |
| | | |
| | | |
| | | // 删除 |
| | | deletea(e) { |
| | | console.log('删除图片', e); |
| | | }, |
| | | ProductionTask() { |
| | | if (this.formData.num == 0 || this.formData.num == undefined) { |
| | | uni.showToast({ |
| | |
| | | duration: 2000 |
| | | }); |
| | | this.$Router.replaceAll({ |
| | | name: 'reportRepairList' |
| | | name: 'index' |
| | | }) |
| | | |
| | | } |