配置下拉

This commit is contained in:
2025-08-13 17:28:12 +08:00
parent 73f4b2ae54
commit ba34cfb459
2 changed files with 95 additions and 2 deletions

View File

@@ -14,3 +14,21 @@ export const updateMaterialInfo = (code, w) => post('api/bmMaterial/updateMateri
material_id: code,
single_weight: w
})
// export const getSect = () => {
// let res = {
// data: [
// { value: '01', label: 'code1' },
// { value: '02', label: 'code2' },
// { value: '03', label: 'code3' },
// { value: '04', label: 'code4' }
// ]
// }
// return res
// }
// 仓库列表 - 配置页
export const getSect = (code, w) => post('api/pda/iosIn/getSect', {
page: '1',
size: '10',
stor_code: 'XB'
})

View File

@@ -29,10 +29,34 @@
<label>刷新时间</label>
<input type="number" class="inputStyle" v-model="setTime">
</div>
<div class="inputOuter">
<!-- <div class="inputOuter">
<label>仓库编码</label>
<input type="text" class="inputStyle" v-model="secCode">
</div> -->
<div class="inputOuter">
<label>仓库编码</label>
<el-select
class="selectWraper"
v-model="selectedValues"
multiple
:multiple-limit="2"
@change="handleChange"
placeholder="请选择最多2个"
>
<el-option
v-for="item in options2"
:key="item.value"
:label="item.label"
:value="item.value"
:disabled="isOptionDisabled(item.value)"
>
</el-option>
</el-select>
</div>
<!-- <div class="inputOuter">
<label>已选择</label>
<input type="text" class="inputStyle" v-model="displayText" disabled>
</div> -->
</div>
<button class="btn" @click="_config">配置</button>
</div>
@@ -42,6 +66,7 @@
</template>
<script>
import { getSect } from '@js/getData2.js'
export default {
data () {
return {
@@ -52,11 +77,36 @@ export default {
setTime: this.$store.getters.setTime / 1000,
// options: [{value: '1', label: '拣选台'}, {value: '2', label: '仓储监控'}],
options: [{value: '01', label: '仓储监控1'}, {value: '02', label: '仓储监控2'}],
options2: [],
// options2: [
// { value: '01', label: 'code1' },
// { value: '02', label: 'code2' },
// { value: '03', label: 'code3' },
// { value: '04', label: 'code4' }
// ],
selectedValues: [], // 存储选中的value值
value: this.$store.getters.pageNo,
secCode: this.$store.getters.secCode || ''
}
},
computed: {
// 显示选中的标签(用逗号分隔)
displayText () {
return this.selectedValues.map(value => {
const item = this.options2.find(opt => opt.value === value)
return item ? item.label : ''
}).filter(Boolean).join(', ')
},
// 检查选项是否禁用已选满2个且当前未选中时禁用
isOptionDisabled () {
return (value) => {
return this.selectedValues.length >= 2 &&
!this.selectedValues.includes(value)
}
}
},
created () {
this._getSect()
if (this.$store.getters.iskb === '02') {
console.log(this.$store.getters.iskb, 1)
if (this.value === '01' || !this.secCode) {
@@ -70,6 +120,31 @@ export default {
// this._config()
},
methods: {
async _getSect () {
console.log(111)
try {
let res = await getSect()
if (res) {
this.options2 = res.data
// console.log(this.options2, 666)
if (this.options2.length >= 2) {
this.selectedValues = [this.options2[0].value, this.options2[1].value]
} else if (this.options2.length > 0) {
this.selectedValues = this.options2.map(item => item.value)
}
} else {
this.options2 = []
}
} catch (e) {
this.options2 = []
}
},
handleChange () {
// 自动截断多余的选择确保不超过2个
if (this.selectedValues.length > 2) {
this.selectedValues = this.selectedValues.slice(0, 2)
}
},
_config () {
if (this.setTime < 1 || this.setJxtTime < 1) {
this.$message({
@@ -91,7 +166,7 @@ export default {
setJxtTime: this.setJxtTime * 1000,
pageNo: this.value,
iskb: '1',
secCode: this.secCode
secCode: this.displayText
}
console.log()
this.$store.dispatch('setConfig', obj)