loulijun2021
2023-10-18 349332ae95d97beb3e4aca5c30d131c8997c3de6
pages/mjgl/wxsq.vue
@@ -20,12 +20,12 @@
                     <view class="head_left">
                        <view class="head_bar"></view>
                        <view class="head_title">
                           扫描维修工位
                           扫描维修模具
                        </view>
                     </view>
                     <view class="marginRight20">
                        <u-icon name="scan" @click="topScanClick" color="red" size="56"></u-icon>
                        <u-icon name="scan" @click="topScanClick" color="red" size="24"></u-icon>
                     </view>
                  </view>
@@ -36,14 +36,14 @@
                        v-for="item in topContent" :key="item.code">
                        <view style="display: flex;">
                           <view class="flex_column titleFont">
                              <view>工位编码:</view>
                              <view>工位名称:</view>
                              <view>生产车间:</view>
                              <view>模具编码:</view>
                              <view>模具名称:</view>
                              <view>规格型号:</view>
                           </view>
                           <view class="flex_column contentFont">
                              <view>{{item.code}}</view>
                              <view>{{item.name}}</view>
                              <view>{{item.wksp_name}}</view>
                              <view>{{item.spec?item.spec:'/'}}</view>
                           </view>
                        </view>
                        <!--    <u-radio size='40' :key="item.code" :name="item.code"
@@ -53,7 +53,7 @@
                  </view>
               </view>
               <u-gap height="20" bgColor="#eff0f1"></u-gap>
               <u-gap height="10" bgColor="#eff0f1"></u-gap>
               <view class="head" style="padding-bottom: 10rpx;">
                  <view class="head_block" style="margin-bottom: 10rpx;margin-top:20rpx;">
@@ -71,7 +71,7 @@
                     </view>
                  </view>
               </view>
               <u-gap height="20" bgColor="#eff0f1"></u-gap>
               <u-gap height="10" bgColor="#eff0f1"></u-gap>
               <view class="head" style="padding-bottom: 10rpx;">
                  <view class="head_block" style="margin-bottom: 10rpx;margin-top:20rpx;">
@@ -83,17 +83,16 @@
                     </view>
                  </view>
                  <view class='inputClass  contentFont' style="margin: 0 20rpx; width: 95%;">
                     <u--textarea placeholder="请输入" confirm-type="send" border="surround" height='140'
                     <u--textarea placeholder="请输入" confirm-type="send" border="surround" height='80'
                        v-model="descMessage">
                     </u--textarea>
                  </view>
                  <view style="display: flex;">
                     <view v-for="(pic,index) in fileList" :key="pic.name">
                        <view style="margin: 20rpx 0rpx 20rpx 20rpx;position: relative;">
                           <u-icon name="close" color="#fff" size="26"
                           <u-icon name="close" color="#fff" size="16"
                              style="position: absolute;z-index: 10;right: 0;background-color: black;border-radius:50%;"
                              @click="deletePic(pic)"></u-icon>
@@ -111,37 +110,39 @@
         </view>
         <u-button size="large" :loading="isDisabledSubmitButton" loadingText="正在提交,请稍等..." type="primary"
            @click="submit" :disabled="descMessage.toString().length===0" text="确认提交">
         </u-button>
         <view class="footer">
            <u-button size="large" :loading="isDisabledSubmitButton" loadingText="正在提交,请稍等..." type="primary"
               @click="submit" :disabled="descMessage.toString().length===0" text="确认提交">
            </u-button>
         </view>
      </view>
      <scan-code></scan-code>
      <!-- <scan-code></scan-code> -->
   </view>
</template>
<script>
   // import {
   //    MaintainScanDeviceApplyQrCodeData,
   //    MaintainScanDeviceApplySave
   // } from '../../config/api.js'
   import {
      MaintainScanMouldApplyQrCodeData,
      MaintainScanMouldApplySave
   } from '../../config/api.js'
   // import {
   //    data
   // } from '../../uni_modules/uview-ui/libs/mixin/mixin.js';
   import scanCode from '@/components/scan-code/scan-code.vue'
   // import scanCode from '@/components/scan-code/scan-code.vue'
   export default {
      components: {
         scanCode
      },
      // components: {
      //    scanCode
      // },
      onLoad(option) {
         //   const _this = this
         // uni.$off('scancodedate') // 每次进来先 移除全局自定义事件监听器
         // uni.$on('scancodedate', function(content) {
         //    console.log("扫描到的内容为:", content)
         //    _this.getMaintainScanDeviceApplyQrCodeData(content)
         //    _this.getMaintainScanMouldApplyQrCodeData(content)
         // })
      },
      onPullDownRefresh() {
@@ -164,18 +165,21 @@
            selectValue: 'A',
            selectRange: [{
               value: 'A',
               text: '设备点检'
            }, {
               value: 'B',
               text: '设备保养'
            }, {
               value: 'C',
               text: '安灯呼叫'
            }, {
               value: 'D',
               text: '手工'
            }],
                  value: 'A',
                  text: '模具点检'
               }, {
                  value: 'B',
                  text: '模具保养'
               },
               // {
               //    value: 'C',
               //    text: '安灯呼叫'
               // },
               {
                  value: 'D',
                  text: '手工'
               },
            ],
            descMessage: '', //故障描述
            imgPreviewSrcs: [], //图片预览src
@@ -183,7 +187,7 @@
         }
      },
      created() {
         // this.getMaintainScanMouldApplyQrCodeData('002')
      },
      mounted() {
         this.init()
@@ -262,7 +266,7 @@
                     that.$u.toast('此条码已扫描,已在列表中!')
                  } else {
                     //处理扫码事件
                     that.getMaintainScanDeviceApplyQrCodeData(that.scanContent);
                     that.getMaintainScanMouldApplyQrCodeData(that.scanContent);
                  }
               },
               complete: function(res) {
@@ -277,12 +281,12 @@
         },
         // 获取维修工位    
         async getMaintainScanDeviceApplyQrCodeData(val) {
         async getMaintainScanMouldApplyQrCodeData(val) {
            const data = {
               eqpcode: val
               mouldcode: val
            }
            const res = await MaintainScanDeviceApplyQrCodeData(data)
            const res = await MaintainScanMouldApplyQrCodeData(data)
            if (res.code === '200') {
               this.topContent = []
               this.topContent.unshift(res.data[0])
@@ -294,16 +298,9 @@
            const header = {
               // 'Content-Type': 'multipart/form-data',
               'Content-Type': 'application/x-www-form-urlencoded',
               'rediskey': uni.getStorageSync('rediskey'),
               'admin': uni.getStorageSync('usercode'),
               'username': encodeURIComponent(uni.getStorageSync('username')),
               'navTabId': uni.getStorageSync('usercode'),
               'userid': uni.getStorageSync('userid'),
               'guid': uni.getStorageSync('guid'),
               'usertype': 'APP'
               // 'Content-Type': 'application/json',
               'Token': uni.getStorageSync('Token')
            }
            /*
@@ -311,52 +308,66 @@
               手机上请求是需要APP-PLUS的代码
            */
            // #ifdef H5
            // console.log('H5')
            // let formData = new FormData()
            // formData.append("username", uni.getStorageSync('username'))
            // formData.append("eqpcode", this.topContent[0].code)
            // formData.append("wkshpcode", this.topContent[0].wksp_code)
            // formData.append("faultsourcecode", this.selectValue)
            // formData.append("faultdescr", this.descMessage)
            // 目前还是不行的
            let formData = new FormData()
            formData.append("menucode", '2052')
            formData.append("mouldcode", this.topContent[0].code)
            formData.append("faultsourcecode", this.selectValue)
            formData.append("faultdescr", this.descMessage)
            this.fileList.forEach((item, index) => {
               formData.append('files', item.uri)
            })
            // for (var [a, b] of formData.entries()) {
            //    console.log(a, b)
            // }
            // let files = []
            // console.log(this.fileList, 1)
            // this.fileList.forEach((item, index) => {
            //    formData.append('files1', item.file)
            //    files.push(item.uri)
            // })
            // MaintainScanDeviceApplySave(formData).then(res => {
            //    console.log(res, 1)
            // })
            // console.log(this.fileList, 1)
            // let formData = {
            //    menucode: '2052',
            //    mouldcode: this.topContent[0].code,
            //    faultsourcecode: this.selectValue,
            //    faultdescr: this.descMessage,
            //    files
            // }
            // MaintainScanMouldApplySave('2052', '001', 'A', '123', formData).then(res => {
            MaintainScanMouldApplySave(JSON.stringify(formData)).then(res => {
               console.log(res, 1)
            })
            // #endif
            // #ifdef APP-PLUS ||MP  
            // const temp = [{
            //    name: 'files1'
            // }]
            // 目前可以的
            let formData = {
               username: uni.getStorageSync('username'),
               eqpcode: this.topContent[0].code,
               wkshpcode: this.topContent[0].wksp_code,
               menucode: '2052',
               mouldcode: this.topContent[0].code,
               faultsourcecode: this.selectValue,
               faultdescr: this.descMessage,
            }
            console.log(formData)
            console.log(JSON.stringify(formData))
            this.isDisabledSubmitButton = true
            uni.uploadFile({
               url: this.$baseUrl + '/AppDeviceManage/MaintainScanDeviceApplySave',
               url: this.$baseUrl + '/MouldManager/MaintainScanMouldApplySave',
               files: this.fileList.length === 0 ? [{
                  uri: '/'
               }] : this.fileList,
               // files: [{"uri": "/"   }],
               // files: [{
               //    "uri": "/"
               // }],
               header: header,
               formData: formData,
               success: (res) => {
                  console.log(JSON.stringify(res))
                  let result = JSON.parse(res.data)
                  if (res.statusCode == 200 && result.code == '200') {
                     uni.$u.toast('提交成功!')
@@ -371,6 +382,7 @@
                  this.isDisabledSubmitButton = false
               },
               fail(res) {
                  console.log(res)
                  uni.$u.toast('提交失败!')
                  this.isDisabledSubmitButton = false
               },