<template> <div class="clxx"> <div class="left"> <div v-for="item in menuList" :key="item.id" :class="['item', checkedId == item.id ? 'active' : '']" @click="menuClick(item)"> {{ item.label }} </div> </div> <div class="right"> <!-- 材料目录明细 --> <div class="clmlmx-box" v-if="checkedId == '1'"> <div class="title">申请材料目录</div> <lb-table :column="column" :key="key" :heightNum="210" :pagination="false" :data="tableData"> </lb-table> </div> <!-- 材料预览 --> <div class="clyl-box" v-else> <div class="menu-tree"> <div class="item"> 材料目录 <i :class="iclass" @click="iconClick()"></i> <el-collapse-transition> <div v-show="menuOpen"> <div v-for="item in tableData" :key="item.bsmSj" :class="['child', treeCheckId == item.bsmSj ? 'checked' : '']" @click="treeClick(item)"> {{ item.sjmc }} </div> </div> </el-collapse-transition> </div> </div> <image-preview :previewImg="previewImg" /> </div> </div> <clxxAddDialog v-model="isDialog" /> </div> </template> <script> import { mapGetters } from "vuex"; import clxxAddDialog from "./clxxAddDialog.vue"; import imagePreview from '@/views/components/imagePreview.vue' import { clmlInit, move, save, clmlDelete } from "@/api/fqsq.js"; export default { components: { clxxAddDialog, imagePreview }, data () { return { isDialog: false, menuList: [ { id: "1", label: "材料目录明细", }, { id: "2", label: "材料预览", }, ], menuOpen: true, iclass: "itemIcon el-icon-caret-bottom", treeCheckId: "", checkedId: "1", column: [ { width: "60", renderHeader: (h, scope) => { return ( <i class="el-icon-plus pointer" onClick={() => { this.handleAdd() }} ></i> ); }, render: (h, scope) => { // 新建的材料,可删除 if (scope.row.sfxjcl === "1") { return ( <i class="el-icon-minus pointer" onClick={() => { this.handleDelete(scope.$index, scope.row); }} ></i> ); } }, }, { width: "60", label: "序号", type: "index", }, { prop: "isrequired", label: "是否必选", width: "100", render: (h, scope) => { // 新增的材料,全部为系统默认可选 if (scope.row.sfxjcl === "1") { return ( <div> <span>可选</span> </div> ); } // 系统配置的材料 else { return ( <div> <span>必选</span> </div> ); } }, }, { prop: "sjmc", label: "材料名称", }, { prop: "sjlx", label: "材料类型", render: (h, scope) => { return ( <div> <span>{this.dicStatus(scope.row.sjlx, "A40")}</span> </div> ); }, }, { prop: "sjsl", label: "份数", }, { prop: "smzt", label: "扫描状态", render: (h, scope) => { if (scope.row.children.length > 0) { return ( <div> <span>已扫描</span> </div> ); } else { return ( <div> <span>未扫描</span> </div> ); } }, }, { prop: "ys", label: "扫描页数", }, { label: "操作", width: "90", render: (h, scope) => { return ( <div> <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> </div> ); }, }, ], key: 0, tableData: [], previewImg: { index: 0, selectedIndex: 0, imgList: [ { url: 'https://img2.baidu.com/it/u=2955521104,3257476296&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=1111' }, { url: 'https://img1.baidu.com/it/u=2383300938,4241539174&fm=253&fmt=auto&app=138&f=JPEG?w=307&h=500' } ], } }; }, computed: { ...mapGetters(["dictData"]), }, mounted () { if (this.$parent.index == 1) { this.clmlmxInit(); } }, methods: { // 左侧菜单点击 menuClick (item) { this.checkedId = item.id; }, // 添加材料目录 handleAdd () { this.isDialog = true; }, // 上移 moveUpward (index, row) { let obj = { xh: row.xh, bsmSlsq: row.bsmSlsq, moveDirection: "up", }; // 接口待调 move(obj).then((res) => { this.clmlmxInit(); }); }, // 下移 moveDown (index, row) { let obj = { xh: row.xh, bsmSlsq: row.bsmSlsq, moveDirection: "down", }; // 接口待调 move(obj).then((res) => { console.log("222222222", res); this.clmlmxInit(); }); }, // 材料目录明细初始化 clmlmxInit () { this.id = this.$parent.$parent.$parent.id; this.unitData = this.$parent.$parent.$parent.unitData; var formdata = new FormData(); formdata.append("bsmSldy", this.unitData[0].bsmSldy); formdata.append("bsmSlsq", this.id); clmlInit(formdata).then((res) => { if (res.result.result) { 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; } }); }, // 新增弹窗保存 addSave (data) { let maxXh = 0; this.tableData && this.tableData.forEach((item) => { if (item.xh > maxXh) { maxXh = item.xh; } }); let obj = { bsmSlsq: this.id, xh: maxXh + 1, isrequired: "0", sjmc: data.clmc, sjlx: data.cllx, sfxjcl: "1", // 是否是新建材料 }; save(obj).then((res) => { if (res.code == 200) { this.$message({ message: "新增成功", type: "success", }); this.tableData = res.result ? res.result : []; // 加载表格 this.clmlmxInit(); } }); }, // 材料目录删除 handleDelete (index, row) { clmlDelete({ sjBsm: row.bsmSj }).then((res) => { if (res.code == 200) { this.$message({ message: "删除成功", type: "success", }); // 加载表格 this.clmlmxInit(); } }); }, // 材料目录关闭收起 iconClick () { this.menuOpen = !this.menuOpen; if (this.menuOpen) { this.iclass = "itemIcon el-icon-caret-bottom close"; } else { this.iclass = "itemIcon el-icon-caret-bottom open"; } }, // 材料目录点击选中 treeClick (item) { this.treeCheckId = item.bsmSj; this.title = item.sjmc; this.titleYs = 1; this.titleNum = item.children.length; }, // 小图片点击 imgClick (item, index) { this.showImg = item; this.titleYs = index + 1; }, // 字典 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; } }, }, }; </script> <style scoped lang='scss'> @import "~@/styles/mixin.scss"; .active { background: $light-blue !important; color: #fff; } .clxx { width: 100%; display: flex; padding-left: 15px; height: calc(100vh - 150px); .left { display: flex; flex-direction: column; justify-content: space-between; .item { width: 42px; height: 49%; @include flex-center; background-color: #E4E7ED; border-bottom-right-radius: 10px; padding: 15px; cursor: pointer; transition: all 0.3s; &:hover { @extend .active; } } } .right { width: 100%; height: 100%; padding: 0 15px; .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 { width: 100%; height: 100%; display: flex; .menu-tree { width: 20%; height: 100%; margin-right: 30px; border-right: 1px dotted #d9d9d9; padding: 0 24px; .item { height: 60px; line-height: 60px; border-bottom: 1px solid #e8e8e8; font-size: 16px; color: #4a4a4a; .itemIcon { float: right; line-height: 60px; cursor: pointer; } @keyframes open { 100% { transform: rotate(180deg); } } @keyframes close { 0% { transform: rotate(180deg); } 100% { transform: rotate(-0deg); } } .open { animation: open 0.5s; animation-fill-mode: both; } .close { animation: close 0.5s; animation-fill-mode: both; } .child { height: 60px; line-height: 60px; border-bottom: 1px solid #e8e8e8; padding-left: 18px; color: #6b6b6b; cursor: pointer; box-sizing: border-box; } .checked { border-radius: 6px; border: 1px solid #4083f9; } } } .clyl-img { width: 75%; height: 100%; background: #f3f4f7; margin: 0 auto; position: relative; } } } } </style>