vue-apps/com.actionsoft.apps.coe.pal/views/workspace/WorkspaceManage.vue
shangxiaoran@qq.com 9d8f9f0e92 初始化应用
2022-06-28 01:29:37 +08:00

235 lines
7.0 KiB
Vue

<template>
<el-container id="workspaceManage">
<el-main id="workspaceManageMain" style="height: 100%;">
<el-table
id="workspaceManageTable"
ref="workspaceManageTable"
:data="tableData"
style="width: 100%;"
:height="tableHeight">
<el-table-column
prop="name"
label="资产库"
min-width="250">
<template slot-scope="scope">
<div>
<div>
<p class="text-general-color">
{{scope.row.name}}
</p>
</div>
<div style="display:table;">
<p class="text-second-color" style="font-size: 12px;">
{{scope.row.desc}}
</p>
</div>
</div>
</template>
</el-table-column>
<el-table-column
prop="admin"
label="管理员"
min-width="180">
</el-table-column>
<el-table-column
prop="count"
label="文件量"
min-width="150">
</el-table-column>
<el-table-column
prop="open"
label="启用"
min-width="150">
<template slot-scope="scope">
<el-switch
style="display: block"
v-model="scope.row.open"
active-color="#4E7FF9"
inactive-color="#E2E2E2"
@change="changeWsStatus(scope.row.wsId, scope.row.name, scope.row.open)">
</el-switch>
</template>
</el-table-column>
<el-table-column
prop="operation"
label="操作">
<template slot-scope="scope">
<div class="operate-icon-display">
<i v-if="scope.row.open" class="el-icon-setting" style="cursor: pointer;" @click="updateWorkspace(scope.row.wsId)"></i>
<i v-if="!scope.row.open" class="el-icon-delete" style="cursor: pointer;" @click="deleteWorkspace(scope.row.wsId, scope.row.name)"></i>
</div>
</template>
</el-table-column>
</el-table>
<WorkspaceUpdate ref="workspaceUpdate"></WorkspaceUpdate>
</el-main>
</el-container>
</template>
<script>
import WorkspaceUpdate from "./WorkspaceUpdate";
import awsuiAxios from "../../awsuiAxios";
export default {
name: "WorkspaceManage",
components: {WorkspaceUpdate},
data() {
return {
tableHeight: (parseInt(this.$store.getters.getTopMainHeightFn) - 22) + 'px',
tableData: []
}
},
computed: {
listenTopMainHeight() {
return this.$store.getters.getTopMainHeightFn;
}
},
created() {
},
mounted() {
const that = this;
that.initData();
},
methods: {
initData() {
const that = this;
const data = {
url:'jd',
data:{
cmd : 'com.actionsoft.apps.coe.pal_ws_manage_data'
}
};
awsuiAxios.post(data).then(function (ro) {
if (ro.result == 'ok') {
let data = ro.data.data;
that.tableData = data;
that.$refs.workspaceManageTable.bodyWrapper.scrollTop = 0;
}
}).catch(error=>{
console.log(error);
})
},
changeWsStatus(wsId, name, open) {// 开启、停用资产库
let state = 1;// 停用
let str = '停用';
if (open) {
state = 0;// 启用
str = '启用';
}
const that = this;
that.$confirm('确定' + str + '[' + name + ']吗?', '提示', {
confirmButtonText: '确定',
confirmButtonClass: 'button-general-color',
cancelButtonText: '取消',
closeOnClickModal: false,
closeOnPressEscape: false,
showClose: true,
type: 'warning'
}).then(() => {
const data = {
url:'jd',
data:{
cmd : 'com.actionsoft.apps.coe.pal_ws_stoporopen',
id : wsId,
state : state
}
};
awsuiAxios.post(data).then(function (ro) {
if (ro.msg == "1") {
// 成功,刷新当前页面
that.$message({
message: str + '成功',
type: 'success'
});
that.initData();
} else {
that.$message.error('变更状态失败请稍后重试');
}
}).catch(error=>{
console.log(error);
})
}).catch(() => {
for (var currRowData in that.tableData) {
if (that.tableData[currRowData].wsId == wsId) {
if (open) {
that.tableData[currRowData].open = false;
} else {
that.tableData[currRowData].open = true;
}
}
}
});
},
deleteWorkspace(wsId, name) {// 删除资产库
const that = this;
that.$confirm('确定要删除吗?', '提示', {
confirmButtonText: '确定',
confirmButtonClass: 'button-general-color',
cancelButtonText: '取消',
closeOnClickModal: false,
closeOnPressEscape: false,
showClose: true,
type: 'warning'
}).then(() => {
const data = {
url:'jd',
data:{
cmd : 'com.actionsoft.apps.coe.pal_ws_remove',
id : wsId,
}
};
awsuiAxios.post(data).then(function (ro) {
if (ro.msg == "1") {
// 成功,刷新当前页面
that.$message({
message: '删除成功',
type: 'success'
});
that.initData();
} else {
that.$message.error('删除失败请稍后重试');
}
}).catch(error=>{
console.log(error);
})
}).catch(() => {
});
},
updateWorkspace(wsId) {// 更新资产库
this.$refs.workspaceUpdate.openUpdateWsDlg('update', wsId, this);
},
updateWorkspaceCallback() {
this.initData();
}
},
watch : {
listenTopMainHeight: function (newd, old) {
this.tableHeight = (parseInt(newd)) - 22 + 'px';
}
}
}
</script>
<style scoped>
#workspaceManage >>> .el-main {
display: block;
-webkit-box-flex: 1;
-ms-flex: 1;
flex: 1;
-ms-flex-preferred-size: auto;
flex-basis: auto;
overflow: auto;
padding-top: 20px;
padding-left: 20px;
padding-right: 0px;
padding-bottom: 0px;
}
#workspaceManage >>> .el-table__row .operate-icon-display{
display: none;
}
#workspaceManage >>> .el-table__row:hover .operate-icon-display{
display: inline-block;
}
</style>