修复前端异步请求问题

This commit is contained in:
橙子
2021-10-24 18:16:26 +08:00
parent dd4a8aad51
commit 7d324db5ae
4 changed files with 118 additions and 120 deletions

View File

@@ -183,7 +183,7 @@ namespace Yi.Framework.Model.DbInit
menu_name="add",is_show=0, menu_name="add",is_show=0,
mould=new mould() mould=new mould()
{ {
mould_name="del",url="/Mould/addMould" mould_name="add",url="/Mould/addMould"
} }
} }
} }

View File

@@ -9,7 +9,7 @@
v-model="selected" v-model="selected"
:search="search" :search="search"
> >
<slot/> <slot />
<template v-slot:top> <template v-slot:top>
<!-- 搜索框 --> <!-- 搜索框 -->
<v-toolbar flat> <v-toolbar flat>
@@ -24,7 +24,7 @@
></v-text-field> ></v-text-field>
<v-btn <v-btn
v-if="axiosUrls.add!=''" v-if="axiosUrls.add != null"
color="primary" color="primary"
dark dark
class="mb-2 mx-2" class="mb-2 mx-2"
@@ -35,7 +35,7 @@
<!-- 添加提示框 --> <!-- 添加提示框 -->
<v-dialog <v-dialog
v-if="axiosUrls.add!=''" v-if="axiosUrls.add != null"
v-model="dialog" v-model="dialog"
max-width="500px" max-width="500px"
> >
@@ -72,9 +72,8 @@
</v-dialog> </v-dialog>
<v-btn <v-btn
v-if="axiosUrls.del!=''" v-if="axiosUrls.del != null"
color="secondary" color="secondary"
class="mb-2" class="mb-2"
@click="deleteItem(null)" @click="deleteItem(null)"
> >
@@ -85,26 +84,19 @@
<!-- 表格中的删除和修改 --> <!-- 表格中的删除和修改 -->
<template v-slot:item.actions="{ item }"> <template v-slot:item.actions="{ item }">
<slot name="action" :item="item"></slot> <slot name="action" :item="item"></slot>
<v-icon <v-icon
v-if="axiosUrls.update!=''" v-if="axiosUrls.update != null"
small small
class="mr-2" class="mr-2"
@click="editItem(item)" @click="editItem(item)"
> >
mdi-pencil mdi-pencil
</v-icon> </v-icon>
<v-icon <v-icon v-if="axiosUrls.del != null" small @click="deleteItem(item)">
v-if="axiosUrls.del!=''"
small
@click="deleteItem(item)"
>
mdi-delete mdi-delete
</v-icon> </v-icon>
</template> </template>
<!-- 初始化 --> <!-- 初始化 -->
@@ -116,7 +108,6 @@
<script> <script>
import itemApi from "./TableApi.js"; import itemApi from "./TableApi.js";
export default { export default {
name: "ccTable", name: "ccTable",
props: { props: {
defaultItem: { defaultItem: {
@@ -146,15 +137,21 @@ export default {
}, },
watch: { watch: {
selected:{ axiosUrls: {
handler(val, oldVal){ handler(val, oldVal) {
this.$emit("selected",val); this.dataInit(val.get);
}, },
deep:true deep: true,
},
selected: {
handler(val, oldVal) {
this.$emit("selected", val);
},
deep: true,
}, },
dialog(val) { dialog(val) {
val || this.close(); val || this.close();
} },
}, },
created() { created() {
@@ -162,12 +159,17 @@ export default {
}, },
methods: { methods: {
initialize() { dataInit(getStr) {
itemApi.getItem(this.axiosUrls.get).then((resp) => { itemApi.getItem(getStr).then((resp) => {
const response = resp.data; const response = resp.data;
this.desserts = response; this.desserts = response;
}); });
},
initialize() {
if(this.axiosUrls.get!=undefined && this.axiosUrls.get!=null )
{
this.dataInit(this.axiosUrls.get)
}
this.$nextTick(() => { this.$nextTick(() => {
this.editedItem = Object.assign({}, this.defaultItem); this.editedItem = Object.assign({}, this.defaultItem);
this.editedIndex = -1; this.editedIndex = -1;

View File

@@ -58,7 +58,7 @@
<v-btn v-if="item.mould" class="mr-2">接口地址:{{ item.mould.url }}</v-btn> <v-btn v-if="item.mould" class="mr-2">接口地址:{{ item.mould.url }}</v-btn>
<ccCombobox <ccCombobox
headers="设置接口权限" headers="设置接口权限"
itemText="mould_name" itemText="url"
:items="mouldList" :items="mouldList"
@select="getSelect" @select="getSelect"
> >

View File

@@ -28,10 +28,6 @@ export default {
data: () => ({ data: () => ({
start: true, start: true,
axiosUrls: { axiosUrls: {
// get: "role/getrole",
// update: "role/updaterole",
// del: "role/delListrole",
// add: "role/addrole",
}, },
headers: [ headers: [
{ text: "编号", align: "start", value: "id" }, { text: "编号", align: "start", value: "id" },