2024-06-17 23:13:49 +08:00
|
|
|
|
<!-- 用户管理 -->
|
|
|
|
|
<template>
|
2024-06-21 00:50:41 +08:00
|
|
|
|
<div class="app-container model-detail">
|
2024-06-17 23:13:49 +08:00
|
|
|
|
<!-- 用户新增/编辑表单 -->
|
2024-06-21 00:50:41 +08:00
|
|
|
|
<el-card>
|
2024-07-10 02:00:20 +08:00
|
|
|
|
<template #header
|
|
|
|
|
><svg-icon icon-class="pause" style="width: 20px; height: 20px" /> 算子基本信息
|
|
|
|
|
</template>
|
2024-06-17 23:13:49 +08:00
|
|
|
|
<el-row>
|
|
|
|
|
<el-col :lg="12" :xs="24">
|
|
|
|
|
<el-form
|
|
|
|
|
ref="userFormRef"
|
|
|
|
|
:model="formData"
|
|
|
|
|
:rules="rules"
|
|
|
|
|
v-loading="loading"
|
|
|
|
|
label-width="80px"
|
|
|
|
|
>
|
2024-07-10 02:00:20 +08:00
|
|
|
|
<el-form-item label="算子名称" prop="operator_name">
|
|
|
|
|
<el-input v-model="formData.operator_name" placeholder="请输入算子名称" />
|
2024-06-17 23:13:49 +08:00
|
|
|
|
</el-form-item>
|
2024-07-10 02:00:20 +08:00
|
|
|
|
<el-form-item label="算子类型" prop="oper_sub_type">
|
|
|
|
|
<el-row style="width: 100%">
|
2024-06-17 23:13:49 +08:00
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-select
|
2024-07-10 02:00:20 +08:00
|
|
|
|
v-model="formData.oper_main_type"
|
|
|
|
|
placeholder="请选择算子主类型"
|
|
|
|
|
size="large"
|
2024-06-17 23:13:49 +08:00
|
|
|
|
style="width: 100%"
|
2024-07-10 02:00:20 +08:00
|
|
|
|
@change="handleChange"
|
2024-06-17 23:13:49 +08:00
|
|
|
|
>
|
2024-07-10 02:00:20 +08:00
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in listOpt.operTypeList"
|
|
|
|
|
:key="item.oper_main_type"
|
|
|
|
|
:label="item.oper_main_type_name"
|
|
|
|
|
:value="item.oper_main_type"
|
|
|
|
|
/>
|
2024-06-17 23:13:49 +08:00
|
|
|
|
</el-select>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-select
|
2024-07-10 02:00:20 +08:00
|
|
|
|
v-model="formData.oper_sub_type"
|
|
|
|
|
placeholder="请选择算子子类型"
|
|
|
|
|
size="large"
|
2024-06-17 23:13:49 +08:00
|
|
|
|
style="width: 100%"
|
|
|
|
|
>
|
2024-07-10 02:00:20 +08:00
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in listOpt.operTypeList"
|
|
|
|
|
:key="item.oper_sub_type"
|
|
|
|
|
:label="item.oper_sub_type_name"
|
|
|
|
|
:value="item.oper_sub_type"
|
|
|
|
|
/>
|
2024-06-17 23:13:49 +08:00
|
|
|
|
</el-select>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
</el-form-item>
|
2024-07-10 02:00:20 +08:00
|
|
|
|
<el-form-item label="算子说明" prop="operator_desc">
|
2024-06-17 23:13:49 +08:00
|
|
|
|
<el-input
|
2024-07-10 02:00:20 +08:00
|
|
|
|
v-model="formData.operator_desc"
|
2024-06-24 23:18:47 +08:00
|
|
|
|
:rows="2"
|
2024-06-17 23:13:49 +08:00
|
|
|
|
type="textarea"
|
2024-06-24 23:18:47 +08:00
|
|
|
|
placeholder="请输入算子说明"
|
2024-07-10 02:00:20 +08:00
|
|
|
|
maxlength="1024"
|
2024-06-17 23:13:49 +08:00
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
2024-07-10 02:00:20 +08:00
|
|
|
|
<el-form-item label="算子文件">
|
2024-06-17 23:13:49 +08:00
|
|
|
|
<el-upload
|
2024-07-10 02:00:20 +08:00
|
|
|
|
action=""
|
2024-06-17 23:13:49 +08:00
|
|
|
|
class="upload-demo"
|
2024-07-10 02:00:20 +08:00
|
|
|
|
ref="upload"
|
|
|
|
|
:on-change="handleFileChange"
|
|
|
|
|
:on-remove="handleFileRemove"
|
|
|
|
|
:auto-upload="false"
|
|
|
|
|
:limit="1"
|
|
|
|
|
accept="application/json"
|
2024-06-17 23:13:49 +08:00
|
|
|
|
>
|
|
|
|
|
<el-button type="primary"
|
|
|
|
|
><el-icon class="el-icon--upload"> <i-ep-upload-filled /> </el-icon
|
|
|
|
|
>选择文件</el-button
|
|
|
|
|
>
|
|
|
|
|
<template #tip>
|
2024-07-10 02:00:20 +08:00
|
|
|
|
<div class="el-upload__tip">
|
|
|
|
|
请上传大小不超过 <strong style="color: red">10M</strong>,格式为
|
|
|
|
|
<strong style="color: red">json</strong> 的文件
|
|
|
|
|
</div>
|
2024-06-17 23:13:49 +08:00
|
|
|
|
</template>
|
|
|
|
|
</el-upload>
|
|
|
|
|
</el-form-item>
|
2024-07-10 02:00:20 +08:00
|
|
|
|
<el-form-item label="文件预览">
|
|
|
|
|
<pre class="line-numbers"><code :class="`language-${type}`">{{code}}</code></pre>
|
|
|
|
|
</el-form-item>
|
2024-06-17 23:13:49 +08:00
|
|
|
|
</el-form>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :lg="12" :xs="24">
|
2024-06-21 00:19:54 +08:00
|
|
|
|
<!-- <div style="padding-left: 35px">
|
2024-06-17 23:13:49 +08:00
|
|
|
|
<el-divider content-position="left"
|
|
|
|
|
><strong style="color: #409eff">算子参数</strong></el-divider
|
|
|
|
|
>
|
|
|
|
|
<el-table :data="list" style="width: 100%" stripe>
|
2024-06-19 21:43:47 +08:00
|
|
|
|
<el-table-column prop="csmc" label="参数名称" align="left"/>
|
|
|
|
|
<el-table-column prop="csmc" label="参数描述" align="left"/>
|
2024-06-17 23:13:49 +08:00
|
|
|
|
<el-table-column label="操作" fixed="right" width="120">
|
|
|
|
|
<template #default="scope">
|
2024-06-18 01:16:44 +08:00
|
|
|
|
<el-button type="primary" plain size="small"><i-ep-view />查看参数</el-button>
|
2024-06-17 23:13:49 +08:00
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
2024-06-21 00:19:54 +08:00
|
|
|
|
</div> -->
|
2024-06-17 23:13:49 +08:00
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
</el-card>
|
2024-06-21 00:50:41 +08:00
|
|
|
|
<el-card class="card-footer">
|
2024-07-10 02:00:20 +08:00
|
|
|
|
<el-button type="primary" @click="handleSubmit"><i-ep-check />确 定</el-button>
|
|
|
|
|
<el-button @click="closeBack"><i-ep-close />取 消</el-button>
|
2024-06-17 23:13:49 +08:00
|
|
|
|
</el-card>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2024-07-10 02:00:20 +08:00
|
|
|
|
import request from "axios";
|
|
|
|
|
import ConstApi from "@/api/const";
|
|
|
|
|
import JsonViewer from 'vue-json-viewer';
|
2024-06-17 23:13:49 +08:00
|
|
|
|
|
|
|
|
|
import UserAPI from "@/api/user";
|
|
|
|
|
import { UserForm } from "@/api/user/model";
|
|
|
|
|
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
const loading = ref(false); // 加载状态
|
2024-07-10 02:00:20 +08:00
|
|
|
|
const fileStatus = ref(false); // 文件状态
|
|
|
|
|
|
|
|
|
|
// JSON渲染
|
|
|
|
|
const props = withDefaults(defineProps<{
|
|
|
|
|
type?: string
|
|
|
|
|
code: string
|
|
|
|
|
}>(), {
|
|
|
|
|
type: "json",
|
|
|
|
|
code: `<el-upload
|
|
|
|
|
v-model:file-list="fileList"
|
|
|
|
|
class="upload-demo"
|
|
|
|
|
action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15"
|
|
|
|
|
multiple
|
|
|
|
|
:on-preview="handlePreview"
|
|
|
|
|
:on-remove="handleRemove"
|
|
|
|
|
:before-remove="beforeRemove"
|
|
|
|
|
:limit="3"
|
|
|
|
|
:on-exceed="handleExceed"
|
|
|
|
|
>
|
|
|
|
|
<el-button type="primary">Click to upload</el-button>
|
|
|
|
|
<template #tip>
|
|
|
|
|
<div class="el-upload__tip">
|
|
|
|
|
jpg/png files with a size less than 500KB.
|
|
|
|
|
</div>
|
|
|
|
|
</el-upload>
|
|
|
|
|
`
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
watch(() => props.code, () => {
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
Prism.highlightAll()
|
|
|
|
|
})
|
|
|
|
|
})
|
2024-06-17 23:13:49 +08:00
|
|
|
|
|
|
|
|
|
const calTypeList = ref<OptionType[]>(); // 角色下拉数据源
|
|
|
|
|
|
|
|
|
|
// 用户表单数据
|
|
|
|
|
const formData = reactive<UserForm>({
|
|
|
|
|
status: 1,
|
|
|
|
|
});
|
|
|
|
|
|
2024-07-10 02:00:20 +08:00
|
|
|
|
// 基础数据列表
|
|
|
|
|
let listOpt = reactive({
|
|
|
|
|
operTypeList: [],
|
|
|
|
|
operSubTypeList: [],
|
|
|
|
|
});
|
|
|
|
|
|
2024-06-17 23:13:49 +08:00
|
|
|
|
// 校验规则
|
|
|
|
|
const rules = reactive({
|
2024-06-24 23:18:47 +08:00
|
|
|
|
username: [{ required: true, message: "不能为空", trigger: "blur" }],
|
|
|
|
|
nickname: [{ required: true, message: "不能为空", trigger: "blur" }],
|
|
|
|
|
deptId: [{ required: true, message: "不能为空", trigger: "blur" }],
|
|
|
|
|
roleIds: [{ required: true, message: "不能为空", trigger: "blur" }],
|
2024-06-17 23:13:49 +08:00
|
|
|
|
email: [
|
|
|
|
|
{
|
|
|
|
|
pattern: /\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/,
|
|
|
|
|
message: "请输入正确的邮箱地址",
|
|
|
|
|
trigger: "blur",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
mobile: [
|
|
|
|
|
{
|
|
|
|
|
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
|
|
|
|
|
message: "请输入正确的手机号码",
|
|
|
|
|
trigger: "blur",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const list = [
|
|
|
|
|
{
|
|
|
|
|
csmc: "图像分类算子名称",
|
|
|
|
|
csms: "进行19种类型的图像分类模型",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
csmc: "目标检测算子名称",
|
|
|
|
|
csms: "人员检测的模型",
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/** 表单提交 */
|
|
|
|
|
const handleSubmit = useThrottleFn(() => {
|
|
|
|
|
loading.value = true;
|
|
|
|
|
setTimeout(() => {
|
2024-06-20 22:50:57 +08:00
|
|
|
|
ElMessage.success("保存成功");
|
2024-06-17 23:13:49 +08:00
|
|
|
|
loading.value = false;
|
|
|
|
|
closeBack();
|
|
|
|
|
}, 1000);
|
|
|
|
|
}, 3000);
|
|
|
|
|
|
|
|
|
|
/** 返回默认页面 */
|
|
|
|
|
function closeBack() {
|
|
|
|
|
router.replace({ path: "/operatorLibrary/calculate" });
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-10 02:00:20 +08:00
|
|
|
|
/** 算子主类型改变 */
|
|
|
|
|
function handleChange() {
|
|
|
|
|
listOpt.operTypeList.forEach((item) => {
|
|
|
|
|
if (item.oper_main_type == formData.oper_main_type) {
|
|
|
|
|
listOpt.operSubTypeList.value = item.oper_sub_type_list;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 文件上传
|
|
|
|
|
function handleFileChange(file) {
|
|
|
|
|
//先创建一个读文件的对象 FileReader
|
|
|
|
|
let reader = new FileReader();
|
|
|
|
|
//判断浏览器是否支持 FileReader
|
|
|
|
|
if (typeof FileReader === "undefined") {
|
|
|
|
|
this.$message({
|
|
|
|
|
type: "info",
|
|
|
|
|
message: "您的浏览器不支持文件读取。",
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
uploadFile(file).then((res) => {
|
|
|
|
|
props.code = res;
|
|
|
|
|
fileStatus.value = true;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 文件读取
|
|
|
|
|
function uploadFile(file) {
|
|
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
|
|
let reader = new FileReader();
|
|
|
|
|
reader.readAsArrayBuffer(file.raw);
|
|
|
|
|
reader.onload = function (e) {
|
|
|
|
|
var ints = new Uint8Array(e.target.result); //要使用读取的内容,所以将读取内容转化成Uint8Array
|
|
|
|
|
let snippets = new TextDecoder("UTF-8").decode(ints); //二进制缓存区内容转化成中文(即也就是读取到的内容)
|
|
|
|
|
resolve(snippets);
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 文件删除
|
|
|
|
|
function handleFileRemove() {
|
|
|
|
|
props.code = "";
|
|
|
|
|
fileStatus.value = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 初始化选项列表
|
|
|
|
|
const initData = () => {
|
|
|
|
|
request.all(ConstApi.operMainType()).then((res) => {
|
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
listOpt.operTypeList.value = res.data.data.oper_main_type_list;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2024-06-17 23:13:49 +08:00
|
|
|
|
onMounted(() => {
|
2024-07-10 02:00:20 +08:00
|
|
|
|
initData();
|
2024-06-17 23:13:49 +08:00
|
|
|
|
});
|
|
|
|
|
</script>
|
2024-07-10 02:00:20 +08:00
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
.model-detail {
|
|
|
|
|
:deep(.el-card__header) {
|
|
|
|
|
padding: 8px 4px;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
2024-06-21 00:50:41 +08:00
|
|
|
|
}
|
2024-07-10 02:00:20 +08:00
|
|
|
|
.sp-file {
|
|
|
|
|
color: #29d;
|
2024-06-21 00:50:41 +08:00
|
|
|
|
}
|
2024-07-10 02:00:20 +08:00
|
|
|
|
.tb-base-info {
|
|
|
|
|
line-height: 30px;
|
2024-06-21 00:50:41 +08:00
|
|
|
|
}
|
2024-07-10 02:00:20 +08:00
|
|
|
|
:deep(.svg-icon) {
|
|
|
|
|
margin-right: 8px;
|
2024-06-21 00:50:41 +08:00
|
|
|
|
}
|
2024-07-10 02:00:20 +08:00
|
|
|
|
.card-footer {
|
2024-06-17 23:13:49 +08:00
|
|
|
|
position: fixed;
|
2024-06-21 00:50:41 +08:00
|
|
|
|
width: calc(100% - 215px);
|
2024-06-17 23:13:49 +08:00
|
|
|
|
bottom: 0px;
|
2024-07-10 02:00:20 +08:00
|
|
|
|
:deep(.el-card__body) {
|
|
|
|
|
padding: 10px;
|
|
|
|
|
.el-pagination {
|
2024-06-21 00:50:41 +08:00
|
|
|
|
justify-content: end;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-06-17 23:13:49 +08:00
|
|
|
|
}
|
|
|
|
|
</style>
|
2024-07-10 02:00:20 +08:00
|
|
|
|
<style lang="scss">
|
|
|
|
|
pre {
|
|
|
|
|
span {
|
|
|
|
|
font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
|
|
|
|
|
}
|
|
|
|
|
code {
|
|
|
|
|
font-size: 16px !important;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|