Blame view

src/views/workflow/components/clxx/clxxUnify.vue 12.5 KB
1
<!--
xiaomiao committed
2
 * @Description:
3
 * @Autor: renchao
4
 * @LastEditTime: 2023-10-24 16:08:44
5
-->
蔡俊立 committed
6 7
<template>
  <div class="clxx">
8 9 10 11 12 13 14 15 16 17 18 19 20
    <!-- 材料预览 -->
    <div class="clyl-box">
      <div class="menu-tree">
        <el-button
          type="primary"
          native-type="submit"
          @click="viewDetail"
          style="width: 100%; margin-top: 10px">申请材料目录</el-button>
        <div class="item">
          材料目录({{ tableData.length }})
          <div class="tableList">
            <div
              style="
xiaomiao committed
21 22 23 24 25
                  text-align: center;
                  line-height: 20px;
                  color: black;
                  font-size: 14px;
                "
26 27 28 29 30 31 32 33 34 35 36
              v-if="tableData.length == 0">
              暂无数据
            </div>
            <div
              v-for="(item, index) in tableData"
              :key="item.bsmSj"
              :class="['child', treeCheckId == item.bsmSj ? 'checked' : '']"
              @click="treeClick(item, index)">
              <span v-if="item.isrequired == 1" class="required">必选</span>
              <span class="item_name">{{ item.sjmc }}</span>
              <span class="cl_number" :key="key">({{ item.ys ? item.ys : 0 }})</span>
蔡俊立 committed
37 38 39
            </div>
          </div>
        </div>
40 41 42 43 44 45
        <el-button
          type="primary"
          native-type="submit"
          style="width: 100%"
          @click="handleAdd()"
          v-if="ableOperation">新增</el-button>
蔡俊立 committed
46
      </div>
47 48
      <image-preview
        ref="imageRef"
49
        :key="imgKey"
50 51 52 53 54 55
        v-if="tableData.length > 0"
        :previewImg="previewImg"
        :ableOperation="ableOperation"
        @updateList="updateList"
        @nextPriview="nextPriview"
        @prevPriview="prevPriview" />
蔡俊立 committed
56 57 58 59 60
    </div>
    <clxxAddDialog v-model="isDialog" />
  </div>
</template>
<script>
61 62 63 64
  import { mapGetters } from "vuex";
  import clxxAddDialog from "../dialog/clxxAddDialog.vue";
  import clxxDetailDialog from "../dialog/clxxDetailDialog.vue";
  import imagePreview from "@/views/components/imagePreview.vue";
65
  import { InitClml, saveClml, getClmxList } from "@/api/clxx.js";
66 67 68 69
  export default {
    components: { clxxAddDialog, imagePreview, clxxDetailDialog },
    data () {
      return {
70
        imgKey: 0,
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
        //表单是否可操作
        ableOperation: true,
        isDialog: false,
        iclass: "",
        // 材料目录选中
        treeCheckIndex: 0,
        treeCheckId: "",
        key: 0,
        tableData: [],
        previewImg: {
          // 收件标识码
          bsmSj: "",
          bsmSlsq: this.$parent.bsmSlsq,
          index: 0,
          selectedIndex: 0,
          imgList: [],
        },
      };
89
    },
90 91
    computed: {
      ...mapGetters(["dictData"]),
92
    },
93 94
    created () {
      this.clmlInitList(1);
95
    },
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
    computed: {
      ...mapGetters(["workFresh"]),
    },
    watch: {
      workFresh: {
        handler (newVal, oldVal) {
          if (newVal) this.clmlInitList(1);
        },
      },
    },
    mounted () {
      this.ableOperation = this.$parent.ableOperation;
    },
    methods: {
      /**
       * @description: 自动预览
       * @author: renchao
       */
      nextPriview () {
        if (this.treeCheckIndex < this.tableData.length) {
          this.treeCheckIndex++;
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
          if (this.tableData[this.treeCheckIndex]) {
            this.treeCheckId = this.tableData[this.treeCheckIndex].bsmSj;
            // 判断页数
            let ys = this.tableData[this.treeCheckIndex].ys
            this.previewImg.index = 0;
            // 获取材料明细
            if (ys > 0) {
              getClmxList(this.treeCheckId).then(res => {
                this.previewImg.imgList = res.result ? res.result : [];
              })
            } else {
              this.previewImg.imgList = []
            }
            this.previewImg.bsmSj = this.tableData[this.treeCheckIndex].bsmSj;
          } else {
            this.$message.error('没有最后一张了');
          }
134 135 136 137 138 139 140 141 142 143
        }
      },
      /**
       * @description: prevPriview
       * @author: renchao
       */
      prevPriview () {
        if (this.treeCheckIndex >= 1) {
          this.treeCheckIndex--;
          this.treeCheckId = this.tableData[this.treeCheckIndex].bsmSj;
144 145 146 147 148 149 150 151 152 153 154 155
          // 判断页数
          let ys = this.tableData[this.treeCheckIndex].ys
          if (ys > 0) {
            // 获取材料明细
            getClmxList(this.treeCheckId).then(res => {
              this.previewImg.imgList = res.result ? res.result : [];
              this.previewImg.index = this.previewImg.imgList.length - 1;
            })
          } else {
            this.previewImg.imgList = [];
            this.previewImg.index = 0
          }
156
          this.previewImg.bsmSj = this.tableData[this.treeCheckIndex].bsmSj;
157 158
        } else {
          this.$message.error('没有第一张了');
xiaomiao committed
159
        }
160 161 162 163 164 165 166 167 168 169 170 171
      },
      /**
       * @description: 材料目录明细初始化
       * @param {*} type
       * @author: renchao
       */
      clmlInitList (type) {
        //type  1:列表初始化  2:新增材料
        return new Promise((resolve) => {
          this.unitData = this.$parent.unitData;
          var formdata = new FormData();
          formdata.append("bsmSlsq", this.$parent.bsmSlsq);
172
          formdata.append("bsmSldy", this.$parent.currentSelectProps.bsmSldy);
xiaomiao committed
173

174 175 176 177 178 179 180
          InitClml(formdata).then((res) => {
            if (res.code == 200) {
              resolve(res.code);
              if (res.result && res.result.length > 0) {
                this.tableData = res.result;
                if (type == 1) {
                  this.treeClick(this.tableData[0], 0);
181
                } else if (type == 2) {
182 183 184 185 186 187
                  //新增材料后刷新列表焦点置于新增的对象上
                  this.treeClick(
                    this.tableData[this.tableData.length - 1],
                    this.tableData.length - 1
                  );
                }
蔡俊立 committed
188
              }
189 190
            } else {
              this.$message.error(res.message);
191
            }
192
          });
xiaomiao committed
193
        });
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
      },
      /**
       * @description: setChecked
       * @param {*} item
       * @author: renchao
       */
      setChecked (item) {
        this.treeCheckId = item.bsmSj;
        this.title = item.sjmc;
        this.titleYs = 1;
        this.titleNum = item.children.length;
        this.previewImg.imgList = item.children;
        this.previewImg.bsmSj = item.bsmSj;
      },
      /**
       * @description: updateList
       * @param {*} val
       * @author: renchao
       */
      updateList (val) {
        let that = this;
        if (val.children.length != 0) {
          //删除最后一张图片时 val=null
          this.tableData.forEach((item) => {
            if (item.bsmSj === val.bsmSj) {
219
              item.ys = val.children.length;
220 221 222 223 224
            }
          });
          this.previewImg.imgList = _.cloneDeep(val.children);
          if (this.previewImg.index == this.previewImg.imgList.length) {
            this.previewImg.index = this.previewImg.index - 1;
xiaomiao committed
225
          }
226
          this.key++
227 228 229 230
        } else {
          this.previewImg.imgList = [];
          this.tableData.forEach((item, index) => {
            if (this.treeCheckId == item.bsmSj) {
renchao@pashanhoo.com committed
231
              item.ys = 0;
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248
              that.treeCheckIndex = index;
            }
          });
        }
      },
      /**
       * @description: 添加材料目录
       * @author: renchao
       */
      handleAdd () {
        this.isDialog = true;
      },
      /**
       * @description: 新增弹窗保存
       * @param {*} data
       * @author: renchao
       */
249
      addSave (data) {
250 251 252 253 254 255 256 257 258
        let obj = {
          bsmSlsq: this.$parent.bsmSlsq,
          isrequired: "1",
          sjmc: data.clmc,
          sjsl: 0,
          smzt: "",
          ys: 0,
          sjlx: data.cllx,
          sfxjcl: "1", // 是否必选
259
          sfggcl: data.sfggcl,
260
        };
261
        //是否公共材料
262 263
        if (data.sfggcl == "0") {
          obj["bsmSldy"] = this.$parent.currentSelectProps.bsmSldy;
264
        }
265
        if (this.$route.query?.djywbm == "DJBBL") {
266
          obj.bsmSldy = this.$parent.bsmRepair
蔡俊立 committed
267
        }
268 269 270 271 272 273 274 275
        saveClml(obj).then(async (res) => {
          if (res.code == 200) {
            let res = await this.clmlInitList(2);
            if (res == 200)
              this.$message({
                message: "新增成功",
                type: "success",
              });
xiaomiao committed
276 277
          }
        });
278 279 280 281 282 283 284 285 286 287 288
      },
      /**
       * @description: 材料目录点击选中
       * @param {*} item
       * @param {*} index
       * @author: renchao
       */
      treeClick (item, index) {
        this.previewImg.index = 0;
        this.treeCheckId = item?.bsmSj;
        this.treeCheckIndex = index;
289 290 291 292
        // 获取材料明细
        getClmxList(item.bsmSj).then(res => {
          this.previewImg.imgList = res.result ? res.result : [];
        })
293
        this.previewImg.bsmSj = item?.bsmSj;
294 295 296
        if (this.$refs.imageRef) {
          this.$refs.imageRef.initialIndex = 0
        }
297
        this.imgKey++
298 299 300 301 302 303 304 305 306 307 308 309
      },
      /**
       * @description: 小图片点击
       * @param {*} item
       * @param {*} index
       * @author: renchao
       */
      imgClick (item, index) {
        this.showImg = item;
        this.titleYs = index + 1;
      },
      //查看明细
310
      async viewDetail () {
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325
        await this.clmlInitList();
        this.$store.dispatch("user/reWorkFresh", false);
        this.$popupDialog(
          "申请材料目录",
          "workflow/components/dialog/clxxDetailDialog",
          {
            data: this.tableData,
            bsmSldy: this.$parent.currentSelectProps.bsmSldy,
            unitData: this.$parent.unitData,
            ableOperation: this.$parent.ableOperation,
            bsmRepair: this.$parent.bsmRepair
          },
          "60%",
          true
        )
326 327 328 329 330
      },
      //设置tableData
      setTableData (tableData) {
        this.$nextTick((res) => {
          this.tableData = tableData;
331 332 333
        })
      }
    }
334
  }
蔡俊立 committed
335
</script>
xiaomiao committed
336
<style scoped lang="scss">
337
  @import "~@/styles/mixin.scss";
蔡俊立 committed
338

339 340 341 342
  .active {
    background: $light-blue !important;
    color: #fff;
  }
343

344 345 346 347 348
  .required {
    font-size: 12px;
    color: $pink;
    float: left;
  }
蔡俊立 committed
349

350
  .cl_number {
351
    width: 30px;
xiaomiao committed
352
  }
蔡俊立 committed
353

354
  .clxx {
xiaomiao committed
355
    width: 100%;
356 357 358
    display: flex;
    padding-left: 5px;
    height: calc(100vh - 125px);
xiaomiao committed
359

360 361 362 363
    .left {
      display: flex;
      flex-direction: column;
      justify-content: space-between;
xiaomiao committed
364

365 366 367 368 369 370 371 372 373 374 375 376 377
      .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
378 379 380
      }
    }

381 382 383 384 385 386 387 388 389 390 391 392 393 394 395
    .clmlmx-box {
      margin: 0 auto;

      .title {
        text-align: center;
        height: 60px;
        line-height: 60px;
        border: 1px solid #dfe6ec;
        font-size: 20px;
        background: #81d3f81a;
        margin-bottom: -1px;
      }
    }

    .clyl-box {
蔡俊立 committed
396 397
      width: 100%;
      height: 100%;
398 399 400 401 402 403 404 405 406 407
      display: flex;
      .tableList {
        margin-top: 10px;
      }
      .menu-tree {
        width: 20%;
        min-width: 160px;
        height: 100%;
        font-size: 14px;
        border-right: 1px dotted #d9d9d9;
408
        padding: 0 10px;
蔡俊立 committed
409

410 411 412 413 414
        .item {
          line-height: 30px;
          padding-top: 5px;
          border-bottom: 1px solid #e8e8e8;
          font-size: 16px;
蔡俊立 committed
415
          text-align: center;
416
          color: $light-blue;
蔡俊立 committed
417

418 419 420 421 422
          .itemIcon {
            float: right;
            line-height: 60px;
            cursor: pointer;
          }
423

424 425
          .child {
            line-height: 32px;
426
            border-bottom: 1px solid #e8e8e8;
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445
            padding-left: 10px;
            color: #6b6b6b;
            cursor: pointer;
            box-sizing: border-box;
            border-radius: 6px;
            line-height: 20px;
            transition: all 0.3s;
            padding: 8px 0;
            overflow: hidden;
            display: flex;
            justify-content: space-between;
          }
          .item_name {
            flex: 1;
            font-size: 14px;
            display: flex;
            justify-content: center;
          }
          .child:hover {
xiaomiao committed
446
            color: $light-blue;
447 448
            transform: scale(1.1);
          }
449

450 451 452
          .checked {
            border: 1px solid $light-blue;
            color: $light-blue;
453
            box-sizing: border-box;
蔡俊立 committed
454 455
          }
        }
456
      }
蔡俊立 committed
457

458 459 460 461 462 463
      .clyl-img {
        width: 75%;
        height: 100%;
        background: #f3f4f7;
        margin: 0 auto;
        position: relative;
蔡俊立 committed
464 465 466
      }
    }
  }
xiaomiao committed
467
</style>