|
|
@ -2,9 +2,8 @@ |
|
|
|
<view class="my-2"> |
|
|
|
<!-- 工具箱 --> |
|
|
|
<view v-if="train.tools.length"> |
|
|
|
<u-radio-group v-model="radioDefaultValue" @change="radioGroupChange"> |
|
|
|
<!-- v-for="(tool, index) in train.tools" --> |
|
|
|
<u-radio @change="radioChange" v-for="(tool, index) in train.tools" :key="index" :name="item.toolId"> |
|
|
|
<u-radio-group v-model="radioDefaultValue"> |
|
|
|
<u-radio @change="radioChange(tool)" v-for="(tool, index) in train.tools" :key="index" :name="item.toolId"> |
|
|
|
{{ item.toolCode }} |
|
|
|
</u-radio> |
|
|
|
</u-radio-group> |
|
|
@ -57,9 +56,29 @@ import ProcessRestore from './ProcessRestore'; |
|
|
|
|
|
|
|
export default { |
|
|
|
components: { ResultLevel, ProcessRestore }, |
|
|
|
props: { train: { type: Object, default: null } }, |
|
|
|
props: { train: { type: Object, default: null }, task: { type: Object, default: null } }, |
|
|
|
data() { |
|
|
|
return {}; |
|
|
|
return { |
|
|
|
list: [ |
|
|
|
{ |
|
|
|
id: '1', |
|
|
|
name: 'apple', |
|
|
|
disabled: false, |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: '2', |
|
|
|
name: 'banner', |
|
|
|
disabled: false, |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: '3', |
|
|
|
name: 'orange', |
|
|
|
disabled: false, |
|
|
|
}, |
|
|
|
], |
|
|
|
// u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中 |
|
|
|
value: 'orange', |
|
|
|
}; |
|
|
|
}, |
|
|
|
|
|
|
|
computed: { |
|
|
@ -76,13 +95,18 @@ export default { |
|
|
|
}, |
|
|
|
|
|
|
|
methods: { |
|
|
|
// 选中某个单选框时,由radio时触发 |
|
|
|
radioChange(e) { |
|
|
|
console.log(e); |
|
|
|
}, |
|
|
|
// 选中任一radio时,由radio-group触发 |
|
|
|
radioGroupChange(e) { |
|
|
|
console.log(e); |
|
|
|
/** |
|
|
|
* 选择工具 |
|
|
|
* @param { String } equipmentId 设备ID |
|
|
|
* @param { String } recordId 训练计划ID |
|
|
|
*/ |
|
|
|
async radioChange(item) { |
|
|
|
try { |
|
|
|
const params = { equipmentId: item.equipmentId, recordId: this.task.id }; |
|
|
|
await this.$u.api.chooseTool(params); |
|
|
|
} catch (error) { |
|
|
|
console.error('error: ', error); |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
}; |
|
|
|