提交 2864f2d4 编写于 作者: 刘英杰's avatar 刘英杰

优化loading、弹窗

上级 cc29572f
...@@ -15,15 +15,30 @@ ...@@ -15,15 +15,30 @@
<!-- </div>--> <!-- </div>-->
<!-- </template>--> <!-- </template>-->
<Table :columns="columns" :data="data"> <Table :columns="columns" :data="data" :loading="loading">
<template #action="{row}"> <template #action="{row}">
<Button type="primary" size="small" @click="update(row)">修改</Button> <Button type="primary" size="small" @click="update(row)">修改</Button>
<Button type="error" size="small" @click="Delete(row)" style="margin-left: 10px;">删除</Button> <Button type="error" size="small" @click="Delete(row)" style="margin-left: 10px;">删除</Button>
</template>
</Table>
<div style="width: 100%;height: 70px;display: flex;align-items: center;">
<Page show-total
show-sizer
show-elevator
:total="total"
:page-size="page_size"
model-value="page_index"
@on-change="currentPage"
@on-page-size-change="currentPageCount"
/>
</div>
<Modal <Modal
v-model="modal" v-model="modal"
title="值班类型" title="值班类型"
@on-ok="modalOk(row)" @on-ok="modalOk"
cancel-text="取消" cancel-text="取消"
ok-text="确认" ok-text="确认"
:mask-closable="false" :mask-closable="false"
...@@ -35,7 +50,7 @@ ...@@ -35,7 +50,7 @@
</FormItem> </FormItem>
<FormItem label="时间" prop="input2"> <FormItem label="时间" prop="input2">
<TimePicker @on-change="selectTileValue" format="HH:mm" type="timerange" placement="bottom-end" <TimePicker @on-change="selectTileValue" format="HH:mm" type="timerange" placement="bottom-end"
placeholder="Select time" style="width: 100%"/> placeholder="请选择时间" style="width: 100%"/>
</FormItem> </FormItem>
<!-- <FormItem label="选择教师" prop="input2" >--> <!-- <FormItem label="选择教师" prop="input2" >-->
<!-- <Select v-model="teacherSelectCurrentValue" filterable placeholder="请选择或搜索...">--> <!-- <Select v-model="teacherSelectCurrentValue" filterable placeholder="请选择或搜索...">-->
...@@ -49,26 +64,12 @@ ...@@ -49,26 +64,12 @@
<!-- </FormItem>--> <!-- </FormItem>-->
</Form> </Form>
</Modal> </Modal>
</template>
</Table>
<div style="width: 100%;height: 70px;display: flex;align-items: center;">
<Page show-total
show-sizer
show-elevator
:total="total"
:page-size="page_size"
model-value="page_index"
@on-change="currentPage"
@on-page-size-change="currentPageCount"
/>
</div>
</div> </div>
</template> </template>
<script> <script>
import * as hooks from '../../../../hooks/index'
import * as api from '../../../../api/lezRequest' import * as api from '../../../../api/lezRequest'
//这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等) //这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
//例如:import 《组件名称》 from '《组件路径》'; //例如:import 《组件名称》 from '《组件路径》';
...@@ -80,6 +81,7 @@ ...@@ -80,6 +81,7 @@
data() { data() {
//这里存放数据", //这里存放数据",
return { return {
loading: false,
modal: false, modal: false,
formTop: { formTop: {
id: '', id: '',
...@@ -158,7 +160,8 @@ ...@@ -158,7 +160,8 @@
this.formTop.input2 = e[1] this.formTop.input2 = e[1]
console.log("🚀🚀🚀,", e[1]) console.log("🚀🚀🚀,", e[1])
}, },
async modalOk() { modalOk() {
hooks.myEncapsulationFunction(async () => {
let data = { let data = {
"watchhourid": this.formTop.id, "watchhourid": this.formTop.id,
"watchhourname": this.formTop.timeName, "watchhourname": this.formTop.timeName,
...@@ -166,22 +169,26 @@ ...@@ -166,22 +169,26 @@
"watchhour_end_time": this.formTop.input2, "watchhour_end_time": this.formTop.input2,
} }
const res = await api.WatchHourSave(data) const res = await api.WatchHourSave(data)
await this.GetWatchHourList()
this.GetWatchHourList() return res
})
}, },
update(e) { update(e) {
console.log(e)
this.formTop.id = e.watchhourid; this.formTop.id = e.watchhourid;
this.formTop.timeName = e.watchhourname; this.formTop.timeName = e.watchhourname;
this.modal = true this.modal = true
}, },
async DeleteAction() { async DeleteAction() {
hooks.myEncapsulationFunction(async () => {
let data = { let data = {
id: this.formTop.id id: this.formTop.id
} }
const res = await api.WatchHourDel(data) const res = await api.WatchHourDel(data)
this.GetWatchHourList() await this.GetWatchHourList()
return res
})
}, },
Delete(e) { Delete(e) {
this.formTop.id = e.watchhourid this.formTop.id = e.watchhourid
...@@ -232,7 +239,9 @@ ...@@ -232,7 +239,9 @@
} }
}, },
async GetWatchHourList(searchValue = '') { async GetWatchHourList(searchValue = '') {
this.$Spin.show();
hooks.getInitListRequest(async () => {
this.loading = true
let data = { let data = {
condition: this.searchValue, condition: this.searchValue,
page_size: this.page_size, page_size: this.page_size,
...@@ -241,7 +250,9 @@ ...@@ -241,7 +250,9 @@
const res = await api.GetWatchHourList(data) const res = await api.GetWatchHourList(data)
this.data = res.response.data this.data = res.response.data
this.total = res.response.data_count this.total = res.response.data_count
this.publicMessage(res) this.loading = false
})
} }
}, },
//生命周期 - 创建之前",数据模型未加载,方法未加载,html模板未加载 //生命周期 - 创建之前",数据模型未加载,方法未加载,html模板未加载
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<!-- </div>--> <!-- </div>-->
<!-- </template>--> <!-- </template>-->
<Table :columns="columns" :data="data"> <Table :columns="columns" :data="data" :loading="loading">
<!-- 签到类型 --> <!-- 签到类型 -->
<template #sign_type="{ row }"> <template #sign_type="{ row }">
<span v-if="row.sign_type == 0">免打卡</span> <span v-if="row.sign_type == 0">免打卡</span>
...@@ -26,10 +26,24 @@ ...@@ -26,10 +26,24 @@
<template #action="{row}"> <template #action="{row}">
<Button type="primary" size="small" @click="update(row)">修改</Button> <Button type="primary" size="small" @click="update(row)">修改</Button>
<Button type="error" size="small" @click="Delete(row)" style="margin-left: 10px;">删除</Button> <Button type="error" size="small" @click="Delete(row)" style="margin-left: 10px;">删除</Button>
</template>
</Table>
<div style="width: 100%;height: 70px;display: flex;align-items: center;">
<Page show-total
show-sizer
show-elevator
:total="total"
:page-size="page_size"
model-value="page_index"
@on-change="currentPage"
@on-page-size-change="currentPageCount"
/>
</div>
<Modal <Modal
v-model="modal" v-model="modal"
title="值班类型" title="值班类型"
@on-ok="modalOk(row)" @on-ok="modalOk"
cancel-text="取消" cancel-text="取消"
ok-text="确认" ok-text="确认"
:mask-closable="false" :mask-closable="false"
...@@ -68,27 +82,13 @@ ...@@ -68,27 +82,13 @@
<!-- </FormItem>--> <!-- </FormItem>-->
</Form> </Form>
</Modal> </Modal>
</template>
</Table>
<div style="width: 100%;height: 70px;display: flex;align-items: center;">
<Page show-total
show-sizer
show-elevator
:total="total"
:page-size="page_size"
model-value="page_index"
@on-change="currentPage"
@on-page-size-change="currentPageCount"
/>
</div>
</div> </div>
</template> </template>
<script> <script>
import * as api from '../../../../api/lezRequest' import * as api from '../../../../api/lezRequest'
import * as hooks from '../../../../hooks/index'
//这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等) //这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
//例如:import 《组件名称》 from '《组件路径》'; //例如:import 《组件名称》 from '《组件路径》';
export default { export default {
...@@ -111,6 +111,7 @@ ...@@ -111,6 +111,7 @@
page_size: 10, page_size: 10,
page_index: 1, page_index: 1,
total: null, total: null,
loading: false,
columns: [ columns: [
{ {
title: '序号', title: '序号',
...@@ -182,7 +183,8 @@ ...@@ -182,7 +183,8 @@
}, },
//方法集合", //方法集合",
methods: { methods: {
async modalOk() { modalOk() {
hooks.myEncapsulationFunction(async () => {
let data = { let data = {
"watchtypeid": this.formTop.id, "watchtypeid": this.formTop.id,
"watchtypename": this.formTop.input1, "watchtypename": this.formTop.input1,
...@@ -191,8 +193,9 @@ ...@@ -191,8 +193,9 @@
"sign_type": this.formTop.type, "sign_type": this.formTop.type,
} }
const res = await api.WatchTypeSave(data) const res = await api.WatchTypeSave(data)
await this.GetWatchTypeList()
this.GetWatchTypeList() return res
})
}, },
update(e) { update(e) {
// console.log(e) // console.log(e)
...@@ -204,11 +207,14 @@ ...@@ -204,11 +207,14 @@
this.modal = true this.modal = true
}, },
async DeleteAction() { async DeleteAction() {
hooks.myEncapsulationFunction(async () => {
let data = { let data = {
id: this.formTop.id id: this.formTop.id
} }
const res = await api.WatchTypeDel(data) const res = await api.WatchTypeDel(data)
this.GetWatchTypeList() await this.GetWatchTypeList()
return res
})
}, },
Delete(e) { Delete(e) {
this.formTop.id = e.watchtypeid this.formTop.id = e.watchtypeid
...@@ -259,7 +265,8 @@ ...@@ -259,7 +265,8 @@
} }
}, },
async GetWatchTypeList(searchValue = '') { async GetWatchTypeList(searchValue = '') {
this.$Spin.show(); hooks.getInitListRequest(async () => {
this.loading = true
let data = { let data = {
name: this.searchValue, name: this.searchValue,
page_size: this.page_size, page_size: this.page_size,
...@@ -268,12 +275,14 @@ ...@@ -268,12 +275,14 @@
const res = await api.GetWatchTypeList(data) const res = await api.GetWatchTypeList(data)
this.data = res.response.data this.data = res.response.data
this.total = res.response.data_count this.total = res.response.data_count
this.publicMessage(res) this.loading = false
})
} }
}, },
//生命周期 - 创建之前",数据模型未加载,方法未加载,html模板未加载 //生命周期 - 创建之前",数据模型未加载,方法未加载,html模板未加载
beforeCreate() { beforeCreate() {
console.info("🚀🚀🚀,")
}, },
//生命周期 - 创建完成(可以访问当前this实例)",数据模型已加载,方法已加载,html模板已加载,html模板未渲染 //生命周期 - 创建完成(可以访问当前this实例)",数据模型已加载,方法已加载,html模板已加载,html模板未渲染
......
...@@ -114,6 +114,7 @@ ...@@ -114,6 +114,7 @@
<script> <script>
import * as api from '../../api/lezRequest' import * as api from '../../api/lezRequest'
import * as hooks from '@/hooks/index'
export default { export default {
name: 'numberLimit', name: 'numberLimit',
......
...@@ -167,6 +167,7 @@ ...@@ -167,6 +167,7 @@
//例如:import 《组件名称》 from '《组件路径》'; //例如:import 《组件名称》 from '《组件路径》';
import * as api from '../../api/lezRequest' import * as api from '../../api/lezRequest'
import Vue from "vue"; import Vue from "vue";
import * as hooks from '@/hooks/index'
export default { export default {
//import引入的组件需要注入到对象中才能使用", //import引入的组件需要注入到对象中才能使用",
......
...@@ -16,8 +16,7 @@ ...@@ -16,8 +16,7 @@
</div> </div>
</template> </template>
<Table :columns="columns" :data="data"> <Table :columns="columns" :data="data" :loading="loading">
<template #action="{row}"> <template #action="{row}">
<Button type="primary" size="small" @click="update(row)">修改</Button> <Button type="primary" size="small" @click="update(row)">修改</Button>
<Button type="error" size="small" @click="roleDelete(row)" style="margin-left: 10px;">删除</Button> <Button type="error" size="small" @click="roleDelete(row)" style="margin-left: 10px;">删除</Button>
...@@ -64,6 +63,7 @@ ...@@ -64,6 +63,7 @@
//例如:import 《组件名称》 from '《组件路径》'; //例如:import 《组件名称》 from '《组件路径》';
import * as api from '../../api/lezRequest' import * as api from '../../api/lezRequest'
import Vue from "vue"; import Vue from "vue";
import * as hooks from '@/hooks/index'
export default { export default {
//import引入的组件需要注入到对象中才能使用", //import引入的组件需要注入到对象中才能使用",
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
data() { data() {
//这里存放数据", //这里存放数据",
return { return {
loading: false,
searchValue: '', // 搜索框的值 searchValue: '', // 搜索框的值
total: null, total: null,
page_size: 10, page_size: 10,
...@@ -250,8 +251,10 @@ ...@@ -250,8 +251,10 @@
}, },
async GetUserRoleList() { async GetUserRoleList() {
this.$Spin.show();
hooks.getInitListRequest(async () => {
// 获取初始话列表 // 获取初始话列表
this.loading = true
let data = { let data = {
"page_index": this.page_index, "page_index": this.page_index,
"page_size": this.page_size, "page_size": this.page_size,
...@@ -261,7 +264,9 @@ ...@@ -261,7 +264,9 @@
this.data = [] this.data = []
this.data = res.response.data this.data = res.response.data
this.total = res.response.data_count this.total = res.response.data_count
this.publicMessage(res) this.loading = false
})
} }
......
Markdown 格式
0% or
您添加了 0 人 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册 或