刘翔宇-旅管家 3 years ago
parent c6af8fec92
commit 3606bc5344

@ -1,7 +1,8 @@
import axios from 'axios' import axios from 'axios'
import { MessageBox, Message } from 'element-ui' import { MessageBox, Message ,Loading} from 'element-ui'
import store from '@/store' import store from '@/store'
import { getToken } from '@/utils/auth' import { getToken } from '@/utils/auth'
let loading;
// create an axios instance // create an axios instance
const service = axios.create({ const service = axios.create({
@ -13,8 +14,12 @@ const service = axios.create({
// request interceptor // request interceptor
service.interceptors.request.use( service.interceptors.request.use(
config => { config => {
// do something before request is sent // do something before request is sent
loading = Loading.service({
lock:true,
background:"rgba(0,0,0,0.4)",
text:"正在加载中..."
})
if (store.getters.token) { if (store.getters.token) {
// let each request carry token // let each request carry token
// ['X-Token'] is a custom headers key // ['X-Token'] is a custom headers key
@ -45,6 +50,7 @@ service.interceptors.response.use(
* You can also judge the status by HTTP Status Code * You can also judge the status by HTTP Status Code
*/ */
response => { response => {
loading.close()
const res = response.data const res = response.data
// if the custom code is not 20000, it is judged as an error. // if the custom code is not 20000, it is judged as an error.
@ -74,6 +80,7 @@ service.interceptors.response.use(
} }
}, },
error => { error => {
loading.close()
console.log('err' + error) // for debug console.log('err' + error) // for debug
Message({ Message({
message: error.message, message: error.message,

@ -15,7 +15,7 @@
</LxHeader> </LxHeader>
</div> </div>
<div ref="lxTable"> <div ref="lxTable">
<el-table :data="tableData" class="v-table" :height="tableHeight" style="width: 100%"> <el-table :data="tableData" class="v-table" :height="tableHeight" style="width: 100%">
<el-table-column type="index" width="50" align="center" fixed="left"> </el-table-column> <el-table-column type="index" width="50" align="center" fixed="left"> </el-table-column>
<el-table-column :prop="column.field" :align="column.align" v-for="(column,index) in columns" <el-table-column :prop="column.field" :align="column.align" v-for="(column,index) in columns"
:label="column.title" :width="column.width" :fixed="column.fixed"> :label="column.title" :width="column.width" :fixed="column.fixed">
@ -31,10 +31,11 @@
</el-link> </el-link>
</div> </div>
<div v-if="column.field=='task_departments'"> <div v-if="column.field=='task_departments'">
<el-tag v-for="(tag, tIndex) in scope.row['task_name']" <block v-for="(tag, tIndex) in scope.row['task_name']">
style="margin-right: 5px;margin-bottom: 5px;"> <el-tag style="margin-right: 5px;margin-bottom: 5px;" v-if="tag.id">
{{tag.name}} {{tag.name}}
</el-tag> </el-tag>
</block>
</div> </div>
<div v-if="column.field=='admin'"> <div v-if="column.field=='admin'">
{{scope.row[column.field]?scope.row[column.field].name:""}} {{scope.row[column.field]?scope.row[column.field].name:""}}
@ -298,18 +299,18 @@
listtask({ listtask({
page: this.paginations.page, page: this.paginations.page,
page_size: this.paginations.page_size, page_size: this.paginations.page_size,
keyword:this.searchFields.KeyWord keyword: this.searchFields.KeyWord
}).then(response => { }).then(response => {
var that = this var that = this
for(var m of response.data){ for (var m of response.data) {
if(m.safety_task_departments){ if (m.safety_task_departments) {
let task_list = [] let task_list = []
for(var k of m.safety_task_departments){ for (var k of m.safety_task_departments) {
let dep = Object.assign({}, k.departments) let dep = Object.assign({}, k.departments)
task_list.push(dep) task_list.push(dep)
} }
m.task_name = task_list m.task_name = task_list
} }
} }
this.tableData = response.data; this.tableData = response.data;
this.paginations.page_size = response.total; this.paginations.page_size = response.total;

@ -127,7 +127,7 @@
}, },
edit(obj) { edit(obj) {
this.form = this.$options.data().form this.form = this.$options.data().form;
this.form.type = parseInt(this.$route.path.split("_")[1]); this.form.type = parseInt(this.$route.path.split("_")[1]);
if (obj) { if (obj) {
var result = Object.assign(this.form, obj); var result = Object.assign(this.form, obj);
@ -138,7 +138,8 @@
this.dialogFormVisible = true; this.dialogFormVisible = true;
}, },
addchildren(obj) { addchildren(obj) {
this.form = this.$options.data().form this.form = this.$options.data().form;
this.form.type = parseInt(this.$route.path.split("_")[1]);
if (obj) { if (obj) {
this.form.pname = obj.name; this.form.pname = obj.name;
this.form.pid = obj.id; this.form.pid = obj.id;

Loading…
Cancel
Save