|
@@ -9,12 +9,12 @@
|
|
|
</view>
|
|
|
<input type="text" v-model="reportName">
|
|
|
</view>
|
|
|
- <view class="form-item margin-top" >
|
|
|
+ <view class="form-item margin-top">
|
|
|
<view class="title">
|
|
|
<text class="necessary">*</text>
|
|
|
巡检状态:
|
|
|
</view>
|
|
|
- <radio-group name="gender" @change="radioChange" >
|
|
|
+ <radio-group name="gender" @change="radioChange">
|
|
|
<label class="">
|
|
|
<radio value="0" checked /><text>正常</text>
|
|
|
</label>
|
|
@@ -34,9 +34,14 @@
|
|
|
<text class="necessary">*</text>
|
|
|
上传图片:
|
|
|
</view>
|
|
|
- <view class="unload-box">
|
|
|
- <view ref="input" class="input" >
|
|
|
- </view>
|
|
|
+
|
|
|
+
|
|
|
+ <view class="unload-box" @tap="goCamera()">
|
|
|
+
|
|
|
+
|
|
|
+ <image v-if="this.imgUrl" mode="aspectFit" style="width:70rpx;height:70rpx" :src="this.imgUrl"
|
|
|
+ :data-src="this.imgUrl"></image>
|
|
|
+ <view v-else style="background:rgb(223 215 215 / 63%);font-size:22rpx;line-height:40rpx;margin-top:20rpx;padding:0 20px;display:inline-block;border-radius:10rpx">请上传 + </view>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="form-item margin-top">
|
|
@@ -58,10 +63,12 @@
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
- noClick:true,
|
|
|
+ noClick: true,
|
|
|
imgList: [],
|
|
|
msg: '',
|
|
|
id: '',
|
|
|
+ img: '',
|
|
|
+ imgUrl: '',
|
|
|
reportName: '',
|
|
|
radioOne: 0,
|
|
|
zb_id: 0
|
|
@@ -75,13 +82,13 @@
|
|
|
|
|
|
mounted() {
|
|
|
// 创建附件上传
|
|
|
- var _self = this;
|
|
|
- var input = document.createElement('input'); //创建元素
|
|
|
- input.type = 'file' //添加file类型
|
|
|
- input.onchange = (event) => {
|
|
|
- _self.upFile(input, event)
|
|
|
- }
|
|
|
- this.$refs.input.$el.appendChild(input)
|
|
|
+ // var _self = this;
|
|
|
+ // var input = document.createElement('input'); //创建元素
|
|
|
+ // input.type = 'file' //添加file类型
|
|
|
+ // input.onchange = (event) => {
|
|
|
+ // _self.upFile(input, event)
|
|
|
+ // }
|
|
|
+ // this.$refs.input.$el.appendChild(input)
|
|
|
|
|
|
},
|
|
|
methods: {
|
|
@@ -90,51 +97,83 @@
|
|
|
this.radioOne = e.detail.value;
|
|
|
},
|
|
|
|
|
|
- upFile(input, event) {
|
|
|
- var _self = this;
|
|
|
- uni.uploadFile({
|
|
|
- url:this.$BASE_URL+'Inspection/setUpload',
|
|
|
- files: [{
|
|
|
- file: input.files[0],
|
|
|
- uri: event.srcElement.value
|
|
|
- }],
|
|
|
- success: (uploadFileRes) => {
|
|
|
- var data = JSON.parse(uploadFileRes.data)
|
|
|
- this.img = data.img_url;
|
|
|
- alert(this.img)
|
|
|
- },
|
|
|
- fail: (err) => {
|
|
|
- console.log(err)
|
|
|
+ goCamera() {
|
|
|
+ const that = this;
|
|
|
+ uni.chooseImage({
|
|
|
+ count: 1, // 最多可以选择的图片张数
|
|
|
+ sizeType: ['original', 'compressed'], //original 原图,compressed 压缩图,默认二者都有
|
|
|
+ sourceType: ['album'], //从相册选择
|
|
|
+ success: function(res) {
|
|
|
+ console.log(res);
|
|
|
+ const tempFilePaths = res.tempFilePaths;
|
|
|
+ that.imgUrl = res.tempFilePaths[0];
|
|
|
+ alert(res.tempFilePaths[0])
|
|
|
+
|
|
|
+ uni.uploadFile({
|
|
|
+ url: that.$BASE_URL + 'Inspection/setUpload',
|
|
|
+ filePath: tempFilePaths[0],
|
|
|
+ name: 'file',
|
|
|
+ formData: {
|
|
|
+ 'user': 'test'
|
|
|
+ },
|
|
|
+ success: (uploadFileRes) => {
|
|
|
+ console.log('uploadFileRes')
|
|
|
+ that.img = JSON.parse(uploadFileRes.data).img_url;
|
|
|
+ alert(uploadFileRes.data)
|
|
|
+ alert(that.img)
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
+
|
|
|
},
|
|
|
|
|
|
+ // upFile(input, event) {
|
|
|
+ // var _self = this;
|
|
|
+ // uni.uploadFile({
|
|
|
+ // url:this.$BASE_URL+'Inspection/setUpload',
|
|
|
+ // files: [{
|
|
|
+ // file: input.files[0],
|
|
|
+ // uri: event.srcElement.value
|
|
|
+ // }],
|
|
|
+ // success: (uploadFileRes) => {
|
|
|
+ // var data = JSON.parse(uploadFileRes.data)
|
|
|
+ // this.img = data.img_url;
|
|
|
+ // alert(this.img)
|
|
|
+ // },
|
|
|
+ // fail: (err) => {
|
|
|
+ // console.log(err)
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // },
|
|
|
+
|
|
|
addSubmit() {
|
|
|
-
|
|
|
- if (!this.img) {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (!this.reportName.replace(/^\s*/g, '')) {
|
|
|
uni.showToast({
|
|
|
- title: "请上传图片",
|
|
|
+ title: "请输入上报名称",
|
|
|
icon: "none"
|
|
|
});
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- if (!this.reportName.replace(/^\s*/g,'')) {
|
|
|
+ if (!this.img) {
|
|
|
uni.showToast({
|
|
|
- title: "请输入上报名称",
|
|
|
+ title: "请上传图片",
|
|
|
icon: "none"
|
|
|
});
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- if (!this.msg.replace(/^\s*/g,'')) {
|
|
|
+
|
|
|
+ if (!this.msg.replace(/^\s*/g, '')) {
|
|
|
uni.showToast({
|
|
|
title: "请输入巡检描述",
|
|
|
icon: "none"
|
|
|
});
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
this.powerSubmitRes({
|
|
|
"zb_id": this.zb_id,
|
|
|
"spot_id": this.id,
|
|
@@ -168,11 +207,11 @@
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss">
|
|
|
-.unload-box{
|
|
|
- width:calc(100% - 200rpx)
|
|
|
-}
|
|
|
-.textarea{
|
|
|
- width:calc(100% - 200rpx)
|
|
|
-
|
|
|
-}
|
|
|
+ .unload-box {
|
|
|
+ width: calc(100% - 200rpx)
|
|
|
+ }
|
|
|
+
|
|
|
+ .textarea {
|
|
|
+ width: calc(100% - 200rpx)
|
|
|
+ }
|
|
|
</style>
|