123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- <template>
- <view>
- <form action="">
- <view style='height:30rpx'></view>
- <view class="form-item">
- <view class="title">
- <text class="necessary">*</text>
- 上报名称:
- </view>
- <input type="text" v-model="reportName">
- </view>
- <view class="form-item margin-top">
- <view class="title">
- <text class="necessary">*</text>
- 巡检状态:
- </view>
- <radio-group name="gender" @change="radioChange">
- <label class="">
- <radio value="0" checked /><text>正常</text>
- </label>
- <label class="">
- <radio value="1" /><text>异常</text>
- </label>
- <label class="">
- <radio value="2" /><text>故障</text>
- </label>
- <label>
- <radio value="3" /><text>其他</text>
- </label>
- </radio-group>
- </view>
- <view class="form-item margin-top">
- <view class="title">
- <text class="necessary">*</text>
- 上传图片:
- </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">
- <view class="title">
- <text class="necessary">*</text>
- 巡检描述:
- </view>
- <textarea maxlength="-1" @input="textareaAInput" placeholder="" v-model="msg"></textarea>
- </view>
- <view class="btn-area submitBottomBtn padding-lr-sm">
- <button class="bg-blue round margin-top" @click="$noMultipleClicks(addSubmit)">提 交 </button>
- </view>
- </form>
-
- <helang-compress ref="helangCompress"></helang-compress>
- </view>
- </template>
- <script>
- import helangCompress from '../../../components/helang-compress/helang-compress';
- export default {
- components: {
- helangCompress
- },
- data() {
- return {
- noClick: true,
- imgList: [],
- msg: '',
- id: '',
- img: '',
- imgUrl: '',
- reportName: '',
- radioOne: 0,
- zb_id: 0,
-
- params: {
- maxSize: 800,
- fileType: 'png',
- quality: 0.85,
- minSize: 640
- },
-
-
- }
- },
- onLoad: function(option) {
- this.id = option.id;
- this.zb_id = option.zb_id
- },
- mounted() {
- },
- methods: {
- radioChange(e) {
- console.log('type:' + e.detail.value);
- this.radioOne = e.detail.value;
- },
- goCamera() {
- const that = this;
- uni.chooseImage({
- count: 1, // 最多可以选择的图片张数
- sizeType: ['original', 'compressed'], //original 原图,compressed 压缩图,默认二者都有
- sourceType: ['camera', 'album'],
- success: function(res) {
- console.log(res);
- that.imgUrl = res.tempFilePaths[0];
- var tempFilePaths = res.tempFilePaths[0];
- that.$refs.helangCompress.compress({
- src: tempFilePaths,
- maxSize: that.params.maxSize,
- fileType: that.params.fileType,
- quality: that.params.quality,
- minSize: that.params.minSize
- }).then((res) => {
- uni.hideLoading();
- // uni.showToast({
- // title: "压缩成功",
- // icon: "success"
- // })
- tempFilePaths = [res][0];
-
- uni.uploadFile({
- url: that.$BASE_URL + 'Inspection/setUpload',
- filePath: tempFilePaths,
- name: 'file',
- success: (uploadFileRes) => {
-
- uni.showToast({
- title: "上传成功",
- icon: "success"
- })
- that.img = JSON.parse(uploadFileRes.data).img_url;
- }
- });
- }).catch((err) => {
- uni.hideLoading();
- uni.showToast({
- title: "压缩失败",
- icon: "none"
- })
- })
- }
- })
- },
-
- addSubmit() {
- if (!this.reportName.replace(/^\s*/g, '')) {
- uni.showToast({
- title: "请输入上报名称",
- icon: "none"
- });
- return
- }
- if (!this.img) {
- uni.showToast({
- title: "请上传图片",
- icon: "none"
- });
- return
- }
- if (!this.msg.replace(/^\s*/g, '')) {
- uni.showToast({
- title: "请输入巡检描述",
- icon: "none"
- });
- return
- }
- this.powerSubmitRes({
- "zb_id": this.zb_id,
- "spot_id": this.id,
- "report_name": this.reportName,
- "spot_abnormal": this.radioOne,
- "img": this.img,
- "dwsb_remarks": this.msg,
- })
- },
- async powerSubmitRes(params = {}) {
- const res = await this.$myRequest({
- url: 'Inspection/setInspection',
- data: params
- })
- if (res.data.flag) {
- uni.showToast({
- title: "提交成功",
- });
- setTimeout(() => {
- uni.navigateTo({
- url: '/pages/xunJian/planInnerList/planInnerList?id=' + this.zb_id,
- });
- }, 1000);
- }
- },
- textareaAInput(e) {
- this.textareaAValue = e.detail.value
- },
- }
- }
- </script>
- <style lang="scss">
- .unload-box {
- width: calc(100% - 200rpx)
- }
- .textarea {
- width: calc(100% - 200rpx)
- }
- </style>
|