feat (接口定义): 完善操作历史代码

This commit is contained in:
fit2-zhao 2021-10-15 10:28:47 +08:00 committed by fit2-zhao
parent bb2e85c418
commit 960acf52b3
2 changed files with 11 additions and 62 deletions

View File

@ -6,8 +6,7 @@
<el-col class="kv-checkbox" v-if="isShowEnable"> <el-col class="kv-checkbox" v-if="isShowEnable">
<el-checkbox v-if="!isDisable(index)" v-model="item.enable" :disabled="isReadOnly"/> <el-checkbox v-if="!isDisable(index)" v-model="item.enable" :disabled="isReadOnly"/>
</el-col> </el-col>
<span style="margin-left: 10px" v-else></span> <span style="margin-left: 10px" v-else/>
<el-col class="item"> <el-col class="item">
<input class="el-input el-input__inner" v-if="!suggestions" :disabled="isReadOnly" v-model="item.name" size="small" maxlength="200" show-word-limit :style="item.style"/> <input class="el-input el-input__inner" v-if="!suggestions" :disabled="isReadOnly" v-model="item.name" size="small" maxlength="200" show-word-limit :style="item.style"/>
<el-autocomplete :disabled="isReadOnly" :maxlength="400" v-if="suggestions" v-model="item.name" size="small" show-word-limit :style="item.style"/> <el-autocomplete :disabled="isReadOnly" :maxlength="400" v-if="suggestions" v-model="item.name" size="small" show-word-limit :style="item.style"/>
@ -29,6 +28,8 @@
</template> </template>
<script> <script>
const background_new = "background:#F3E6E7;";
const background_old = "background:#E2ECDC";
export default { export default {
name: "MsApiKeyValueDetail", name: "MsApiKeyValueDetail",
components: {}, components: {},
@ -111,13 +112,13 @@ export default {
if (itemStr.indexOf("--name") !== -1) { if (itemStr.indexOf("--name") !== -1) {
itemStr = itemStr.replaceAll("--", ""); itemStr = itemStr.replaceAll("--", "");
let obj = JSON.parse(itemStr); let obj = JSON.parse(itemStr);
obj.style = "background:#F3E6E7;text-decoration:line-through;text-decoration-color:red"; obj.style = background_new;
obj.box = true; obj.box = true;
this.data.push(obj); this.data.push(obj);
} else if (itemStr.indexOf("++name") !== -1) { } else if (itemStr.indexOf("++name") !== -1) {
itemStr = itemStr.replaceAll("++", ""); itemStr = itemStr.replaceAll("++", "");
let obj = JSON.parse(itemStr); let obj = JSON.parse(itemStr);
obj.style = "background:#E2ECDC"; obj.style = background_old;
this.data.push(obj); this.data.push(obj);
} else if (itemStr.indexOf("**") !== -1) { } else if (itemStr.indexOf("**") !== -1) {
itemMap.forEach(function (value, key) { itemMap.forEach(function (value, key) {
@ -129,10 +130,10 @@ export default {
newObj[key] = value; newObj[key] = value;
} }
}); });
item.style = "background:#E2ECDC"; item.style = background_old;
this.data.push(item); this.data.push(item);
newObj["box"] = true; newObj["box"] = true;
newObj["style"] = "background:#F3E6E7;text-decoration:line-through;text-decoration-color:red"; newObj["style"] = background_new;
newObj["required"] = newObj.required ? this.$t('commons.selector.required') : this.$t('commons.selector.not_required'); newObj["required"] = newObj.required ? this.$t('commons.selector.required') : this.$t('commons.selector.not_required');
this.data.push(newObj); this.data.push(newObj);
} else { } else {

View File

@ -6,27 +6,22 @@
<el-tag <el-tag
:class="getClass(tag)" :class="getClass(tag)"
v-for="(tag, idx) in innerTags" v-for="(tag) in innerTags"
v-bind="$attrs" v-bind="$attrs"
type="info" type="info"
:key="tag" :key="tag"
:size="size" :size="size"
:closable="!readOnly" :closable="!readOnly"
:disable-transitions="false" :disable-transitions="false">
@close="remove(idx)">
{{ getTag(tag) }} {{ getTag(tag) }}
</el-tag> </el-tag>
<input <input
:disabled="readOnly" :disabled="readOnly"
class="tag-input el-input" class="tag-input el-input"
v-model="newTag" v-model="newTag"
:placeholder="$t('commons.tag_tip')" :placeholder="$t('commons.tag_tip')"/>
@keydown.delete.stop="removeLastTag"
@keydown="addNew"
@blur="addNew"/>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
name: 'MsInputTag', name: 'MsInputTag',
@ -63,53 +58,6 @@ export default {
} }
}, },
methods: { methods: {
addNew(e) {
if (e && (!this.addTagOnKeys.includes(e.keyCode)) && (e.type !== 'blur')) {
return
}
if (e) {
e.stopPropagation()
e.preventDefault()
}
let addSuccess = false
if (this.newTag.includes(',')) {
this.newTag.split(',').forEach(item => {
if (this.addTag(item.trim())) {
addSuccess = true
}
})
} else {
if (this.addTag(this.newTag.trim())) {
addSuccess = true
}
}
if (addSuccess) {
this.tagChange()
this.newTag = ''
}
},
addTag(tag) {
tag = tag.trim()
if (tag && !this.innerTags.includes(tag)) {
this.innerTags.push(tag)
return true
}
return false
},
remove(index) {
this.innerTags.splice(index, 1)
this.tagChange()
},
removeLastTag() {
if (this.newTag) {
return
}
this.innerTags.pop()
this.tagChange()
},
tagChange() {
this.$emit('input', this.innerTags)
},
getTag(tag) { getTag(tag) {
if (tag && (tag.indexOf("++") !== -1 || tag.indexOf("--") !== -1)) { if (tag && (tag.indexOf("++") !== -1 || tag.indexOf("--") !== -1)) {
tag = tag.substring(2); tag = tag.substring(2);