Skip to content

Commit

Permalink
perf: 编辑执行方案的名称,空间太小了,改成和新建的一致 TencentBlueKing#1300
Browse files Browse the repository at this point in the history
  • Loading branch information
hLinx committed Sep 21, 2022
1 parent 3c4efc5 commit 60f93c0
Showing 1 changed file with 8 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
enter-trigger
:maxlength="60"
behavior="simplicity"
@input="handleInput"
@submit="handleSubmit" />
<i
v-if="errorInfo"
Expand All @@ -46,10 +45,9 @@
</div>
</template>
<script>
import _ from 'lodash';
import TaskPlanService from '@service/task-plan';
import I18n from '@/i18n';
import { calcTextWidth, getOffset } from '@utils/assist';
import { getOffset } from '@utils/assist';
import { planNameRule } from '@utils/validator';
export default {
Expand Down Expand Up @@ -104,26 +102,14 @@
this.isSubmiting = false;
this.isEditing = true;
this.errorInfo = '';
this.inputWidth = this.$refs.text.getBoundingClientRect().width;
const windowClienWidth = window.innerWidth;
const { left } = getOffset(this.$refs.box);
this.inputWidth = windowClienWidth - left - 230;
// 输入框自动获取焦点
setTimeout(() => {
this.$refs.input.$el.querySelector('.bk-form-input').focus();
});
},
/**
* @desc 用户输入时自适应输入框宽度
* @param { String } value 输入值
*/
handleInput: _.throttle(function (value) {
const windowClienWidth = window.innerWidth;
const offset = 60;
const width = calcTextWidth(value, this.$refs.box) + offset;
const { left } = getOffset(this.$refs.box);
const maxWidth = windowClienWidth - left - 230;
if (width <= maxWidth && width > this.inputWidth) {
this.inputWidth = width;
}
}, 60),
/**
* @desc 提交编辑值
*/
Expand Down Expand Up @@ -173,7 +159,10 @@
this.isEditing = false;
this.$emit('on-edit-success');
this.messageSuccess(I18n.t('template.执行方案名称编辑成功'));
});
})
.finally(() => {
this.isSubmiting = false;
});
});
},
},
Expand Down

0 comments on commit 60f93c0

Please sign in to comment.