index.vue 19.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
      <el-form-item label="项目编码" prop="fIntersectConstructionId">
        <el-input
          v-model="queryParams.fIntersectConstructionId"
          placeholder="请输入项目编码"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="意外事件标题" prop="fTitle">
        <el-input
          v-model="queryParams.fTitle"
          placeholder="请输入意外事件标题"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
22
      
23 24 25 26
      <el-form-item label="上报状态" prop="fUploadType">
        <el-select v-model="queryParams.fUploadType" placeholder="请选择上报状态" clearable size="small">
          <el-option label="未上报" value="0" />
          <el-option label="已上报" value="1" />
27 28 29
        </el-select>
      </el-form-item>

30 31 32 33 34 35 36 37 38 39 40 41 42 43
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
44
          v-if="user.roleId==5"
45 46 47 48 49 50 51 52 53 54
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
55
          v-if="user.roleId==5"
56 57 58 59 60 61 62 63 64 65
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
66
          v-if="user.roleId==5"
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
		     :loading="exportLoading"
          @click="handleExport"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="incList" @selection-change="handleSelectionChange">
耿迪迪's avatar
耿迪迪 committed
83 84 85
      <el-table-column label="项目编码" align="center" prop="projectCode" :show-overflow-tooltip="true"/>
      <el-table-column label="意外事件标题" align="center" prop="fTitle" :show-overflow-tooltip="true"/>
      <el-table-column label="意外事件描述" align="center" prop="fDescription" :show-overflow-tooltip="true"/>
86
      <el-table-column label="意外事件发生时间" align="center" prop="fOccurrenctTime" :show-overflow-tooltip="true"/>
耿迪迪's avatar
耿迪迪 committed
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
      <el-table-column label="附件" align="center" prop="fAttachment">
        <template slot-scope="scope">
          <span
            class="dbtn"
            @click="checkFile(scope.row.fAttachment)"
            v-if="scope.row.fAttachment != null && scope.row.fAttachment!=''"
          >
            <i class="el-icon el-icon-view"></i>查看/下载
          </span>
          <span v-else>-</span>
        </template>
      </el-table-column>
      <el-table-column label="备注" align="center" prop="fRemark" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <span v-if="scope.row.fRemark">
            {{ scope.row.fRemark }}
          </span>
          <span v-else>-</span>
        </template>
      </el-table-column>
107 108
      <el-table-column :label="uploadStateLabel" align="center" prop="uploadState" :formatter="uploadStateFormat" />
      <el-table-column :label="uploadTimeLabel" align="center" prop="uploadTime" :formatter="uploadTimeFormat" />
109 110
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
耿迪迪's avatar
耿迪迪 committed
111 112 113 114 115 116
          <el-button
            size="mini"
            type="text"
            icon="el-icon-document"
            @click="handleDetail(scope.row)"
          >详情</el-button>
117 118 119 120 121
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
122
            v-if="user.roleId==5&&scope.row.entUploadState==0"
123 124 125 126 127 128
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
129
            v-if="user.roleId==5&&scope.row.entUploadState==0"
130
          >删除</el-button>
耿迪迪's avatar
耿迪迪 committed
131 132 133 134
          <el-button
            size="mini"
            type="text"
            @click="handleReport(scope.row)"
135
            v-if="judgeUploadIsShow((scope.row))"
136
          >上报</el-button>
137 138 139 140 141 142 143 144 145 146 147 148 149
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改涉气第三方施工意外事件对话框 -->
耿迪迪's avatar
耿迪迪 committed
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body destroy-on-close :close-on-click-modal="false">
      <el-form ref="form" :model="form" :rules="rules" label-width="140px">
        <el-row class="el-row-table">
          <el-col :span="12">
            <el-form-item label="项目编码" prop="fIntersectConstructionId">
              <el-select
                v-model="form.fIntersectConstructionId"
                placeholder="请输入项目编码"
                style="width: 100%"
              >
                <el-option
                  v-for="item in projectInfo"
                  :key="'' + item.fConGasProInforId"
                  :label="item.fProjectCode"
                  :value="'' +item.fConGasProInforId"
                />
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="意外事件标题" prop="fTitle">
              <el-input v-model="form.fTitle" placeholder="请输入意外事件标题" />
            </el-form-item>
          </el-col>

          <el-col :span="24">
            <el-form-item label="意外事件描述" prop="fDescription">
              <el-input type="textarea" v-model="form.fDescription" placeholder="请输入意外事件描述" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="意外事件发生时间" prop="fOccurrenctTime">
              <el-date-picker
                style="width: 100%"
                v-model="form.fOccurrenctTime"
                type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="意外事件发生事件时间">
              </el-date-picker>
            </el-form-item>
          </el-col>

          <el-col :span="24">
            <el-form-item label="附件" prop="fAttachment">
              <FileUpload
                listType="picture"
                @resFun="getFileInfo"
                @remove="listRemove"
                :fileArr="fileList"
              />
              <el-input v-show="false" disabled v-model="form.fAttachment"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="24">
            <el-form-item label="备注" prop="fRemark">
              <el-input v-model="form.fRemark" placeholder="请输入备注" />
            </el-form-item>
          </el-col>

        </el-row>

214 215 216 217 218 219
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
耿迪迪's avatar
耿迪迪 committed
220 221 222

    <!-- 详情 -->
    <DetailInfo ref="detail"/>
223 224 225 226
  </div>
</template>

<script>
227
import { listInc, getInc, delInc, addInc, updateInc, exportInc, reportAccidentInfo,entReportConGasProInfo} from "@/api/thirdbuild/accident";
耿迪迪's avatar
耿迪迪 committed
228 229
import { conGasProInfoList } from "@/api/thirdbuild/project";
import FileUpload from '@/components/FileUpload';
230
import{getInfo} from "@/api/login"
耿迪迪's avatar
耿迪迪 committed
231
let uploadfile = require("@/assets/uploadfile.png");
232
import { enterpriseLists } from "@/api/regulation/info";
耿迪迪's avatar
耿迪迪 committed
233
import DetailInfo from "./components/DetailInfo";
234 235 236
export default {
  name: "Inc",
  components: {
耿迪迪's avatar
耿迪迪 committed
237 238
    FileUpload,
    DetailInfo
239 240 241
  },
  data() {
    return {
242
      user:{},
243 244
      uploadStateLabel:"",
      uploadTimeLabel:"",
245
      enterprises: [],
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 涉气第三方施工意外事件表格数据
      incList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        fIntersectConstructionId: null,
        fTitle: null,
        fDescription: null,
        fOccurrenctTime: null,
        fAttachment: null,
        fRemark: null,
276 277
        fUpdateTime: null,
        fUploadType:null,
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        fIntersectConstructionId: [
          { required: true, message: "项目编码不能为空", trigger: "blur" }
        ],
        fTitle: [
          { required: true, message: "意外事件标题不能为空", trigger: "blur" }
        ],
        fDescription: [
          { required: true, message: "意外事件描述", trigger: "blur" }
        ],
        fOccurrenctTime: [
          { required: true, message: "意外事件发生事件不能为空", trigger: "blur" }
        ],
        fAttachment: [
          { required: true, message: "附件不能为空", trigger: "blur" }
        ],
耿迪迪's avatar
耿迪迪 committed
298 299 300
      },
      projectInfo: [],
      fileList: []
301 302 303
    };
  },
  created() {
304 305
    this.getuserInfo(); 
    this.getEnterpriseLists();
306 307
  },
  methods: {
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328
    //所属单位
    getEnterpriseLists(){
      const param = {}; 
        enterpriseLists(param).then(response => { 
          if (response.rows.length>1){ 
            this.enterprises = response.rows;
            this.enterpriseName = response.rows[0].enterpriseName; 
        }else { 
          this.enterprises = response.rows;
          this.enterpriseName = response.rows[0].enterpriseName; 
        }
      }); 
    },
    getuserInfo(){
      getInfo().then(response => {
        this.user = response.user.roles[0]
        this.getList();
        this.getProjectInfo();
      });
    },
    
329
    //上报状态动态展示
330 331 332 333
    uploadStateFormat(row, column) { 
      //角色 1 超级管理员  5 企业
      let roleId = this.user.roleId;
      if (roleId == 5) {
334
        this.uploadStateLabel = "上报状态"
335
        if (row.entUploadState == '0') {
336
          return "未上报"
337
        } else{
338
          return "已上报"
339 340
        } 
      } else { 
341
        this.uploadStateLabel = "上报省厅状态"
342
        if (row.govUploadState == '0') {
343
          return "未上报"
344
        } else{
345
          return "已上报"
346 347 348
        } 
      } 
    },
349
    //上报时间动态展示
350 351 352 353
    uploadTimeFormat(row, column) {
      //角色 1 超级管理员  5 企业
      let roleId = this.user.roleId;
      if (roleId == 5) {
354
        this.uploadTimeLabel = "上报时间"
355 356
        return row.entUploadTime;
      } else {
357
        this.uploadTimeLabel = "上报省厅时间"
358 359 360 361
        return row.govUploadTime;
      }

    },
362 363 364
    /** 查询涉气第三方施工意外事件列表 */
    getList() {
      this.loading = true;
365 366 367
      // 企业查自己的数据
      if (this.user.roleId == 5) {
        this.queryParams.fCompanyInfoId = this.$store.state.user.enterpriseId 
368
        this.queryParams.entUploadState = this.queryParams.fUploadType;
369
      }
370 371 372 373
      // 政府如果按照状态查的话,是查的 govUploadState
      if (this.user.roleId == 3) {
        this.queryParams.govUploadState = this.queryParams.fUploadType;
      } 
374 375 376 377 378 379
      listInc(this.queryParams).then(response => {
        this.incList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
380
    
381
    //判断 上报是否需要显示,上报分为企业上报 和 政府端上报
382 383 384 385 386
    judgeUploadIsShow(row) { 

      //角色 1 超级管理员  5 企业
      let roleId = this.user.roleId;

387
      // 企业端 上报状态 0-未上报,1-已上报
388 389
      let entUploadState = row.entUploadState;

390
      // 政府端 上报状态 0-未上报,1-已上报
391 392
      let govUploadState = row.govUploadState;

393
      // 如果政府端都已经上报,那就不能显示了。
394 395 396 397
      if(govUploadState === '1') {
        return false;
      }

398
      // 如果企业端上报了,则企业端就不能显示了,政府端和 超级管理员能显示
399 400 401 402 403 404 405 406 407 408 409 410
      if(entUploadState === '1' && govUploadState === '0') {
        if (roleId === 5) {
          return false;
        } else {
          return true;
        }
      }

      // 别的情况,都显示
      return true;

    },
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        fConGasProIncId: null,
        fIntersectConstructionId: null,
        fTitle: null,
        fDescription: null,
        fOccurrenctTime: null,
        fAttachment: null,
        fRemark: null,
        fUpdateTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.fConGasProIncId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加涉气第三方施工意外事件";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const fConGasProIncId = row.fConGasProIncId || this.ids
      getInc(fConGasProIncId).then(response => {
        this.form = response.data;
458 459 460 461
        if (this.form.fAttachment) {

          this.fileList = [{name: '附件', url: uploadfile}];
        } 
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476
        this.open = true;
        this.title = "修改涉气第三方施工意外事件";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.fConGasProIncId != null) {
            updateInc(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
477
            this.form.fCompanyInfoId=this.enterprises[0].enterpriseId;
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509
            addInc(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const fConGasProIncIds = row.fConGasProIncId || this.ids;
      this.$confirm('是否确认删除涉气第三方施工意外事件编号为"' + fConGasProIncIds + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delInc(fConGasProIncIds);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有涉气第三方施工意外事件数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          this.exportLoading = true;
510 511 512 513 514 515 516 517 518 519
          
          // 企业查自己的数据
          if (this.user.roleId == 5) {
            this.queryParams.fCompanyInfoId = this.$store.state.user.enterpriseId 
            this.queryParams.entUploadState = this.queryParams.fUploadType;
          }
          // 政府如果按照状态查的话,是查的 govUploadState
          if (this.user.roleId == 3) {
            this.queryParams.govUploadState = this.queryParams.fUploadType;
          } 
520 521 522 523 524
          return exportInc(queryParams);
        }).then(response => {
          this.download(response.msg);
          this.exportLoading = false;
        }).catch(() => {});
耿迪迪's avatar
耿迪迪 committed
525 526 527
    },
    //获取第三方施工项目信息
    getProjectInfo(){
528 529 530 531 532 533
      // 企业查自己的数据
      let conGasProInfoQueryParams = {};
      if (this.user.roleId == 5) {
        conGasProInfoQueryParams.fCompanyInfoId= this.$store.state.user.enterpriseId 
      } 
      conGasProInfoList(conGasProInfoQueryParams).then(res =>{
耿迪迪's avatar
耿迪迪 committed
534 535 536 537 538
        if(res.code == 200 && res.data){
          this.projectInfo = res.data;
        }
      })
    },
539
    //上报
540
    getFileInfo(res){  
耿迪迪's avatar
耿迪迪 committed
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557
      this.form.fAttachment = res.url;
      this.fileList.push({
        name: res.fileName,
        url: uploadfile,
      });
    },
    listRemove(e) {
      this.form.fAttachment = "";
      this.fileList = [];
    },
    checkFile(url) {
      window.open(url,'_blank');
    },
    //详情
    handleDetail(row){
      this.$refs.detail.getDetailInfo(row.fConGasProIncId);
    },
558
    /** 上报按钮操作 */
559 560
    handleReport(row) { 

561
      // 如果是 超级管理员 或这企业,并且 企业端上报状态为0
562
      if ((this.user.roleId == 5 || this.user.roleId == 1) && row.entUploadState == '0') {
563
        this.$confirm('是否确认上报项目编号为"' + row.projectCode + '"的数据项?', "警告", {
564 565 566 567 568 569 570
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return entReportConGasProInfo({fConGasProIncId : row.fConGasProIncId});
        }).then(() => {
          this.getList();
571
        this.msgSuccess("上报成功");
572
        }).catch(() => {});
573 574
      } 
      
575
      // 如果是 超级管理员 或这政府,并且 政府端上报状态为0
576
      if ((this.user.roleId == 3 || this.user.roleId == 1) && row.govUploadState == '0') {
577
        this.$confirm('是否确认上报项目编号为"' + row.projectCode + '"的数据项?', "警告", {
耿迪迪's avatar
耿迪迪 committed
578 579 580 581 582 583 584
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return reportAccidentInfo({fConGasProIncId : row.fConGasProIncId});
        }).then(() => {
          this.getList();
585
        this.msgSuccess("上报成功");
586 587
        }).catch(() => {});
      }
耿迪迪's avatar
耿迪迪 committed
588
    },
589 590 591
  }
};
</script>
耿迪迪's avatar
耿迪迪 committed
592 593 594 595 596 597 598 599 600 601 602 603 604
<style scoped lang="scss">
  .dbtn {
    display: inline-block;
    line-height: normal;
    padding-left: 2px;
    padding-right: 2px;
    cursor: pointer;
    border-radius: 3px;
    border-style: solid;
    border-width: 0;
    color: rgb(48, 180, 107);
  }
</style>