梦学谷项目分析
Posted 一只燕仔
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了梦学谷项目分析 相关的知识,希望对你有一定的参考价值。
项目代码如下:
<template>
<div>
<!-- 面包屑 -->
<bread />
<div class="body">
<!-- 栅格化 -->
<el-row :span="24">
<el-col :span="4"
><el-input v-model="serachForm.VendorName" placeholder="供应商名称"></el-input
></el-col>
<el-col :span="4"
><el-input v-model="serachForm.Linkman" placeholder="联系人"></el-input
></el-col>
<el-col :span="4"
><el-input v-model="serachForm.Telephone" placeholder="联系电话"></el-input
></el-col>
<el-col :span="5">
<el-button type="primary" @click="searchProvide">查询</el-button>
<el-button type="primary" @click="addDialog = true">新增</el-button>
<el-button @click="resetProvider">重置</el-button>
</el-col>
<el-col :span="5"></el-col>
</el-row>
</div>
<!-- 表格 -->
<el-table
min-height="390px"
:data="provideList"
border
style="width: 100%; margin-top: 7px"
>
<el-table-column type="index" label="序号" width="70"> </el-table-column>
<el-table-column prop="name" label="供应商名称" width="130">
</el-table-column>
<el-table-column prop="linkman" label="联系人"> </el-table-column>
<el-table-column prop="mobile" label="联系电话"> </el-table-column>
<el-table-column prop="remark" label="备注"> </el-table-column>
<el-table-column label="操作" width="160">
<template slot-scope="scope">
<el-button size="mini" @click="editProvider(scope.row.id)"
>编辑</el-button
>
<el-button
size="mini"
type="danger"
@click="deleteProvider(scope.row.id)"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<el-pagination
@size-change="ChangeSize"
@current-change="ChangePage"
:current-page="queryInfo.pagenum"
:page-sizes="[10, 20, 30, 40]"
:page-size="queryInfo.pagesize"
layout="total, sizes, prev, pager, next, jumper"
:total="total"
>
</el-pagination>
<!-- 添加弹框 -->
<el-dialog
title="添加供应商"
:visible.sync="addDialog"
width="50%"
@close="addClosed"
>
<!-- 内容区域 -->
<el-form
:model="addForm"
:rules="rules"
ref="addFormRef"
label-width="130px"
>
<el-form-item label="供应商名称" prop="name">
<el-input v-model="addForm.name"></el-input>
</el-form-item>
<el-form-item label="联系人" prop="linkman">
<el-input v-model="addForm.linkman"></el-input>
</el-form-item>
<el-form-item label="联系电话" prop="mobile">
<el-input v-model="addForm.mobile"></el-input>
</el-form-item>
<el-form-item label="备注" prop="remark">
<textarea v-model="addForm.remark" cols="70" rows="5"></textarea>
</el-form-item>
</el-form>
<!-- 底部区域 -->
<span slot="footer" class="dialog-footer">
<el-button @click="addDialog = false">取 消</el-button>
<el-button type="primary" @click="addProvider">确 定</el-button>
</span>
</el-dialog>
<!-- 编辑弹框 -->
<el-dialog
title="修改供应商"
:visible.sync="editDialog"
@close="editClosed()"
width="50%"
>
<!-- 内容区域 -->
<el-form
:model="editForm"
:rules="rules"
ref="editFormRef"
label-width="130px"
>
<el-form-item label="供应商名称" prop="name">
<el-input v-model="editForm.name"></el-input>
</el-form-item>
<el-form-item label="联系人" prop="linkman">
<el-input v-model="editForm.linkman"></el-input>
</el-form-item>
<el-form-item label="联系电话" prop="mobile">
<el-input v-model="editForm.mobile"></el-input>
</el-form-item>
<el-form-item label="备注" prop="remark">
<textarea v-model="editForm.remark" cols="70" rows="5"></textarea>
</el-form-item>
</el-form>
<!-- 底部区域 -->
<span slot="footer" class="dialog-footer">
<el-button @click="editDialog = false">取 消</el-button>
<el-button type="primary" @click="edit">确 定</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import bread from "../bread";
export default {
name: "",
data() {
return {
provideList: [], //供应商数据列表
serachForm: {
VendorName: "", //供应商名称搜索
Linkman: "", //联系人搜索
Telephone: "", //联系电话搜索
},
queryInfo: {
query: "",
pagenum: 1, //分页参数
pagesize: 10,
},
total: 0, //总条数
addDialog: false, //控制添加模态框的显示隐藏
addForm: {
//添加
name: "",
linkman: "",
mobile: "",
remark: "",
},
rules: {
//规则
name: [
{ required: true, message: "请输入供应商名称", trigger: "blur" },
],
linkman: [{ required: true, message: "请输入联系人", trigger: "blur" }],
mobile: [
{ required: true, message: "请输入联系电话", trigger: "blur" },
],
},
editDialog: false, //控制修改模态框的显示隐藏
editForm: {},
};
},
props: [], //接收父组件传过来的值
components: {},
mounted() {
this.getProvider();
},
methods: {
//获取供应商列表
getProvider() {
this.$http.post("supplier/list/search/1/10").then((res) => {
console.log(res);
this.provideList = res.data.rows;
console.log(this.provideList)
this.total = res.data.total;
});
},
//改变条数
ChangeSize(newSize) {
this.queryInfo.pagesize = newSize;
this.getProvider();
},
//改变页面
ChangePage(current) {
this.queryInfo.pagenum = current;
this.getProvider();
},
//删除供应商
deleteProvider(id) {
this.$confirm("此操作将永久删除该供应商, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
this.$http.delete("supplier/" + id).then((res) => {
/* console.log(res); */
if (res.code !== 2000) {
this.$message.error(res.message);
} else {
this.getProvider();
this.$message.success(res.message);
}
});
})
.catch(() => {
this.$message({
type: "info",
message: "已取消删除",
});
});
},
//重置input框
resetProvider() {
(this.serachForm.VendorName = ""), (this.serachForm.Linkman = ""), (this.serachForm.Telephone = "");
},
//新增供应商
addProvider() {
this.$refs.addFormRef.validate((valid) => {
/* console.log(valid) */
if (!valid) {
return;
} else {
this.$http.post(`supplier`, this.addForm).then((res) => {
/* console.log(res) */
if (res.code !== 2000) {
this.$message.error(res.message);
} else {
this.$message.success(res.message);
this.addDialog = false;
this.getProvider();
}
});
}
});
},
//关闭添加模态框,并重置表单
addClosed() {
this.$refs.addFormRef.resetFields();
},
//关闭编辑模态框
editClosed() {
this.$refs.editFormRef.resetFields();
},
//编辑供应商信息
editProvider(id) {
console.log(id);
this.$http.get(`supplier/${id}`).then((res) => {
console.log(res)
if (res.code !== 2000) {
return this.$message.error(res.message);
} else {
this.editForm = res.data;
}
});
this.editDialog = true;
},
//编辑供应商
edit() {
this.$refs.editFormRef.validate((valid) => {
// console.log(valid)
if (!valid) {
return;
}
this.$http
.put("supplier/" + this.editForm.id, {
email: this.editForm.name,
mobile: this.editForm.mobile,
})
.then((res) => {
// console.log(res);
if (res.code !== 2000) {
return this.$message.error(res.message);
}
this.$message.success(res.message);
this.editDialog = false;
this.getProvider();
});
});
},
//查询
searchProvide(){
// console.log(this.serachForm);
/* this.getProvider(); */
this.$http.post("supplier/list/search/1/10");
// console.log(res);
this.provideList= res.rows;
}
},
computed: {},
watch: {},
components: { bread },
};
</script>
<style lang="scss" scoped>
.el-row {
margin: 20px 0px;
.el-col {
margin-left: 5px;
}
}
.el-table {
text-align: center;
}
</style>
以上是关于梦学谷项目分析 的主要内容,如果未能解决你的问题,请参考以下文章