修复前端异步请求问题
This commit is contained in:
@@ -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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,122 +1,113 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-data-table
|
<v-data-table
|
||||||
:headers="headers"
|
:headers="headers"
|
||||||
:items="desserts"
|
:items="desserts"
|
||||||
sort-by="calories"
|
sort-by="calories"
|
||||||
class="elevation-1"
|
class="elevation-1"
|
||||||
item-key="id"
|
item-key="id"
|
||||||
show-select
|
show-select
|
||||||
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>
|
||||||
<v-spacer></v-spacer>
|
<v-spacer></v-spacer>
|
||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="search"
|
v-model="search"
|
||||||
append-icon="mdi-magnify"
|
append-icon="mdi-magnify"
|
||||||
label="搜索"
|
label="搜索"
|
||||||
single-line
|
single-line
|
||||||
hide-details
|
hide-details
|
||||||
class="mx-4"
|
class="mx-4"
|
||||||
></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"
|
||||||
@click="dialog = true"
|
@click="dialog = true"
|
||||||
>
|
>
|
||||||
添加新项
|
添加新项
|
||||||
</v-btn>
|
</v-btn>
|
||||||
|
|
||||||
<!-- 添加提示框 -->
|
<!-- 添加提示框 -->
|
||||||
<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"
|
||||||
>
|
>
|
||||||
<v-card>
|
<v-card>
|
||||||
<v-card-title>
|
<v-card-title>
|
||||||
<span class="headline">{{ formTitle }}</span>
|
<span class="headline">{{ formTitle }}</span>
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
|
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
<v-container>
|
<v-container>
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-col
|
<v-col
|
||||||
cols="12"
|
cols="12"
|
||||||
sm="6"
|
sm="6"
|
||||||
md="4"
|
md="4"
|
||||||
v-for="(value, key, index) in editedItem"
|
v-for="(value, key, index) in editedItem"
|
||||||
:key="index"
|
:key="index"
|
||||||
>
|
>
|
||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="editedItem[key]"
|
v-model="editedItem[key]"
|
||||||
:label="key"
|
:label="key"
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-container>
|
</v-container>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
|
|
||||||
<v-card-actions>
|
<v-card-actions>
|
||||||
<v-spacer></v-spacer>
|
<v-spacer></v-spacer>
|
||||||
<v-btn color="blue darken-1" text @click="close"> 取消 </v-btn>
|
<v-btn color="blue darken-1" text @click="close"> 取消 </v-btn>
|
||||||
<v-btn color="blue darken-1" text @click="save"> 保存 </v-btn>
|
<v-btn color="blue darken-1" text @click="save"> 保存 </v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</v-card>
|
</v-card>
|
||||||
</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)"
|
|
||||||
>
|
|
||||||
删除所选
|
|
||||||
</v-btn>
|
|
||||||
</v-toolbar>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<!-- 表格中的删除和修改 -->
|
|
||||||
<template v-slot:item.actions="{ item }">
|
|
||||||
|
|
||||||
<slot name="action" :item="item"></slot>
|
|
||||||
|
|
||||||
<v-icon
|
|
||||||
v-if="axiosUrls.update!=''"
|
|
||||||
small
|
|
||||||
class="mr-2"
|
|
||||||
@click="editItem(item)"
|
|
||||||
>
|
>
|
||||||
mdi-pencil
|
删除所选
|
||||||
</v-icon>
|
</v-btn>
|
||||||
<v-icon
|
</v-toolbar>
|
||||||
v-if="axiosUrls.del!=''"
|
</template>
|
||||||
small
|
|
||||||
@click="deleteItem(item)"
|
|
||||||
>
|
|
||||||
mdi-delete
|
|
||||||
</v-icon>
|
|
||||||
|
|
||||||
|
<!-- 表格中的删除和修改 -->
|
||||||
|
<template v-slot:item.actions="{ item }">
|
||||||
|
<slot name="action" :item="item"></slot>
|
||||||
|
|
||||||
</template>
|
<v-icon
|
||||||
|
v-if="axiosUrls.update != null"
|
||||||
|
small
|
||||||
|
class="mr-2"
|
||||||
|
@click="editItem(item)"
|
||||||
|
>
|
||||||
|
mdi-pencil
|
||||||
|
</v-icon>
|
||||||
|
<v-icon v-if="axiosUrls.del != null" small @click="deleteItem(item)">
|
||||||
|
mdi-delete
|
||||||
|
</v-icon>
|
||||||
|
</template>
|
||||||
|
|
||||||
<!-- 初始化 -->
|
<!-- 初始化 -->
|
||||||
<template v-slot:no-data>
|
<template v-slot:no-data>
|
||||||
<v-btn color="primary" @click="initialize"> 刷新 </v-btn>
|
<v-btn color="primary" @click="initialize"> 刷新 </v-btn>
|
||||||
</template>
|
</template>
|
||||||
</v-data-table>
|
</v-data-table>
|
||||||
</template>
|
</template>
|
||||||
<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;
|
||||||
|
|||||||
@@ -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"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -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" },
|
||||||
|
|||||||
Reference in New Issue
Block a user