MrShi
2025-08-19 f2ac76666299407545fb733f0d21f6e8cfe538a3
h5/pages/reporting_she/reporting_she.vue
@@ -7,12 +7,12 @@
         <u-form-item label="部门" labelWidth="120" prop="companyName" borderBottom required>
            <u--input v-model="model.companyName" border="none" placeholder="请选择部门" disabledColor="#ffffff"
               disabled></u--input>
            <u-icon slot="right" name="arrow-right"></u-icon>
            <!-- <u-icon slot="right" name="arrow-right"></u-icon> -->
         </u-form-item>
         <u-form-item label="上报时间" labelWidth="120" prop="submitDate" borderBottom required>
            <u--input v-model="model.submitDate" border="none" placeholder="请选择上报时间" disabledColor="#ffffff"
               disabled></u--input>
            <u-icon slot="right" name="arrow-right"></u-icon>
            <!-- <u-icon slot="right" name="arrow-right"></u-icon> -->
         </u-form-item>
         <u-form-item label="发生时间" labelWidth="120" prop="happenTime" borderBottom @click="openTime" required>
            <u--input v-model="model.happenTime" border="none" placeholder="请选择发生时间" disabledColor="#ffffff"
@@ -48,18 +48,18 @@
            <u--input v-model="model.remark" border="none" placeholder="如选择其它区域请务必填写具体位置"></u--input>
         </u-form-item>
         <u-form-item label="是否外部就医" labelWidth="120" prop="outJiuyi" borderBottom required>
            <u-radio-group v-model="model.outJiuyi" placement="row">
            <u-radio-group v-model="model.outJiuyi" placement="row" @change="model.isYiwushi = ''; model.isHurted = ''">
               <u-radio label="否" name="0"></u-radio>
               <u-radio label="是" name="1"></u-radio>
            </u-radio-group>
         </u-form-item>
         <u-form-item label="是否医务室" labelWidth="120" prop="isYiwushi" borderBottom required>
            <u-radio-group v-model="model.isYiwushi" placement="row">
         <u-form-item label="是否医务室" labelWidth="120" prop="isYiwushi" borderBottom required v-if="model.outJiuyi === '0'">
            <u-radio-group v-model="model.isYiwushi" placement="row" @change="model.isHurted = ''">
               <u-radio label="否" name="0"></u-radio>
               <u-radio label="是" name="1"></u-radio>
            </u-radio-group>
         </u-form-item>
         <u-form-item label="是否受伤" labelWidth="120" prop="isHurted" borderBottom required>
         <u-form-item label="是否受伤" labelWidth="120" prop="isHurted" borderBottom required v-if="model.isYiwushi === '0'">
            <u-radio-group v-model="model.isHurted" placement="row">
               <u-radio label="否" name="0"></u-radio>
               <u-radio label="是" name="1"></u-radio>
@@ -80,13 +80,13 @@
            <u--textarea v-model="model.eventInfo" placeholder="请输入事件说明" style="margin-top: 15rpx;" maxlength="200" count></u--textarea>
         </u-form-item>
         <u-form-item label="上传图片" labelWidth="120" prop="multifileList" labelPosition="top" borderBottom>
            <u-upload
            <UploadImage
               :fileList="model.multifileList"
               @afterRead="afterRead"
               @delete="deletePic"
               accept="image"
               name="1"
               style="margin-top: 15rpx;"></u-upload>
               folder="WORKORDER_FILE_PATH"
               @dele="deletePic"
               @getFileList="afterRead"
               style="margin-top: 15rpx;"
            />
         </u-form-item>
      </u--form>
      <u-button type="primary" text="提交" @click="submit" style="margin-top: 60rpx;"></u-button>
@@ -105,7 +105,7 @@
         <view class="slot-content">
            <u-icon name="checkmark-circle-fill" color="#3875C5" size="70"></u-icon>
            <text>提交成功</text>
            <text>感谢您的反馈</text>
            <text>已收到您的上报,稍后会有相关同事和您联系</text>
         </view>
      </u-modal>
      <!-- 发生地点 -->
@@ -137,9 +137,10 @@
<script>
   import { mapState } from 'vuex'
   import UploadImage from '@/components/uploadImage/uploadImage.vue'
   import pengTree from '@/uni_modules/peng-tree/peng-tree/peng-tree.vue'
   export default {
      components: { pengTree },
      components: { pengTree, UploadImage },
      computed: {
         ...mapState(['userInfo'])
      },
@@ -257,6 +258,39 @@
         this.getType()
      },
      methods: {
         selectImage() {
            var that = this
            that.$ww.chooseImage({
               count: 1,
               sizeType: ['original', 'compressed'],
               sourceType: ['album', 'camera'],
               success(res) {
                  let serverIds = that.getUploadImage(res.localIds)
                  console.log(serverIds)
               },
               fail(err) {
                  console.log(err)
               }
            })
         },
         // 获取服务器图片id
         getUploadImage(localIds) {
            var that = this
            let serverIds = []
            localIds.forEach(localId => {
               that.$ww.uploadImage({
                  localId,
                  success(res) {
                     console.log(res.serverId)
                     serverIds.push(res.serverId)
                  },
                  fail(err) {
                     console.log(err)
                  }
               })
            })
            return serverIds;
         },
         closeTime() {
            this.show1 = false
            this.canScroll()
@@ -320,6 +354,29 @@
            this.canScroll()
            this.show4 = false
         },
         next1() {
            this.model.name = ''
            this.model.submitDate = uni.$u.timeFormat(new Date().getTime(), 'yyyy-mm-dd hh:MM')
            this.model.companyName = ''
            this.model.happenTime = ''
            this.model.memberType = ''
            this.model.memberTypeName = ''
            this.model.memberNames = ''
            this.model.memberQwids = ''
            this.model.localtionId = ''
            this.model.localtionName = ''
            this.model.remark = ''
            this.model.outJiuyi = ''
            this.model.isYiwushi = ''
            this.model.isHurted = ''
            this.model.typeId = ''
            this.model.typeName = ''
            this.model.workRelated = ''
            this.model.eventInfo = ''
            this.model.multifileList = []
            this.model.fileList = []
            this.model.type = 0
         },
         toDesc() {
            uni.navigateTo({
               url: `/pages/details_she/details_she?id=${this.id}`
@@ -328,55 +385,23 @@
            this.show4 = false
         },
         // 删除图片
         deletePic(event) {
            this.model.multifileList.forEach((item, index) => {
               if (item.imgaddr === event.file.imgaddr) {
                  this.model.multifileList.splice(index, 1)
               }
            })
         deletePic(index) {
            this.model.multifileList.splice(index, 1)
         },
         // 新增图片
         async afterRead(event) {
            // event.file.forEach(async (item) => {
            //    const filePath = item.url
            //    uni.uploadFile({
            //       url: this.$baseUrl + '/web/public/upload',
            //       filePath,
            //       name: "file",
            //       formData: {
            //          folder: "WORKORDER_FILE_PATH"
            //       },
            //       success: (res) => {
            //          let obj = JSON.parse(res.data)
            //          if (obj.code === 200) {
            //             obj.data.fileurl = obj.data.imgaddr
            //             this.model.multifileList.push(obj.data)
            //          }
            //       }
            //    });
            // })
            uni.uploadFile({
               url: this.$baseUrl + '/web/public/upload',
               filePath: event.file.url,
               name: "file",
               formData: {
                  folder: "WORKORDER_FILE_PATH"
               },
               success: (res) => {
                  let obj = JSON.parse(res.data)
                  if (obj.code === 200) {
                     obj.data.fileurl = obj.data.imgaddr
                     this.model.multifileList.push(obj.data)
                  }
               }
            });
         async afterRead(arr) {
            this.model.multifileList = [...this.model.multifileList, ...arr]
         },
         // 提交
         submit() {
            var that = this
            that.$refs.uForm.validate().then(async () => {
               let res = await that.$u.api.workOrderCreate(that.model)
               let form = JSON.parse(JSON.stringify(that.model))
               form.submitDate = form.submitDate + ':00'
               form.happenTime = form.happenTime + ':00'
               let res = await that.$u.api.workOrderCreate(form)
               if (res.code === 200) {
                  that.next1()
                  that.id = res.data
                  this.stopScroll()
                  that.show4 = true