Commit 8720db63 by liangjianmin

fix(picking): 修复其他属性选择逻辑及初始化问题

- 将其他属性列表数据源由其他attrOptions改为otherAttrList
- 修正选择器显示文案,选中索引为-1时显示“请选择”
- 初始化选择索引为-1,避免默认选中错误值
- 修改根据属性值查找索引逻辑,使用otherAttrList数组
- 更新onOtherAttrChange事件,正确赋值选择的属性
- 新增获取其他属性列表接口调用及数据赋值方法
- 在页面初始化时调用获取其他属性列表方法
parent 5807a98f
Showing with 21 additions and 7 deletions
...@@ -726,9 +726,9 @@ ...@@ -726,9 +726,9 @@
<view class="edit-form-item"> <view class="edit-form-item">
<view class="edit-label">其他属性:</view> <view class="edit-label">其他属性:</view>
<view class="edit-input-box"> <view class="edit-input-box">
<picker @change="onOtherAttrChange" :value="editSkuFormParams.picking_other_attr_index" :range="otherAttrOptions" range-key="label"> <picker @change="onOtherAttrChange" :value="editSkuFormParams.picking_other_attr_index" :range="otherAttrList">
<view class="edit-picker-value row verCenter bothSide"> <view class="edit-picker-value row verCenter bothSide">
<text>{{ otherAttrOptions[editSkuFormParams.picking_other_attr_index].label }}</text> <text>{{ editSkuFormParams.picking_other_attr_index == -1 ? '请选择' : editSkuFormParams.picking_other_attr }}</text>
<text class="iconfont icon-xialajiantou"></text> <text class="iconfont icon-xialajiantou"></text>
</view> </view>
</picker> </picker>
...@@ -909,7 +909,8 @@ ...@@ -909,7 +909,8 @@
{ label: '大盘', value: 1 }, { label: '大盘', value: 1 },
{ label: '小盘', value: 2 }, { label: '小盘', value: 2 },
{ label: '计数', value: 3 } { label: '计数', value: 3 }
] ],
otherAttrList: [] // 其他属性列表
}; };
}, },
onNavigationBarButtonTap(e) { onNavigationBarButtonTap(e) {
...@@ -925,6 +926,9 @@ ...@@ -925,6 +926,9 @@
this.searchParams.stock_out_id = options.stock_out_id || ''; this.searchParams.stock_out_id = options.stock_out_id || '';
this.warehouse_id = options.warehouse_id || ''; this.warehouse_id = options.warehouse_id || '';
// 获取其他属性列表
this.getOtherAttrList();
//深圳自营仓-默认选择旧标签 //深圳自营仓-默认选择旧标签
if (this.warehouse_id == 9) { if (this.warehouse_id == 9) {
this.old_Label = true; this.old_Label = true;
...@@ -1716,8 +1720,8 @@ ...@@ -1716,8 +1720,8 @@
mpq: goodsInfo.mpq || '', mpq: goodsInfo.mpq || '',
picking_mode_index: 0, picking_mode_index: 0,
picking_mode: goodsInfo.picking_mode || 0, picking_mode: goodsInfo.picking_mode || 0,
picking_other_attr_index: 0, picking_other_attr_index: -1,
picking_other_attr: goodsInfo.picking_other_attr || 0, picking_other_attr: goodsInfo.picking_other_attr || '',
standard_length: goodsInfo.standard_length || '', standard_length: goodsInfo.standard_length || '',
standard_width: goodsInfo.standard_width || '', standard_width: goodsInfo.standard_width || '',
standard_high: goodsInfo.standard_high || '', standard_high: goodsInfo.standard_high || '',
...@@ -1742,7 +1746,7 @@ ...@@ -1742,7 +1746,7 @@
} }
if (goodsInfo.picking_other_attr) { if (goodsInfo.picking_other_attr) {
var otherAttrIndex = this.otherAttrOptions.findIndex(opt => opt.value === goodsInfo.picking_other_attr); var otherAttrIndex = this.otherAttrList.findIndex(opt => opt === goodsInfo.picking_other_attr);
if (otherAttrIndex !== -1) { if (otherAttrIndex !== -1) {
this.editSkuFormParams.picking_other_attr_index = otherAttrIndex; this.editSkuFormParams.picking_other_attr_index = otherAttrIndex;
} }
...@@ -1782,7 +1786,7 @@ ...@@ -1782,7 +1786,7 @@
*/ */
onOtherAttrChange(e) { onOtherAttrChange(e) {
this.editSkuFormParams.picking_other_attr_index = e.detail.value; this.editSkuFormParams.picking_other_attr_index = e.detail.value;
this.editSkuFormParams.picking_other_attr = this.otherAttrOptions[e.detail.value].value; this.editSkuFormParams.picking_other_attr = this.otherAttrList[e.detail.value];
}, },
/** /**
* 保存自营资料 * 保存自营资料
...@@ -1819,6 +1823,16 @@ ...@@ -1819,6 +1823,16 @@
}); });
} }
}); });
},
/**
* 获取其他属性列表
*/
getOtherAttrList() {
this.request(API.getOtherAttrList, 'POST', {}, false).then(res => {
if (res.code === 0) {
this.otherAttrList = res.data.list;
}
});
} }
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment