Blame view

src/views/workflow/components/clxx/clxx.vue 16.1 KB
1
<!--
xiaomiao committed
2
 * @Description:
3
 * @Autor: renchao
4
 * @LastEditTime: 2023-07-04 16:05:44
5
-->
任超 committed
6
<template>
吴蕾 committed
7
  <div class="clxx">
吴蕾 committed
8
    <div class="left">
任超 committed
9
      <div v-for="item in menuList" :key="item.id" :class="['item', checkedId == item.id ? 'active' : '']"
任超 committed
10
        @click="menuClick(item)">
吴蕾 committed
11
        {{ item.label }}
吴蕾 committed
12
      </div>
吴蕾 committed
13 14 15 16 17
    </div>
    <div class="right">
      <!-- 材料目录明细 -->
      <div class="clmlmx-box" v-if="checkedId == '1'">
        <div class="title">申请材料目录</div>
18
        <lb-table :column="column" :key="key" :heightNum="150" :pagination="false" :data="tableData">
吴蕾 committed
19
        </lb-table>
吴蕾 committed
20
      </div>
吴蕾 committed
21
      <!-- 材料预览 -->
任超 committed
22
      <div class="clyl-box" v-else>
任超 committed
23 24
        <div class="menu-tree">
          <div class="item">
任超 committed
25 26
            材料目录({{tableData.length}})
            <div>
任超 committed
27 28
              <div v-for="(item,index) in tableData" :key="item.bsmSj"
                :class="['child', treeCheckId == item.bsmSj ? 'checked' : '']" @click="treeClick(item,index)">
任超 committed
29 30 31
                <span v-if="item.isrequired==1" class="required">必选</span>
                {{ item.sjmc }}
                <span class="cl_number">({{item.children.length}})</span>
任超 committed
32
              </div>
任超 committed
33
            </div>
任超 committed
34 35
          </div>
        </div>
36
        <image-preview ref='imageRef' v-if="tableData.length>0" :ableOperation="ableOperation" :previewImg="previewImg" @updateList="updateList" @nextPriview="nextPriview"
任超 committed
37
          @prevPriview="prevPriview" />
吴蕾 committed
38 39
      </div>
    </div>
吴蕾 committed
40
    <clxxAddDialog v-model="isDialog" />
任超 committed
41 42 43
  </div>
</template>
<script>
44
  import { mapGetters } from "vuex";
45
  import clxxAddDialog from "../dialog/clxxAddDialog.vue";
46 47 48 49 50 51
  import imagePreview from '@/views/components/imagePreview.vue'
  import { InitClml, saveClml, deleteSjClml, moveClml } from "@/api/clxx.js";
  export default {
    components: { clxxAddDialog, imagePreview },
    data () {
      return {
52 53
        //表单是否可操作
        ableOperation: true,
54 55 56 57 58
        isDialog: false,
        menuList: [
          {
            id: "1",
            label: "材料目录明细",
吴蕾 committed
59
          },
60 61 62 63 64 65 66 67 68 69 70 71 72 73
          {
            id: "2",
            label: "材料预览",
          },
        ],
        iclass: "",
        // 材料目录选中
        treeCheckIndex: 0,
        treeCheckId: "",
        checkedId: "1",
        column: [
          {
            width: "50",
            renderHeader: (h, scope) => {
吴蕾 committed
74 75
              return (
                <div>
76
                  {
xiaomiao committed
77
                    this.ableOperation? '序号' :
78 79 80 81 82 83 84
                      <i
                        class="el-icon-plus pointer"
                        onClick={() => {
                          this.handleAdd()
                        }}
                      ></i>
                  }
吴蕾 committed
85
                </div>
86 87 88 89 90
              )
            },
            render: (h, scope) => {
              // 新建的材料,可删除
              // v-show='scope.row.sfxjcl == 1'
吴蕾 committed
91 92
              return (
                <div>
93
                  {
xiaomiao committed
94
                    this.ableOperation? <span>{scope.$index + 1}</span> :
95 96 97 98 99 100 101 102
                      <i
                        class="el-icon-minus pointer"

                        onClick={() => {
                          this.handleDelete(scope.$index, scope.row);
                        }}
                      ></i>
                  }
吴蕾 committed
103
                </div>
104
              )
吴蕾 committed
105 106
            }
          },
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
          {
            prop: "isrequired",
            label: "是否必选",
            width: "50",
            render: (h, scope) => {
              if (scope.row.sfxjcl === "1") {
                return (
                  <div>
                    <span>可选</span>
                  </div>
                );
              }
              else {
                return (
                  <div>
                    <span>必选</span>
                  </div>
                );
              }
            },
          },
          {
            prop: "sjmc",
            label: "材料名称",
吴蕾 committed
131
          },
132 133 134 135 136
          {
            prop: "sjlx",
            label: "材料类型",
            width: "80",
            render: (h, scope) => {
吴蕾 committed
137 138
              return (
                <div>
139
                  <span>{this.dicStatus(scope.row.sjlx, "A40")}</span>
吴蕾 committed
140 141
                </div>
              );
142 143 144 145 146 147 148 149 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
            },
          },
          {
            prop: "sjsl",
            label: "份数",
            width: "50"
          },
          {
            prop: "smzt",
            label: "扫描状态",
            width: "80",
            render: (h, scope) => {
              if (scope.row.children.length > 0) {
                return (
                  <div>
                    <span>已扫描</span>
                  </div>
                );
              } else {
                return (
                  <div>
                    <span>未扫描</span>
                  </div>
                );
              }
            },
          },
          {
            prop: "ys",
            label: "扫描页数",
            width: "50"
          },
          {
            label: "操作",
            width: "80",
            render: (h, scope) => {
吴蕾 committed
178 179
              return (
                <div>
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
                  <el-button
                    type="text"
                    disabled={scope.$index == 0}
                    onClick={() => {
                      this.moveUpward(scope.$index, scope.row);
                    }}
                  >
                    上移
                  </el-button>
                  <el-button
                    type="text"
                    disabled={scope.$index + 1 == this.tableData.length}
                    onClick={() => {
                      this.moveDown(scope.$index, scope.row);
                    }}
                  >
                    下移
                  </el-button>
吴蕾 committed
198 199
                </div>
              );
200
            },
吴蕾 committed
201
          },
202 203 204 205 206 207 208 209 210 211 212
        ],
        key: 0,
        tableData: [],
        previewImg: {
          // 收件标识码
          bsmSj: '',
          bsmSlsq: this.$parent.bsmSlsq,
          index: 0,
          selectedIndex: 0,
          imgList: []
        }
任超 committed
213 214
      }
    },
215 216
    computed: {
      ...mapGetters(["dictData"])
任超 committed
217
    },
218
    created () {
219
      this.ableOperation = this.$parent.currentSelectTab.ableOperation
220
      this.clmlInitList()
任超 committed
221
    },
222 223
    methods: {
      // 自动预览
yuanbo committed
224 225 226 227
      /**
       * @description: 自动预览
       * @author: renchao
       */
228 229 230 231 232 233 234
      nextPriview () {
        if (this.treeCheckIndex < this.tableData.length) {
          this.treeCheckIndex++
          this.treeCheckId = this.tableData[this.treeCheckIndex].bsmSj
          this.previewImg.index = 0
          this.previewImg.imgList = this.tableData[this.treeCheckIndex].children
          this.previewImg.bsmSj = this.tableData[this.treeCheckIndex].bsmSj
任超 committed
235
        }
236
      },
yuanbo committed
237 238 239 240
      /**
       * @description: prevPriview
       * @author: renchao
       */
241 242 243 244 245 246 247 248 249 250
      prevPriview () {
        if (this.treeCheckIndex >= 1) {
          this.treeCheckIndex--
          this.treeCheckId = this.tableData[this.treeCheckIndex].bsmSj
          this.previewImg.index = this.previewImg.imgList.length
          this.previewImg.imgList = this.tableData[this.treeCheckIndex].children
          this.previewImg.bsmSj = this.tableData[this.treeCheckIndex].bsmSj
        }
      },
      // 材料目录明细初始化
yuanbo committed
251 252 253 254
      /**
       * @description: 材料目录明细初始化
       * @author: renchao
       */
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269
      clmlInitList () {
        return new Promise(resolve => {
          this.unitData = this.$parent.unitData;
          var formdata = new FormData();
          formdata.append("bsmSldy", this.unitData[0]?.bsmSldy);
          formdata.append("bsmSlsq", this.$parent.bsmSlsq);
          InitClml(formdata).then((res) => {
            if (res.result.code == 200) {
              resolve(res.code)
              if (res.result.result && res.result.result.length > 0) {
                this.tableData = res.result.result;
                this.treeCheckId = this.tableData[0].bsmSj;
                this.title = this.tableData[0].sjmc;
                this.titleYs = 1;
                this.titleNum = this.tableData[0].children.length;
任超 committed
270

271 272 273 274 275 276
                this.previewImg.imgList = this.tableData[0]?.children;
                this.previewImg.bsmSj = this.tableData[0]?.bsmSj;
              }
            } else {
              this.$message.error(res.result.message)
            }
任超 committed
277
          })
278 279
        })
      },
yuanbo committed
280 281 282 283 284
      /**
       * @description: updateList
       * @param {*} val
       * @author: renchao
       */
285 286 287 288 289 290 291
      updateList (val) {
        let that = this
        if (val != null) { //删除最后一张图片时 val=null
          this.tableData.forEach(item => {
            if (item.bsmSj === val.bsmSj) {
              item.children = val.children
            }
任超 committed
292
          })
293 294 295 296
          this.previewImg.imgList = _.cloneDeep(val.children)
          if (this.previewImg.index == this.previewImg.imgList.length) {
            this.previewImg.index = this.previewImg.index - 1
          }
任超 committed
297
        } else {
298 299 300 301 302 303
          this.previewImg.imgList = []
          this.tableData.forEach((item, index) => {
            if (this.treeCheckId == item.bsmSj) {
              item.children = []
              that.treeCheckIndex = index
            }
任超 committed
304
          })
吴蕾 committed
305
        }
306 307 308

      },
      // 左侧菜单点击
yuanbo committed
309 310 311 312 313
      /**
       * @description: 左侧菜单点击
       * @param {*} item
       * @author: renchao
       */
314 315 316 317
      menuClick (item) {
        this.checkedId = item.id
      },
      // 添加材料目录
yuanbo committed
318 319 320 321
      /**
       * @description: 添加材料目录
       * @author: renchao
       */
322 323 324 325
      handleAdd () {
        this.isDialog = true;
      },
      // 上移
yuanbo committed
326 327 328 329 330 331
      /**
       * @description: 上移
       * @param {*} index
       * @param {*} row
       * @author: renchao
       */
332 333 334 335 336 337 338 339
      moveUpward (index, row) {
        let obj = {
          xh: row.xh,
          bsmSlsq: row.bsmSlsq,
          moveDirection: "UP",
        };
        // 接口待调
        moveClml(obj).then(async (res) => {
任超 committed
340
          if (res.code == 200) {
341 342 343 344
            let res = await this.clmlInitList()
            if (res == 200) this.$message({
              message: '上移成功',
              type: 'success'
任超 committed
345
            })
346 347
          } else {
            this.$message.error(res.message);
任超 committed
348 349
          }
        })
350 351
      },
      // 下移
yuanbo committed
352 353 354 355 356 357
      /**
       * @description: 下移
       * @param {*} index
       * @param {*} row
       * @author: renchao
       */
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
      moveDown (index, row) {
        let obj = {
          xh: row.xh,
          bsmSlsq: row.bsmSlsq,
          moveDirection: "DOWN",
        }
        // 接口待调
        moveClml(obj).then(async (res) => {
          if (res.code == 200) {
            let res = await this.clmlInitList()
            if (res == 200) this.$message({
              message: '下移成功',
              type: 'success'
            })
          } else {
            this.$message.error(res.message);
          }
任超 committed
375
        })
376 377
      },
      // 新增弹窗保存
yuanbo committed
378 379 380 381 382
      /**
       * @description: 新增弹窗保存
       * @param {*} data
       * @author: renchao
       */
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400
      addSave (data) {
        let obj = {
          bsmSlsq: this.$parent.bsmSlsq,
          isrequired: "1",
          sjmc: data.clmc,
          sjsl: 0,
          smzt: '',
          ys: 0,
          sjlx: data.cllx,
          sfxjcl: "1", // 是否必选
        };
        saveClml(obj).then(async (res) => {
          if (res.code == 200) {
            let res = await this.clmlInitList()
            if (res == 200) this.$message({
              message: "新增成功",
              type: "success",
            })
吴蕾 committed
401 402
          }
        });
403 404
      },
      // 材料目录删除
yuanbo committed
405 406 407 408 409 410
      /**
       * @description: 材料目录删除
       * @param {*} index
       * @param {*} row
       * @author: renchao
       */
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434
      handleDelete (index, row) {
        let that = this
        this.$confirm('此操作将永久删除该 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          deleteSjClml({ sjBsm: row.bsmSj }).then(async (res) => {
            if (res.code == 200) {
              let res = await that.clmlInitList()
              if (res == 200) that.$message({
                message: "删除成功",
                type: "success",
              })
            }
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
      },
      // 材料目录点击选中
yuanbo committed
435 436 437 438 439 440
      /**
       * @description: 材料目录点击选中
       * @param {*} item
       * @param {*} index
       * @author: renchao
       */
441 442 443 444
      treeClick (item, index) {
        this.previewImg.index = 0
        this.treeCheckId = item?.bsmSj
        this.treeCheckIndex = index
445
        this.previewImg.imgList = item.children ? item.children : []
446 447 448
        this.previewImg.bsmSj = item?.bsmSj
      },
      // 小图片点击
yuanbo committed
449 450 451 452 453 454
      /**
       * @description: 小图片点击
       * @param {*} item
       * @param {*} index
       * @author: renchao
       */
455 456 457 458 459
      imgClick (item, index) {
        this.showImg = item;
        this.titleYs = index + 1;
      },
      // 字典
yuanbo committed
460 461 462 463 464 465
      /**
       * @description: 字典
       * @param {*} val
       * @param {*} code
       * @author: renchao
       */
466 467 468 469 470 471 472 473 474 475 476 477
      dicStatus (val, code) {
        let data = this.$store.getters.dictData[code],
          name = "暂无";
        if (data) {
          data.map((item) => {
            if (item.dcode == val) {
              name = item.dname;
            }
          });
          return name;
        }
      },
吴蕾 committed
478
    },
479
  };
任超 committed
480 481
</script>
<style scoped lang='scss'>
482
  @import "~@/styles/mixin.scss";
任超 committed
483

484 485 486 487
  .active {
    background: $light-blue !important;
    color: #fff;
  }
任超 committed
488

489 490 491 492 493
  .required {
    font-size: 12px;
    color: $pink;
    float: left;
  }
任超 committed
494

495 496
  .cl_number {
    float: right;
吴蕾 committed
497
  }
任超 committed
498

499
  .clxx {
任超 committed
500
    width: 100%;
501 502 503
    display: flex;
    padding-left: 5px;
    height: calc(100vh - 125px);
504

505 506 507 508
    .left {
      display: flex;
      flex-direction: column;
      justify-content: space-between;
任超 committed
509

510 511 512 513 514 515 516 517 518 519 520 521 522
      .item {
        width: 28px;
        height: 49%;
        @include flex-center;
        background-color: #e4e7ed;
        border-bottom-right-radius: 10px;
        padding: 5px;
        cursor: pointer;
        transition: all 0.3s;

        &:hover {
          @extend .active;
        }
吴蕾 committed
523 524
      }
    }
吴蕾 committed
525

526
    .right {
吴蕾 committed
527
      width: 100%;
吴蕾 committed
528
      height: 100%;
任超 committed
529

530 531
      .clmlmx-box {
        margin: 0 auto;
任超 committed
532

533
        .title {
任超 committed
534
          text-align: center;
535 536 537 538 539 540 541 542
          height: 60px;
          line-height: 60px;
          border: 1px solid #dfe6ec;
          font-size: 20px;
          background: #81d3f81a;
          margin-bottom: -1px;
        }
      }
任超 committed
543

544 545 546 547
      .clyl-box {
        width: 100%;
        height: 100%;
        display: flex;
吴蕾 committed
548

549 550 551 552 553 554 555
        .menu-tree {
          width: 20%;
          min-width: 160px;
          height: 100%;
          margin-right: 10px;
          border-right: 1px dotted #d9d9d9;
          padding: 0 15px;
任超 committed
556

557 558 559 560 561 562
          .item {
            line-height: 30px;
            padding-top: 5px;
            border-bottom: 1px solid #e8e8e8;
            font-size: 16px;
            text-align: center;
任超 committed
563
            color: $light-blue;
任超 committed
564

565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592
            .itemIcon {
              float: right;
              line-height: 60px;
              cursor: pointer;
            }

            .child {
              line-height: 32px;
              border-bottom: 1px solid #e8e8e8;
              padding-left: 10px;
              color: #6b6b6b;
              cursor: pointer;
              box-sizing: border-box;
              border-radius: 6px;
              line-height: 20px;
              transition: all 0.3s;
              padding: 8px 0;
            }

            .child:hover {
              color: $light-blue;
              transform: scale(1.1);
            }

            .checked {
              border: 1px solid $light-blue;
              color: $light-blue;
            }
吴蕾 committed
593 594 595
          }
        }

596 597 598 599 600 601 602
        .clyl-img {
          width: 75%;
          height: 100%;
          background: #f3f4f7;
          margin: 0 auto;
          position: relative;
        }
吴蕾 committed
603 604 605
      }
    }
  }
xiaomiao committed
606
</style>