添加功能选择模型从单选改多选
This commit is contained in:
parent
b80d9f96c2
commit
4f3d6b514d
|
|
@ -9,7 +9,7 @@
|
|||
<el-input-number v-else-if="item.type === 'number'" v-model="form[item.prop]"
|
||||
:disabled="item.disabled" controls-position="right"></el-input-number>
|
||||
<el-select v-else-if="item.type === 'select'" v-model="form[item.prop]" :disabled="item.disabled"
|
||||
:placeholder="item.placeholder" clearable >
|
||||
:placeholder="item.placeholder" clearable :multiple="item.multiple?true:false">
|
||||
<el-option v-for="opt in item.opts" :label="opt.label" :value="opt.value"></el-option>
|
||||
</el-select>
|
||||
<el-date-picker v-else-if="item.type === 'date'" type="date" v-model="form[item.prop]"
|
||||
|
|
@ -39,6 +39,7 @@
|
|||
|
||||
<script lang="ts" setup>
|
||||
import { FormOption } from '@/types/form-option';
|
||||
import { json } from 'd3';
|
||||
import { FormInstance, FormRules, UploadProps } from 'element-plus';
|
||||
import { PropType, ref } from 'vue';
|
||||
|
||||
|
|
@ -62,7 +63,30 @@ const { options, formData, edit, update } = defineProps({
|
|||
});
|
||||
|
||||
|
||||
const form = ref({ ...(edit ? formData : {}) });
|
||||
//const form = ref({ ...(edit ? formData : {}) });
|
||||
const form = ref();
|
||||
|
||||
const doFormData = () => {
|
||||
let a={}
|
||||
let initialForm = { ...(edit ? formData : {}) };
|
||||
|
||||
options.list.forEach(item => {
|
||||
if (item.type === 'select' && item.multiple) {
|
||||
let ids = formData[item.prop];
|
||||
let id_list = JSON.parse(ids);
|
||||
console.log(id_list);
|
||||
let selectedValues = [];
|
||||
for (let i = 0; i < id_list.length; i++) {
|
||||
selectedValues.push(id_list[i]["id"]);
|
||||
}
|
||||
if (!Array.isArray(initialForm[item.prop])) {
|
||||
initialForm[item.prop] = selectedValues;
|
||||
}
|
||||
}
|
||||
});
|
||||
return initialForm;
|
||||
};
|
||||
form.value=doFormData();
|
||||
|
||||
const rules: FormRules = options.list.map(item => {
|
||||
if (item.required) {
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ const routes: RouteRecordRaw[] = [
|
|||
title: '功能管理',
|
||||
permiss: '54',
|
||||
},
|
||||
component: () => import(/* webpackChunkName: "system-user" */ '../views/system/function.vue'),
|
||||
component: () => import(/* webpackChunkName: "system-user" */ '../views/system/manage-function.vue'),
|
||||
},
|
||||
{
|
||||
path: '/manage-file',
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ export interface Function{
|
|||
Name: string;
|
||||
Info: string;
|
||||
UserID: number;
|
||||
ModelID: number;
|
||||
ModelID: number | Object | Array<any>;
|
||||
ModelIDs: string;
|
||||
Function: string;
|
||||
}
|
||||
|
|
@ -124,7 +124,7 @@ let options_edit = ref<FormOption>({
|
|||
span: 12,
|
||||
list: [
|
||||
{ type: 'input', label: '名称', prop: 'Name', required: true },
|
||||
{ type: 'select', label: '模型', prop: 'ModelID', required: true, opts:model_select_opts.value, multiple: true},
|
||||
{ type: 'select', label: '模型', prop: 'ModelIDS', required: true, opts:model_select_opts.value, multiple: true},
|
||||
{ type: 'input', label: '功能', prop: 'Function', required: true },
|
||||
{ type: 'input', label: '描述', prop: 'Info', required: true },
|
||||
]
|
||||
|
|
@ -138,19 +138,26 @@ const rowData = ref({});
|
|||
const handleEdit = async (row: Function) => {
|
||||
let data = row;
|
||||
rowData.value = data;
|
||||
console.log("edit_row_data:", rowData.value);
|
||||
//console.log("edit_row_data:", rowData.value);
|
||||
isEdit.value = true;
|
||||
visible.value = true;
|
||||
};
|
||||
const updateData = async (data) => {
|
||||
let model_id =[]
|
||||
let model_id_list= data["ModelID"]
|
||||
for (let i = 0; i < model_id_list.length; i++) {
|
||||
model_id.push({"id":model_id_list[i]})
|
||||
}
|
||||
let model_ids = JSON.stringify(model_id)
|
||||
let result ={}
|
||||
try{
|
||||
let req={
|
||||
token:localStorage.getItem("token"),
|
||||
id: data.ID,
|
||||
name: data.Name,
|
||||
model_id: data.ModelID,
|
||||
model_id: model_id_list[0],
|
||||
function: data.Function,
|
||||
model_ids: model_ids,
|
||||
info: data.Info
|
||||
};
|
||||
result = await UpdateFunctionService(req)
|
||||
|
|
@ -2,5 +2,46 @@
|
|||
<div>
|
||||
<h2>智能选题推荐</h2>
|
||||
</div>
|
||||
<el-select v-model="selected" placeholder="请选择" multiple>
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
<el-button type="primary" @click="handleSearch">查询</el-button>
|
||||
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive } from 'vue';
|
||||
interface Option {
|
||||
value: string;
|
||||
label: string;
|
||||
}
|
||||
interface OptionList {
|
||||
value: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
const selected = ref();
|
||||
const options = ref<Option[]>([
|
||||
{ value: 'option1', label: '选项1' },
|
||||
{ value: 'option2', label: '选项2' },
|
||||
{ value: 'option3', label: '选项3' },
|
||||
{ value: 'option4', label: '选项4' },
|
||||
]);
|
||||
const handleSearch = async () => {
|
||||
// 这里可以添加查询逻辑
|
||||
console.log('Selected:', selected.value);
|
||||
// 发送请求到后端,获取推荐结果
|
||||
// let req={
|
||||
// token: localStorage.getItem('token'),
|
||||
// type: "ID",
|
||||
// id: parseInt(query.name)
|
||||
// }
|
||||
// let result = await FindModelService(req);
|
||||
// tableData.value = result.data;
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in New Issue