This commit is contained in:
Alone
2024-09-14 15:10:43 +08:00
parent 6c64bbd82a
commit 610dee88cd
4241 changed files with 0 additions and 622695 deletions
-279
View File
@@ -1,279 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>资源分类</title>
{include file="common/header"/}
<el-form :inline="true">
<el-form-item>
<el-button icon="el-icon-plus" size="small" @click="clickAdd" plain>添加</el-button>
</el-form-item>
<el-form-item>
<el-button icon="el-icon-delete" size="small" @click="postMultDelete" plain>批量删除</el-button>
</el-form-item>
</el-form>
<el-table :data="dataList" @selection-change="changeSelection" v-loading="loading">
<el-table-column type="selection" width="50">
</el-table-column>
<el-table-column prop="source_category_id" label="ID" width="60">
</el-table-column>
<el-table-column prop="name" label="分类名称">
</el-table-column>
<el-table-column label="状态" width="80">
<template slot-scope="scope">
<el-switch v-model="scope.row.status==1?true:false" active-color="#ff4949"
@change="clickStatus(scope.row)">
</el-switch>
</template>
</el-table-column>
<el-table-column prop="sort" label="排序" width="80">
</el-table-column>
<el-table-column label="操作" width="180">
<template slot-scope="scope">
<el-link type="primary" @click="clickEdit(scope.row)" :underline="false">编辑</el-link>&nbsp;
<el-link type="danger" @click="clickDelete(scope.row)" :underline="false">删除</el-link>
</template>
</el-table-column>
</el-table>
<!-- 添加框 -->
<el-dialog title="添加资源分类名称" :visible.sync="dialogFormAdd" width="500px" :modal-append-to-body='false' append-to-body :close-on-click-modal='false'>
<el-form :model="formAdd" :rules="rules" ref="formAdd">
<el-form-item prop="name" label="分类名称" :label-width="formLabelWidth">
<el-input size="medium" autocomplete="off" v-model="formAdd.name"></el-input>
</el-form-item>
<el-form-item prop="sort" label="排序" :label-width="formLabelWidth">
<el-input-number v-model="formAdd.sort" :min="0" :max="999" size="medium" style="width: 120px;"
controls-position="right" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="postAdd()">确认添加</el-button>
</div>
</el-dialog>
<!-- 修改框 -->
<el-dialog title="修改资源分类信息" :visible.sync="dialogFormEdit" width="500px" :modal-append-to-body='false' append-to-body :close-on-click-modal='false'>
<el-form :model="formEdit" :rules="rules" ref="formEdit">
<el-form-item prop="name" label="分类名称" :label-width="formLabelWidth">
<el-input size="medium" autocomplete="off" v-model="formEdit.name"></el-input>
</el-form-item>
<el-form-item prop="sort" label="排序" :label-width="formLabelWidth">
<el-input-number v-model="formEdit.sort" :min="0" :max="999" size="medium" style="width: 120px;"
controls-position="right" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="postEdit()">确认修改</el-button>
</div>
</el-dialog>
{include file="common/footer"/}
<script>
var app = new Vue({
el: '#app',
data() {
this.getList();
return {
formLabelWidth: '80px',
dialogFormAdd: false,
dialogFormEdit: false,
loading: true,
dataList: [],
selectList: [],
formAdd: {
sort: 0
},
formEdit: {
},
rules: {
name: [ { required: true, message: '请输入分类名称', trigger: 'blur' }],
}
}
},
methods: {
postMultDelete() {
var that = this;
if (that.selectList.length == 0) {
that.$message.error('未选择任何分类!');
return;
}
this.$confirm('即将删除选中的分类, 是否确认?', '批量删除', {
confirmButtonText: '删除',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
axios.post('/admin/source_category/delete', Object.assign({}, PostBase, {
source_category_id: that.selectList.join(",")
}))
.then(function (response) {
that.getList();
if (response.data.code == CODE_SUCCESS) {
that.$message({
message: response.data.message,
type: 'success'
});
} else {
that.$message.error(response.data.message);
}
})
.catch(function (error) {
that.$message.error('服务器内部错误');
});
}).catch(() => {
});
},
changeSelection(list) {
var that = this;
that.selectList = [];
for (var index in list) {
that.selectList.push(list[index].source_category_id);
}
},
postEdit() {
var that = this;
that.$refs["formEdit"].validate((valid) => {
if (valid) {
axios.post('/admin/source_category/update', Object.assign({}, PostBase, that.formEdit))
.then(function (response) {
that.getList();
if (response.data.code == CODE_SUCCESS) {
that.$message({
message: response.data.message,
type: 'success'
});
that.dialogFormEdit = false;
} else {
that.$message.error(response.data.message);
}
})
.catch(function (error) {
that.$message.error('服务器内部错误');
console.log(error);
});
}
});
},
postAdd() {
var that = this;
that.$refs['formAdd'].validate((valid) => {
if (valid) {
axios.post('/admin/source_category/add', Object.assign({}, PostBase, that.formAdd))
.then(function (response) {
that.getList();
if (response.data.code == CODE_SUCCESS) {
that.$message({
message: response.data.message,
type: 'success'
});
that.dialogFormAdd = false;
} else {
that.$message.error(response.data.message);
}
})
.catch(function (error) {
that.$message.error('服务器内部错误');
console.log(error);
});
}
});
},
clickAdd() {
var that = this;
that.formAdd = { sort: 0 };
that.dialogFormAdd = true;
},
clickDelete(row) {
var that = this;
this.$confirm('即将删除这个分类, 是否确认?', '删除提醒', {
confirmButtonText: '删除',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
axios.post('/admin/source_category/delete', Object.assign({}, PostBase, {
source_category_id: row.source_category_id
}))
.then(function (response) {
that.getList();
if (response.data.code == CODE_SUCCESS) {
that.$message({
message: response.data.message,
type: 'success'
});
} else {
that.$message.error(response.data.message);
}
})
.catch(function (error) {
that.$message.error('服务器内部错误');
console.log(error);
});
}).catch(() => {
});
},
clickStatus(row) {
var that = this;
axios.post(row.status ? '/admin/source_category/enable' : '/admin/source_category/disable', Object.assign({}, PostBase, {
source_category_id: row.source_category_id
}))
.then(function (response) {
that.getList();
if (response.data.code == CODE_SUCCESS) {
that.$message({
message: response.data.message,
type: 'success'
});
} else {
that.$message.error(response.data.message);
}
})
.catch(function (error) {
that.$message.error('服务器内部错误');
console.log(error);
});
},
clickEdit(row) {
var that = this;
that.formEdit = row;
axios.post('/admin/source_category/detail', Object.assign({}, PostBase, {
source_category_id: row.source_category_id
}))
.then(function (response) {
if (response.data.code == CODE_SUCCESS) {
that.formEdit = response.data.data;
that.dialogFormEdit = true;
} else {
that.$message.error(response.data.message);
}
})
.catch(function (error) {
that.$message.error('服务器内部错误');
console.log(error);
});
},
getList() {
var that = this;
that.loading = true;
axios.post('/admin/source_category/getList', Object.assign({}, PostBase))
.then(function (response) {
that.loading = false;
if (response.data.code == CODE_SUCCESS) {
that.dataList = response.data.data;
} else {
that.$message.error(response.data.message);
}
})
.catch(function (error) {
that.loading = false;
that.$message.error('服务器内部错误');
console.log(error);
});
}
}
})
</script>
</html>