| | |
| | | ></u--input> |
| | | </view> |
| | | |
| | | <!-- 图标/箭头类型(例如跳转其它设置页) --> |
| | | <!-- 可以根据需要扩展 v-else-if="item.type === 'link'" --> |
| | | </u-cell> |
| | | |
| | | <!-- 如果需要配置更多设置项,可以参考下方的样式结构 --> |
| | | <!-- |
| | | <u-cell |
| | | title="其他设置" |
| | | :border="true" |
| | | :isLink="true" |
| | | size="large" |
| | | titleStyle="font-size: 30rpx; color: #333333;" |
| | | > |
| | | <view slot="icon" class="cell-icon-wrap bg-yellow"> |
| | | <u-icon name="setting" color="#ffffff" size="20"></u-icon> |
| | | <!-- displayFields 类型设置项(点击打开弹窗) --> |
| | | <view slot="value" v-else-if="item.type === 'displayFields'" @tap="openFieldsPopup(item.key)"> |
| | | <text style="color: #909399; font-size: 26rpx;">{{ $t('settings.manageFields') }} ▶</text> |
| | | </view> |
| | | </u-cell> |
| | | --> |
| | | </u-cell-group> |
| | | </view> |
| | | |
| | | <!-- 字段管理弹窗 --> |
| | | <u-popup |
| | | :show="showFieldsPopup" |
| | | mode="bottom" |
| | | round="12" |
| | | @close="showFieldsPopup = false" |
| | | > |
| | | <view class="fields-popup"> |
| | | <view class="fields-popup-header"> |
| | | <text class="fields-popup-title">{{ $t('settings.containerBindingFields') }}</text> |
| | | <text class="fields-popup-restore" @tap="restoreDefaultFields">{{ $t('settings.restoreDefault') }}</text> |
| | | </view> |
| | | |
| | | <!-- 已配置字段列表 --> |
| | | <view class="fields-list"> |
| | | <view |
| | | class="field-item" |
| | | v-for="(field, idx) in editingFields" |
| | | :key="idx" |
| | | > |
| | | <view class="field-info"> |
| | | <text class="field-name">{{ field.field }}</text> |
| | | <text class="field-label">{{ $t(field.label) }}</text> |
| | | </view> |
| | | <u-icon |
| | | name="minus-circle-fill" |
| | | color="#f56c6c" |
| | | size="22" |
| | | @click="removeField(idx)" |
| | | ></u-icon> |
| | | </view> |
| | | </view> |
| | | |
| | | <!-- 添加新字段 --> |
| | | <view class="add-field-section"> |
| | | <view class="add-field-row"> |
| | | <u--input |
| | | v-model="newFieldName" |
| | | :placeholder="$t('settings.fieldName')" |
| | | border="surround" |
| | | customStyle="flex: 1; margin-right: 16rpx;" |
| | | ></u--input> |
| | | <u--input |
| | | v-model="newFieldLabel" |
| | | :placeholder="$t('settings.fieldLabel')" |
| | | border="surround" |
| | | customStyle="flex: 1;" |
| | | ></u--input> |
| | | </view> |
| | | <u-button |
| | | type="primary" |
| | | size="small" |
| | | :text="$t('settings.addField')" |
| | | @click="addField" |
| | | customStyle="margin-top: 16rpx;" |
| | | ></u-button> |
| | | </view> |
| | | |
| | | <!-- 底部按钮 --> |
| | | <view class="fields-popup-footer"> |
| | | <u-button |
| | | :text="$t('common.cancel')" |
| | | @click="showFieldsPopup = false" |
| | | customStyle="flex: 1; margin-right: 20rpx;" |
| | | ></u-button> |
| | | <u-button |
| | | type="primary" |
| | | :text="$t('common.confirm')" |
| | | @click="saveFields" |
| | | customStyle="flex: 1;" |
| | | ></u-button> |
| | | </view> |
| | | </view> |
| | | </u-popup> |
| | | </view> |
| | | </template> |
| | | |
| | |
| | | orderCombNeedSplit: true, |
| | | orderCombSeparator: ';', |
| | | orderCombArrayIndex: 0, |
| | | orderCombStartPos: 3 |
| | | } |
| | | orderCombStartPos: 3, |
| | | containerBindingFields: [ |
| | | { field: 'maktx', label: 'container.matName' }, |
| | | { field: 'specs', label: 'container.matSpec' }, |
| | | { field: 'batch', label: 'container.matBatch' }, |
| | | { field: 'anfme', label: 'container.matQty' } |
| | | ] |
| | | }, |
| | | showFieldsPopup: false, |
| | | editingFieldsKey: '', |
| | | editingFields: [], |
| | | newFieldName: '', |
| | | newFieldLabel: '', |
| | | defaultContainerBindingFields: [ |
| | | { field: 'maktx', label: 'container.matName' }, |
| | | { field: 'specs', label: 'container.matSpec' }, |
| | | { field: 'batch', label: 'container.matBatch' }, |
| | | { field: 'anfme', label: 'container.matQty' } |
| | | ] |
| | | } |
| | | }, |
| | | computed: { |
| | |
| | | iconName: 'play-right-fill', |
| | | iconBgColor: 'bg-green', |
| | | type: 'number' |
| | | }, |
| | | { |
| | | key: 'containerBindingFields', |
| | | title: this.$t('settings.containerBindingFields'), |
| | | iconName: 'grid-fill', |
| | | iconBgColor: 'bg-green', |
| | | type: 'displayFields' |
| | | } |
| | | ] |
| | | } |
| | |
| | | methods: { |
| | | saveSettings() { |
| | | uni.setStorageSync('appSettings', this.appSettings) |
| | | }, |
| | | openFieldsPopup(key) { |
| | | this.editingFieldsKey = key |
| | | this.editingFields = JSON.parse(JSON.stringify(this.appSettings[key] || [])) |
| | | this.newFieldName = '' |
| | | this.newFieldLabel = '' |
| | | this.showFieldsPopup = true |
| | | }, |
| | | removeField(idx) { |
| | | this.editingFields.splice(idx, 1) |
| | | }, |
| | | addField() { |
| | | if (!this.newFieldName || !this.newFieldLabel) { |
| | | uni.showToast({ title: this.$t('settings.fieldRequired'), icon: 'none' }) |
| | | return |
| | | } |
| | | this.editingFields.push({ |
| | | field: this.newFieldName, |
| | | label: this.newFieldLabel |
| | | }) |
| | | this.newFieldName = '' |
| | | this.newFieldLabel = '' |
| | | }, |
| | | restoreDefaultFields() { |
| | | this.editingFields = JSON.parse(JSON.stringify(this.defaultContainerBindingFields)) |
| | | }, |
| | | saveFields() { |
| | | this.appSettings[this.editingFieldsKey] = JSON.parse(JSON.stringify(this.editingFields)) |
| | | this.saveSettings() |
| | | this.showFieldsPopup = false |
| | | } |
| | | } |
| | | } |
| | |
| | | .bg-green { |
| | | background-color: #63d98f; |
| | | } |
| | | |
| | | /* 字段管理弹窗样式 */ |
| | | .fields-popup { |
| | | padding: 40rpx 30rpx; |
| | | max-height: 70vh; |
| | | } |
| | | |
| | | .fields-popup-header { |
| | | display: flex; |
| | | justify-content: space-between; |
| | | align-items: center; |
| | | margin-bottom: 30rpx; |
| | | } |
| | | |
| | | .fields-popup-title { |
| | | font-size: 32rpx; |
| | | font-weight: bold; |
| | | color: #303133; |
| | | } |
| | | |
| | | .fields-popup-restore { |
| | | font-size: 26rpx; |
| | | color: #409eff; |
| | | } |
| | | |
| | | .fields-list { |
| | | max-height: 400rpx; |
| | | overflow-y: auto; |
| | | margin-bottom: 30rpx; |
| | | } |
| | | |
| | | .field-item { |
| | | display: flex; |
| | | justify-content: space-between; |
| | | align-items: center; |
| | | padding: 20rpx 16rpx; |
| | | background-color: #f5f7fa; |
| | | border-radius: 8rpx; |
| | | margin-bottom: 12rpx; |
| | | } |
| | | |
| | | .field-info { |
| | | display: flex; |
| | | flex-direction: column; |
| | | } |
| | | |
| | | .field-name { |
| | | font-size: 28rpx; |
| | | color: #303133; |
| | | font-weight: 500; |
| | | } |
| | | |
| | | .field-label { |
| | | font-size: 24rpx; |
| | | color: #909399; |
| | | margin-top: 4rpx; |
| | | } |
| | | |
| | | .add-field-section { |
| | | padding: 20rpx 0; |
| | | border-top: 1px solid #ebeef5; |
| | | } |
| | | |
| | | .add-field-row { |
| | | display: flex; |
| | | align-items: center; |
| | | } |
| | | |
| | | .fields-popup-footer { |
| | | display: flex; |
| | | margin-top: 30rpx; |
| | | } |
| | | </style> |