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

优化loading、弹窗显示等方式

上级 4b83d67b
import {Message, Modal, Spin} from "view-design"; import {Message, Modal, Spin} from "view-design";
import Cookies from "js-cookie"; import Cookies from "js-cookie";
import Vue from "vue";
let vm = new Vue()
export function publicConfirm(publicFunction) { export function publicConfirm(publicFunction) {
// 公共弹窗删除 // 公共弹窗删除
...@@ -78,6 +81,7 @@ export async function myEncapsulationFunction(fun) { ...@@ -78,6 +81,7 @@ export async function myEncapsulationFunction(fun) {
export function getInitListRequest(fun) { export function getInitListRequest(fun) {
try { try {
vm.prototypeLoading = true
fun() fun()
return false return false
} catch (e) { } catch (e) {
...@@ -86,6 +90,8 @@ export function getInitListRequest(fun) { ...@@ -86,6 +90,8 @@ export function getInitListRequest(fun) {
content: e content: e
}) })
return false return false
} finally {
} }
} }
......
...@@ -43,7 +43,10 @@ import './styles/index.less'; ...@@ -43,7 +43,10 @@ import './styles/index.less';
import './libs/iview-pro/iview-pro.css'; import './libs/iview-pro/iview-pro.css';
if (window) window.$t = (key, value) => i18n.t(key, value); if (window) window.$t = (key, value) => i18n.t(key, value);
import * as hooks from '@/hooks/index'
Vue.prototype.hooks = hooks;
Vue.prototype.prototypeLoading = false;
Vue.use(plugins); Vue.use(plugins);
Vue.use(ViewUI, { Vue.use(ViewUI, {
......
...@@ -471,7 +471,7 @@ ...@@ -471,7 +471,7 @@
{ {
title: "联系方式", title: "联系方式",
key: 'mobile', key: 'mobile',
minWidth: 100, minWidth: 120,
}, },
{ {
title: "值班要求", title: "值班要求",
...@@ -911,12 +911,10 @@ ...@@ -911,12 +911,10 @@
}) })
}, },
currentPage(e) { currentPage(e) {
console.log(e)
this.page_index = e this.page_index = e
this.getWatchList() this.getWatchList()
}, },
currentPageCount(e) { currentPageCount(e) {
console.log(e, 'currentPageCount')
this.page_size = e this.page_size = e
this.getWatchList() this.getWatchList()
}, },
......
...@@ -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 #role_name="{row}">--> <!-- <template #role_name="{row}">-->
<!-- <span v-for="(item,index) in row.role_name" :key="index" style="margin-left: 5px"> <Tag color="success">{{item}}</Tag></span>--> <!-- <span v-for="(item,index) in row.role_name" :key="index" style="margin-left: 5px"> <Tag color="success">{{item}}</Tag></span>-->
...@@ -73,7 +73,6 @@ ...@@ -73,7 +73,6 @@
//例如: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引入的组件需要注入到对象中才能使用",
...@@ -81,7 +80,7 @@ ...@@ -81,7 +80,7 @@
data() { data() {
//这里存放数据", //这里存放数据",
return { return {
loading: false,
total: null, total: null,
page_size: 10, page_size: 10,
page_index: 1, page_index: 1,
...@@ -172,20 +171,18 @@ ...@@ -172,20 +171,18 @@
} }
}, },
async GetLogAll() { async GetLogAll() {
this.$Spin.show() this.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,
} }
const res = await api.GetLogAll(data) const res = await api.GetLogAll(data)
this.total = res.response.data_count this.total = res.response.data_count
this.data = res.response.data this.data = res.response.data
this.publicMessage(res) this.loading = false
this.$Spin.hide() })
} }
}, },
//生命周期 - 创建之前",数据模型未加载,方法未加载,html模板未加载 //生命周期 - 创建之前",数据模型未加载,方法未加载,html模板未加载
beforeCreate() { beforeCreate() {
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
</div> </div>
</div> </div>
<!-- <div style="border:none;height: 2px;background-color: #f4efea;"></div>--> <!-- <div style="border:none;height: 2px;background-color: #f4efea;"></div>-->
<Table ref="selection" :border="false" :columns="columns" :data="data" class="table"> <Table ref="selection" :border="false" :loading="loading" :columns="columns" :data="data" class="table">
<template #messageinfo="{ row }"> <template #messageinfo="{ row }">
...@@ -114,12 +114,12 @@ ...@@ -114,12 +114,12 @@
<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',
data() { data() {
return { return {
loading: false,
send_state: '', send_state: '',
is_succeed: '', is_succeed: '',
send_stateSearch: '', send_stateSearch: '',
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
messageReset(row) { messageReset(row) {
this.messageModal = true this.messageModal = true
this.messageResetObject = row this.messageResetObject = row
console.log("🚀🚀🚀,", row)
}, },
OfficeArraySort() { OfficeArraySort() {
console.log(this.SelectValue); console.log(this.SelectValue);
...@@ -253,7 +253,6 @@ ...@@ -253,7 +253,6 @@
background: true, background: true,
content: '查询成功!' content: '查询成功!'
}); });
// this.GetMessageimeListEvent() // this.GetMessageimeListEvent()
}, },
searchTimeValue(searchTimeValue) { searchTimeValue(searchTimeValue) {
...@@ -268,8 +267,9 @@ ...@@ -268,8 +267,9 @@
this.GetMessageimeListEvent() this.GetMessageimeListEvent()
}, },
async GetMessageimeListEvent() { // 初始化日期列表 async GetMessageimeListEvent() { // 初始化日期列表
this.$Spin.show() this.hooks.getInitListRequest(async () => {
this.data = [] this.loading = true
// this.data = []
let data = { let data = {
send_state: this.send_stateSearch, send_state: this.send_stateSearch,
is_succeed: this.is_succeedSearch, is_succeed: this.is_succeedSearch,
...@@ -277,9 +277,11 @@ ...@@ -277,9 +277,11 @@
page_size: this.page_size page_size: this.page_size
} }
const res = await api.GetMessageList(data) const res = await api.GetMessageList(data)
res.response.data.map((curent, index) => { this.loading = false
this.data.push(curent) // res.response.data.map((curent, index) => {
}) // this.data.push(curent)
// })
this.data = res.response.data
if (this.data.length === 0 && this.page_index !== 1) { if (this.data.length === 0 && this.page_index !== 1) {
// 输入分页数据未空 则改变页数 为 1 且保持当前页面的数据条数 // 输入分页数据未空 则改变页数 为 1 且保持当前页面的数据条数
// this.page_index = this.page_index - 1 // this.page_index = this.page_index - 1
...@@ -287,8 +289,7 @@ ...@@ -287,8 +289,7 @@
this.currentPage(this.page_index) this.currentPage(this.page_index)
} }
this.total = res.response.data_count this.total = res.response.data_count
console.log(res); })
this.$Spin.hide()
}, },
}, },
mounted() { mounted() {
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
</div> </div>
</template> </template>
<Table :columns="columns" :data="data"> <Table :columns="columns" :data="data" :loading="loading">
<template #role_name="{row}"> <template #role_name="{row}">
<span v-for="(item,index) in row.role_name" :key="index" style="margin-left: 5px"> <Tag <span v-for="(item,index) in row.role_name" :key="index" style="margin-left: 5px"> <Tag
color="success">{{ item }}</Tag></span> color="success">{{ item }}</Tag></span>
...@@ -110,10 +110,10 @@ ...@@ -110,10 +110,10 @@
</div> </div>
</div> </div>
<Table :columns="modalSelect.column" :data="modalSelect.tList" @on-select-all="modalTableSelectAll" <Table :loading="loading3" :columns="modalSelect.column" :data="modalSelect.tList"
@on-select-all="modalTableSelectAll"
@on-select-all-cancel="modalTableSelectAllCancel" @on-select="modalTableSelect" @on-select-all-cancel="modalTableSelectAllCancel" @on-select="modalTableSelect"
@on-select-cancel="modalTableSelectCancel"> @on-select-cancel="modalTableSelectCancel">
</Table> </Table>
<div style="height: 30px;margin-top: 20px"> <div style="height: 30px;margin-top: 20px">
<Page show-total <Page show-total
...@@ -130,7 +130,6 @@ ...@@ -130,7 +130,6 @@
<template #footer> <template #footer>
<Button type="text" @click="modalSelect.modal = false" style="margin-left: 10px;">取消</Button> <Button type="text" @click="modalSelect.modal = false" style="margin-left: 10px;">取消</Button>
<Button type="primary" @click="teacherListOk" style="margin-left: 10px;">确认权限</Button> <Button type="primary" @click="teacherListOk" style="margin-left: 10px;">确认权限</Button>
</template> </template>
</Modal> </Modal>
...@@ -168,6 +167,7 @@ ...@@ -168,6 +167,7 @@
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' import * as hooks from '@/hooks/index'
import {getInitListRequest} from "@/hooks/index";
export default { export default {
//import引入的组件需要注入到对象中才能使用", //import引入的组件需要注入到对象中才能使用",
...@@ -234,6 +234,8 @@ ...@@ -234,6 +234,8 @@
roleCreateTime: '', roleCreateTime: '',
}, },
modal: false, // 触发modal modal: false, // 触发modal
loading: false,
loading3: false,
columns: [ columns: [
{ {
title: '序号', title: '序号',
...@@ -336,9 +338,9 @@ ...@@ -336,9 +338,9 @@
this.modalSelect.modal = true this.modalSelect.modal = true
}, },
async teacherListOk() { teacherListOk() {
this.hooks.myEncapsulationFunction(async () => {
if (!!this.modalSelect.checkboxValue.length) { if (!!this.modalSelect.checkboxValue.length) {
this.$Spin.show()
let data = { let data = {
tid: this.modalSelect.tid, tid: this.modalSelect.tid,
role: this.modalSelect.checkboxValue, role: this.modalSelect.checkboxValue,
...@@ -347,12 +349,13 @@ ...@@ -347,12 +349,13 @@
const res = await api.UserInfoSave(data) const res = await api.UserInfoSave(data)
this.modalSelect.modal = false this.modalSelect.modal = false
this.modalSelect.checkboxValue = [] this.modalSelect.checkboxValue = []
await this.GetUserList() this.GetUserList()
await this.getTorR() this.getTorR()
return res
} else { } else {
this.$Message.error('请选择权限') this.$Message.error('请选择权限')
} }
})
}, },
modalTableSelectCancel(selection, row) { modalTableSelectCancel(selection, row) {
this.modalSelect.tid = [] this.modalSelect.tid = []
...@@ -429,10 +432,13 @@ ...@@ -429,10 +432,13 @@
}); });
} }
}, },
async roleDeleteEvent() { roleDeleteEvent() {
this.hooks.myEncapsulationFunction(async () => {
let data = {"id": this.formTop.roleId} let data = {"id": this.formTop.roleId}
const res = await api.UserInfoDel(data) const res = await api.UserInfoDel(data)
await this.GetUserList() this.GetUserList()
return res
})
}, },
// 编辑用户 // 编辑用户
roleUpdate(row) { roleUpdate(row) {
...@@ -516,23 +522,29 @@ ...@@ -516,23 +522,29 @@
// } // }
// }) // })
}, },
async getTorR() { getTorR() {
this.hooks.getInitListRequest(async () => {
this.loading3 = true
let teacherData = { let teacherData = {
condition: this.modalSelect.search, condition: this.modalSelect.search,
page_index: this.modalSelect.page_index, page_index: this.modalSelect.page_index,
page_size: this.modalSelect.page_size, page_size: this.modalSelect.page_size,
} }
this.$Spin.show() // this.$Spin.show()
//获取 两类 下拉框 初始值 //获取 两类 下拉框 初始值
const teacherRes = await api.GetTeacher(teacherData) const teacherRes = await api.GetTeacher(teacherData)
this.modalSelect.tList = teacherRes.response.data this.modalSelect.tList = teacherRes.response.data
this.modalSelect.total = teacherRes.response.data_count this.modalSelect.total = teacherRes.response.data_count
this.loading3 = false
const roleRes = await api.UserRoleSelect() const roleRes = await api.UserRoleSelect()
this.modalSelect.rList = roleRes.response this.modalSelect.rList = roleRes.response
this.$Spin.hide() // this.$Spin.hide()
})
}, },
async GetUserList() { async GetUserList() {
this.$Spin.show(); this.hooks.getInitListRequest(async () => {
this.loading = true
// 获取初始话列表 // 获取初始话列表
let data = { let data = {
"page_index": this.page_index, "page_index": this.page_index,
...@@ -543,8 +555,7 @@ ...@@ -543,8 +555,7 @@
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
let teacherData = { let teacherData = {
condition: '' condition: ''
} }
...@@ -553,10 +564,9 @@ ...@@ -553,10 +564,9 @@
this.cityTeacherList = teacherRes.response this.cityTeacherList = teacherRes.response
const roleRes = await api.UserRoleSelect() const roleRes = await api.UserRoleSelect()
this.cityRoleList = roleRes.response this.cityRoleList = roleRes.response
})
} }
}, },
//生命周期 - 创建之前",数据模型未加载,方法未加载,html模板未加载 //生命周期 - 创建之前",数据模型未加载,方法未加载,html模板未加载
beforeCreate() { beforeCreate() {
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<Input v-model="searchValue" placeholder="请输入权限名称进行查找..."></Input> <Input v-model="searchValue" placeholder="请输入权限名称进行查找..."></Input>
<Button type="primary" :disabled="searchValue === ''" @click="searchEvent" style="margin-left: 10px;">查找 <Button type="primary" :disabled="searchValue === ''" @click="searchEvent" style="margin-left: 10px;">查找
</Button> </Button>
<Button type="primary" @click="addRoleClass" style="margin-left: 10px;">增添权限类型</Button> <!-- <Button type="primary" @click="addRoleClass" style="margin-left: 10px;">增添权限类型</Button>-->
</div> </div>
</template> </template>
...@@ -20,10 +20,27 @@ ...@@ -20,10 +20,27 @@
<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>
</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>
</Card>
<Modal <Modal
v-model="modal" v-model="modal"
:title="`${ModalTitleValue}`" :title="`${ModalTitleValue}`"
@on-ok="modalOk(row)" @on-ok="modalOk"
cancel-text="取消" cancel-text="取消"
ok-text="确认" ok-text="确认"
:mask-closable="false" :mask-closable="false"
...@@ -38,23 +55,6 @@ ...@@ -38,23 +55,6 @@
</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>
</Card>
</div> </div>
</template> </template>
...@@ -132,7 +132,6 @@ ...@@ -132,7 +132,6 @@
//监控data中的数据变化", //监控data中的数据变化",
watch: { watch: {
'formTop.input1'(newValue, oldValue) { 'formTop.input1'(newValue, oldValue) {
console.log(newValue)
}, },
// searchValue(newValue,oldValue){ // searchValue(newValue,oldValue){
// if(newValue === ''){ // if(newValue === ''){
...@@ -145,16 +144,13 @@ ...@@ -145,16 +144,13 @@
searchEvent() { searchEvent() {
// 搜索按钮事件 // 搜索按钮事件
this.page_index = 1 this.page_index = 1
this.GetUserRoleList() this.GetUserRoleList()
}, },
currentPage(e) { currentPage(e) {
console.log(e)
this.page_index = e this.page_index = e
this.GetUserRoleList() this.GetUserRoleList()
}, },
currentPageCount(e) { currentPageCount(e) {
console.log(e, 'currentPageCount')
this.page_size = e this.page_size = e
this.GetUserRoleList() this.GetUserRoleList()
}, },
...@@ -178,7 +174,6 @@ ...@@ -178,7 +174,6 @@
this.$Message['warning']({ this.$Message['warning']({
background: true, background: true,
content: '操作异常' content: '操作异常'
}); });
} else { } else {
this.$Spin.hide(); this.$Spin.hide();
...@@ -190,9 +185,12 @@ ...@@ -190,9 +185,12 @@
} }
}, },
async roleDeleteEvent() { async roleDeleteEvent() {
hooks.myEncapsulationFunction(async () => {
let data = {"id": this.formTop.roleId} let data = {"id": this.formTop.roleId}
const res = await api.UserRoleDel(data) const res = await api.UserRoleDel(data)
await this.GetUserRoleList() await this.GetUserRoleList()
return res
})
}, },
async roleDelete(e) { async roleDelete(e) {
//删除权限类型 //删除权限类型
...@@ -239,13 +237,16 @@ ...@@ -239,13 +237,16 @@
} }
return data return data
}, },
async modalOk(e) { async modalOk() {
//修改弹窗 确认事件 //修改弹窗 确认事件
// this.$refs['updateRoleValue'].validate(async (validateValue) => { // this.$refs['updateRoleValue'].validate(async (validateValue) => {
// if(validateValue){ // if(validateValue){
const data = this.modalOkDataAction(e) hooks.myEncapsulationFunction(async () => {
const data = this.modalOkDataAction(this.formTop)
const res = await api.UserRoleSave(data) const res = await api.UserRoleSave(data)
await this.GetUserRoleList() await this.GetUserRoleList()
return res
})
// } // }
// }) // })
}, },
......
Markdown 格式
0% or
您添加了 0 人 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册 或