index.vue 17.9 KB
Newer Older
耿迪迪's avatar
耿迪迪 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
      <el-form-item label="法律法规标题" prop="systemTitle">
        <el-input
          v-model="queryParams.systemTitle"
          placeholder="请输入法律法规标题"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small">
          <el-option
            v-for = "dict in statusOptions"
            :key = "dict.dictValue"
            :label = "dict.dictLabel"
            :value = "dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="创建时间">
        <el-date-picker
          v-model="dateRange"
          size="small"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始时间"
          end-placeholder="结束时间"
        ></el-date-picker>
      </el-form-item>
      <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"
49
          v-hasPermi="['safetyManagement:enterpriseSystem:add']"
耿迪迪's avatar
耿迪迪 committed
50 51 52 53 54 55
        >新增</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="enterpriseSystemList" >
lizhichao's avatar
lizhichao committed
56
      <el-table-column label="法律法规标题" align="center" prop="systemTitle" width="260px"/>
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
      <el-table-column label="颁布部门" align="center" prop="issueDept" >
        <template slot-scope="scope">
          <span v-if="scope.row.issueDept != null && scope.row.issueDept!=''">
            {{scope.row.issueDept}}
          </span>
          <span v-else>-</span>
        </template>
      </el-table-column>
      <el-table-column label="文号" align="center" prop="referenceNum" >
        <template slot-scope="scope">
          <span v-if="scope.row.referenceNum != null && scope.row.referenceNum!=''">
            {{scope.row.referenceNum}}
          </span>
          <span v-else>-</span>
        </template>
      </el-table-column>
73 74
      <el-table-column label="层级" align="center" prop="hierarchy" :formatter="hierarchyFormat"/>
      <el-table-column label="有效性" align="center" prop="availability" :formatter="availabilityFormat"/>
耿迪迪's avatar
耿迪迪 committed
75 76 77 78 79 80 81 82 83 84 85 86
      <el-table-column label="附件" align="center" prop="fileUrl" width="260px">
        <template slot-scope="scope">
          <span
            class="dbtn"
            @click="checkFile(scope.row.fileUrl)"
            v-if="scope.row.fileUrl != null && scope.row.fileUrl!=''"
          >
            <i class="el-icon el-icon-view"></i>{{scope.row.fileName}}
          </span>
          <span v-else>-</span>
        </template>
      </el-table-column>
lizhichao's avatar
lizhichao committed
87 88 89
      <el-table-column label="状态" align="center" prop="status" :formatter="statusFormat" width="120px" />
      <el-table-column label="创建时间" align="center" prop="createTime" width="150px" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="210px" >
耿迪迪's avatar
耿迪迪 committed
90 91 92 93 94 95
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
96
            v-hasPermi="['safetyManagement:enterpriseSystem:edit']"
耿迪迪's avatar
耿迪迪 committed
97
          >修改</el-button>
98 99 100 101 102 103
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleDetail(scope.row)"
          >详情</el-button>
lizhichao's avatar
lizhichao committed
104
          <el-button
耿迪迪's avatar
耿迪迪 committed
105 106 107 108 109
            v-if="scope.row.status == '0'"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handlePublish(scope.row)"
lizhichao's avatar
lizhichao committed
110
            v-hasPermi="['safetyManagement:enterpriseSystem:edit']"
耿迪迪's avatar
耿迪迪 committed
111 112 113 114 115 116 117
          >发布</el-button>
          <el-button
            v-if="scope.row.status == '1'"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleApproval(scope.row)"
lizhichao's avatar
lizhichao committed
118
            v-hasPermi="['safetyManagement:enterpriseSystem:edit']"
耿迪迪's avatar
耿迪迪 committed
119 120 121 122 123 124 125
          >审批</el-button>
          <el-button
            v-if="scope.row.status == '2'"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleInvalid(scope.row)"
lizhichao's avatar
lizhichao committed
126 127
            v-hasPermi="['safetyManagement:enterpriseSystem:edit']"
          >作废</el-button>
耿迪迪's avatar
耿迪迪 committed
128 129 130 131 132
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
133
            v-hasPermi="['safetyManagement:enterpriseSystem:remove']"
耿迪迪's avatar
耿迪迪 committed
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

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

    <!-- 添加或修改法律法规管理对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1200px" @closed="dialogClose" @open="dialogOpen" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <div class="division">
          <div style="width: 45%;">
            <div class="dialogTitle">法律法规基本信息</div>
            <el-form-item label="法律法规标题" prop="systemTitle">
              <el-input v-model="form.systemTitle" placeholder="请输入法律法规标题" :disabled="readOnly"/>
            </el-form-item>
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
            <el-form-item label="层级" prop="hierarchy">
              <el-select v-model="form.hierarchy" placeholder="请选择层级" clearable size="small" :disabled="readOnly" style="width: 100%">
                <el-option
                  v-for = "dict in hierarchys"
                  :key = "dict.dictValue"
                  :label = "dict.dictLabel"
                  :value = "dict.dictValue"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="文号" prop="referenceNum">
              <el-input v-model="form.referenceNum" placeholder="请输入文号" :disabled="readOnly"/>
            </el-form-item>
            <el-form-item label="颁布部门" prop="issueDept">
              <el-input v-model="form.issueDept" placeholder="请输入颁布部门" :disabled="readOnly"/>
            </el-form-item>
            <el-form-item label="有效性" prop="availability">
              <el-select v-model="form.availability" placeholder="请选择有效性" clearable size="small" :disabled="readOnly" style="width: 100%">
                <el-option
                  v-for = "dict in availabilitys"
                  :key = "dict.dictValue"
                  :label = "dict.dictLabel"
                  :value = "dict.dictValue"
                />
              </el-select>
            </el-form-item>
耿迪迪's avatar
耿迪迪 committed
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" placeholder="请输入备注" :disabled="readOnly" />
            </el-form-item>
            <el-form-item label="附件" v-if="!readOnly" prop="fileUrl">
              <FileUpload
                listType="picture"
                @resFun="getFileInfo"
                @remove="listRemove"
                :fileArr="fileList"
              />
              <el-input v-show="false" disabled v-model="form.fileUrl"></el-input>
            </el-form-item>
            <el-form-item label="附件" v-if="readOnly" prop="fileUrl" >
              <span
                class="dbtn"
                @click="checkFile(form.fileUrl)"
                v-if="form.fileUrl!=null && form.fileUrl != ''"
              >
                <i class="el-icon el-icon-view"></i>{{form.fileName}}
              </span>
              <span v-else>-</span>
            </el-form-item>
lizhichao's avatar
lizhichao committed
204
            <el-form-item v-show="operate" label="审批" prop="status">
耿迪迪's avatar
耿迪迪 committed
205 206
              <el-radio v-model="form.status" label="2">通过</el-radio>
              <el-radio v-model="form.status" label="0">驳回</el-radio>
lizhichao's avatar
lizhichao committed
207
            </el-form-item>
耿迪迪's avatar
耿迪迪 committed
208 209 210 211 212 213 214
          </div>
          <div style="width: 58%;margin-left: 2%">
            <div class="dialogTitle">法律法规内容</div>
            <editor id="editor" v-if="isOpen" :readOnly="readOnly" v-model="form.content" :min-height="300"/>
          </div>
        </div>
      </el-form>
215
      <div slot="footer" class="dialog-footer" v-show="!readOnly">
耿迪迪's avatar
耿迪迪 committed
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 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
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listEnterpriseSystem, getEnterpriseSystem, delEnterpriseSystem, addEnterpriseSystem, updateEnterpriseSystem, exportEnterpriseSystem } from "@/api/safetyManagement/enterpriseSystem";
import Editor from '@/components/Editor';
let uploadfile = require("@/assets/uploadfile.png");
import FileUpload from '@/components/FileUpload';

export default {
  name: "EnterpriseSystem",
  components: {
    Editor,
    FileUpload
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 日期范围
      dateRange: [],
      // 法律法规管理表格数据
      enterpriseSystemList: [],
      statusOptions: [],
      fileList:[],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      isOpen:false,
      operate: false,
      readOnly: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        systemType: '2',
        systemTitle: null,
        content: null,
271
        isDel: '0',
耿迪迪's avatar
耿迪迪 committed
272 273 274 275 276 277 278 279
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        systemTitle: [
          { required: true, message: "标题不能为空", trigger: "blur" }
        ],
280 281 282 283 284 285
        hierarchy: [
          { required: true, message: "请选择层级", trigger: "change" }
        ],
      },
      hierarchys:[],
      availabilitys:[]
耿迪迪's avatar
耿迪迪 committed
286 287 288 289 290 291 292
    };
  },
  created() {
    this.getList();
    this.getDicts("t_enterprise_system_status").then(response =>{
      this.statusOptions = response.data;
    })
293 294 295 296 297 298 299
    this.getDicts("t_hierarchy").then(response =>{
        this.hierarchys = response.data;
    })
    this.getDicts("t_availability").then(response =>{
        this.availabilitys = response.data;
    })

耿迪迪's avatar
耿迪迪 committed
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338
  },
  methods: {
    // 状态
    statusFormat(row, column) {
      return this.selectDictLabel(this.statusOptions, row.status);
    },
    /** 查询法律法规管理列表 */
    getList() {
      this.loading = true;
      listEnterpriseSystem(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
        this.enterpriseSystemList = response.rows;
        console.log("enterpriseSystemList", this.enterpriseSystemList)
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
      this.fileList = [];
    },
    // 表单重置
    reset() {
      this.form = {
        systemId: null,
        systemTitle: null,
        systemType: '2',
        content: null,
        fileUrl: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        isDel: null,
        remark: null
      };
      this.resetForm("form");
      this.fileList = [];
lizhichao's avatar
lizhichao committed
339
      this.operate=false;
耿迪迪's avatar
耿迪迪 committed
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.readOnly=false;
      this.reset();
      this.open = true;
      this.title = "添加法律法规信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.readOnly=false;
      this.reset();
      const systemId = row.systemId || this.ids
      getEnterpriseSystem(systemId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改法律法规信息";
        if(this.form.fileUrl!=null||this.form.fileUrl==""){
          this.fileList = [{name: this.form.fileName, url: uploadfile}];
        }
      });
    },
373 374 375 376 377 378 379 380 381 382 383 384 385 386
    /** 详情按钮操作*/
    handleDetail(row) {
      this.readOnly=true;
      this.reset();
      const systemId = row.systemId || this.ids
      getEnterpriseSystem(systemId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "法律法规信息详情";
        if(this.form.fileUrl!=null||this.form.fileUrl==""){
          this.fileList = [{name: this.form.fileName, url: uploadfile}];
        }
      });
    },
耿迪迪's avatar
耿迪迪 committed
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 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 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 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 510 511 512
    /** 审批按钮操作 */
    handleApproval(row) {
      this.readOnly = true;
      this.reset();
      const systemId = row.systemId || this.ids
      getEnterpriseSystem(systemId).then(response => {
        this.form = response.data;
        this.form.status = '2';
        this.operate = true;
        this.open = true;
        this.title = "审批法律法规信息";
        if(this.form.fileUrl!=null||this.form.fileUrl==""){
          this.fileList = [{name: this.form.fileName, url: uploadfile}];
        }
      });
    },
    dialogClose(){
      this.isOpen=false;
    },
    dialogOpen(){
      this.isOpen=true;
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.systemId != null) {
            if(this.operate){
              updateEnterpriseSystem(this.form).then(response => {
                this.msgSuccess("审批成功");
                this.open = false;
                this.operate = false;
                this.readOnly = false;
                this.getList();
              });
            } else {
              updateEnterpriseSystem(this.form).then(response => {
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              });
            }
          } else {
            addEnterpriseSystem(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 发布按钮操作 */
    handlePublish(row) {
      this.$confirm('确认要发布 "' + row.systemTitle + '" 的法律法规信息?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function() {
        row.status = '1';
        return updateEnterpriseSystem(row);
      }).then(() => {
        this.getList();
        this.msgSuccess("发布成功");
      }).catch(() => {});
    },
    /** 作废按钮操作 */
    handleInvalid(row) {
      this.$confirm('确认要作废 "' + row.systemTitle + '" 的法律法规信息?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function() {
        row.status = '3';
        return updateEnterpriseSystem(row);
      }).then(() => {
        this.getList();
        this.msgSuccess("作废成功");
      }).catch(() => {});
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      this.$confirm('是否确认删除 "' + row.systemTitle + '" 的法律法规信息?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          row.isDel = '1';
          return updateEnterpriseSystem(row);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有法律法规管理数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          this.exportLoading = true;
          return exportEnterpriseSystem(queryParams);
        }).then(response => {
          this.download(response.msg);
          this.exportLoading = false;
        }).catch(() => {});
    },
    //上传
    getFileInfo(res){
      this.form.fileUrl = res.url;
      this.form.fileName = res.fileName;
      this.fileList.push({
        name: res.fileName,
        url: uploadfile,
      });
    },
    listRemove(e) {
      this.fileList = [];
      this.form.fileUrl = null;
      this.form.fileName = null;
    },
    checkFile(url) {
      window.open(url,'_blank');
    },
513 514 515 516 517 518
    hierarchyFormat(row,colum){
      return this.selectDictLabel(this.hierarchys, row.hierarchy);
    },
    availabilityFormat(row,colum){
      return this.selectDictLabel(this.availabilitys, row.availability);
    }
耿迪迪's avatar
耿迪迪 committed
519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549
  }
};
</script>
<style>
  .division{
    display:flex;
    flex-direction:row;
    justify-content:flex-start;
  }

  .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);
  }

  .dialogTitle {
    background: #1c84c6;
    color: white;
    height: 20px;
    line-height: 20px;
    text-align: center;
    margin-bottom: 10px;
  }
</style>