计算:功能实现
This commit is contained in:
parent
3f24d59284
commit
13807f850b
@ -11,6 +11,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="modulesList">
|
||||
<el-scrollbar>
|
||||
<div class="moduleRow" v-for="row in rowLength" :key="moduleList[(row - 1) * colLen].name">
|
||||
<div class="moduleItem">
|
||||
<div class="itemMain">
|
||||
@ -39,9 +40,21 @@
|
||||
</el-icon>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
<el-button type="primary">查看</el-button>
|
||||
<el-button v-if="moduleList[(row - 1) * colLen].disabled === 1" type="primary" plain @click="active(moduleList[(row - 1) * colLen].name)">激活</el-button>
|
||||
<el-button v-if="moduleList[(row - 1) * colLen].disabled === 0" type="danger" plain @click="deactive(moduleList[(row - 1) * colLen].name)">禁用</el-button>
|
||||
<el-button type="primary" @click="getScript(moduleList[(row - 1) * colLen].name)">查看</el-button>
|
||||
<el-button
|
||||
v-if="moduleList[(row - 1) * colLen].disabled === 1"
|
||||
type="primary"
|
||||
plain
|
||||
@click="active(moduleList[(row - 1) * colLen].name)"
|
||||
>激活</el-button
|
||||
>
|
||||
<el-button
|
||||
v-if="moduleList[(row - 1) * colLen].disabled === 0"
|
||||
type="danger"
|
||||
plain
|
||||
@click="deactive(moduleList[(row - 1) * colLen].name)"
|
||||
>禁用</el-button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="moduleItem" v-if="moduleList[(row - 1) * colLen + 1]">
|
||||
@ -54,8 +67,7 @@
|
||||
<div class="updateTime">{{ '更新于:----' }}</div>
|
||||
<!--
|
||||
<div class="updateTime">{{ '更新于:' + moduleList[(row - 1) * colLen + 1]?.updateTime ?? '--' }}</div>
|
||||
-->
|
||||
</div>
|
||||
--></div>
|
||||
<div class="main-main">
|
||||
{{ moduleList[(row - 1) * colLen + 1].description }}
|
||||
</div>
|
||||
@ -71,7 +83,7 @@
|
||||
</el-icon>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
<el-button type="primary">查看</el-button>
|
||||
<el-button type="primary" @click="getScript(moduleList[(row - 1) * colLen + 1].name)">查看</el-button>
|
||||
<el-button
|
||||
v-if="moduleList[(row - 1) * colLen + 1].disabled === 1"
|
||||
type="primary"
|
||||
@ -90,8 +102,14 @@
|
||||
</div>
|
||||
<div class="moduleItem" style="visibility: hidden" v-else></div>
|
||||
</div>
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
</div>
|
||||
<el-dialog v-model="previewVisible" title="脚本预览" width="800">
|
||||
<el-scrollbar height="500">
|
||||
<p v-html="previewContent"></p>
|
||||
</el-scrollbar>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
@ -118,7 +136,6 @@ const rowLength = computed(() => {
|
||||
|
||||
const getList = () => {
|
||||
getCalcListReq().then((res) => {
|
||||
console.log(res)
|
||||
moduleList.value = res.data
|
||||
})
|
||||
}
|
||||
@ -127,16 +144,16 @@ const upload = ref<UploadInstance>()
|
||||
const handleExceed: UploadProps['onExceed'] = (files) => {
|
||||
upload.value!.clearFiles()
|
||||
const file = files[0] as UploadRawFile
|
||||
|
||||
file.uid = genFileId()
|
||||
|
||||
upload.value!.handleStart(file)
|
||||
upload.value!.submit()
|
||||
}
|
||||
const register = (options: any) => {
|
||||
console.log(options)
|
||||
const formData = new FormData()
|
||||
formData.append('file', options.file)
|
||||
registerCalcReq(formData).then((res) => {
|
||||
console.log(res)
|
||||
|
||||
if (res.success) {
|
||||
ElMessage.success('注册/更新成功!')
|
||||
getList()
|
||||
@ -153,30 +170,69 @@ const remove = (name: string) => {
|
||||
})
|
||||
}
|
||||
const active = (name: string) => {
|
||||
console.log(name);
|
||||
|
||||
activeCalcReq({ moduleName: name }).then((res) => {
|
||||
activeCalcReq({ moduleName: name })
|
||||
.then((res) => {
|
||||
if (res.success) {
|
||||
ElMessage.success('激活成功!')
|
||||
getList()
|
||||
} else {
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
ElMessage.error('激活失败!')
|
||||
})
|
||||
}
|
||||
const deactive = (name: string) => {
|
||||
deactiveCalcReq({ moduleName: name }).then((res) => {
|
||||
deactiveCalcReq({ moduleName: name })
|
||||
.then((res) => {
|
||||
if (res.success) {
|
||||
ElMessage.success('禁用成功!')
|
||||
getList()
|
||||
} else {
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
ElMessage.error('禁用失败!')
|
||||
})
|
||||
}
|
||||
|
||||
const previewVisible = ref(false)
|
||||
const previewContent = ref('')
|
||||
|
||||
const getScript = (name: string) => {
|
||||
getScriptCalcReq({ moduleName: name }).then((res) => {
|
||||
if (res.success) {
|
||||
// 预览
|
||||
const txt = 'data:text/plain;charset=utf-8;base64,' + res.data
|
||||
const blob = base64ToBlob(txt)
|
||||
blob.text().then((text) => {
|
||||
let showText = ''
|
||||
for (let i = 0; i < text.length; i++) {
|
||||
if (text[i] == '\n') {
|
||||
showText += '<br>'
|
||||
continue
|
||||
}
|
||||
showText += text[i]
|
||||
}
|
||||
previewContent.value = showText
|
||||
previewVisible.value = true
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
const base64ToBlob = (dataurl: string) => {
|
||||
let arr = dataurl.split(',')
|
||||
let mime = arr[0].match(/:(.*?);/)![1]
|
||||
let bstr = atob(arr[1])
|
||||
let n = bstr.length
|
||||
let u8arr = new Uint8Array(n)
|
||||
while (n--) {
|
||||
u8arr[n] = bstr.charCodeAt(n)
|
||||
}
|
||||
return new Blob([u8arr], { type: 'text/plain' })
|
||||
}
|
||||
getList()
|
||||
</script>
|
||||
|
||||
@ -222,9 +278,7 @@ getList()
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
max-height: 100%;
|
||||
height: calc(100% - 60px);
|
||||
min-width: 912px;
|
||||
.moduleRow {
|
||||
display: flex;
|
||||
|
Loading…
Reference in New Issue
Block a user