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

优化loading、弹窗显示等方式

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