<template>
|
<!--流程模板分类-->
|
<basic-container>
|
<avue-crud
|
ref="crud"
|
v-model="form"
|
:data="tableData"
|
:option="option"
|
:table-loading="tableLoading"
|
@on-load="getTableList"
|
@row-save="rowSaveHandler"
|
@row-update="rowUpdateHandler"
|
@row-click="rowClickHandler"
|
@selection-change="selectionChange"
|
>
|
<template slot="menuLeft" slot-scope="scope">
|
<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>
|
</basic-container>
|
</template>
|
|
<script>
|
import {mapGetters} from "vuex";
|
import basicOption from "@/util/basic-option";
|
import {deletePvolume, getPvolumesPage, savePvolume, updatePvolume} from "@/api/system/fileCab/api";
|
import func from "@/util/func";
|
|
export default {
|
name: "index",
|
data: function () {
|
return {
|
form:{},
|
tableLoading: false,
|
tableData: [],
|
currentRow:null,
|
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),
|
};
|
},
|
option(){
|
return {
|
...basicOption,
|
addBtn:false,
|
editBtn:false,
|
delBtn:false,
|
calcHeight: -60,
|
align:'left',
|
headerAlign:'center',
|
menuWidth:160,
|
dialogMenuPosition: 'right',
|
dialogWidth:600,
|
column: [
|
{
|
label: '分类名称',
|
prop: 'name',
|
span: 24,
|
rules: [{ required: true, message: '请输入分类名称', trigger: 'blur' }]
|
},{
|
label: '描述',
|
prop: 'desc',
|
span: 24,
|
type:'textarea'
|
}]
|
}
|
}
|
},
|
methods: {
|
// 表格请求
|
getTableList() {
|
this.tableLoading = true;
|
getPvolumesPage().then(res => {
|
this.tableData = res.data.data;
|
this.tableLoading = false;
|
})
|
},
|
|
// 新增
|
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()
|
});
|
},
|
|
handleEdit(row,index){
|
this.$refs.crud.rowEdit(row, index);
|
},
|
|
// 编辑
|
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()
|
});
|
},
|
|
// 删除
|
handleDel(row,index) {
|
let params = {
|
ids: row.id
|
}
|
|
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: '已取消删除'
|
});
|
});
|
},
|
|
//选择的行
|
selectionChange(list) {
|
this.selectionList = list;
|
},
|
|
// 行单选
|
rowClickHandler(row) {
|
func.rowClickHandler(
|
row,
|
this.$refs.crud,
|
this.lastIndex,
|
(newIndex) => {
|
this.lastIndex = newIndex;
|
},
|
() => {
|
this.selectionList = [row];
|
}
|
);
|
},
|
}
|
}
|
</script>
|
|
<style scoped>
|
|
</style>
|