管道基础大数据平台系统开发-【前端】-新系統界面
584911253@qq.com
2023-03-02 8bb00665765e8348aeb3a6e799069287e503e1ab
src/views/userManage/resourceManage.vue
@@ -5,29 +5,19 @@
        `${$t('userManage.resManage')}`,
      ]"></My-bread>
    <el-divider />
    <div class="power_quire subpage_Div">
    <div class="power_quire subpage_Div" ref="container">
      <el-form
        ref="form"
        :model="ruleForm"
        :inline="true"
      >
        <el-form-item :label="$t('userManage.resManageObj.name')">
          <el-input v-model="ruleForm.name"></el-input>
        <div class="flex_box">
          <el-form-item :label="$t('userManage.resManageObj.name')" style="margin-right: auto">
          <el-input v-model="ruleForm.name" size="small" style="width:200px" :placeholder="$t('userManage.resManageObj.nameHolder')">
            <i slot="suffix" class="el-icon-search" @click="submitForm"></i>
          </el-input>
        </el-form-item>
        <el-form-item>
          <el-button
            @click="submitForm('ruleForm')"
            icon="el-icon-search"
            size="small"
            type="primary"
            style="background: #1890ff"
          >{{ $t('common.iquery') }}</el-button>
          <el-button
            @click="resetForm('ruleForm')"
            icon="el-icon-refresh"
            type="info"
            size="small"
          >{{ $t('common.empty') }}</el-button>
          <el-button
            v-if="menuStatus.insert"
            @click="setInsertFormdialog"
@@ -42,15 +32,33 @@
            type="danger"
            size="small"
          >{{ $t('common.delete') }}</el-button>
<!--          <el-button-->
<!--            @click="submitForm('ruleForm')"-->
<!--            icon="el-icon-search"-->
<!--            size="small"-->
<!--            type="primary"-->
<!--            style="background: #1890ff"-->
<!--          >{{ $t('common.iquery') }}</el-button>-->
          <el-button
            @click="resetForm('ruleForm')"
            icon="el-icon-refresh"
            type="info"
            size="small"
          >{{ $t('common.empty') }}</el-button>
        </el-form-item>
          </div>
      </el-form>
    </div>
    <div class="table_box ">
    <div class="dividing-line"></div>
    <div class="table_box" :style="styleVar">
      <el-table
        :data="tableData"
        style="width: 100%"
        fit
        border
        @selection-change="handleSelectionChange"
         height="calc(100% - 45px)"
      >
        <el-table-column
          type="selection"
@@ -106,7 +114,7 @@
        >
        </el-table-column>
        <el-table-column
          fixed="right"
          :label="$t('common.operate')"
          width="170px"
        >
@@ -127,8 +135,7 @@
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="pagination_box">
      <div class="pagination_box" style="margin-top: 10px">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
@@ -140,9 +147,11 @@
      >
      </el-pagination>
    </div>
    </div>
     <div class="infoBox_box" v-show="showinfoBox">
    <div
      class="infoBox box_div "
      v-show="showinfoBox"
    >
      <div
        slot="header"
@@ -231,10 +240,10 @@
      </div>
    </div>
     </div>
    <el-dialog
      :title="dialogTitle"
      :visible.sync="isTransfer"
      width="800px"
      append-to-body
    >
      <el-tree
@@ -261,9 +270,9 @@
      :title="$t('userManage.resManageObj.addResource')"
      style="overflow: hidden"
      :visible.sync="InsertFormdialog"
      top="3%"
    >
      <el-form :model="insertform">
     <div style="height: 500px; overflow: auto">
      <el-form :model="insertform" label-position="top">
        <el-form-item
          :label="$t('userManage.resManageObj.name')"
          :label-width="formLabelWidth"
@@ -271,6 +280,7 @@
          <el-input
            v-model="insertform.name"
            autocomplete="off"
            style="width:85%"
          ></el-input>
        </el-form-item>
        <el-form-item
@@ -280,6 +290,7 @@
          <el-input
            v-model="insertform.server"
            autocomplete="off"
            style="width:85%"
          ></el-input>
        </el-form-item>
        <el-form-item
@@ -289,6 +300,7 @@
          <el-input
            v-model="insertform.source"
            autocomplete="off"
            style="width:85%"
          ></el-input>
        </el-form-item>
        <el-form-item
@@ -299,7 +311,7 @@
            :popper-append-to-body="false"
            v-model="insertform.depValue"
            placeholder="请选择"
            style="width:92.5%"
            style="width:85%"
          >
            <el-option
              :value="insertform.depid"
@@ -334,7 +346,7 @@
            :popper-append-to-body="false"
            v-model="insertform.dirValue"
            placeholder="请选择"
            style="width:92.5%"
            style="width:85%"
          >
            <el-option
              :value="insertform.dirid"
@@ -359,18 +371,26 @@
          <el-input
            v-model="insertform.descr"
            autocomplete="off"
            style="width:85%"
          ></el-input>
        </el-form-item>
        <el-form-item
          :label="$t('userManage.resManageObj.img')"
          :label-width="formLabelWidth"
        >
          <el-input
         <div class="BoxFlex">
           <div class="BoxFlexinput">
             <el-input
            v-model="insertform.img"
            disabled
            autocomplete="off"
            style="width:100%"
          ></el-input>
          <input
          </div>
           <div class="BoxFlexbutton">
             <input
            name="file1"
            :accept="'.jpg,.png'"
            type="file"
@@ -379,18 +399,21 @@
            style="display: none"
            @change="insertFile"
          />
          <el-link
              <el-link
            :title="$t('common.append')"
            :underline="false"
            @click="getIsertFile"
            style="margin-left: 10px"
            style="margin-left: 6px"
          ><i class="el-icon-plus"></i></el-link>
          <el-link
            :title="$t('common.upload')"
            :underline="false"
            @click="setUploadFile(0)"
            style="margin-left: 10px"
          ><i class="el-icon-upload2"></i></el-link>
           </div>
         </div>
        </el-form-item>
        <el-form-item
          :label="$t('userManage.resManageObj.bak')"
@@ -399,10 +422,12 @@
          <el-input
            v-model="insertform.bak"
            autocomplete="off"
            style="width:85%"
          ></el-input>
        </el-form-item>
      </el-form>
     </div>
      <div
        slot="footer"
        class="dialog-footer"
@@ -424,11 +449,12 @@
    </el-dialog>
    <el-dialog
      :title="$t('userManage.userInfoObj.editPermission')"
      style="overflow: hidden"
      :visible.sync="EditFormdialog"
      :before-close="EditFromDataClose"
    >
      <el-form :model="upform">
        <div style="height: 500px; overflow: auto">
      <el-form :model="upform" label-position="top">
        <el-form-item
          :label="$t('userManage.resManageObj.name')"
          :label-width="formLabelWidth"
@@ -436,6 +462,7 @@
          <el-input
            v-model="upform.name"
            autocomplete="off"
            style="width:85%"
          ></el-input>
        </el-form-item>
        <el-form-item
@@ -445,6 +472,7 @@
          <el-input
            v-model="upform.server"
            autocomplete="off"
            style="width:85%"
          ></el-input>
        </el-form-item>
        <el-form-item
@@ -454,6 +482,7 @@
          <el-input
            v-model="upform.source"
            autocomplete="off"
            style="width:85%"
          ></el-input>
        </el-form-item>
        <el-form-item
@@ -464,7 +493,7 @@
            :popper-append-to-body="false"
            v-model="upform.depValue"
            placeholder="请选择"
            style="width:92.5%"
            style="width:85%"
          >
            <el-option
              :value="upform.depid"
@@ -499,7 +528,7 @@
            :popper-append-to-body="false"
            v-model="upform.dirValue"
            placeholder="请选择"
            style="width:92.5%"
            style="width:85%"
          >
            <el-option
              :value="upform.dirid"
@@ -534,17 +563,24 @@
          <el-input
            v-model="upform.descr"
            autocomplete="off"
            style="width:85%"
          ></el-input>
        </el-form-item>
        <el-form-item
          :label="$t('userManage.resManageObj.img')"
          :label-width="formLabelWidth"
        >
         <div class="BoxFlex">
            <div class="BoxFlexinput">
          <el-input
            v-model="upform.img"
            disabled
            autocomplete="off"
             style="width:100%"
          ></el-input>
            </div>
 <div class="BoxFlexbutton">
          <input
            name="file1"
            :accept="'.jpg,.png'"
@@ -566,6 +602,8 @@
            @click="setUploadFile(1)"
            style="margin-left: 10px"
          ><i class="el-icon-upload2"></i></el-link>
 </div>
         </div>
        </el-form-item>
        <el-form-item
          :label="$t('userManage.resManageObj.bak')"
@@ -574,10 +612,12 @@
          <el-input
            v-model="upform.bak"
            autocomplete="off"
            style="width:85%"
          ></el-input>
        </el-form-item>
      </el-form>
        </div>
      <div
        slot="footer"
        class="dialog-footer"
@@ -648,10 +688,10 @@
</template>
<script>
import $ from 'jquery';
import { getToken } from '../../utils/auth.js';
import moment from 'moment';
import MyBread from '../../components/MyBread.vue';
import $ from "jquery";
import { getToken } from "../../utils/auth.js";
import moment from "moment";
import MyBread from "../../components/MyBread.vue";
import {
  select_Res_ByPageAndCount,
  insertRes,
@@ -660,17 +700,17 @@
  upload_res,
  selectdirTab,
  selectdepTab,
} from '../../api/api.js';
import styleDirTree from '../datamanage/styleDirTree.vue';
import styleDepTree from '../datamanage/styleDepTree.vue';
} from "../../api/api.js";
import styleDirTree from "../datamanage/styleDirTree.vue";
import styleDepTree from "../datamanage/styleDepTree.vue";
export default {
  components: { MyBread, styleDirTree, styleDepTree },
  data() {
    return {
      props: {
        label: 'name',
        value: 'id',
        children: 'children',
        label: "name",
        value: "id",
        children: "children",
        checkStrictly: true,
        emitPath: false,
      },
@@ -682,10 +722,10 @@
        update: false,
        upload: false,
      },
      formLabelWidth: '130px',
      formLabelWidth: "130px",
      ruleForm: {},
      isTransfer: false,
      dialogTitle: '',
      dialogTitle: "",
      data: [],
      InsertFormdialog: false,
      showinfoBox: false,
@@ -697,13 +737,13 @@
      ImageFile: null,
      uploadFile: null,
      insertform: {
        img: '',
        depValue: '',
        dirValue: ''
        img: "",
        depValue: "",
        dirValue: "",
      },
      tableData: [],
      itemdetail: {},
      upform: { img: '' },
      upform: { img: "" },
      multipleSelection: [],
      count: 0,
      listData: {
@@ -712,8 +752,13 @@
        pageSize: 10,
      },
      defaultProps: {
        children: 'children',
        label: 'label',
        children: "children",
        label: "label",
      },
      tableHeight: 0,
      timer: 0,
      styleVar: {
        height: "calc(100% - 109px)",
      },
    };
  },
@@ -728,22 +773,43 @@
    }
    this.getRoleTabelData();
  },
  mounted() {
    window.addEventListener("resize", this.onResize);
    this.calHeight();
  },
  beforeDestroy() {
    this.timer && clearTimeout(this.timer);
    window.removeEventListener("resize", this.onResize);
  },
  methods: {
    onResize() {
      this.timer && clearTimeout(this.timer);
      this.timer = setTimeout(() => {
        this.calHeight();
      }, 500);
    },
    calHeight() {
      this.$nextTick(() => {
        const rect = this.$refs.container.getBoundingClientRect();
        this.tableHeight = `${rect.height + 97}px`;
        // this.styleVar["height"] = `calc(100% - ${rect.height + 97}px)`;
        this.styleVar["height"] = `calc(100% - ${rect.height + 30}px)`;
      });
    },
    handleEditDepList(data, node, nodeData) {
      this.upform.depid = data.id
      this.upform.depid = data.id;
      this.upform.depValue = data.name;
    },
    handleEditDirList(data, node, nodeData) {
      this.upform.dirid = data.id
      this.upform.dirid = data.id;
      this.upform.dirValue = data.name;
    },
    handleDepList(data, node, nodeData) {
      this.insertform.depid = data.id
      this.insertform.depid = data.id;
      this.insertform.depValue = data.name;
    },
    handleDirList(data, node, nodeData) {
      this.insertform.dirid = data.id
      this.insertform.dirid = data.id;
      this.insertform.dirValue = data.name;
    },
    treeData(source) {
@@ -751,7 +817,7 @@
      return cloneData.filter((father) => {
        // 循环所有项
        let branchArr = cloneData.filter((child) => father.id == child.pid); // 对比ID,分别上下级菜单,并返回数据
        branchArr.length > 0 ? (father.children = branchArr) : ''; // 给父级添加一个children属性,并赋值
        branchArr.length > 0 ? (father.children = branchArr) : ""; // 给父级添加一个children属性,并赋值
        // 属于同一对象问题,例如:令 a=b、c=1 ,然后再令 b.c=c , 那么 a.c=b.c=c=1 ;同理,后续令 c.d=2 ,那么 a.c.d 也是=2;
        // 由此循环多次后,就能形成相应的树形数据结构
        return father.pid == 0; // 返回一级菜单
@@ -760,16 +826,16 @@
    async getDepList() {
      const data = await selectdepTab();
      if (data.code != 200) {
        return this.$message.error('单位列表调用失败');
        return this.$message.error("单位列表调用失败");
      }
      this.depList = this.treeData(data.result)
      this.depList = this.treeData(data.result);
    },
    async getDirList() {
      const data = await selectdirTab();
      if (data.code != 200) {
        return this.$message.error('目录列表调用失败');
        return this.$message.error("目录列表调用失败");
      }
      this.dirList = this.treeData(data.result)
      this.dirList = this.treeData(data.result);
    },
    setInsertFormdialog() {
      this.getDepList();
@@ -778,59 +844,59 @@
    },
    showPermsMenu(res) {
      switch (res.tag) {
        case '/delete':
        case "/delete":
          this.menuStatus.delete = true;
          break;
        case '/insert':
        case "/insert":
          this.menuStatus.insert = true;
          break;
        case '/update':
        case "/update":
          this.menuStatus.update = true;
          break;
        case '/upload':
        case "/upload":
          this.menuStatus.upload = true;
          break;
      }
    },
    getIsertFile() {
      $('#imageFile').click();
      $("#imageFile").click();
    },
    getupdateFile() {
      $('#editimageFile').click();
      $("#editimageFile").click();
    },
    async setUploadFile(res) {
      var fs;
      if (res == 0) {
        fs = document.getElementById('imageFile');
        fs = document.getElementById("imageFile");
      } else if (res == 1) {
        fs = document.getElementById('editimageFile');
        fs = document.getElementById("editimageFile");
        if (fs.files.length == 0) {
          return;
        }
      }
      var formData = new FormData();
      formData.append('file', fs.files[0]);
      formData.append("file", fs.files[0]);
      var val_data = await upload_res(formData);
      if (val_data.code == 200) {
        this.uploadFile = val_data.result;
        this.$message({
          message: '上传成功!',
          type: 'success',
          message: "上传成功!",
          type: "success",
        });
      } else {
        this.$message({
          message: '上传失败!',
          type: 'warning',
          message: "上传失败!",
          type: "warning",
        });
      }
    },
    insertFile() {
      var val = document.getElementById('imageFile').files;
      var val = document.getElementById("imageFile").files;
      if (!val || !val.length) return;
      this.insertform.img = val[0].name;
    },
    updateFile() {
      var val = document.getElementById('editimageFile').files;
      var val = document.getElementById("editimageFile").files;
      if (!val || !val.length) return;
      this.upform.img = val[0].name;
    },
@@ -874,19 +940,46 @@
      for (var i in this.multipleSelection) {
        std.push(this.multipleSelection[i].id);
      }
      const data = await deleteRess({ ids: std.toString() });
      if (data.code == 200) {
        this.$message({
          message: '删除成功!',
          type: 'success',
      this.$confirm("此操作将永久删除所选内容, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(async () => {
          const data = await deleteRess({ ids: std.toString() });
          if (data.code == 200) {
            this.$message({
              message: "删除成功!",
              type: "success",
            });
            this.getRoleTabelData();
          } else {
            this.$message({
              message: "删除失败!",
              type: "warning",
            });
          }
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
        this.getRoleTabelData();
      } else {
        this.$message({
          message: '删除失败!',
          type: 'warning',
        });
      }
      // const data = await deleteRess({ ids: std.toString() });
      // if (data.code == 200) {
      //   this.$message({
      //     message: '删除成功!',
      //     type: 'success',
      //   });
      //   this.getRoleTabelData();
      // } else {
      //   this.$message({
      //     message: '删除失败!',
      //     type: 'warning',
      //   });
      // }
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
@@ -912,14 +1005,14 @@
        this.upform = {};
        this.uploadFile = null;
        this.$message({
          message: '修改成功!',
          type: 'success',
          message: "修改成功!",
          type: "success",
        });
        this.getRoleTabelData();
      } else {
        this.$message({
          message: '修改失败!',
          type: 'warning',
          message: "修改失败!",
          type: "warning",
        });
      }
    },
@@ -935,8 +1028,9 @@
        this.itemdetail.updateTime
      );
      this.itemdetail.imageFile = BASE_URL + '/res/download?guid=' + row.img + '&token=' + token;
      console.log(this.itemdetail.imageFile)
      this.itemdetail.imageFile =
        BASE_URL + "/res/download?guid=" + row.img + "&token=" + token;
      console.log(this.itemdetail.imageFile);
    },
    handleEdit(index, row) {
      this.getDepList();
@@ -965,8 +1059,8 @@
    async insertFromData() {
      if (this.insertform.dirid == null || this.insertform.depid == null) {
        this.$message({
          message: '请选择资源所属的目录或单位',
          type: 'warning',
          message: "请选择资源所属的目录或单位",
          type: "warning",
        });
        return;
      }
@@ -977,29 +1071,29 @@
      if (data.code == 200) {
        this.InsertFormdialog = false;
        this.insertform = {
          img: '',
          img: "",
        };
        this.uploadFile = null;
        this.$message({
          message: '添加成功!',
          type: 'success',
          message: "添加成功!",
          type: "success",
        });
        this.getRoleTabelData();
      } else {
        this.$message({
          message: '添加失败!',
          type: 'warning',
          message: "添加失败!",
          type: "warning",
        });
      }
    },
    async getRoleTabelData() {
      if (this.listData.tab == '') {
      if (this.listData.tab == "") {
        delete this.listData.tab;
      }
      this.listData.name = this.ruleForm.name;
      const data = await select_Res_ByPageAndCount(this.listData);
      if (data.code != 200) {
        this.$message.error('列表调用失败');
        this.$message.error("列表调用失败");
      }
      this.tableData = data.result;
      this.count = data.count;
@@ -1012,7 +1106,7 @@
      if (date === undefined || date === null) {
        return;
      }
      return moment(parseInt(date)).format('YYYY-MM-DD HH:mm:ss');
      return moment(parseInt(date)).format("YYYY-MM-DD HH:mm:ss");
    },
    handleClick(row) {
      this.dialogTitle = row.name;
@@ -1026,18 +1120,20 @@
.power_box {
  height: 98%;
  width: 98%;
  padding: 1%;
  padding: 0.5%;
  .el-input {
    width: 730px;
  }
  .power_quire {
    padding: 10px;
    //padding: 10px;
    //margin-top: 20px;
    border-radius: 5px;
    margin-bottom: 10px;
    //margin-bottom: 20px;
    .el-form-item {
      margin: 5px;
    }
@@ -1067,4 +1163,3 @@
  }
}
</style>