ll
liukangdong
2024-10-31 a030368330d5a6bf1d0ed42b6121b53d13b587d0
admin/src/components/operation/HiddenDangerParam.vue
@@ -22,6 +22,11 @@
          default-time="08:00:00"
        />
      </el-form-item>
      <el-form-item label="责任部门" prop="companyId">
        <el-select @change="getAddrList" v-model="param.companyId">
          <el-option v-for="op in department" :key="op.id" :label="op.name" :value="op.id"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="隐患区域" prop="areaId">
        <el-select v-model="param.areaId" @change="changeArea" placeholder="请选择">
          <el-option
@@ -61,6 +66,7 @@
            :action="uploadImgUrl"
            :show-file-list="false"
            :on-success="uploadAvatarSuccess"
            :on-error="uploadError"
            :before-upload="beforeUpload"
          >
            <div class="upload_wrap">
@@ -104,8 +110,9 @@
import dayjs from 'dayjs'
import { allList, memberList } from '@/api/business/hiddenDangerParam'
import { create } from '@/api/business/hiddenDanger'
import { Loading } from 'element-ui'
import { companyGetListPost } from '@/api/business/company'
export default {
  name: 'OperaVisitsHkWindow',
  extends: BaseOpera,
  components: {
    GlobalWindow
@@ -113,6 +120,7 @@
  data () {
    return {
      isShowModal: false,
      loadingInstance: false,
      param: {},
      userInfo: this.$store.state.userInfo,
      uploadImgUrl: process.env.VUE_APP_API_PREFIX + '/visitsAdmin/cloudService/public/uploadBatch',
@@ -124,11 +132,13 @@
      uploadData: {
        folder: 'HIDDEN_DANGER_FILE'
      },
      department: [],
      rules: {
        // starttime: [{ required: true, message: '请选择日期', trigger: 'change' }],
        areaId: [{ required: true, message: '请选择', trigger: 'change' }],
        cateId: [{ required: true, message: '请选择', trigger: 'change' }],
        checkUserId: [{ required: true, message: '请选择', trigger: 'change' }],
        companyId: [{ required: true, message: '请选择', trigger: 'change' }],
        faceImgUrl: [{ required: true, message: '请上传', trigger: 'change' }],
        content: [{ required: true, message: '请输入', trigger: 'blur' }]
@@ -140,15 +150,28 @@
    this.initData()
  },
  methods: {
    initData () {
      allList({ type: 1 }).then(res => { // 类型
        this.typeList = res || []
      })
      allList({ type: 0 }).then(res => { // 位置
        this.addrList = res || []
      })
      memberList({}).then(res => {
        this.memberList = res || []
      })
      this.getfindCompanyTreePage()
    },
    getfindCompanyTreePage() {
      companyGetListPost({})
        .then(res => {
          if (res && res.length > 0) {
            this.department = res
          }
        })
    },
    getAddrList() {
      const { companyId } = this.param
      allList({ type: 0,companyId }).then(res => { // 位置
        this.addrList = res || []
      })
    },
    changeArea (e) {
@@ -158,6 +181,8 @@
      const memberNames = item.memberNames.split(',')
      if (memberIds && memberIds.length === 1) {
        this.$set(this.param, 'checkUserId', memberIds[0])
      } else {
        this.$set(this.param, 'checkUserId', '')
      }
      memberIds.forEach((mem, i) => {
        arr.push({
@@ -168,12 +193,30 @@
      this.memberList = arr
    },
    beforeUpload (file) {
      if (['video/mp4', 'video/ogg', 'video/flv', 'video/avi', 'video/wmv', 'video/rmvb', 'image/jpeg', 'image/png', 'image/gif'].indexOf(file.type) == -1) {
      if (['video/mp4', 'video/ogg', 'video/flv', 'video/avi', 'video/wmv', 'video/rmvb', 'image/jpeg','image/jpg', 'image/png', 'image/gif'].indexOf(file.type) == -1) {
        this.$message.error('请上传正确的视频/图片格式')
        return false
      }
      this.loadingInstance = Loading.service({
        lock: true,
        text: 'Loading',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      })
    },
    uploadError() {
      this.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭
        if(this.loadingInstance){
          this.loadingInstance.close()
        }
      })
    },
    uploadAvatarSuccess (file) {
      this.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭
        if(this.loadingInstance){
          this.loadingInstance.close()
        }
      })
      console.log('file', file)
      const item = file.data[0]
      if (['.mp4', '.avi', '.flv', '.wmv'].some(char => item.imgaddr.includes(char))) {
@@ -255,10 +298,15 @@
  display: flex;
  flex-wrap: wrap;
  .item {
    width: 140px;
    max-height: 140px;
    width: 92px;
    max-height: 92px;
    margin-left: 10px;
    position: relative;
    border: 1px dashed #d9d9d9;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    .close{
      font-size: 20px;
      position: absolute;
@@ -269,8 +317,8 @@
      cursor: pointer;
    }
    .img {
      width: 140px;
      max-height: 90px;
      width: 92px;
      max-height: 92px;
    }
  }
}