This commit is contained in:
hrx 2025-11-18 14:18:42 +08:00
parent 5949af9ca2
commit 19e4a8276b

View File

@ -1,13 +1,69 @@
<template> <template>
<div class="container"> <div class="container">
<el-card> <el-card>
<el-table v-loading="loading" ref="table" :data="tableData" tooltip-effect="dark" style="width: 100%" <!-- 搜索表单 -->
@selection-change="handleSelectionChange" height="calc(100vh - 190px)"> <el-form :model="query" inline class="search-form">
<el-form-item label="客户名称">
<el-input
v-model="query.orgname"
placeholder="请输入客户名称"
size="small"
clearable
@keyup.enter.native="handleSearch">
</el-input>
</el-form-item>
<el-form-item label="联系方式">
<el-input
v-model="query.contactor_phone"
placeholder="请输入联系方式"
size="small"
clearable
@keyup.enter.native="handleSearch">
</el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" size="small" @click="handleSearch">搜索</el-button>
<el-button size="small" @click="handleReset">重置</el-button>
</el-form-item>
</el-form>
<!-- 客户表格 -->
<el-table
v-loading="loading"
ref="table"
:data="tableData"
tooltip-effect="dark"
style="width: 100%"
@selection-change="handleSelectionChange"
height="calc(100vh - 320px)">
<el-table-column type="selection" width="55"></el-table-column> <el-table-column type="selection" width="55"></el-table-column>
<el-table-column prop="orgname" label="客户名称"></el-table-column> <el-table-column prop="orgname" label="客户名称">
<template slot-scope="scope">
{{ scope.row.orgname || scope.row.contactor_phone || '未知客户' }}
</template>
</el-table-column>
<el-table-column label="联系方式" prop="contactor_phone"></el-table-column> <el-table-column label="联系方式" prop="contactor_phone"></el-table-column>
<el-table-column prop="address" label="地址" show-overflow-tooltip></el-table-column> <el-table-column prop="address" label="地址" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.address || '未填写地址' }}
</template>
</el-table-column>
</el-table> </el-table>
<!-- 分页组件 -->
<div class="pagination-container">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="query.page"
:page-sizes="[10, 20, 50, 100]"
:page-size="query.size"
layout="total, sizes, prev, pager, next, jumper"
:total="total">
</el-pagination>
</div>
<!-- 操作按钮 -->
<div class="button-container"> <div class="button-container">
<el-button @click="selectSales()" size="small" type="primary" :disabled="!hasSelection" class="action-button"> <el-button @click="selectSales()" size="small" type="primary" :disabled="!hasSelection" class="action-button">
选择销售 选择销售
@ -18,13 +74,14 @@
</el-button> </el-button>
</div> </div>
</el-card> </el-card>
<!-- 选择销售对话框 -->
<el-dialog class="myDialog" title="选择销售人员" :visible.sync="isShow" width="30%" :before-close="handleClose"> <el-dialog class="myDialog" title="选择销售人员" :visible.sync="isShow" width="30%" :before-close="handleClose">
<el-form ref="form" :model="form" label-width="130px"> <el-form ref="form" :model="form" label-width="130px">
<el-form-item label="请选择销售人员:" style="width: 80%;" prop="sales"> <el-form-item label="请选择销售人员:" style="width: 100%;" prop="sales">
<!-- 添加一个容器来应用滚动样式 -->
<div class="radio-group-container"> <div class="radio-group-container">
<el-radio-group v-model="form.id"> <el-radio-group v-model="form.id">
<div class="radio" v-for="(item, index) in salesData" :key="index"> <div class="radio-item" v-for="(item, index) in salesData" :key="index">
<el-radio :label="item.id">{{ item.username }}</el-radio> <el-radio :label="item.id">{{ item.username }}</el-radio>
</div> </div>
</el-radio-group> </el-radio-group>
@ -49,19 +106,22 @@ export default {
tableData: [], tableData: [],
salesData: [], salesData: [],
isShow: false, isShow: false,
page: 1, total: 0,
form: { form: {
username: '', username: '',
id: '' id: ''
}, },
defaultProps: {
children: "children",
label: "username",
},
customerid: [], // id customerid: [], // id
hasSelection: false, // hasSelection: false, //
userId: sessionStorage.getItem("userId"), userId: sessionStorage.getItem("userId"),
orgid: sessionStorage.getItem("orgid"), orgid: sessionStorage.getItem("orgid"),
query: {
page: 1,
size: 10,
orgid: this.orgid,
orgname: '',
contactor_phone: ''
},
}; };
}, },
created() { created() {
@ -70,25 +130,26 @@ export default {
}, },
methods: { methods: {
getNoinvitationcode() { // getNoinvitationcode() { //
getNoinvitationcodeAPI({ orgid: this.orgid }).then(res => { this.loading = true;
getNoinvitationcodeAPI(this.query).then(res => {
this.loading = false; this.loading = false;
this.tableData = res.data.rows; this.tableData = res.data.rows;
// console.log(res); this.total = res.pagination.total;
}).catch(() => {
this.loading = false;
}); });
}, },
getSales() { // getSales() { //
getSalesAPI({ role: "销售", userid: this.userId }).then(res => { getSalesAPI({ role: "销售", userid: this.userId }).then(res => {
// console.log(res); if (res.data && res.data.length > 0) {
if (res.data.length > 0) {
this.salesData = res.data.map((item) => { this.salesData = res.data.map((item) => {
return { return {
username: item.username, username: item.username,
id: item.id, id: item.id,
}; };
}); });
// } else {
// this.salesData = [];
// this.form.id = this.salesData[0]?.id || '';
} }
}); });
}, },
@ -98,14 +159,12 @@ export default {
}, },
handleSelectionChange(val) { handleSelectionChange(val) {
// ID // ID
this.customerid = val.map(item => item.id); // this.customerid = val.map(item => item.id);
// //
this.hasSelection = this.customerid.length > 0; this.hasSelection = this.customerid.length > 0;
// console.log(this.customerid);
}, },
cancelSelection() { cancelSelection() {
this.$refs.table.clearSelection(); this.$refs.table.clearSelection();
// clearSelection handleSelectionChange
this.hasSelection = false; this.hasSelection = false;
this.customerid = []; this.customerid = [];
}, },
@ -163,54 +222,84 @@ export default {
cancel() { cancel() {
this.isShow = false; this.isShow = false;
}, },
// getFormData(object) { // formdata - 使 handleSearch() {
// const formData = new FormData(); this.query.page = 1; //
// Object.keys(object).forEach(key => { this.getNoinvitationcode();
// const value = object[key]; },
// if (Array.isArray(value)) { handleReset() {
// value.forEach((subValue, i) => { this.query = {
// formData.append(key + `[${i}]`, subValue) page: 1,
// }) size: 10,
// } else { orgid: this.orgid,
// formData.append(key, object[key]) orgname: '',
// } contactor_phone: ''
// }) };
// return formData; this.getNoinvitationcode();
// }, },
handleSizeChange(size) {
this.query.size = size;
this.getNoinvitationcode();
},
handleCurrentChange(page) {
this.query.page = page;
this.getNoinvitationcode();
}
} }
}; };
</script> </script>
<style lang="scss" scoped> <style lang="less" scoped>
.container { .container {
padding: 20px;
.search-form {
margin-bottom: 20px;
.el-form-item {
margin-bottom: 10px;
margin-right: 15px;
}
}
.pagination-container {
margin-top: 20px;
display: flex;
justify-content: center;
}
.button-container { .button-container {
margin-top: 20px; margin-top: 20px;
display: flex; display: flex;
gap: 10px; // gap: 10px;
}
.action-button { .action-button {
padding: 8px 16px; // padding: 8px 16px;
font-size: 14px; // font-size: 14px;
border-radius: 4px; // border-radius: 4px;
}
} }
.myDialog { .myDialog {
.radio-group-container { .radio-group-container {
//
max-height: 200px; max-height: 200px;
overflow-y: auto; overflow-y: auto;
border: 1px solid #e4e7ed; // border: 1px solid #e4e7ed;
border-radius: 4px; // border-radius: 4px;
padding: 5px; // padding: 10px;
} }
.radio { .radio-item {
// margin-bottom: 8px;
margin-bottom: 5px; // padding: 5px;
border-radius: 4px;
transition: background-color 0.3s;
&:hover {
background-color: #f5f7fa;
}
&:last-child { &:last-child {
margin-bottom: 0; // margin-bottom: 0;
} }
} }
@ -220,4 +309,7 @@ export default {
} }
} }
} }
/deep/.el-table__row{
height: 62px!important;
}
</style> </style>