Browse Source

智能查询默认选中and

V1.0
mk 2 years ago
parent
commit
a1323ee9a6
  1. 11
      src/views/modules/home/index.vue
  2. 75
      src/views/modules/shequ/chaxun.vue
  3. 183
      src/views/modules/shequ/cpts/smatr-rules.vue

11
src/views/modules/home/index.vue

@ -1,3 +1,4 @@
<template>
<div>
<div class="g-row">
@ -49,7 +50,7 @@
查一下
</div>
</div>
<div class="btn2" @click="handleClickSearchBtn">
<div class="btn2" @click="handleClickSearchBtn('smart')">
<img src="@/assets/images/index/i-search.png" />
智能查询
</div>
@ -278,7 +279,6 @@
<fastcall ref="fastcall" />
</div>
</template>
<script>
import { requestPost, requestGet } from "@/js/dai/request";
import resiCategoryMap from "@/views/business/resi-category-map.js";
@ -384,11 +384,14 @@ export default {
localStorage.setItem('homeSearchKey',searchKey)
},
handleClickSearchBtn() {
console.log("dddd")
handleClickSearchBtn(str) {
const {
searchData: { type, searchKey },
} = this;
if(str){
this.toSearchPage(type, searchKey);
return
}
if (!searchKey) return this.$message.error("请输入搜索条件");
this.toSearchPage(type, searchKey);
},

75
src/views/modules/shequ/chaxun.vue

@ -3,7 +3,7 @@
<div class="m-box m-search">
<div class="wrap">
<div class="title">
<span>{{smatrFlag?'智能查询':'社区查询'}}</span>
<span>{{ smatrFlag ? '智能查询' : '社区查询' }}</span>
</div>
<div class="tabs">
@ -14,13 +14,14 @@
查房屋
</div>
</div>
<!-- -->
<div class="search">
<div class="search-input">
<div class="input">
<input type="text" :placeholder="typePlaceholder[searchData.type]" v-model="searchData.searchKey"
@keyup.enter="handleClickSearchBtn" />
<div class="close-btn" v-if="searchData.searchKey != ''" @click="searchData.searchKey = ''">
<div class="close-btn" v-if="searchData.searchKey != ''"
@click="searchData.searchKey = '', childrenRulesData = []">
<img src="@/assets/img/shequ/close.png" />
</div>
</div>
@ -33,8 +34,8 @@
</div>
<p v-show="smatrFlag && searchStatus == 'ing'" class="rules_box">
已显示{{ searchData.type == 'fangwu' ? '房屋' : '居民' }}状态为{{ keyWordStr }}的搜索结果如不满足需求 <el-button type="text"
@click="handleClickEditRules">请点击此处调整</el-button>
已显示{{ searchData.type == 'fangwu' ? '房屋' : '居民' }}状态为{{ searchData.searchKey }}的搜索结果如不满足需求 <el-button
type="text" @click="handleClickEditRules">请点击此处调整</el-button>
</p>
</div>
</div>
@ -246,7 +247,7 @@
<el-dialog v-if="showSmatrForm" :visible.sync="showSmatrForm" :append-to-body="true" :close-on-click-modal="false"
:close-on-press-escape="false" :title="'修改条件'" width="880px" top="5vh" class="dialog-h"
@closed="showSmatrForm = false">
<smatr-rules @dialogCancle="dialogCancle" @dialogOk="dialogOk">
<smatr-rules ref="smatr_rules_form" @dialogCancle="dialogCancle" @dialogOk="dialogOk" :rulesData="rulesData">
</smatr-rules>
</el-dialog>
</div>
@ -260,6 +261,7 @@ import getQueryPara from "dai-js/modules/getQueryPara";
import resiInfo from "@/views/modules/cpts/resi/info";
import houseInfo from "@/views/modules/cpts/house/info";
import smatrRules from "./cpts/smatr-rules.vue";
import { requestGet } from '../../../js/dai/request';
export default {
components: {
resiInfo,
@ -383,10 +385,10 @@ export default {
currentPage: "chaxun", // ,
smatrFlag: false,
keyWordStr: '',
showSmatrForm: false,
rulesData : []
rulesData: [],
childrenRulesData: []
};
},
computed: {
@ -410,18 +412,15 @@ export default {
},
methods: {
firstSearch() {
console.log(getQueryPara("type"));
console.log(this.$route.query.type, 'type');
console.log(this.$route.query.searchKey, 'search');
// this.searchData.searchKey = getQueryPara("searchKey");
// this.searchData.type = getQueryPara("type");
this.searchData.searchKey = localStorage.getItem('homeSearchKey') || ''
this.searchData.type = localStorage.getItem('homeSearchType') || ''
this.handleClickSearchBtn();
},
//
handleClickEditRules() {
this.showSmatrForm = true
this.$nextTick(() => {
this.$refs.smatr_rules_form.initForm(this.rulesData.length == 0 ? this.childrenRulesData : this.rulesData)
})
},
computedWidth(label) {
const wd = 20 * label.length;
@ -435,23 +434,24 @@ export default {
});
}
if (row.mobile != ''&&row.mobile) {
if (row.mobile != '' && row.mobile) {
row.mobile = row.mobile.substr(0, 3) + '****' + row.mobile.substr(7, 4)
} else if(row.mobile == '' || row.mobile == '--'){
} else if (row.mobile == '' || row.mobile == '--') {
row.mobile = ""
}
row.idNum = row.idNum.substr(0, 11) + '*****' + row.idNum.substr(16, 2)
return _val || row[item.columnName];
},
handleClickSearchBtn() {
async handleClickSearchBtn() {
const {
searchData: { type, searchKey },
} = this;
localStorage.setItem('homeSearchType', type)
localStorage.setItem('homeSearchKey', searchKey)
if (!searchKey) return this.$message.error("请输入搜索条件");
this.keyWordStr = searchKey
if (!searchKey) return
if (!this.smatrFlag) this.childrenRulesData = []
if (type == "jumin") {
this.searchJumin.pageNo = 1;
this.searchJumin.total = 0;
@ -460,10 +460,28 @@ export default {
this.searchFangwu.pageNo = 1;
this.searchFangwu.total = 0;
this.getSearchFangwu();
}
if (this.smatrFlag && this.childrenRulesData.length === 0) {
this.getRulesList()
}
this.searchStatus = "ing";
},
async getRulesList() {
//MOCK http://127.0.0.1:4523/mock2/2515967/96358430
let url = 'http://127.0.0.1:4523/mock2/2515967/96358430'
let par = {
keyWord: this.searchData.searchKey,
type: this.searchData.type
}
const { data, code, msg } = await requestGet(url, par)
if (code == 0) {
this.rulesData = data
console.log(this.rulesData);
} else {
console.log(msg);
}
},
handleClickSmartSearchBtn() {
this.smatrFlag = !this.smatrFlag
this.searchData.searchKey = ''
@ -513,12 +531,14 @@ export default {
searchData: { searchKey },
searchJumin: { pageSize, pageNo },
} = this;
console.log(this.rulesData);
console.log(this.childrenRulesData);
this.searchJumin.loading = true;
const { data, code, msg } = await requestPost(url, {
searchKey,
pageSize,
pageNo,
smartSearchRules:this.rulesData
smartSearchRules: this.childrenRulesData || null
});
this.searchJumin.loading = false;
if (code === 0) {
@ -545,7 +565,7 @@ export default {
searchKey,
pageSize,
pageNo,
smartSearchRules:this.rulesData
smartSearchRules: this.childrenRulesData || null
});
this.searchFangwu.loading = false;
if (code === 0) {
@ -587,14 +607,15 @@ export default {
this.handleClickSearchBtn()
// this.searchData.searchKey = ''
},
dialogCancle(){
dialogCancle() {
this.showSmatrForm = false
},
dialogOk(rulesData){
dialogOk(rulesData) {
this.showSmatrForm = false
if(rulesData){
this.rulesData = rulesData || null
this.handleClickSearchBtn()
this.rulesData = []
if (rulesData) {
this.childrenRulesData = rulesData || null
this.handleClickSearchBtn()
}
}
},

183
src/views/modules/shequ/cpts/smatr-rules.vue

@ -68,7 +68,7 @@
</el-table-column>
<el-table-column label="条件关系" align="center" width="100">
<template slot-scope="scope" v-if="scope.$index != tableData.length - 1">
<el-select v-model="scope.row.nextLogicalRel" placeholder="请选择" clearable>
<el-select v-model="scope.row.nextLogicalRel" placeholder="请选择" clearable disabled>
<el-option v-for="item in nextLogicalRelOpction" :label="item.label" :value="item.value"
:key="item.value">
</el-option>
@ -98,11 +98,6 @@ import { requestPost, requestGet } from "@/js/dai/request";
export default {
data() {
return {
timeout: null,
tagObj: {},
searchList: [],
tableData: [
{
dataSource: "", //
@ -110,7 +105,7 @@ export default {
itemId: "", //
queryType: "", //
colVal: "", //
nextLogicalRel: "", //,
nextLogicalRel: "and", //,
tableName: "", //
colKey: "",
itemIdOpction: [],
@ -122,7 +117,7 @@ export default {
{ label: "人员信息", value: "resi" },
{ label: "房屋信息", value: "house" },
],
queryTypeOpction: [{}],
queryTypeOpction: [],
nextLogicalRelOpction: [
{ label: "并且", value: "and" },
{ label: "或者", value: "or" },
@ -131,38 +126,23 @@ export default {
},
created() { },
async mounted() {
await this.getLabelList();
},
methods: {
async initForm(type, row) {
await this.getFormEdit();
async initForm(data) {
// await this.getFormEdit();
this.tableData = data
console.log(data);
for (let i in this.tableData) {
this.handleChangeSource(this.tableData[i], [i], type);
this.handleChangeFieldsType(this.tableData[i], [i], type);
this.handleChangeSource(this.tableData[i], [i]);
this.handleChangeFieldsType(this.tableData[i], [i]);
setTimeout(() => {
this.handleChangeFieldsName(this.tableData[i], [i], type);
this.handleChangeFieldsName(this.tableData[i], [i]);
}, 300);
}
},
async handleSelect(item) {
console.log(item);
await this.initForm("info", item);
},
async getLabelList() {
const url = "/governance/resiSearchTag/listResiSearchTags";
let params = {
pageSize: 99,
};
let { data, msg, code } = await requestPost(url, params);
if (code == 0) {
this.searchList = data.list;
} else {
this.$message.error(msg);
}
},
//
async handleChangeSource(row, index, type) {
async handleChangeSource(row, index) {
console.log(row);
if (row.dataSource == "resi") {
let url = "/oper/customize/icformitemgroup/list";
@ -178,15 +158,15 @@ export default {
this.$message.error(msg);
}
this.hadeleClearForm(this.tableData[index], index);
if (!type) {
this.tableData[index].itemGroupId = "";
this.tableData[index].itemId = "";
this.tableData[index].colKey = "";
this.tableData[index].colVal = "";
this.tableData[index].nextLogicalRel = "";
this.tableData[index].queryType = "";
this.tableData[index].itemIdOpction = [];
}
// if (!type) {
// this.tableData[index].itemGroupId = "";
// this.tableData[index].itemId = "";
// this.tableData[index].colKey = "";
// this.tableData[index].colVal = "";
// this.tableData[index].nextLogicalRel = "";
// this.tableData[index].queryType = "";
// this.tableData[index].itemIdOpction = [];
// }
} else if (row.dataSource == "house") {
let url = "/governance/policy/item-list/house";
let params = {};
@ -197,14 +177,14 @@ export default {
this.$message.error(msg);
}
this.hadeleClearForm(this.tableData[index], index);
if (!type) {
this.tableData[index].itemGroupId = "";
this.tableData[index].itemId = "";
this.tableData[index].colKey = "";
this.tableData[index].colVal = "";
this.tableData[index].nextLogicalRel = "";
this.tableData[index].queryType = "";
}
// if (!type) {
// this.tableData[index].itemGroupId = "";
// this.tableData[index].itemId = "";
// this.tableData[index].colKey = "";
// this.tableData[index].colVal = "";
// this.tableData[index].nextLogicalRel = "";
// this.tableData[index].queryType = "";
// }
} else if (row.dataSource == "stat") {
let url = "/governance/policy/item-list/stat";
let params = {};
@ -215,14 +195,14 @@ export default {
this.$message.error(msg);
}
this.hadeleClearForm(this.tableData[index], index);
if (!type) {
this.tableData[index].itemGroupId = "";
this.tableData[index].itemId = "";
this.tableData[index].colKey = "";
this.tableData[index].colVal = "";
this.tableData[index].nextLogicalRel = "";
this.tableData[index].queryType = "";
}
// if (!type) {
// this.tableData[index].itemGroupId = "";
// this.tableData[index].itemId = "";
// this.tableData[index].colKey = "";
// this.tableData[index].colVal = "";
// this.tableData[index].nextLogicalRel = "";
// this.tableData[index].queryType = "";
// }
} else {
this.hadeleClearForm(this.tableData[index], index);
this.tableData[index].itemGroupId = "";
@ -238,7 +218,7 @@ export default {
},
//
async handleChangeFieldsType(row, index, type) {
async handleChangeFieldsType(row, index) {
console.log(row, index, "字段类别row");
if (row.dataSource != "resi") return;
const url = "/oper/customize/icformitem/getItemListV2";
@ -247,14 +227,14 @@ export default {
policyFlag: "1",
};
this.hadeleClearForm(this.tableData[index], index);
if (!type) {
this.tableData[index].itemId = "";
this.tableData[index].colKey = "";
this.tableData[index].colVal = "";
this.tableData[index].nextLogicalRel = "";
this.tableData[index].queryType = "";
this.tableData[index].itemIdOpction = [];
}
// if (!type) {
// this.tableData[index].itemId = "";
// this.tableData[index].colKey = "";
// this.tableData[index].colVal = "";
// this.tableData[index].nextLogicalRel = "";
// this.tableData[index].queryType = "";
// this.tableData[index].itemIdOpction = [];
// }
let { data, code, msg } = await requestPost(url, params);
if (code == 0) {
this.$set(this.tableData[index], "itemIdOpction", data);
@ -264,7 +244,7 @@ export default {
}
},
//
async handleChangeFieldsName(row, index, type) {
async handleChangeFieldsName(row, index) {
console.log(row, "字段名称row");
var arr = [];
// colKeycolumnName
@ -272,22 +252,22 @@ export default {
arr = row.itemIdOpction.filter((item) => item.colKey == row.itemId);
this.tableData[index].tableName = arr[0].tableName;
this.tableData[index].colKey = arr[0].colKey;
if (!type) {
this.tableData[index].colVal = "";
this.tableData[index].nextLogicalRel = "";
this.tableData[index].queryType = "";
}
// if (!type) {
// this.tableData[index].colVal = "";
// this.tableData[index].nextLogicalRel = "";
// this.tableData[index].queryType = "";
// }
// this.tableData[index].colVal = ''
// this.tableData[index].queryType = ''
} else if (row.dataSource == "resi" && row.itemId != "") {
arr = row.itemIdOpction.filter((item) => item.itemId == row.itemId);
this.tableData[index].tableName = arr[0].tableName;
this.tableData[index].colKey = arr[0].columnName;
if (!type) {
this.tableData[index].colVal = "";
this.tableData[index].nextLogicalRel = "";
this.tableData[index].queryType = "";
}
// if (!type) {
// this.tableData[index].colVal = "";
// this.tableData[index].nextLogicalRel = "";
// this.tableData[index].queryType = "";
// }
// this.tableData[index].colVal = ''
// this.tableData[index].queryType = ''
}
@ -348,36 +328,26 @@ export default {
};
this.$set(this.tableData, index, obj);
},
async getFormEdit(id) {
const url = `/governance/resiSearchTag/listResiSearchRulesByTagId?tagId=${id}`;
let { code, msg, data } = await requestGet(url);
if (code == 0) {
console.log(data, "获取到的详情信息");
this.tableData = data;
} else if (code >= 8000) {
this.$message.error(msg);
}
},
async handleComfirm() {
let messageObj = {};
messageObj = this.validateRule(this.tableData);
if (messageObj) {
this.$message.error(messageObj);
return;
}
for (let i in this.tableData) {
for (let j in this.tableData[i]) {
if (
typeof this.tableData[i][j] != "string" &&
typeof this.tableData[i][j] != "number"
) {
this.$delete(this.tableData[i], j);
}
let messageObj = {};
messageObj = this.validateRule(this.tableData);
if (messageObj) {
this.$message.error(messageObj);
return;
}
for (let i in this.tableData) {
for (let j in this.tableData[i]) {
if (
typeof this.tableData[i][j] != "string" &&
typeof this.tableData[i][j] != "number"
) {
this.$delete(this.tableData[i], j);
}
}
this.$emit("dialogOk", this.tableData);
}
this.$emit("dialogOk", this.tableData);
// this.addSubmit();
// this.addSubmit();
},
handleCancle() {
this.$emit("dialogCancle");
@ -441,7 +411,7 @@ export default {
obj.itemId = "";
obj.queryType = "";
obj.colVal = "";
obj.nextLogicalRel = "";
obj.nextLogicalRel = "and";
obj.itemIdOpction = [];
this.tableData.push(obj);
},
@ -454,7 +424,12 @@ export default {
this.tableData[index].queryType = "";
},
},
props: {},
props: {
rulesData: {
type: Array,
default: () => []
}
},
computed: {},
watch: {},
};

Loading…
Cancel
Save