Blame view

src/views/workflow/components/clxx/clxxUnify.vue 11.1 KB
1
<!--
xiaomiao committed
2
 * @Description:
3
 * @Autor: renchao
4
 * @LastEditTime: 2023-08-01 15:19:13
5
-->
蔡俊立 committed
6 7 8 9 10 11
<template>
  <div class="clxx">
    <div class="right">
      <!-- 材料预览 -->
      <div class="clyl-box">
        <div class="menu-tree">
12
          <el-button type="primary" native-type="submit" @click="viewDetail" style="width:100%;margin-top:10px;">查看明细</el-button>
蔡俊立 committed
13 14 15 16 17 18 19 20 21 22 23 24
          <div class="item">
            材料目录({{tableData.length}})
            <div style="margin-top:10px">
              <div style="text-align: center;line-height:20px;color:black;font-size:14px" 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>
                {{ item.sjmc }}
                <span class="cl_number">({{item.children ? item.children.length : 0}})</span>
              </div>
            </div>
          </div>
25
          <el-button type="primary" native-type="submit" style="width:100%" @click="handleAdd()"
xiaomiao committed
26
            v-if="ableOperation">新增</el-button>
蔡俊立 committed
27
        </div>
28 29
        <image-preview ref='imageRef' v-if="tableData.length>0" :previewImg="previewImg" :ableOperation="ableOperation" @updateList="updateList"
          @nextPriview="nextPriview"
蔡俊立 committed
30 31 32 33 34 35 36
          @prevPriview="prevPriview" />
      </div>
    </div>
    <clxxAddDialog v-model="isDialog" />
  </div>
</template>
<script>
37
  import { mapGetters } from "vuex";
38 39
  import clxxAddDialog from "../dialog/clxxAddDialog.vue";
  import clxxDetailDialog from "../dialog/clxxDetailDialog.vue";
40
  import imagePreview from '@/views/components/imagePreview.vue'
1  
renchao@pashanhoo.com committed
41
  import { InitClml, saveClml } from "@/api/clxx.js";
42 43 44 45
  export default {
    components: { clxxAddDialog, imagePreview, clxxDetailDialog },
    data () {
      return {
46 47
        //表单是否可操作
        ableOperation: true,
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
        isDialog: false,
        iclass: "",
        // 材料目录选中
        treeCheckIndex: 0,
        treeCheckId: "",
        key: 0,
        tableData: [],
        previewImg: {
          // 收件标识码
          bsmSj: '',
          bsmSlsq: this.$parent.bsmSlsq,
          index: 0,
          selectedIndex: 0,
          imgList: []
        }
蔡俊立 committed
63 64
      }
    },
65 66
    computed: {
      ...mapGetters(["dictData"])
蔡俊立 committed
67
    },
68 69 70
    created () {
      this.clmlInitList(1)
    },
71 72 73 74 75 76 77 78 79 80
    computed: {
      ...mapGetters(['workFresh'])
    },
    watch: {
      workFresh: {
        handler (newVal, oldVal) {
          if (newVal) this.clmlInitList(1)
        }
      }
    },
81 82 83
    mounted () {
      this.ableOperation = this.$parent.ableOperation
    },
84 85
    methods: {
      // 自动预览
yuanbo committed
86 87 88 89
      /**
       * @description: 自动预览
       * @author: renchao
       */
90 91 92 93 94 95 96 97 98
      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
        }
      },
yuanbo committed
99 100 101 102
      /**
       * @description: prevPriview
       * @author: renchao
       */
103 104 105 106 107 108 109 110 111 112
      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
113 114 115 116 117
      /**
       * @description: 材料目录明细初始化
       * @param {*} type
       * @author: renchao
       */
118 119 120 121 122 123 124
      clmlInitList (type) {
        //type  1:列表初始化  2:新增材料
        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);
125
          formdata.append("clfl", 2);
126 127 128 129 130 131 132 133 134 135 136
          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);
                } else {
                  //新增材料后刷新列表焦点置于新增的对象上
                  this.treeClick(this.tableData[this.tableData.length - 1], this.tableData.length - 1);
                }
蔡俊立 committed
137
              }
138 139
            } else {
              this.$message.error(res.message)
蔡俊立 committed
140
            }
141
          })
蔡俊立 committed
142
        })
143
      },
yuanbo committed
144 145 146 147 148
      /**
       * @description: setChecked
       * @param {*} item
       * @author: renchao
       */
149 150 151 152 153 154 155 156
      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;
      },
yuanbo committed
157 158 159 160 161
      /**
       * @description: updateList
       * @param {*} val
       * @author: renchao
       */
162 163
      updateList (val) {
        let that = this
164
        if (val.children.length != 0) { //删除最后一张图片时 val=null
165 166 167 168 169 170 171 172
          this.tableData.forEach(item => {
            if (item.bsmSj === val.bsmSj) {
              item.children = val.children
            }
          })
          this.previewImg.imgList = _.cloneDeep(val.children)
          if (this.previewImg.index == this.previewImg.imgList.length) {
            this.previewImg.index = this.previewImg.index - 1
蔡俊立 committed
173
          }
174 175 176 177 178 179 180
        } else {
          this.previewImg.imgList = []
          this.tableData.forEach((item, index) => {
            if (this.treeCheckId == item.bsmSj) {
              item.children = []
              that.treeCheckIndex = index
            }
蔡俊立 committed
181 182
          })
        }
183 184
      },
      // 添加材料目录
yuanbo committed
185 186 187 188
      /**
       * @description: 添加材料目录
       * @author: renchao
       */
189 190 191 192
      handleAdd () {
        this.isDialog = true;
      },
      // 新增弹窗保存
yuanbo committed
193 194 195 196 197
      /**
       * @description: 新增弹窗保存
       * @param {*} data
       * @author: renchao
       */
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
      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(2)
            if (res == 200) this.$message({
              message: "新增成功",
              type: "success",
            })
蔡俊立 committed
216 217
          }
        });
218 219
      },
      // 材料目录点击选中
yuanbo committed
220 221 222 223 224 225
      /**
       * @description: 材料目录点击选中
       * @param {*} item
       * @param {*} index
       * @author: renchao
       */
226 227 228 229
      treeClick (item, index) {
        this.previewImg.index = 0
        this.treeCheckId = item?.bsmSj
        this.treeCheckIndex = index
230
        this.previewImg.imgList = item.children ? item.children : []
231 232 233
        this.previewImg.bsmSj = item?.bsmSj
      },
      // 小图片点击
yuanbo committed
234 235 236 237 238 239
      /**
       * @description: 小图片点击
       * @param {*} item
       * @param {*} index
       * @author: renchao
       */
240 241 242 243 244
      imgClick (item, index) {
        this.showImg = item;
        this.titleYs = index + 1;
      },
      // 字典
yuanbo committed
245 246 247 248 249 250
      /**
       * @description: 字典
       * @param {*} val
       * @param {*} code
       * @author: renchao
       */
251 252 253 254 255 256
      dicStatus (val, code) {
        let data = this.$store.getters.dictData[code],
          name = "暂无";
        if (data) {
          data.map((item) => {
            if (item.dcode == val) {
257
              name = item.dname
258 259
            }
          });
260
          return name
261 262 263 264
        }
      },
      //查看明细
      viewDetail () {
265
        this.$store.dispatch('user/reWorkFresh', false)
266
        this.$popupDialog("查看明细", "workflow/components/dialog/clxxDetailDialog", {
267
          data: this.tableData,
268 269
          unitData: this.$parent.unitData,
          ableOperation: this.$parent.ableOperation
270
        }, "60%", true)
271 272 273 274 275
      },
      //设置tableData
      setTableData (tableData) {
        this.$nextTick(res => {
          this.tableData = tableData;
蔡俊立 committed
276
        })
277
      },
蔡俊立 committed
278
    },
279
  };
蔡俊立 committed
280 281
</script>
<style scoped lang='scss'>
282
  @import "~@/styles/mixin.scss";
蔡俊立 committed
283

284 285 286 287
  .active {
    background: $light-blue !important;
    color: #fff;
  }
蔡俊立 committed
288

289 290 291 292 293
  .required {
    font-size: 12px;
    color: $pink;
    float: left;
  }
蔡俊立 committed
294

295 296
  .cl_number {
    float: right;
蔡俊立 committed
297 298
  }

299
  .clxx {
蔡俊立 committed
300
    width: 100%;
301 302 303 304 305 306 307 308
    display: flex;
    padding-left: 5px;
    height: calc(100vh - 125px);

    .left {
      display: flex;
      flex-direction: column;
      justify-content: space-between;
蔡俊立 committed
309

310 311 312 313 314 315 316 317 318
      .item {
        width: 28px;
        height: 49%;
        @include flex-center;
        background-color: #e4e7ed;
        border-bottom-right-radius: 10px;
        padding: 5px;
        cursor: pointer;
        transition: all 0.3s;
蔡俊立 committed
319

320 321 322
        &:hover {
          @extend .active;
        }
蔡俊立 committed
323 324 325
      }
    }

326
    .right {
蔡俊立 committed
327 328 329
      width: 100%;
      height: 100%;

330 331
      .clmlmx-box {
        margin: 0 auto;
蔡俊立 committed
332

333
        .title {
蔡俊立 committed
334
          text-align: center;
335 336 337 338 339 340 341 342
          height: 60px;
          line-height: 60px;
          border: 1px solid #dfe6ec;
          font-size: 20px;
          background: #81d3f81a;
          margin-bottom: -1px;
        }
      }
蔡俊立 committed
343

344 345 346 347
      .clyl-box {
        width: 100%;
        height: 100%;
        display: flex;
蔡俊立 committed
348

349 350 351 352 353 354 355
        .menu-tree {
          width: 20%;
          min-width: 160px;
          height: 100%;
          margin-right: 10px;
          border-right: 1px dotted #d9d9d9;
          padding: 0 15px;
蔡俊立 committed
356

357 358 359 360 361 362
          .item {
            line-height: 30px;
            padding-top: 5px;
            border-bottom: 1px solid #e8e8e8;
            font-size: 16px;
            text-align: center;
蔡俊立 committed
363 364
            color: $light-blue;

365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392
            .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
393 394 395
          }
        }

396 397 398 399 400 401 402
        .clyl-img {
          width: 75%;
          height: 100%;
          background: #f3f4f7;
          margin: 0 auto;
          position: relative;
        }
蔡俊立 committed
403 404 405
      }
    }
  }
xiaomiao committed
406
</style>