mirror of https://github.com/veops/cmdb.git
fix: computed code area tab
This commit is contained in:
parent
ebe460934d
commit
3398fdf499
|
@ -6,7 +6,12 @@
|
||||||
</a-tab-pane>
|
</a-tab-pane>
|
||||||
<a-tab-pane key="script" :disabled="!canDefineComputed">
|
<a-tab-pane key="script" :disabled="!canDefineComputed">
|
||||||
<span style="font-size:12px;" slot="tab">{{ $t('cmdb.ciType.code') }}</span>
|
<span style="font-size:12px;" slot="tab">{{ $t('cmdb.ciType.code') }}</span>
|
||||||
<codemirror style="z-index: 9999" :options="cmOptions" v-model="compute_script"></codemirror>
|
<codemirror
|
||||||
|
style="z-index: 9999"
|
||||||
|
:options="cmOptions"
|
||||||
|
v-model="compute_script"
|
||||||
|
@input="onCodeChange"
|
||||||
|
></codemirror>
|
||||||
</a-tab-pane>
|
</a-tab-pane>
|
||||||
<template slot="tabBarExtraContent" v-if="showCalcComputed">
|
<template slot="tabBarExtraContent" v-if="showCalcComputed">
|
||||||
<a-button type="primary" size="small" @click="handleCalcComputed">
|
<a-button type="primary" size="small" @click="handleCalcComputed">
|
||||||
|
@ -49,8 +54,26 @@ export default {
|
||||||
height: '200px',
|
height: '200px',
|
||||||
theme: 'monokai',
|
theme: 'monokai',
|
||||||
tabSize: 4,
|
tabSize: 4,
|
||||||
lineWrapping: true,
|
indentUnit: 4,
|
||||||
|
lineWrapping: false,
|
||||||
readOnly: !this.canDefineComputed,
|
readOnly: !this.canDefineComputed,
|
||||||
|
extraKeys: {
|
||||||
|
Tab: (cm) => {
|
||||||
|
if (cm.somethingSelected()) {
|
||||||
|
cm.indentSelection('add')
|
||||||
|
} else {
|
||||||
|
cm.replaceSelection(Array(cm.getOption('indentUnit') + 1).join(' '), 'end', '+input')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'Shift-Tab': (cm) => {
|
||||||
|
if (cm.somethingSelected()) {
|
||||||
|
cm.indentSelection('subtract')
|
||||||
|
} else {
|
||||||
|
const cursor = cm.getCursor()
|
||||||
|
cm.setCursor({ line: cursor.line, ch: cursor.ch - 4 })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -83,6 +106,9 @@ export default {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
onCodeChange(v) {
|
||||||
|
this.compute_script = v.replace('\t', ' ')
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue