master
xy 2 years ago
parent ba2011469c
commit 22b5ec50dc

@ -1,12 +1,18 @@
import request from "@/utils/request";
function customParamsSerializer(params) {
let result = '';
let result = "";
for (let key in params) {
if (params.hasOwnProperty(key)) {
if (Array.isArray(params[key])) {
params[key].forEach((item,index) => {
result += `${key}[${index}][key]=${item.key}&${key}[${index}][op]=${item.op}&${key}[${index}][value]=${item.value}&`;
});
if (typeof params[key] === "object") {
params[key].forEach((item, index) => {
if (typeof item === "object") {
result += `${key}[${index}][key]=${item.key}&${key}[${index}][op]=${item.op}&${key}[${index}][value]=${item.value}&`;
} else {
result += `${key}[${index}]=${item}&`;
}
});
}
} else {
result += `${key}=${params[key]}&`;
}
@ -14,14 +20,14 @@ function customParamsSerializer(params) {
}
return result.slice(0, -1);
}
export function index(params,isLoading = false) {
export function index(params, isLoading = false) {
return request({
method: "get",
url: "/api/admin/base-form/index",
params,
paramsSerializer: customParamsSerializer,
isLoading
})
isLoading,
});
}
export function show(params, isLoading = true) {
@ -29,30 +35,30 @@ export function show(params, isLoading = true) {
method: "get",
url: "/api/admin/base-form/show",
params,
isLoading
})
isLoading,
});
}
export function save(data) {
return request({
method: "post",
url: "/api/admin/base-form/save",
data
})
data,
});
}
export function destroy(params) {
return request({
method: "get",
url: "/api/admin/base-form/destroy",
params
})
params,
});
}
export function imports(data) {
return request({
method: "post",
url: "/api/admin/base-form/import",
data
})
data,
});
}

@ -34,8 +34,11 @@
</div>
<div class="xy-table-item-content">
<el-button @click="addOptions"></el-button>
<div style="width: 300px;margin-bottom: 10px;" v-for="item in form.option_list" :key="item.myindex">
<div style="font-weight: 600">选项{{ indexFormat(item.myindex) }}</div>
<div style="width: 300px;margin-bottom: 20px;" v-for="(item, index) in form.option_list" :key="item.myindex">
<div style="font-weight: 600;display: flex;align-items: center;justify-content: space-between;">
选项{{ indexFormat(item.myindex) }}
<el-button size="mini" type="danger" icon="el-icon-delete" circle @click="form.option_list.splice(index, 1)"></el-button>
</div>
<el-input style="flex: 2;" v-model="item.title" placeholder="选项"></el-input>
<div style="margin-top: 6px;display: flex;justify-content: space-between;align-items: center;">
<el-switch v-model="item.is_correct" active-text="正确" inactive-text="错误" :active-value="1" :inactive-value="0"></el-switch>
@ -126,6 +129,13 @@ export default {
async getDetail() {
const res = await show({ id: this.id });
this.$integrateData(this.form, res);
this.form.option_list = res?.options.map(i => {
return {
title: i.title,
is_correct: i.is_correct,
myindex: i.myindex,
}
})
},
submit() {

@ -94,6 +94,7 @@ export default {
select: {
page: 1,
page_size: 10,
show_relation: ['video','image'],
table_name: "map_points",
activity_list_id: 7,
filter: [],

Loading…
Cancel
Save