This commit is contained in:
@@ -65,10 +65,15 @@
|
||||
<select class="input attr-type" v-model="attr.attrType">
|
||||
<option value="number">数字</option>
|
||||
<option value="text">文本</option>
|
||||
<option value="formula">公式</option>
|
||||
</select>
|
||||
<input class="input attr-unit" v-model="attr.unit" placeholder="单位" />
|
||||
<text class="attr-delete" @click="removeAttr(index)">×</text>
|
||||
</view>
|
||||
<view v-for="(attr, index) in attributes" :key="'formula-'+index" class="formula-item" v-if="attr.attrType === 'formula'">
|
||||
<text class="formula-label">公式:</text>
|
||||
<input class="input formula-input" v-model="attr.formula" placeholder="例如: length * width" />
|
||||
</view>
|
||||
<view class="add-attr-btn" @click="addAttr">
|
||||
<text>+ 添加属性</text>
|
||||
</view>
|
||||
@@ -192,17 +197,18 @@ export default {
|
||||
name: a.name,
|
||||
attrType: a.attrType || 'number',
|
||||
unit: a.unit || '',
|
||||
formula: a.formula || '',
|
||||
attrId: a.attrId
|
||||
}))
|
||||
if (this.attributes.length === 0) {
|
||||
this.attributes.push({ name: '', attrType: 'number', unit: '', attrId: '' })
|
||||
this.attributes.push({ name: '', attrType: 'number', unit: '', formula: '', attrId: '' })
|
||||
}
|
||||
} catch (e) {
|
||||
this.attributes = [{ name: '', attrType: 'number', unit: '', attrId: '' }]
|
||||
this.attributes = [{ name: '', attrType: 'number', unit: '', formula: '', attrId: '' }]
|
||||
}
|
||||
},
|
||||
addAttr() {
|
||||
this.attributes.push({ name: '', attrType: 'number', unit: '', attrId: '' })
|
||||
this.attributes.push({ name: '', attrType: 'number', unit: '', formula: '', attrId: '' })
|
||||
},
|
||||
removeAttr(index) {
|
||||
this.attributes.splice(index, 1)
|
||||
@@ -464,5 +470,29 @@ export default {
|
||||
border: 2rpx dashed #667eea;
|
||||
border-radius: 12rpx;
|
||||
margin-top: 20rpx;
|
||||
|
||||
.formula-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 20rpx;
|
||||
padding: 10rpx 0;
|
||||
background: #fffbe6;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
</style>
|
||||
|
||||
.formula-label {
|
||||
font-size: 26rpx;
|
||||
color: #fa8c16;
|
||||
padding: 0 20rpx;
|
||||
}
|
||||
|
||||
.formula-input {
|
||||
flex: 1;
|
||||
height: 70rpx;
|
||||
background: transparent;
|
||||
border-radius: 12rpx;
|
||||
padding: 0 20rpx;
|
||||
font-size: 26rpx;
|
||||
color: #fa8c16;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user