index.vue 10.9 KB
Newer Older
耿迪迪's avatar
耿迪迪 committed
1 2 3
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
zhangjianqian's avatar
zhangjianqian committed
4 5 6 7 8 9 10 11 12 13 14 15 16
      <el-form-item label="所属部门" prop="deptId">
        <treeselect v-model="queryParams.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />
        <!--<el-select v-model="queryParams.deptId" filterable placeholder="请选择部门" >-->
          <!--<el-option-->
            <!--v-for="item in deptList"-->
            <!--:key="item.deptId"-->
            <!--:label="item.deptName"-->
            <!--:value="item.deptId"-->
          <!--&gt;-->
          <!--</el-option>-->
        <!--</el-select>-->
      </el-form-item>
      <el-form-item label="风险点" prop="riskPoint">
耿迪迪's avatar
耿迪迪 committed
17
        <el-input
zhangjianqian's avatar
zhangjianqian committed
18 19
          v-model="queryParams.riskPoint"
          placeholder="请输入风险点"
耿迪迪's avatar
耿迪迪 committed
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </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"
          v-hasPermi="['system:library:add']"
        >新增</el-button>
      </el-col>
zhangjianqian's avatar
zhangjianqian committed
42

耿迪迪's avatar
耿迪迪 committed
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
		  :loading="exportLoading"
          @click="handleExport"
          v-hasPermi="['system:library:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="libraryList" @selection-change="handleSelectionChange">
      <!--<el-table-column type="selection" width="55" align="center" />-->
zhangjianqian's avatar
zhangjianqian committed
59 60 61 62 63 64 65
      <!--<el-table-column label="风险点" align="center" prop="libraryId" />-->
      <el-table-column label="所属部门" align="center" prop="deptName" />
      <el-table-column label="风险点" align="center" prop="riskPoint" />
      <el-table-column label="隐患名称" align="center" prop="inspectTerm" />
      <el-table-column label="检查依据" align="center" prop="inspectBasis" />
      <!--<el-table-column label="排查库标题" align="center" prop="libraryName" />-->
      <el-table-column label="内容以及标准" align="center" prop="libraryContent" />
耿迪迪's avatar
耿迪迪 committed
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:library:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:library:remove']"
          >删除</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="800px" append-to-body>
zhangjianqian's avatar
zhangjianqian committed
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-form-item label="所属部门" prop="deptId">
          <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />
          <!--<el-select v-model="form.deptId" filterable placeholder="请选择部门" >-->
            <!--<el-option-->
              <!--v-for="item in deptList"-->
              <!--:key="item.deptId"-->
              <!--:label="item.deptName"-->
              <!--:value="item.deptId"-->
            <!--&gt;-->
            <!--</el-option>-->
          <!--</el-select>-->
        </el-form-item>
        <!--<el-form-item label="所属部门" prop="deptId">-->
          <!--<el-input v-model="form.deptId" placeholder="请输入部门" />-->
        <!--</el-form-item>-->
        <el-form-item label="风险点" prop="riskPoint">
          <el-input v-model="form.riskPoint" placeholder="请输入风险点" />
        </el-form-item>
        <el-form-item label="隐患名称" prop="inspectTerm">
          <el-input v-model="form.inspectTerm" placeholder="请输入隐患名称" />
耿迪迪's avatar
耿迪迪 committed
117
        </el-form-item>
zhangjianqian's avatar
zhangjianqian committed
118 119 120 121 122 123 124 125
        <el-form-item label="检查依据" prop="inspectBasis">
          <el-input type="textarea" v-model="form.inspectBasis" placeholder="请输入检查依据" />
        </el-form-item>
        <!--<el-form-item label="排查库标题" prop="libraryName">-->
          <!--<el-input v-model="form.libraryName" placeholder="请输入排查库标题" />-->
        <!--</el-form-item>-->
        <el-form-item label="内容以及标准" prop="libraryContent">
          <el-input type="textarea"  v-model="form.libraryContent" :min-height="192"/>
耿迪迪's avatar
耿迪迪 committed
126 127 128 129 130 131 132 133 134 135 136 137 138
        </el-form-item>
      </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>
  </div>
</template>

<script>
import { listLibrary, getLibrary, delLibrary, addLibrary, updateLibrary, exportLibrary } from "@/api/system/library";
import Editor from '@/components/Editor';
zhangjianqian's avatar
zhangjianqian committed
139 140 141
import { treeselect } from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
耿迪迪's avatar
耿迪迪 committed
142 143 144
export default {
  name: "Library",
  components: {
zhangjianqian's avatar
zhangjianqian committed
145
    Editor,Treeselect
耿迪迪's avatar
耿迪迪 committed
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 隐患排查库表格数据
      libraryList: [],
zhangjianqian's avatar
zhangjianqian committed
165
      deptList:[],
耿迪迪's avatar
耿迪迪 committed
166 167 168 169
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
zhangjianqian's avatar
zhangjianqian committed
170 171
      // 部门树选项
      deptOptions: undefined,
耿迪迪's avatar
耿迪迪 committed
172 173 174 175
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
zhangjianqian's avatar
zhangjianqian committed
176 177
        deptId: null,
        riskPoint: null,
耿迪迪's avatar
耿迪迪 committed
178 179 180 181 182
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
zhangjianqian's avatar
zhangjianqian committed
183 184 185 186 187
        deptId: [
          { required: true, message: "部门不能为空", trigger: "change" }
        ],
        riskPoint: [
          { required: true, message: "风险点不能为空", trigger: "change" }
耿迪迪's avatar
耿迪迪 committed
188
        ],
zhangjianqian's avatar
zhangjianqian committed
189 190 191
        inspectTerm: [
          { required: true, message: "隐患名称不能为空", trigger: "change" }
        ],
192 193 194
       // inspectBasis: [
         // { required: true, message: "检查依据不能为空", trigger: "change" }
       // ],
zhangjianqian's avatar
zhangjianqian committed
195 196 197
          // libraryContent: [
          //   { required: true, message: "内容/标准不能为空", trigger: "change" }
          // ],
耿迪迪's avatar
耿迪迪 committed
198 199 200 201 202
      }
    };
  },
  created() {
    this.getList();
zhangjianqian's avatar
zhangjianqian committed
203
    this.getTreeselect();
耿迪迪's avatar
耿迪迪 committed
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
  },
  methods: {
    /** 查询隐患排查库列表 */
    getList() {
      this.loading = true;
      listLibrary(this.queryParams).then(response => {
        this.libraryList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        libraryId: null,
zhangjianqian's avatar
zhangjianqian committed
224 225 226 227
        deptId: null,
        riskPoint: null,
        inspectTerm: null,
        inspectBasis: null,
耿迪迪's avatar
耿迪迪 committed
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 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298
        libraryName: null,
        libraryContent: 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.libraryId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加隐患排查库";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const libraryId = row.libraryId || this.ids
      getLibrary(libraryId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改隐患排查库";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.libraryId != null) {
            updateLibrary(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addLibrary(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const libraryIds = row.libraryId || this.ids;
      this.$confirm('是否确认删除隐患排查库编号为"' + libraryIds + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delLibrary(libraryIds);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(() => {});
    },
zhangjianqian's avatar
zhangjianqian committed
299 300 301 302 303 304 305 306 307 308 309 310
    /** 查询部门列表 */
    // getDeptList() {
    //   listDept().then(response => {
    //     this.deptList = response.data;
    // });
    // },
    /** 查询部门下拉树结构 */
    getTreeselect() {
      treeselect().then(response => {
        this.deptOptions = response.data;
    });
    },
耿迪迪's avatar
耿迪迪 committed
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有隐患排查库数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          this.exportLoading = true;
          return exportLibrary(queryParams);
        }).then(response => {
          this.download(response.msg);
          this.exportLoading = false;
        }).catch(() => {});
    }
  }
};
</script>
<style lang="scss" scoped>
zhangjianqian's avatar
zhangjianqian committed
330 331
  ::v-deep .vue-treeselect{
    width: 200px;
耿迪迪's avatar
耿迪迪 committed
332
  }
zhangjianqian's avatar
zhangjianqian committed
333 334
  ::v-deep .el-form-item--medium .el-form-item__content{
    line-height: 34px;
耿迪迪's avatar
耿迪迪 committed
335 336
  }
</style>