马宇豪
2023-07-13 01f3e49f3763a25ef67a4c3e5786491703a1aece
src/views/newSpecialWorkSystem/workTicket/zysq/components/plate.vue
@@ -132,10 +132,10 @@
          </el-col>
          <el-col :span="12">
            <el-form-item label="盲板位置示意图" prop="workDetail.bpLocationMapPath">
              <el-upload accept="image/*" :auto-upload="true" :on-exceed="showTip" :on-preview="handlePictureCardPreview" :limit='imgLimit' v-model:file-list="fileList" :http-request="upload" :action="uploadUrl" list-type="picture-card" :on-remove="handleRemove" :before-remove="beforeRemove" :before-upload="getUploadUrl">
              <el-upload accept="image/*" :auto-upload="true" :on-exceed="showTip" :on-preview="handlePictureCardPreview" :limit='imgLimit' v-model:file-list="fileList" :http-request="upload" :action="uploadUrl" list-type="picture-card" :before-remove="beforeRemove" :before-upload="getUploadUrl">
                <el-icon><Plus /></el-icon>
                <template #tip>
                  <div class="el-upload__tip">上传jpg/png图片尺寸小于5M,最多可上传3张</div>
                  <div class="el-upload__tip">上传jpg/png图片尺寸小于2M,最多可上传3张</div>
                </template>
              </el-upload>
            </el-form-item>
@@ -154,15 +154,19 @@
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
        <el-col :span="12" class="valueSelect">
          <el-form-item label="关联其他特殊作业" prop="involveOtherWork">
            <el-select v-model="form.involveOtherWork" multiple clearable>
              <el-option
                  v-for="item in otherWorkList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.label"
              />
<!--            <el-select v-model="form.involveOtherWork" multiple clearable>-->
<!--              <el-option-->
<!--                  v-for="item in otherWorkList"-->
<!--                  :key="item.value"-->
<!--                  :label="item.label"-->
<!--                  :value="item.label"-->
<!--              />-->
<!--            </el-select>-->
            <el-select v-model="form.involveOtherWork" multiple clearable :teleported="false" @click="openWorkSelect">
              <el-option v-for="item in otherWorks" :key="item.workApplyId" :label="item.workContent" :value="item.workApplyId">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
@@ -282,7 +286,7 @@
        <el-row style="display: flex;justify-content: center">
          <el-table :data="safetyMeasureBasicList" style="width: 90%" border>
            <el-table-column type="index" label="序号" width="100px" align="center"/>
            <el-table-column prop="measureContent" label="安全措施" align="center"/>
            <el-table-column prop="measureContent" label="安全措施"/>
          </el-table>
        </el-row>
        <el-row>
@@ -358,6 +362,7 @@
      <div class="applyBtn">
         <el-button type="primary" size="large" plain @click="submitForm(ruleFormRef)">提交申报</el-button>
      </div>
    <work-select ref="workSelectRef" @refreshWorks="getSelected()"></work-select>
   </div>
</template>
@@ -371,12 +376,12 @@
   import { ElMessage, ElMessageBox } from 'element-plus'
   import type { FormInstance, FormRules } from 'element-plus'
   import { workApplyApi } from '/@/api/specialWorkSystem/workApply';
  import workSelect from "/@/views/newSpecialWorkSystem/workTicket/zysq/components/workSelect.vue";
  import {UploadProps} from "element-plus/es";
  import axios from "axios";
   interface stateType {
      form: Object,
      workLevelList: Array<any>,
      otherWorkList: Array<any>,
      equipmentDialog: boolean,
    props:{},
    depProps:{},
@@ -392,8 +397,8 @@
  }
   export default defineComponent({
      name: 'fireForm',
      components: {},
      props:['departList','departList2','workerList','deviceList'],
      components: {workSelect},
      props:['departList','departList2','workerList','deviceList','otherWorks'],
      setup(props: any, context: any) {
         const userInfo = useUserInfo()
         const { userInfos } = storeToRefs(userInfo);
@@ -414,7 +419,7 @@
          workContent: '',
          workLocation: '',
          riskIdentification: '',
          involveOtherWork: '',
          involveOtherWork: [],
          safetyMeasureUids: [],
          approvalDepBasicList: [],
          acceptUid: null,
@@ -444,40 +449,6 @@
            value: 12
          }
        ],
            otherWorkList: [
               {
                  label: "动火作业",
                  value: 1
               },
               {
                  label: "受限空间作业",
                  value: 2
               },
               {
                  label: "吊装作业",
                  value: 3
               },
               {
                  label: "动土作业",
                  value: 4
               },
               {
                  label: "断路作业",
                  value: 5
               },
               {
                  label: "高处作业",
                  value: 6
               },
               {
                  label: "临时用电作业",
                  value: 7
               },
               {
                  label: "盲板抽堵作业",
                  value: 8
               }
            ],
        props:{
          expandTrigger: 'hover',
          label: 'depName',
@@ -527,11 +498,18 @@
        "workDetail.preparedByName": [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
        "workDetail.preparedTime": [{ required: true, message: '该内容不能为空', trigger: 'blur' }]
         });
      const workSelectRef = ref()
         // 页面载入时执行方法
         onMounted(() => {
      });
      const openWorkSelect = ()=>{
        workSelectRef.value.openDialog(state.form.involveOtherWork)
      }
      const getSelected = ()=>{
        state.form.involveOtherWork = workSelectRef.value.selected
      }
      const findParent = ()=>{
        state.form.seDepId = findNearestDepLevel2DepId(props.departList2,state.form.applyDepId)
@@ -587,9 +565,9 @@
                return
              }
            }
            if(Array.isArray(state.form.involveOtherWork)){
              state.form.involveOtherWork = state.form.involveOtherWork.join(',')
            }
            // if(Array.isArray(state.form.involveOtherWork)){
            //   state.form.involveOtherWork = state.form.involveOtherWork.join(',')
            // }
            state.form.workDetail.bpLocationMapPath = state.form.workDetail.bpLocationMapPath.join(',')
            const res = await workApplyApi().submitPlateApply(state.form)
            if (res.data.code === '200') {
@@ -606,7 +584,7 @@
                type: 'warning',
                message: res.data.msg
              });
              state.form.involveOtherWork = state.form.involveOtherWork.split(',')
              // state.form.involveOtherWork = state.form.involveOtherWork.split(',')
              state.form.workDetail.bpLocationMapPath = state.form.workDetail.bpLocationMapPath.split(',')
            }
          } else {
@@ -655,13 +633,13 @@
      };
      const getUploadUrl = async (rawFile: any) => {
        const fileSize = rawFile.size / 1024 / 1024 < 5 ? '1' : '0'
        if(fileSize === '0'){
        // const fileSize = rawFile.size / 1024 / 1024 < 5 ? '1' : '0'
        if(rawFile.size / 1024 / 1024 > 2){
          ElMessage({
            type: 'warning',
            message: '文件大小不能超过5M。'
            message: '文件大小不能超过2M。'
          });
          return false
          return Promise.reject(false)
        }else{
          const res = await workApplyApi().getUpload9Url(rawFile.name);
          state.form.workDetail.bpLocationMapPath.push(res.data.data.fileName)
@@ -686,29 +664,31 @@
      };
      const beforeRemove = (file: {}, fileList: []) => {
        const result = new Promise((resolve, reject) => {
          ElMessageBox.confirm('此操作将删除该图片, 是否继续?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          })
              .then(() => {
                // console.log(state.workDetail.bpLocationMapPath,'path')
                const list = JSON.parse(JSON.stringify(state.form.workDetail.bpLocationMapPath))
                fileList.map((item,index)=>{
                  if(item.uid === file.uid){
                    fileList.splice(index,1)
                    state.form.workDetail.bpLocationMapPath.splice(index,1)
                    // 请求删除接口
                    deletePic(false,list[index])
                  }
        if (file && file.status === "success") {
          const result = new Promise((resolve, reject) => {
            ElMessageBox.confirm('此操作将删除该图片, 是否继续?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            })
                .then(() => {
                  // console.log(state.workDetail.bpLocationMapPath,'path')
                  const list = JSON.parse(JSON.stringify(state.form.workDetail.bpLocationMapPath))
                  fileList.map((item, index) => {
                    if (item.uid === file.uid) {
                      fileList.splice(index, 1)
                      state.form.workDetail.bpLocationMapPath.splice(index, 1)
                      // 请求删除接口
                      deletePic(list[index])
                    }
                  })
                })
              })
              .catch(() => {
                reject(false);
              });
        });
        return result;
                .catch(() => {
                  reject(false);
                });
          });
          return result;
        }
      };
      // 删除图片接口
@@ -754,6 +734,9 @@
        showTip,
        handlePictureCardPreview,
        beforeRemove,
        openWorkSelect,
        getSelected,
        workSelectRef,
            Search,
            ruleFormRef,
            applyRules,
@@ -768,9 +751,11 @@
      width: 100%;
    height: 100vh;
      overflow: hidden;
      position: relative;
    overflow-y: scroll;
    padding: 0 0 120px;
    &::-webkit-scrollbar{
      width: 0;
      background-color: transparent;
    }
      .homeCard{
         width: 100%;
         padding: 20px;
@@ -780,10 +765,6 @@
         margin-bottom: 20px;
      }
      .applyBtn{
      position: fixed;
      left: 0;
      bottom: 0;
      z-index: 999;
         width: 100%;
         background: #fff;
         padding: 20px 0;
@@ -811,7 +792,11 @@
         width: 100% !important;
      }
   }
  .valueSelect{
    ::v-deep(.el-popper){
      display: none !important;
    }
  }
   .tab-i{
      margin-bottom: 15px;