feat: 属性配置支持公式类型输入
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Agent
2026-03-30 13:54:21 +00:00
parent 7df8920049
commit 24ab834a27

View File

@@ -65,10 +65,15 @@
<select class="input attr-type" v-model="attr.attrType"> <select class="input attr-type" v-model="attr.attrType">
<option value="number">数字</option> <option value="number">数字</option>
<option value="text">文本</option> <option value="text">文本</option>
<option value="formula">公式</option>
</select> </select>
<input class="input attr-unit" v-model="attr.unit" placeholder="单位" /> <input class="input attr-unit" v-model="attr.unit" placeholder="单位" />
<text class="attr-delete" @click="removeAttr(index)">×</text> <text class="attr-delete" @click="removeAttr(index)">×</text>
</view> </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"> <view class="add-attr-btn" @click="addAttr">
<text>+ 添加属性</text> <text>+ 添加属性</text>
</view> </view>
@@ -192,17 +197,18 @@ export default {
name: a.name, name: a.name,
attrType: a.attrType || 'number', attrType: a.attrType || 'number',
unit: a.unit || '', unit: a.unit || '',
formula: a.formula || '',
attrId: a.attrId attrId: a.attrId
})) }))
if (this.attributes.length === 0) { if (this.attributes.length === 0) {
this.attributes.push({ name: '', attrType: 'number', unit: '', attrId: '' }) this.attributes.push({ name: '', attrType: 'number', unit: '', formula: '', attrId: '' })
} }
} catch (e) { } catch (e) {
this.attributes = [{ name: '', attrType: 'number', unit: '', attrId: '' }] this.attributes = [{ name: '', attrType: 'number', unit: '', formula: '', attrId: '' }]
} }
}, },
addAttr() { addAttr() {
this.attributes.push({ name: '', attrType: 'number', unit: '', attrId: '' }) this.attributes.push({ name: '', attrType: 'number', unit: '', formula: '', attrId: '' })
}, },
removeAttr(index) { removeAttr(index) {
this.attributes.splice(index, 1) this.attributes.splice(index, 1)
@@ -464,5 +470,29 @@ export default {
border: 2rpx dashed #667eea; border: 2rpx dashed #667eea;
border-radius: 12rpx; border-radius: 12rpx;
margin-top: 20rpx; margin-top: 20rpx;
.formula-item {
display: flex;
align-items: center;
margin-bottom: 20rpx;
padding: 10rpx 0;
background: #fffbe6;
border-radius: 12rpx;
}
.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> </style>