|
|
@@ -96,6 +96,7 @@
|
|
|
plain
|
|
|
icon="el-icon-edit"
|
|
|
size="mini"
|
|
|
+ :loading="conditionLoading"
|
|
|
@click="checkWithCondition()"
|
|
|
>按筛选条件选中
|
|
|
</el-button>
|
|
|
@@ -151,6 +152,14 @@
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
+ <pagination
|
|
|
+ v-show="total>0"
|
|
|
+ :total="total"
|
|
|
+ :page.sync="queryParams.pageNum"
|
|
|
+ :limit.sync="queryParams.pageSize"
|
|
|
+ :page-sizes="pageSizes"
|
|
|
+ @pagination="getList"
|
|
|
+ />
|
|
|
<div slot="footer" class="dialog-footer" style="width: 100%;display: flex;flex-direction: row-reverse;margin-top: 20px;z-index: 9898989;padding-top: 5px">
|
|
|
<el-button type="primary" @click="submitForm" style="margin-bottom: 5px">确 定</el-button>
|
|
|
</div>
|
|
|
@@ -213,9 +222,12 @@ export default {
|
|
|
// 遮罩层
|
|
|
loading: true,
|
|
|
// 选中数组
|
|
|
+ rows: [],
|
|
|
ids: [],
|
|
|
names: [],
|
|
|
userIds: [],
|
|
|
+ conditionLoading: false,
|
|
|
+ isSyncingSelection: false,
|
|
|
// 非单个禁用
|
|
|
single: true,
|
|
|
// 非多个禁用
|
|
|
@@ -232,6 +244,8 @@ export default {
|
|
|
open: false,
|
|
|
// 查询参数
|
|
|
queryParams: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
customerCode: null,
|
|
|
customerName: null,
|
|
|
mobile: null,
|
|
|
@@ -314,11 +328,49 @@ export default {
|
|
|
this.getList();
|
|
|
},
|
|
|
initSelect(){
|
|
|
- if(this.rows && this.rows.length > 0){
|
|
|
- this.rows.forEach(row => {
|
|
|
- this.$refs.table.toggleRowSelection(row);
|
|
|
- })
|
|
|
+ this.syncTableSelection();
|
|
|
+ },
|
|
|
+ syncTableSelection(){
|
|
|
+ if (!this.$refs.table) {
|
|
|
+ return;
|
|
|
}
|
|
|
+ this.isSyncingSelection = true;
|
|
|
+ const selectedIds = new Set((this.rows || []).map(item => item.customerId));
|
|
|
+ this.$refs.table.clearSelection();
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.customerList.forEach(row => {
|
|
|
+ if (selectedIds.has(row.customerId)) {
|
|
|
+ this.$refs.table.toggleRowSelection(row, true);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.isSyncingSelection = false;
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ buildQueryParams(extraParams = {}) {
|
|
|
+ const params = Object.assign({}, this.queryParams, extraParams);
|
|
|
+ if (this.receiveTimeRange != null && this.receiveTimeRange.length === 2) {
|
|
|
+ params.receiveTimeRange = this.receiveTimeRange[0] + "--" + this.receiveTimeRange[1];
|
|
|
+ } else {
|
|
|
+ params.receiveTimeRange = null;
|
|
|
+ }
|
|
|
+ if (this.ctsTypeArr.length > 0) {
|
|
|
+ params.customerType = this.ctsTypeArr.toString();
|
|
|
+ } else {
|
|
|
+ params.customerType = null;
|
|
|
+ }
|
|
|
+ if (this.sourceArr.length > 0) {
|
|
|
+ params.source = this.sourceArr.toString();
|
|
|
+ } else {
|
|
|
+ params.source = null;
|
|
|
+ }
|
|
|
+ if (this.tagIds.length > 0) {
|
|
|
+ params.tags = this.tagIds.toString();
|
|
|
+ } else {
|
|
|
+ params.tags = null;
|
|
|
+ }
|
|
|
+ return params;
|
|
|
},
|
|
|
getRowKeys(item){
|
|
|
return item.customerId;
|
|
|
@@ -382,32 +434,8 @@ export default {
|
|
|
/** 查询客户列表 */
|
|
|
getList() {
|
|
|
this.loading = true;
|
|
|
- if(this.receiveTimeRange!=null&&this.receiveTimeRange.length==2){
|
|
|
- this.queryParams.receiveTimeRange=this.receiveTimeRange[0]+"--"+this.receiveTimeRange[1]
|
|
|
- }
|
|
|
- else{
|
|
|
- this.queryParams.receiveTimeRange=null;
|
|
|
- }
|
|
|
- if(this.ctsTypeArr.length>0){
|
|
|
- this.queryParams.customerType=this.ctsTypeArr.toString();
|
|
|
- }
|
|
|
- else{
|
|
|
- this.queryParams.customerType=null
|
|
|
- }
|
|
|
-
|
|
|
- if(this.sourceArr.length>0){
|
|
|
- this.queryParams.source=this.sourceArr.toString();
|
|
|
- }
|
|
|
- else{
|
|
|
- this.queryParams.source=null
|
|
|
- }
|
|
|
- if(this.tagIds.length>0){
|
|
|
- this.queryParams.tags=this.tagIds.toString();
|
|
|
- }
|
|
|
- else{
|
|
|
- this.queryParams.tags=null
|
|
|
- }
|
|
|
- listCustomerAll(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
|
|
|
+ const params = this.buildQueryParams();
|
|
|
+ listCustomerAll(this.addDateRange(params, this.dateRange)).then(response => {
|
|
|
this.customerList = response.rows;
|
|
|
this.total = response.total;
|
|
|
this.loading = false;
|
|
|
@@ -421,6 +449,7 @@ export default {
|
|
|
},
|
|
|
/** 搜索按钮操作 */
|
|
|
handleQuery() {
|
|
|
+ this.queryParams.pageNum = 1;
|
|
|
this.getList();
|
|
|
},
|
|
|
/** 重置按钮操作 */
|
|
|
@@ -429,11 +458,14 @@ export default {
|
|
|
},
|
|
|
// 多选框选中数据
|
|
|
handleSelectionChange(selection) {
|
|
|
+ if (this.isSyncingSelection) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
this.rows = selection;
|
|
|
- this.ids = selection.map(item => item.customerId)
|
|
|
- this.names = selection.map(item => item.customerName)
|
|
|
- this.single = selection.length!==1
|
|
|
- this.multiple = !selection.length
|
|
|
+ this.ids = selection.map(item => item.customerId);
|
|
|
+ this.names = selection.map(item => item.customerName);
|
|
|
+ this.single = selection.length !== 1;
|
|
|
+ this.multiple = !selection.length;
|
|
|
},
|
|
|
getTreeselect() {
|
|
|
var that=this;
|
|
|
@@ -456,58 +488,35 @@ export default {
|
|
|
this.getList();
|
|
|
},
|
|
|
submitForm(){
|
|
|
- console.log(this.ids);
|
|
|
+ if (!this.rows || this.rows.length === 0) {
|
|
|
+ this.$message.warning("请至少选择一位客户");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.$emit("success", { ids: this.ids, names: this.names, rows: this.rows });
|
|
|
+ this.shows = false;
|
|
|
this.$nextTick(() => {
|
|
|
- this.$emit("success", {ids: this.ids, names: this.names, rows: this.rows})
|
|
|
- this.shows = false;
|
|
|
- this.$refs.table.clearSelection();
|
|
|
- })
|
|
|
+ if (this.$refs.table) {
|
|
|
+ this.$refs.table.clearSelection();
|
|
|
+ }
|
|
|
+ });
|
|
|
},
|
|
|
- //按照筛选条件选择客户
|
|
|
+ // 按照筛选条件选择客户
|
|
|
checkWithCondition(){
|
|
|
-
|
|
|
- let queryParamNoPage = {};
|
|
|
- queryParamNoPage = this.queryParams;
|
|
|
- if(this.receiveTimeRange!=null&&this.receiveTimeRange.length==2){
|
|
|
- queryParamNoPage.receiveTimeRange=this.receiveTimeRange[0]+"--"+this.receiveTimeRange[1]
|
|
|
- }
|
|
|
- else{
|
|
|
- queryParamNoPage.receiveTimeRange=null;
|
|
|
- }
|
|
|
- if(this.ctsTypeArr.length>0){
|
|
|
- queryParamNoPage.customerType=this.ctsTypeArr.toString();
|
|
|
- }
|
|
|
- else{
|
|
|
- queryParamNoPage.customerType=null
|
|
|
- }
|
|
|
-
|
|
|
- if(this.sourceArr.length>0){
|
|
|
- queryParamNoPage.source=this.sourceArr.toString();
|
|
|
- }
|
|
|
- else{
|
|
|
- queryParamNoPage.source=null
|
|
|
- }
|
|
|
- if(this.tagIds.length>0){
|
|
|
- queryParamNoPage.tags=this.tagIds.toString();
|
|
|
- }
|
|
|
- else{
|
|
|
- queryParamNoPage.tags=null
|
|
|
- }
|
|
|
- listNoPage(this.addDateRange(queryParamNoPage, this.dateRange)).then(response => {
|
|
|
- let resList = response.rows;
|
|
|
- this.ids = [];
|
|
|
- this.names = [];
|
|
|
- this.rows = [];
|
|
|
- if(!!resList){
|
|
|
- this.ids = resList.map(item => item.customerId);
|
|
|
- this.names = resList.map(item => item.customerName);
|
|
|
- this.rows = resList;
|
|
|
+ this.conditionLoading = true;
|
|
|
+ const params = this.buildQueryParams();
|
|
|
+ listNoPage(this.addDateRange(params, this.dateRange)).then(response => {
|
|
|
+ const resList = response.rows || [];
|
|
|
+ this.rows = resList;
|
|
|
+ this.ids = resList.map(item => item.customerId);
|
|
|
+ this.names = resList.map(item => item.customerName);
|
|
|
+ this.syncTableSelection();
|
|
|
+ if (resList.length === 0) {
|
|
|
+ this.$message.warning("当前筛选条件下没有可选择的客户");
|
|
|
+ } else {
|
|
|
+ this.$message.success(`已按筛选条件选中 ${resList.length} 位客户,点击确定完成回传`);
|
|
|
}
|
|
|
- this.$nextTick(() => {
|
|
|
- this.$emit("success", {ids: this.ids, names: this.names, rows: this.rows})
|
|
|
- this.shows = false;
|
|
|
- this.$refs.table.clearSelection();
|
|
|
- })
|
|
|
+ }).finally(() => {
|
|
|
+ this.conditionLoading = false;
|
|
|
});
|
|
|
}
|
|
|
}
|