wangting
2024-10-23 dbcbde4397e0d0d28cf77a1cfafbe9a801d32182
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<template>
  <!--文仓管理页面-->
  <basic-container>
    <avue-crud
      ref="logCrud"
      :data="tableData"
      :option="option"
      :table-loading="tableLoading"
      @on-load="getTableList"
      @row-save="rowSaveHandler"
      @row-update="rowUpdateHandler"
      @row-del="rowDeleteHandler"
    >
      <template slot="menuLeft" slot-scope="scope">
        <el-button icon="el-icon-download" plain size="small" type="primary" @click="exportClickHandler">导出</el-button>
      </template>
      <template #menu="{row,index,size}">
        <el-button icon="el-icon-user" type="text" size="small" @click="userHandler(row,index)">分配成员</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 func from "@/util/func";
import basicOption from "@/util/basic-option";
import {addUser, deleteUser, updateUser} from "@/api/system/user/api";
import {listUserByRoleOid, listUserUnInRoleOid, saveRight} from "@/api/system/role/api";
 
export default {
  name: "index",
  data: function () {
    return {
      tableLoading: false,
      tableData: [],
      option: {
        ...basicOption,
        calcHeight: -60,
        align:'left',
        headerAlign:'center',
        menuWidth:260,
        dialogMenuPosition: 'right',
        dialogWidth:600,
        column: [
          {
            label: '卷名',
            prop: 'truename',
            width: 200,
            span: 24,
            rules: [{ required: true, message: '请输入卷名', trigger: 'blur' }]
          },{
            label: '服务器',
            prop: 'type',
            span: 24,
            rules: [{ required: true, message: '请输入服务器', trigger: 'blur' }]
          },{
            label: '卷服务',
            prop: 'date',
            span: 24,
            rules: [{ required: true, message: '请输入卷服务', trigger: 'blur' }]
          }, {
            label: '机器类型',
            prop: 'username',
            width: 120,
            span: 24,
            type:'radio',
            dicData:[{
              label:'Unix',
              value:'Unix'
            },{
              label:'Win NT',
              value:'Win NT'
            }],
            value:'Win NT'
          },{
            label: '路径名称',
            prop: 'userIp',
            span: 24,
            overHidden: true,
            rules: [{ required: true, message: '请输入路径名称', trigger: 'blur' }]
          },{
            label: '首选路径',
            prop: 'loc',
            width: 120,
            span: 24,
            type: 'switch',
            value:false
          }]
      },
      currentRow:null,
      leftRoleData: [],  // 分配成员穿梭框左侧初始数据
      rightRoleData: [], // 分配成员穿梭框右侧初始数据
      transferTitle: ['文件柜外成员', '文件柜内成员'],
    }
  },
  methods: {
    // 表格请求
    getTableList() {
      this.tableLoading = true;
      getLogListByContion(1, 50, {}).then(res => {
        this.tableData = res.data.data;
        this.tableLoading = false;
      })
    },
 
    // 新增
    rowSaveHandler(row, done,loading) {
      addUser(row).then(res => {
        if (res.data.code === 200) {
          this.$message.success(res.data.obj);
          this.getTableList();
          done();
        }
      }).catch(err => {
        loading()
      });
    },
 
    // 编辑
    rowUpdateHandler(row, index, done,loading) {
      updateUser(row).then(res => {
        if (res.data.code === 200) {
          this.$message.success(res.data.obj);
          this.getTableList();
          done()
        }
      }).catch(err => {
        loading()
      });
    },
 
    // 删除
    rowDeleteHandler(row) {
      let params = {
        ids: row.id
      }
 
      this.$confirm('您确定要删除当前的卷节点吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        deleteUser(params).then(res => {
          if (res.data.code === 200) {
            this.$message.success(res.data.obj);
            this.getTableList();
          }
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },
    // 导出
    exportClickHandler() {
      const loading = this.$loading({});
      exportLog().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();
      })
    },
  }
}
</script>
 
<style scoped>
 
</style>