1.searchSelect组件调整为页面缓存数据。

This commit is contained in:
xiaosuonian 2025-07-08 09:35:52 +08:00
parent 10a7c5e372
commit 14b5f68377
5 changed files with 139 additions and 198 deletions

View File

@ -1,13 +1,34 @@
// searchData.js - 搜索配置的独立模块
export const selectConfigs =[
// 点选择
// 出厂入厂
{
key: 'truepound',
key: 'outinpound',
params: 't_data_truepound;id;concat(name,\' \',usrcode)',
where: "poundtype = '1' or poundtype = '2'",
orderby: 'usrcode asc'
},
// 倒短
{
key: 'shortdispound',
params: 't_data_truepound;id;concat(name,\' \',usrcode)',
where: 'poundtype = \'3\'',
orderby: 'usrcode asc'
},
// 铁水
{
key: 'moltenironpound',
params: 't_data_truepound;id;concat(name,\' \',usrcode)',
where: 'poundtype = \'4\'',
orderby: 'usrcode asc'
},
// 成品
{
key: 'steelpound',
params: 't_data_truepound;id;concat(name,\' \',usrcode)',
where: 'poundtype = \'5\'',
orderby: 'usrcode asc'
},
// 业务磅点
{
key: 'buspound',

View File

@ -14,9 +14,7 @@
<!-- />-->
<!-- </el-select>-->
<search-select v-model="queryParams.poundid"
params = "t_data_truepound;id;concat(name,' ',usrcode)"
where="poundtype = '4'"
orderby="usrcode asc"
:options = "getOptionsByKey('moltenironpound')"
></search-select>
</el-form-item>
</el-col>
@ -73,9 +71,7 @@
<!-- />-->
<!-- </el-select>-->
<search-select v-model="queryPageParams.mstBill.recunitid"
params = "t_data_pounddata;usrcode;concat(name,' ',usrcode)"
where="type = 'receivingCompany'"
orderby="usrcode asc"
:options = "getOptionsByKey('recunit')"
clearable
></search-select>
</el-form-item>
@ -89,9 +85,7 @@
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<search-select v-model="queryPageParams.mstBill.itmcode"
params = "t_data_pounddata;usrcode;concat(name,' ',usrcode)"
where="type = 'productName'"
orderby="usrcode asc"
:options = "getOptionsByKey('itmcode')"
clearable
></search-select>
</el-form-item>
@ -101,9 +95,7 @@
<el-col :span="24">
<el-form-item label="发货单位" prop="sendunitid">
<search-select v-model="queryPageParams.mstBill.sendunitid"
params = "t_data_pounddata;usrcode;concat(name,' ',usrcode)"
where="type = 'shippingCompany'"
orderby="usrcode asc"
:options = "getOptionsByKey('sendunit')"
clearable
></search-select>
</el-form-item>
@ -111,9 +103,7 @@
<el-col :span="24">
<el-form-item label="生产班组" prop="trnunitid">
<search-select v-model="queryPageParams.mstBill.trnunitid"
params = "t_data_pounddata;usrcode;concat(name,' ',usrcode)"
where="type = 'teamOrCarrier'"
orderby="usrcode asc"
:options = "getOptionsByKey('trnunit')"
clearable
></search-select>
</el-form-item>
@ -153,9 +143,7 @@
<search-select
:disabled = "true"
v-model="scope.row.itmcode"
params = "t_data_pounddata;usrcode;concat(name,' ',usrcode)"
where="type = 'productName'"
orderby="usrcode asc"
:options = "getOptionsByKey('itmcode')"
class="search-select-custom-disabled"
></search-select>
</template>
@ -168,9 +156,7 @@
<search-select
:disabled = "true"
v-model="scope.row.sendunitid"
params = "t_data_pounddata;usrcode;concat(name,' ',usrcode)"
where="type = 'shippingCompany'"
orderby="usrcode asc"
:options = "getOptionsByKey('sendunit')"
class="search-select-custom-disabled"
></search-select>
</template>
@ -180,9 +166,7 @@
<search-select
:disabled = "true"
v-model="scope.row.recunitid"
params = "t_data_pounddata;usrcode;concat(name,' ',usrcode)"
where="type = 'receivingCompany'"
orderby="usrcode asc"
:options = "getOptionsByKey('recunit')"
class="search-select-custom-disabled"
></search-select>
</template>
@ -192,9 +176,7 @@
<search-select
:disabled = "true"
v-model="scope.row.trnunitid"
params = "t_data_pounddata;usrcode;concat(name,' ',usrcode)"
where="type = 'teamOrCarrier'"
orderby="usrcode asc"
:options = "getOptionsByKey('trnunit')"
class="search-select-custom-disabled"
></search-select>
</template>
@ -236,9 +218,7 @@
<search-select
:disabled = "true"
v-model="scope.row.appliid"
params = "t_data_poundmst;id;usrcode"
where=""
orderby="usrcode asc"
:options = "getOptionsByKey('appli')"
class="search-select-custom-disabled"
></search-select>
</template>
@ -252,9 +232,7 @@
<search-select
:disabled = "true"
v-model="scope.row.sendunitid"
params = "t_data_pounddata;usrcode;concat(name,' ',usrcode)"
where="type = 'shippingCompany'"
orderby="usrcode asc"
:options = "getOptionsByKey('sendunit')"
class="search-select-custom-disabled"
></search-select>
</template>
@ -264,9 +242,7 @@
<search-select
:disabled = "true"
v-model="scope.row.recunitid"
params = "t_data_pounddata;usrcode;concat(name,' ',usrcode)"
where="type = 'receivingCompany'"
orderby="usrcode asc"
:options = "getOptionsByKey('recunit')"
class="search-select-custom-disabled"
></search-select>
</template>
@ -276,9 +252,7 @@
<search-select
:disabled = "true"
v-model="scope.row.itmcode"
params = "t_data_pounddata;usrcode;concat(name,' ',usrcode)"
where="type = 'productName'"
orderby="usrcode asc"
:options = "getOptionsByKey('itmcode')"
class="search-select-custom-disabled"
></search-select>
</template>
@ -359,9 +333,7 @@
<search-select
:disabled = "true"
v-model="scope.row.appliid"
params = "t_data_poundmst;id;usrcode"
where=""
orderby="usrcode asc"
:options = "getOptionsByKey('appli')"
class="search-select-custom-disabled"
></search-select>
</template>
@ -373,9 +345,7 @@
<search-select
:disabled = "true"
v-model="scope.row.sendunitid"
params = "t_data_pounddata;usrcode;concat(name,' ',usrcode)"
where="type = 'shippingCompany'"
orderby="usrcode asc"
:options = "getOptionsByKey('sendunit')"
class="search-select-custom-disabled"
></search-select>
</template>
@ -385,9 +355,7 @@
<search-select
:disabled = "true"
v-model="scope.row.recunitid"
params = "t_data_pounddata;usrcode;concat(name,' ',usrcode)"
where="type = 'receivingCompany'"
orderby="usrcode asc"
:options = "getOptionsByKey('recunit')"
class="search-select-custom-disabled"
></search-select>
</template>
@ -397,9 +365,7 @@
<search-select
:disabled = "true"
v-model="scope.row.trnunitid"
params = "t_data_pounddata;usrcode;concat(name,' ',usrcode)"
where="type = 'teamOrCarrier'"
orderby="usrcode asc"
:options = "getOptionsByKey('trnunit')"
class="search-select-custom-disabled"
></search-select>
</template>
@ -409,9 +375,7 @@
<search-select
:disabled = "true"
v-model="scope.row.itmcode"
params = "t_data_pounddata;usrcode;concat(name,' ',usrcode)"
where="type = 'productName'"
orderby="usrcode asc"
:options = "getOptionsByKey('itmcode')"
class="search-select-custom-disabled"
></search-select>
</template>
@ -480,9 +444,7 @@
<el-col :span="18">
<el-form-item prop="carno" label-width="40">
<search-select v-model="queryParams.carno"
params = "t_data_pounddata;usrcode;usrcode"
where="type = 'plateNumber'"
orderby="usrcode asc"
:options = "getOptionsByKey('carno')"
></search-select>
</el-form-item>
</el-col>
@ -528,10 +490,7 @@
<el-form-item label="业务磅点" prop="poundid">
<search-select
v-model="mstBillFormData.mstBillForm.poundid"
params="t_data_buspound;id;concat(name,' ',usrcode)"
where = ""
orderby="usrcode asc"
:clearable = "true"
:options = "getOptionsByKey('buspound')"
:disabled = "true"
></search-select>
</el-form-item>
@ -541,9 +500,7 @@
<el-col :span="16">
<el-form-item label="发货单位" prop="sendunitid">
<search-select v-model="mstBillFormData.mstBillForm.sendunitid"
params = "t_data_pounddata;usrcode;concat(name,' ',usrcode)"
where="type = 'shippingCompany'"
orderby="usrcode asc"
:options = "getOptionsByKey('sendunit')"
clearable
></search-select>
</el-form-item>
@ -551,9 +508,7 @@
<el-col :span="8">
<el-form-item label="品名" prop="itmcode">
<search-select v-model="mstBillFormData.mstBillForm.itmcode"
params = "t_data_pounddata;usrcode;concat(name,' ',usrcode)"
where="type = 'productName'"
orderby="usrcode asc"
:options = "getOptionsByKey('itmcode')"
clearable
></search-select>
</el-form-item>
@ -563,9 +518,7 @@
<el-col :span="16">
<el-form-item label="收货单位" prop="recunitid">
<search-select v-model="mstBillFormData.mstBillForm.recunitid"
params = "t_data_pounddata;usrcode;concat(name,' ',usrcode)"
where="type = 'receivingCompany'"
orderby="usrcode asc"
:options = "getOptionsByKey('recunit')"
clearable
></search-select>
</el-form-item>
@ -580,9 +533,7 @@
<el-col :span="16">
<el-form-item label="班组/承运" prop="trnunitid">
<search-select v-model="mstBillFormData.mstBillForm.trnunitid"
params = "t_data_pounddata;usrcode;concat(name,' ',usrcode)"
where="type = 'teamOrCarrier'"
orderby="usrcode asc"
:options = "getOptionsByKey('trnunit')"
clearable
></search-select>
</el-form-item>
@ -610,9 +561,7 @@
<el-form-item label="主榜单编号" prop="usrcode" readonly>
<!-- <el-input v-model="mstBillFormData.mstBillForm.usrcode" placeholder="请输入主榜单编号" />-->
<search-select v-model="poundBillDetailFormData.poundBillDetailForm.appliid"
params = "t_data_poundmst;id;usrcode"
where=""
orderby="usrcode asc"
:options = "getOptionsByKey('appli')"
disabled
class="search-select-custom-disabled"
></search-select>
@ -626,9 +575,7 @@
<el-col :span="8">
<el-form-item label="发货单位" prop="sendunitid">
<search-select v-model="poundBillDetailFormData.poundBillDetailForm.sendunitid"
params = "t_data_pounddata;usrcode;concat(name,' ',usrcode)"
where="type = 'shippingCompany'"
orderby="usrcode asc"
:options = "getOptionsByKey('sendunit')"
></search-select>
</el-form-item>
</el-col>
@ -637,18 +584,14 @@
<el-col :span="16">
<el-form-item label="收货单位" prop="recunitid">
<search-select v-model="poundBillDetailFormData.poundBillDetailForm.recunitid"
params = "t_data_pounddata;usrcode;concat(name,' ',usrcode)"
where="type = 'receivingCompany'"
orderby="usrcode asc"
:options = "getOptionsByKey('recunit')"
></search-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="品名" prop="itmcode">
<search-select v-model="poundBillDetailFormData.poundBillDetailForm.itmcode"
params = "t_data_pounddata;usrcode;concat(name,' ',usrcode)"
where="type = 'productName'"
orderby="usrcode asc"
:options = "getOptionsByKey('itmcode')"
></search-select>
</el-form-item>
</el-col>
@ -713,7 +656,10 @@ import {
updateTransPoundbill
} from "@/api/measurement/bill/poundbill";
import {getCarnoEmpwgtData} from "@/api/measurement/basedata/empwgtdata";
//searchSelect
import { getSearchSelectData } from "@/api/tool/gen.js";
//searchData
import {selectConfigs} from "@/components/SearchSelect/searchdata.js";
export default {
name: "Moltenironpound",
components: {SearchSelect},
@ -839,10 +785,16 @@ export default {
thisSelectedRow:{},
isWght:true,
},
//searchSelect
searchData: {
optionsMap: {},
selectConfigs:selectConfigs
},
}
},
created() {
// this.getList()
this.loadAllSelectOptions();
},
watch: {
//
@ -1261,7 +1213,33 @@ export default {
}
//
await complete(this.mstBillFormData.selectedIds[0])
},
//searchSelect
buildCacheKey({ params, where, groupby = '', orderby = '' }) {
return `${params}|${where}|${groupby}|${orderby}`;
},
async loadAllSelectOptions() {
for (const cfg of this.searchData.selectConfigs) {
const key = this.buildCacheKey(cfg);
if (!this.searchData.optionsMap[key]) {
const [tableName, value, label] = cfg.params.split(';');
const res = await getSearchSelectData({
tableName: tableName,
value: value,
label: label,
where: cfg.where,
groupby: cfg.groupby,
orderby: cfg.orderby
});
this.$set(this.searchData.optionsMap, key, res.code === 200 ? res.data : []);
}
}
},
getOptionsByKey(key) {
const cfg = this.searchData.selectConfigs.find(c => c.key === key);
return this.searchData.optionsMap[this.buildCacheKey(cfg)] || [];
},
}
}
</script>

View File

@ -15,7 +15,7 @@
<!-- />-->
<!-- </el-select>-->
<search-select v-model="queryParams.poundid"
:options="getOptionsByKey('truepound')"
:options="getOptionsByKey('outinpound')"
></search-select>
</el-form-item>
</el-col>

View File

@ -15,7 +15,7 @@
<!-- />-->
<!-- </el-select>-->
<search-select v-model="queryParams.poundid"
:options="this.getOptionsByKey('truepound')"
:options="this.getOptionsByKey('shortdispound')"
></search-select>
</el-form-item>
</el-col>
@ -882,74 +882,6 @@ export default {
isWght:true,
},
//searchSelect
searchData111:{
optionsMap:{},
selectConfigs:[
//
{
key: 'truepound',
params: 't_data_truepound;id;concat(name,\' \',usrcode)',
where: 'poundtype = \'3\'',
orderby: 'usrcode asc'
},
//
{
key: 'buspound',
params: "t_data_buspound;id;concat(name,' ',usrcode)",
where: '',
orderby: 'usrcode asc'
},
//
{
key: 'carno',
params : "t_data_pounddata;usrcode;usrcode",
where : "type = 'plateNumber'",
orderby : "usrcode asc"
},
//
{
key: 'cardriver',
params : "t_data_pounddata;usrcode;usrcode",
where : "type = 'driverName'",
orderby : "usrcode asc"
},
//
{
key: 'itmcode',
params : "t_data_pounddata;usrcode;concat(name,' ',usrcode)",
where : "type = 'productName'",
orderby : "usrcode asc"
},
//
{
key: 'recunit',
params : "t_data_pounddata;usrcode;concat(name,' ',usrcode)",
where : "type = 'receivingCompany'",
orderby : "usrcode asc"
},
//
{
key: 'trnunit',
params : "t_data_pounddata;usrcode;concat(name,' ',usrcode)",
where : "type = 'teamOrCarrier'",
orderby : "usrcode asc"
},
//
{
key: 'sendunit',
params : "t_data_pounddata;usrcode;concat(name,' ',usrcode)",
where : "type = 'shippingCompany'",
orderby : "usrcode asc"
},
//
{
key: 'appli',
params : "t_data_poundmst;id;usrcode",
where : "",
orderby : "usrcode asc"
},
]
},
searchData: {
optionsMap: {},
selectConfigs:selectConfigs

View File

@ -6,9 +6,7 @@
<el-col :span="24">
<el-form-item label="磅点" prop="poundid" label-width="40">
<search-select v-model="queryParams.poundid"
params = "t_data_truepound;id;concat(name,' ',usrcode)"
where="poundtype = '5'"
orderby="usrcode asc"
:options = "getOptionsByKey('steelpound')"
></search-select>
</el-form-item>
</el-col>
@ -85,9 +83,7 @@
<search-select
:disabled = "true"
v-model="scope.row.itmcode"
params = "t_data_pounddata;usrcode;concat(name,' ',usrcode)"
where="type = 'productName'"
orderby="usrcode asc"
:options = "getOptionsByKey('itmcode')"
class="search-select-custom-disabled"
></search-select>
</template>
@ -99,9 +95,7 @@
<search-select
:disabled = "true"
v-model="scope.row.sendunitid"
params = "t_data_pounddata;usrcode;concat(name,' ',usrcode)"
where="type = 'shippingCompany'"
orderby="usrcode asc"
:options = "getOptionsByKey('sendunit')"
class="search-select-custom-disabled"
></search-select>
</template>
@ -111,9 +105,7 @@
<search-select
:disabled = "true"
v-model="scope.row.recunitid"
params = "t_data_pounddata;usrcode;concat(name,' ',usrcode)"
where="type = 'receivingCompany'"
orderby="usrcode asc"
:options = "getOptionsByKey('recunit')"
class="search-select-custom-disabled"
></search-select>
</template>
@ -123,9 +115,7 @@
<search-select
:disabled = "true"
v-model="scope.row.trnunitid"
params = "t_data_pounddata;usrcode;concat(name,' ',usrcode)"
where="type = 'teamOrCarrier'"
orderby="usrcode asc"
:options = "getOptionsByKey('trnunit')"
class="search-select-custom-disabled"
></search-select>
</template>
@ -173,9 +163,7 @@
<search-select
:disabled = "true"
v-model="scope.row.appliid"
params = "t_data_poundmst;id;usrcode"
where=""
orderby="usrcode asc"
:options = "getOptionsByKey('appli')"
class="search-select-custom-disabled"
></search-select>
</template>
@ -287,10 +275,7 @@
<el-form-item label="业务磅点" prop="poundid">
<search-select
v-model="mstBillFormData.mstBillForm.poundid"
params="t_data_buspound;id;concat(name,' ',usrcode)"
where = ""
orderby="usrcode asc"
:clearable = "true"
:options = "getOptionsByKey('buspound')"
:disabled = "true"
></search-select>
</el-form-item>
@ -300,9 +285,7 @@
<el-col :span="16">
<el-form-item label="发货单位" prop="sendunitid">
<search-select v-model="mstBillFormData.mstBillForm.sendunitid"
params = "t_data_pounddata;usrcode;concat(name,' ',usrcode)"
where="type = 'shippingCompany'"
orderby="usrcode asc"
:options = "getOptionsByKey('sendunit')"
clearable
></search-select>
</el-form-item>
@ -310,9 +293,7 @@
<el-col :span="8">
<el-form-item label="品名" prop="itmcode">
<search-select v-model="mstBillFormData.mstBillForm.itmcode"
params = "t_data_pounddata;usrcode;concat(name,' ',usrcode)"
where="type = 'productName'"
orderby="usrcode asc"
:options = "getOptionsByKey('itmcode')"
clearable
></search-select>
</el-form-item>
@ -322,9 +303,7 @@
<el-col :span="16">
<el-form-item label="收货单位" prop="recunitid">
<search-select v-model="mstBillFormData.mstBillForm.recunitid"
params = "t_data_pounddata;usrcode;concat(name,' ',usrcode)"
where="type = 'receivingCompany'"
orderby="usrcode asc"
:options = "getOptionsByKey('recunit')"
clearable
></search-select>
</el-form-item>
@ -382,9 +361,7 @@
<el-form-item label="主榜单编号" prop="usrcode" readonly>
<!-- <el-input v-model="mstBillFormData.mstBillForm.usrcode" placeholder="请输入主榜单编号" />-->
<search-select v-model="poundBillDetailFormData.poundBillDetailForm.appliid"
params = "t_data_poundmst;id;usrcode"
where=""
orderby="usrcode asc"
:options = "getOptionsByKey('appli')"
disabled
class="search-select-custom-disabled"
></search-select>
@ -402,9 +379,7 @@
<el-col :span="8">
<el-form-item label="品名" prop="itmcode">
<search-select v-model="poundBillDetailFormData.poundBillDetailForm.itmcode"
params = "t_data_pounddata;usrcode;concat(name,' ',usrcode)"
where="type = 'productName'"
orderby="usrcode asc"
:options = "getOptionsByKey('itmcode')"
></search-select>
</el-form-item>
</el-col>
@ -448,6 +423,10 @@ import SearchSelect from "@/components/SearchSelect";
import {addPoundmst, getNumber, getPoundmst, listPoundmst, updatePoundmst,complete} from "@/api/measurement/bill/poundmst";
import {addTransPoundbill, getNumber as getPoundBillNumber,getMaxBundleNo, listPoundbill,addSteelPoundbill} from "@/api/measurement/bill/poundbill";
import Decimal from "decimal.js";
//searchSelect
import { getSearchSelectData } from "@/api/tool/gen.js";
//searchData
import {selectConfigs} from "@/components/SearchSelect/searchdata.js";
export default {
name: "Steelpound",
@ -568,11 +547,17 @@ export default {
autoPound:false,
isWeighing: false, //
weightTimer: null //
}
},
//searchSelect
searchData: {
optionsMap: {},
selectConfigs:selectConfigs
},
}
},
created() {
// this.getList()
this.loadAllSelectOptions();
},
watch: {
//
@ -985,7 +970,32 @@ export default {
}
//
await complete(this.mstBillFormData.selectedIds[0])
},
//searchSelect
buildCacheKey({ params, where, groupby = '', orderby = '' }) {
return `${params}|${where}|${groupby}|${orderby}`;
},
async loadAllSelectOptions() {
for (const cfg of this.searchData.selectConfigs) {
const key = this.buildCacheKey(cfg);
if (!this.searchData.optionsMap[key]) {
const [tableName, value, label] = cfg.params.split(';');
const res = await getSearchSelectData({
tableName: tableName,
value: value,
label: label,
where: cfg.where,
groupby: cfg.groupby,
orderby: cfg.orderby
});
this.$set(this.searchData.optionsMap, key, res.code === 200 ? res.data : []);
}
}
},
getOptionsByKey(key) {
const cfg = this.searchData.selectConfigs.find(c => c.key === key);
return this.searchData.optionsMap[this.buildCacheKey(cfg)] || [];
},
}
}