<!--
|
* @Author: lzhe lzhe@example.com
|
* @Date: 2024-03-26 10:28:33
|
* @LastEditors: lzhe lzhe@example.com
|
* @LastEditTime: 2024-06-05 15:15:52
|
* @FilePath: /smart-web/src/views/master/person/main/index.vue
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
-->
|
<template>
|
<div class="user-main">
|
<div class="user-top">
|
<div class="right-bottom">
|
<el-button type="primary" @click="addSupplier">新建</el-button>
|
<el-button type="danger" plain @click="delSupplier" :disabled="selection.length == 0">删除</el-button>
|
</div>
|
<div>
|
<el-input v-model="searchData.keyword" placeholder="输入检索内容" style="width: 180px;margin-right: 8px;" clearable>
|
<template #suffix><el-button type="primary" text @click="searchclick">搜索</el-button></template>
|
</el-input>
|
</div>
|
</div>
|
<div class="user-table">
|
<el-table ref="multipleTableRef" :data="tableData" border style="width: 100%" class="multipleTableRef" @selection-change="handleSelectionChange">
|
<el-table-column type="selection" width="55" />
|
<el-table-column prop="code" label="供应商编号"></el-table-column>
|
<el-table-column prop="name" label="供应商名称"></el-table-column>
|
<el-table-column prop="address" label="供应商地址"></el-table-column>
|
<el-table-column prop="tel" label="联系方式"></el-table-column>
|
<el-table-column fixed="right" label="操作">
|
<template #default="scope">
|
<el-button type="text" size="small" @click="table_edit(scope.row, scope.$index)">编辑</el-button>
|
<el-button text type="primary" size="small" @click="table_del(scope.row, scope.$index)">删除</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
<el-pagination
|
style="margin-top: 12px;"
|
@size-change="handleSizeChange"
|
@current-change="handleCurrentChange"
|
:current-page="currentPage4"
|
:page-sizes="[15, 50, 100]"
|
:page-size="15"
|
layout="total, sizes, prev, pager, next, jumper"
|
:total="total">
|
</el-pagination>
|
</div>
|
</div>
|
|
<save-dialog v-if="dialog.save" ref="saveDialog" @success="addUserSuccess" @closed="dialog.save=false"></save-dialog>
|
</template>
|
<script>
|
import saveDialog from './addSupplierInfo'
|
export default {
|
name: "supplier",
|
data(){
|
return {
|
selection: [],
|
searchData: {
|
keyword: "",
|
current: "1",
|
size: "15"
|
},
|
total: 0,
|
isSaveing: false,
|
dialog: {
|
save: false
|
},
|
leftActive: true,
|
tableData: []
|
}
|
},
|
created(){
|
|
},
|
mounted(){
|
this.searchSupplier();
|
},
|
components: {
|
saveDialog
|
},
|
methods: {
|
addUserSuccess() {
|
this.searchclick();
|
},
|
table_del(row) {
|
this.$confirm('确定将选择数据删除?','提示', {
|
type: 'warning',
|
}).then(() => {
|
this.$HTTP.delete(`/api/blade-cps/supplier/remove?supplierIds=${row.id}`).then(res=> {
|
if(res.code == 200) {
|
this.searchclick();
|
this.$message.success("操作成功");
|
}else {
|
this.$alert(res.message, "提示", {type: 'error'});
|
}
|
})
|
}).catch(() => {
|
//取消
|
})
|
},
|
searchclick() {
|
this.searchData.current = "1";
|
this.searchData.size = "15";
|
this.searchSupplier();
|
},
|
searchSupplier() {
|
this.$HTTP.get("/api/blade-cps/supplier/page",this.searchData).then(res=> {
|
if(res.code == 200) {
|
res.data.records.forEach(item=> {
|
if(item.status == "1") {
|
item.status = true;
|
}else {
|
item.status = false;
|
}
|
})
|
this.tableData = res.data.records;
|
this.total = res.data.total;
|
}
|
})
|
},
|
//添加
|
addSupplier(){
|
this.dialog.save = true
|
this.$nextTick(() => {
|
this.$refs.saveDialog.open()
|
})
|
},
|
table_edit(row){
|
this.dialog.save = true
|
this.$nextTick(() => {
|
this.$refs.saveDialog.open('edit').setData(row)
|
})
|
},
|
//查看
|
table_show(row){
|
this.dialog.save = true
|
this.$nextTick(() => {
|
this.$refs.saveDialog.open('show').setData(row)
|
})
|
},
|
handleSelectionChange(selection) {
|
this.selection = selection;
|
},
|
delSupplier() {
|
if(this.selection.length == 0) {
|
this.$message({
|
message: '请选择至少一条数据',
|
type: 'warning'
|
});
|
return;
|
}
|
var selStr = "";
|
this.selection.map(item=> {
|
selStr += item.id + ","
|
})
|
selStr = selStr.replace(/,$/, '');
|
var that = this;
|
this.$confirm('确定将选择数据删除?','提示', {
|
type: 'warning',
|
}).then(() => {
|
that.$HTTP.delete("/api/blade-cps/supplier/remove?supplierIds="+selStr).then(res=> {
|
if(res.code == 200) {
|
that.$message.success("操作成功");
|
that.searchSupplier();
|
}
|
})
|
}).catch(() => {
|
//取消
|
})
|
},
|
handleSizeChange(val) {
|
console.log(`每页 ${val} 条`);
|
this.searchData.current = "1";
|
this.searchData.size = val;
|
this.searchSupplier();
|
},
|
handleCurrentChange(val) {
|
console.log(`当前页: ${val}`);
|
this.searchData.current = val;
|
this.searchSupplier();
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
.user-main {
|
background-color: #f9fafb;
|
border: 1px solid #dcdfe6;
|
box-shadow: 0 2px 4px 0 rgba(0,0,0,.12), 0 0 6px 0 rgba(0,0,0,.04);
|
margin: 8px;
|
padding: 8px;
|
background-color: #fff;
|
}
|
.user-top {
|
width: 100%;
|
display: flex;
|
justify-content: space-between;
|
margin-bottom: 8px;
|
}
|
.user-table {
|
width: 100%;
|
margin-bottom: 8px;
|
|
}
|
.multipleTableRef {
|
margin-bottom: 8px;
|
}
|
</style>
|