提交代码
parent
e3c367de3f
commit
97e9012556
|
@ -1,3 +1,8 @@
|
|||
# 代理前缀
|
||||
VITE_APP_BASE_API = '/mk/ai/api/'
|
||||
# VITE_APP_BASE_API = '/mk/ai/api/'
|
||||
|
||||
VITE_APP_BASE_API = '/api'
|
||||
|
||||
# 线上接口地址
|
||||
# VITE_APP_API_URL = http://10.5.1.137:8800
|
||||
|
||||
|
|
|
@ -1,57 +1,65 @@
|
|||
import request from "@/utils/request";
|
||||
//获取算子列表
|
||||
const list=(data)=>{
|
||||
const list = (data) => {
|
||||
return request({
|
||||
url: `/operators`,
|
||||
method: "get",
|
||||
params:data
|
||||
});
|
||||
params: data
|
||||
});
|
||||
}
|
||||
//新增算子
|
||||
const add=(data)=>{
|
||||
const add = (data) => {
|
||||
return request({
|
||||
url: `/operators`,
|
||||
method: "post",
|
||||
data:data
|
||||
});
|
||||
data: data
|
||||
});
|
||||
}
|
||||
//获取算子程序列表
|
||||
const getPrograms=(data)=>{
|
||||
const getPrograms = (data) => {
|
||||
return request({
|
||||
url: `/operators/programs`,
|
||||
method: "get",
|
||||
params:data
|
||||
});
|
||||
params: data
|
||||
});
|
||||
}
|
||||
//新增算子程序文件
|
||||
const addPrograms=(data)=>{
|
||||
const addPrograms = (data) => {
|
||||
return request({
|
||||
url: `/operators/programs`,
|
||||
method: "post",
|
||||
data:data
|
||||
});
|
||||
data: data
|
||||
});
|
||||
}
|
||||
//删除算子程序文件
|
||||
const deletePrograms=(id)=>{
|
||||
const deletePrograms = (id) => {
|
||||
return request({
|
||||
url: `/operators/programs/${id}`,
|
||||
method: "delete"
|
||||
});
|
||||
});
|
||||
}
|
||||
//删除算子
|
||||
const deleteOperator=(id)=>{
|
||||
const deleteOperator = (id) => {
|
||||
return request({
|
||||
url: `/operators/${id}`,
|
||||
method: "delete"
|
||||
});
|
||||
});
|
||||
}
|
||||
//获取算子详情
|
||||
const findOne=(id)=>{
|
||||
const findOne = (id) => {
|
||||
return request({
|
||||
url: `/operators/${id}`,
|
||||
method: "get"
|
||||
});
|
||||
});
|
||||
}
|
||||
//获取算子详情
|
||||
const uploadProgramsFile = (data) => {
|
||||
return request({
|
||||
url: `/operators/programs/upload`,
|
||||
method: "post"
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
export default {
|
||||
list,
|
||||
|
@ -60,5 +68,6 @@ export default {
|
|||
addPrograms,
|
||||
deletePrograms,
|
||||
deleteOperator,
|
||||
findOne
|
||||
findOne,
|
||||
uploadProgramsFile
|
||||
}
|
|
@ -34,17 +34,22 @@ service.interceptors.response.use(
|
|||
) {
|
||||
return response;
|
||||
}
|
||||
|
||||
if(true){
|
||||
return response;
|
||||
}
|
||||
// if(true){
|
||||
// return response;
|
||||
// }
|
||||
const { code, data, msg } = response.data;
|
||||
if (code === ResultEnum.SUCCESS) {
|
||||
return data;
|
||||
}
|
||||
|
||||
ElMessage.error(msg || "系统出错");
|
||||
return Promise.reject(new Error(msg || "Error"));
|
||||
return response;
|
||||
}else if (code === ResultEnum.TOKEN_INVALID) {
|
||||
ElMessage.warning("登录状态已过期,请重新登录");
|
||||
const userStore = useUserStoreHook();
|
||||
userStore.resetToken().then(() => {
|
||||
location.href = '#/login';
|
||||
});
|
||||
}else{
|
||||
ElMessage.error(msg || "系统出错");
|
||||
return Promise.reject(new Error(msg || "Error"));
|
||||
}
|
||||
},
|
||||
(error: any) => {
|
||||
// 异常处理
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
<!-- 账号密码提示 -->
|
||||
<div class="mt-10 text-sm">
|
||||
<span>{{ $t("login.username") }}: admin</span>
|
||||
<span class="ml-4"> {{ $t("login.password") }}: 123456</span>
|
||||
<span class="ml-4"> {{ $t("login.password") }}: 12345678</span>
|
||||
</div>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
@ -159,7 +159,6 @@ function handleLogin() {
|
|||
},
|
||||
{}
|
||||
);
|
||||
|
||||
router.push({ path: redirect, query: otherQueryParams });
|
||||
})
|
||||
.catch((e) => {
|
||||
|
|
|
@ -10,7 +10,12 @@
|
|||
<el-col :lg="12" :xs="24">
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" label-width="80px">
|
||||
<el-form-item label="算子名称" prop="operator_name">
|
||||
<el-input v-model="formData.operator_name" placeholder="请输入算子名称" />
|
||||
<el-input
|
||||
v-model="formData.operator_name"
|
||||
maxlength="64"
|
||||
show-word-limit
|
||||
placeholder="请输入算子名称"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="算子类型" prop="oper_sub_type">
|
||||
<el-row style="width: 100%">
|
||||
|
@ -107,8 +112,8 @@
|
|||
|
||||
<script setup lang="ts">
|
||||
import ConstApi from "@/api/const";
|
||||
import { useUserStore } from "@/store";
|
||||
import OperatorApi from "@/api/operator";
|
||||
|
||||
const router = useRouter();
|
||||
const formRef = ref(ElForm); // 表单
|
||||
const loading = ref(false); // 加载状态
|
||||
|
@ -121,7 +126,6 @@ const uploadRef = ref<UploadInstance>();
|
|||
const formData = reactive({
|
||||
status: 1,
|
||||
});
|
||||
const userStore = useUserStore();
|
||||
|
||||
// 基础数据列表
|
||||
let listOpt = reactive({
|
||||
|
@ -132,9 +136,9 @@ let listOpt = reactive({
|
|||
// 校验规则
|
||||
const rules = reactive({
|
||||
operator_name: [{ required: true, message: "算子名称不能为空", trigger: "blur" }],
|
||||
oper_main_type: [{ required: true, message: "算子类型不能为空", trigger: "blur" }],
|
||||
oper_sub_type: [{ required: true, message: "算子类型不能为空", trigger: "blur" }],
|
||||
operator_desc: [{ required: true, message: "算子说明不能为空", trigger: "blur" }],
|
||||
oper_main_type: [{ required: true, message: "算子类型不能为空", trigger: "change" }],
|
||||
oper_sub_type: [{ required: true, message: "算子类型不能为空", trigger: "change" }],
|
||||
operator_desc: [{ required: false, message: "算子说明不能为空", trigger: "blur" }],
|
||||
parameters: [{ required: true, message: "算子文件不能为空", trigger: "blur" }],
|
||||
});
|
||||
|
||||
|
@ -149,8 +153,6 @@ const handleSubmit = useThrottleFn(() => {
|
|||
formRef.value.validate((valid: any) => {
|
||||
if (valid) {
|
||||
loading.value = true;
|
||||
formData.user_id = userStore.user?.id;
|
||||
formData.create_time = new Date();
|
||||
OperatorApi.add(formData)
|
||||
.then((res) => {
|
||||
if (res.data.code == 0) {
|
||||
|
@ -172,7 +174,7 @@ function closeBack() {
|
|||
|
||||
/** 算子主类型改变 */
|
||||
function handleChange() {
|
||||
router.pushpeList.forEach((item) => {
|
||||
listOpt.operTypeList.forEach((item) => {
|
||||
if (item.oper_main_type == formData.oper_main_type) {
|
||||
listOpt.operSubTypeList = item.oper_sub_type_list;
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@
|
|||
<el-card class="card-footer">
|
||||
<el-button @click="closeBack"><i-ep-close />取 消</el-button>
|
||||
</el-card>
|
||||
<paramDialog ref="paramDialogRef"></paramDialog>
|
||||
<paramDialog ref="paramDialogRef" @myQuery="handleQuery"></paramDialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
|
@ -33,18 +33,23 @@
|
|||
placeholder="请输入程序版本"
|
||||
/>
|
||||
</el-form-item>
|
||||
<!--整数@input="filterInput"-->
|
||||
<el-form-item label="程序文件" prop="program_file_name">
|
||||
<el-upload
|
||||
v-model:file-list="fileList"
|
||||
action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15"
|
||||
ref="uploadRef"
|
||||
:action="uploadUrl"
|
||||
:headers="headersObject"
|
||||
v-model:file-list="fileList"
|
||||
class="upload-demo"
|
||||
:data="uploadData"
|
||||
:on-exceed="handleFileExceed"
|
||||
:on-change="handleFileChange"
|
||||
:auto-upload="false"
|
||||
:before-upload="beforeUpload"
|
||||
:on-success="uploadsuccess"
|
||||
:auto-upload="true"
|
||||
:limit="1"
|
||||
accept="application/x-tar"
|
||||
accept="application/x-gzip"
|
||||
>
|
||||
<!--el-upload-accept 多个以逗号隔开application/x-tar-->
|
||||
<el-button type="primary"
|
||||
><el-icon class="el-icon--upload"> <i-ep-upload-filled /> </el-icon
|
||||
>选择文件</el-button
|
||||
|
@ -70,6 +75,7 @@
|
|||
<script setup name="calculateParam">
|
||||
import ConstApi from "@/api/const";
|
||||
import OperatorApi from "@/api/operator";
|
||||
import { TOKEN_KEY } from "@/enums/CacheEnum";
|
||||
|
||||
const open = ref(false); // 表单数据
|
||||
const form = ref({}); // 表单数据
|
||||
|
@ -78,6 +84,16 @@ const formRef = ref(ElForm); // 表单
|
|||
const loading = ref(false); // 加载状态
|
||||
const fileList = ref([]); // 文件列表
|
||||
const uploadRef = ref(""); // 上传组件
|
||||
const uploadUrl = ref(import.meta.env.VITE_APP_BASE_API + "/operators/programs/upload"); // 上传组件
|
||||
const uploadData = reactive({
|
||||
program_file_name: null,
|
||||
file_content: null,
|
||||
});
|
||||
|
||||
// 上传请求头
|
||||
const headersObject = reactive({
|
||||
Authorization: localStorage.getItem(TOKEN_KEY),
|
||||
});
|
||||
|
||||
// 基础数据列表
|
||||
let listOpt = ref([]);
|
||||
|
@ -91,14 +107,17 @@ const rules = reactive({
|
|||
program_file_name: [{ required: true, message: "程序文件不能为空", trigger: "blur" }],
|
||||
});
|
||||
|
||||
const emit = defineEmits(["myQuery"]);
|
||||
|
||||
/** 表单提交 */
|
||||
const handleSubmit = useThrottleFn(() => {
|
||||
formRef.value.validate((valid) => {
|
||||
if (valid) {
|
||||
loading.value = true;
|
||||
OperatorApi.addPrograms(form)
|
||||
OperatorApi.addPrograms(form.value)
|
||||
.then((res) => {
|
||||
if (res.data.code == 0) {
|
||||
emit('myQuery');
|
||||
ElMessage.success("保存成功");
|
||||
cancel();
|
||||
}
|
||||
|
@ -110,9 +129,10 @@ const handleSubmit = useThrottleFn(() => {
|
|||
});
|
||||
}, 3000);
|
||||
|
||||
// 文件上传
|
||||
function handleFileChange(file) {
|
||||
formRef.value.validateField("program_file_name");
|
||||
// 文件上传前置方法
|
||||
function beforeUpload(file) {
|
||||
uploadData.program_file_name = file.name;
|
||||
uploadData.file_content = file;
|
||||
}
|
||||
|
||||
// 文件超出限制
|
||||
|
@ -120,6 +140,17 @@ function handleFileExceed() {
|
|||
ElMessage.warning("已达到上传文件限制,请删除后继续上传!");
|
||||
}
|
||||
|
||||
//上传成功
|
||||
function uploadsuccess(res,file){
|
||||
form.value.program_file_name = res.data.program_file_name;
|
||||
formRef.value.validateField("program_file_name");
|
||||
}
|
||||
|
||||
function filterInput(event) {
|
||||
// 使用正则表达式过滤非整数字符
|
||||
form.value.program_version = event.replace(/\D/g, '');
|
||||
}
|
||||
|
||||
/** 返回默认页面 */
|
||||
function cancel() {
|
||||
open.value = false;
|
||||
|
@ -132,13 +163,27 @@ const initPageData = () => {
|
|||
});
|
||||
};
|
||||
|
||||
// 充值表单
|
||||
function resetForm() {
|
||||
form.value.operator_id = null;
|
||||
form.value.operator_name = null;
|
||||
form.value.oper_main_type_name = null;
|
||||
form.value.oper_sub_type_name = null;
|
||||
form.value.cmpt_hardware_type = null;
|
||||
form.value.program_version = null;
|
||||
fileList.value = [];
|
||||
}
|
||||
|
||||
/** 页面初始化 */
|
||||
function show(data) {
|
||||
initPageData();
|
||||
form.value.operator_id = data.operator_id;
|
||||
form.value.operator_name = data.operator_name;
|
||||
form.value.oper_main_type_name = data.oper_main_type_name;
|
||||
form.value.oper_sub_type_name = data.oper_sub_type_name;
|
||||
if (form.value.operator_id != data.operator_id) {
|
||||
resetForm();
|
||||
initPageData();
|
||||
form.value.operator_id = data.operator_id;
|
||||
form.value.operator_name = data.operator_name;
|
||||
form.value.oper_main_type_name = data.oper_main_type_name;
|
||||
form.value.oper_sub_type_name = data.oper_sub_type_name;
|
||||
}
|
||||
open.value = true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue