田源
2025-01-07 370b26066c560f15f6a84caca2be149e48e86556
Source/plt-web/plt-web-ui/src/views/system/fileCab/index.vue
@@ -2,133 +2,299 @@
  <!--文仓管理页面-->
  <basic-container>
    <avue-crud
      ref="logCrud"
      ref="crud"
      v-model="form"
      :data="tableData"
      :option="option"
      :page.sync="page"
      :table-loading="tableLoading"
      @on-load="getTableList"
      @refresh-change="handleRefresh"
      @search-change="handleSearch"
      @search-reset="handleReset"
      @size-change="sizeChange"
      @current-change="currentChange"
      @row-save="rowSaveHandler"
      @row-update="rowUpdateHandler"
      @row-click="rowClickHandler"
      @selection-change="selectionChange"
    >
      <template slot="menuLeft" slot-scope="scope">
        <el-button icon="el-icon-download" plain size="small" type="primary" @click="exportClickHandler">导出</el-button>
        <el-button v-if="permissionList.addBtn" class="button-custom-icon" size="small" type="primary"
                   @click="$refs.crud.rowAdd()">
          <icon-show :name="permissionList.addBtn.source"></icon-show>
          新 增
        </el-button>
        <el-button v-if="permissionList.exportBtn" class="button-custom-icon" plain size="small" type="primary" @click="exportClickHandler">
          <icon-show :name="permissionList.exportBtn.source"></icon-show>
          导出
        </el-button>
      </template>
      <template slot="menu" slot-scope="{ row, index }">
        <el-button
          v-if="permissionList.editBtn"
          size="small"
          type="text"
          @click="handleEdit(row, index)"
        >
          <icon-show :name="permissionList.editBtn.source"></icon-show>
          编辑
        </el-button>
        <el-button
          v-if="permissionList.delBtn"
          size="small"
          type="text"
          @click="handleDel(row, index)"
        >
          <icon-show :name="permissionList.delBtn.source"></icon-show>
          删除
        </el-button>
      </template>
    </avue-crud>
    <!-- 分配成员穿梭框   -->
    <transfer ref="transfer" :left-role-data="leftRoleData" :right-role-data="rightRoleData"
              :transferTitle="transferTitle" title="文件柜添加成员"
              @transferSend="roleSendHandler">
    </transfer>
  </basic-container>
</template>
<script>
import {exportLog, getLogListByContion} from "@/api/system/log/logBasic";
import {exportPvolumes, getPvolumesPage,savePvolume,updatePvolume,deletePvolume} from "@/api/system/fileCab/api";
import func from "@/util/func";
import basicOption from "@/util/basic-option";
import {listUserByRoleOid, listUserUnInRoleOid, saveRight} from "@/api/system/role/api";
import {mapGetters} from "vuex";
export default {
  name: "index",
  data: function () {
    return {
      form:{},
      tableLoading: false,
      tableData: [],
      option: {
      currentRow:null,
      leftRoleData: [],  // 分配成员穿梭框左侧初始数据
      rightRoleData: [], // 分配成员穿梭框右侧初始数据
      transferTitle: ['文件柜外成员', '文件柜内成员'],
      selectionList: [],
    }
  },
  computed: {
    ids() {
      let ids = [];
      this.selectionList.forEach(ele => {
        ids.push(ele.id);
      });
      return ids.join(",");
    },
    ...mapGetters(["permission"]),
    permissionList() {
      return {
        addBtn: this.vaildData(this.permission[this.$route.query.id].ADD, false),
        delBtn: this.vaildData(this.permission[this.$route.query.id].DELETE, false),
        editBtn: this.vaildData(this.permission[this.$route.query.id].EDIT, false),
        exportBtn: this.vaildData(this.permission[this.$route.query.id].EXPORT, false),
      };
    },
    option(){
      return  {
        ...basicOption,
        addBtn:false,
        editBtn: false,
        delBtn: false,
        editBtn:false,
        delBtn:false,
        calcHeight: -60,
        align:'left',
        headerAlign:'center',
        menu:false,
        searchMenuSpan: 6,
        searchIcon:false,
        menuWidth:160,
        dialogMenuPosition: 'right',
        dialogWidth:600,
        column: [
          {
            label: '卷名',
            prop: 'truename',
            width: 300
          }, {
            label: '机器类型',
            prop: 'username',
            width: 150
          },{
            label: '路径名称',
            prop: 'userIp'
          },{
            label: '首选路径',
            prop: 'moduleName',
            prop: 'name',
            width: 200,
            span: 24,
            rules: [{ required: true, message: '请输入卷名', trigger: 'blur' }]
          },{
            label: '服务器',
            prop: 'type',
            width: 150
            prop: 'host',
            span: 24,
            rules: [{ required: true, message: '请输入服务器', trigger: 'blur' }]
          },{
            label: '卷服务',
            prop: 'date',
            prop: 'service',
            span: 24,
            rules: [{ required: true, message: '请输入卷服务', trigger: 'blur' }]
          }, {
            label: '机器类型',
            prop: 'type',
            width: 120,
            span: 24,
            type:'radio',
            dicData:[{
              label:'Unix',
              value:0
            },{
              label:'Win NT',
              value:1
            }],
            value:1
          },{
            label: '路径名称',
            prop: 'path',
            span: 24,
            overHidden: true,
            rules: [{ required: true, message: '请输入路径名称', trigger: 'blur' }]
          },{
            label: '首选路径',
            prop: 'isvalid',
            width: 120,
            span: 24,
            type: 'switch',
            value:false,
            beforeChange: (done) => {debugger;
              this.$confirm('您确实要修改卷的首选路径吗?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
              }).then(() => {
                done(true);
              }).catch(() => {
                done(false);
              });
            },
          }]
      },
      page: {
        currentPage: 1,
        pageSize: 50,
        total: 0,
        pageSizes: [10, 30, 50, 100],
      },
      searchParams: {}
      }
    }
  },
  methods: {
    // 表格请求
    getTableList() {
      this.tableLoading = true;
      getLogListByContion(this.page.currentPage, this.page.pageSize, {'logType':this.$route.query.logType,...this.searchParams}).then(res => {
      getPvolumesPage().then(res => {
        this.tableData = res.data.data;
        this.page.total = res.data.total;
        this.tableLoading = false;
      })
    },
    // 搜索查询
    handleSearch(params, done) {
      this.searchParams = {
        userName:params.truename,
        ipText:params.userIp,
        startDate:params.date[0],
        endDate:params.date[1]
      };
      this.getTableList();
      done();
    // 新增
    rowSaveHandler(row, done, loading) {
      savePvolume(row).then(res => {
        if (res.data.code === 200) {
          this.$message.success(res.data.obj);
          this.getTableList();
          done();
        }
      }).catch(err => {
        loading()
      });
    },
    // 重置搜索条件
    handleReset() {
      this.searchParams = {};
      this.getTableList();
    handleEdit(row,index){
      this.$refs.crud.rowEdit(row, index);
    },
    // 条数
    sizeChange(val) {
      this.page.pageSize = val;
    // 编辑
    rowUpdateHandler(row, index, done, loading) {
      updatePvolume(row).then(res => {
        if (res.data.code === 200) {
          this.$message.success(res.data.obj);
          this.getTableList();
          done()
        }
      }).catch(err => {
        loading()
      });
    },
    // 页码
    currentChange(val) {
      this.page.currentPage = val;
    },
    // 删除
    handleDel(row,index) {
      let params = {
        ids: row.id
      }
    handleRefresh(){
      this.getTableList();
      this.$confirm('您确定要删除当前的卷节点吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        deletePvolume(params).then(res => {
          if (res.data.code === 200) {
            this.$message.success(res.data.obj);
            this.getTableList();
          }
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },
    // 导出
    exportClickHandler() {
      if (this.ids == null || this.ids == "") {
        this.$message({
          type: 'warning',
          message: '请勾选要导出的数据!'
        });
        return;
      }
      const loading = this.$loading({});
      exportLog().then(res => {
      exportPvolumes({"pvolumeIds": this.ids}).then(res => {
        func.downloadFileByBlobHandler(res);
        this.createdLoading = false
        this.$message.success('导出成功');
        loading.close();
      })
    },
    //分配成员
    userHandler(row, index) {
      this.currentRow = row;
      Promise.all([
        listUserUnInRoleOid({pkRole: row.id}),
        listUserByRoleOid({pkRole: row.id})
      ]).then(([unInRoleRes, byRoleRes]) => {
        if (unInRoleRes.data.code === 200 && byRoleRes.data.code === 200) {
          const leftData = [...unInRoleRes.data.data, ...byRoleRes.data.data];
          // 组装好穿梭框可用数据
          this.leftRoleData = leftData.map(item => {
            return {
              name: item.name + `(${item.id})`,
              oid: item.oid
            }
          })
          this.rightRoleData = byRoleRes.data.data.map(item => item.oid);
          this.$refs.transfer.visible = true;
        }
      });
    },
    // 分配成员穿梭框回填
    roleSendHandler(row) {
      let params = {
        userOids: row.join(','),
        roleId: this.currentRow.id
      }
      saveRight(params).then(res => {
        this.$message.success(res.data.obj);
        this.getTableList();
      })
    },
    //选择的行
    selectionChange(list) {
      this.selectionList = list;
    },
    // 行单选
    rowClickHandler(row) {
      func.rowClickHandler(
        row,
        this.$refs.crud,
        this.lastIndex,
        (newIndex) => {
          this.lastIndex = newIndex;
        },
        () => {
          this.selectionList = [row];
        }
      );
    },
  }
}
</script>