|
@@ -1,21 +1,22 @@
|
|
<template>
|
|
<template>
|
|
<view>
|
|
<view>
|
|
<view class="tab">
|
|
<view class="tab">
|
|
- <u-tabs :list="tab" :current="0"></u-tabs>
|
|
|
|
|
|
+ <u-tabs :list="tab" :current="current" @click="click"></u-tabs>
|
|
</view>
|
|
</view>
|
|
<view class="list">
|
|
<view class="list">
|
|
<view class="item" v-for="(item, index) in list" :key="index">
|
|
<view class="item" v-for="(item, index) in list" :key="index">
|
|
<view class="title">{{ item.companyName }}</view>
|
|
<view class="title">{{ item.companyName }}</view>
|
|
<view class="op">
|
|
<view class="op">
|
|
<text>{{ item.createTime }}</text>
|
|
<text>{{ item.createTime }}</text>
|
|
- <text class="del" @click="del(item)">解除</text>
|
|
|
|
|
|
+ <text class="add" @click="del(item)" v-if="current == 0">点击关联</text>
|
|
|
|
+ <text class="del" @click="del(item)" v-else>解除</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
|
|
<view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
|
|
<u-empty v-if="!loadMore && list.length == 0" text="尚未关联公司"></u-empty>
|
|
<u-empty v-if="!loadMore && list.length == 0" text="尚未关联公司"></u-empty>
|
|
</view>
|
|
</view>
|
|
<view class="footer">
|
|
<view class="footer">
|
|
- <view class="db"><button class="btn" @click="show = true">关联企业</button></view>
|
|
|
|
|
|
+ <view class="db"><button class="btn" @click="show = true">手动关联</button></view>
|
|
</view>
|
|
</view>
|
|
<u-action-sheet round="20" :actions="actions" @select="selectClick" cancelText="取消" :show="show" @close="show = false"></u-action-sheet>
|
|
<u-action-sheet round="20" :actions="actions" @select="selectClick" cancelText="取消" :show="show" @close="show = false"></u-action-sheet>
|
|
</view>
|
|
</view>
|
|
@@ -25,11 +26,12 @@
|
|
export default {
|
|
export default {
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
- tab: [{ name: '全部' }],
|
|
|
|
|
|
+ tab: [{ name: '企业大厅' }, { name: '我的关联' }],
|
|
show: false,
|
|
show: false,
|
|
- actions: [{ name: '扫码关联' }, { name: '手动关联' }],
|
|
|
|
|
|
+ current: 0,
|
|
|
|
+ actions: [{ name: '扫码关联' }, { name: '搜索企业' }],
|
|
list: [],
|
|
list: [],
|
|
- param: { pageNum: 1, pageSize: 10, orderByColumn: 'createTime', isAsc: 'desc' },
|
|
|
|
|
|
+ param: { pageNum: 1, pageSize: 10 },
|
|
loadMore: true
|
|
loadMore: true
|
|
};
|
|
};
|
|
},
|
|
},
|
|
@@ -42,7 +44,7 @@ export default {
|
|
methods: {
|
|
methods: {
|
|
getData() {
|
|
getData() {
|
|
this.http.request({
|
|
this.http.request({
|
|
- url: '/app/relate/list',
|
|
|
|
|
|
+ url: this.current == 0 ? '/app/company/list' : '/app/relate/list',
|
|
data: this.param,
|
|
data: this.param,
|
|
loading: 'false',
|
|
loading: 'false',
|
|
success: (res) => {
|
|
success: (res) => {
|
|
@@ -54,15 +56,20 @@ export default {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
+ click(e) {
|
|
|
|
+ this.current = e.index;
|
|
|
|
+ this.param.state = e.index === 1 ? 0 : 1;
|
|
|
|
+ this.refresh();
|
|
|
|
+ },
|
|
selectClick(e) {
|
|
selectClick(e) {
|
|
- if (e.name == '手动关联') {
|
|
|
|
|
|
+ if (e.name == '搜索企业') {
|
|
uni.navigateTo({ url: '/pages/company/search' });
|
|
uni.navigateTo({ url: '/pages/company/search' });
|
|
} else {
|
|
} else {
|
|
uni.scanCode({
|
|
uni.scanCode({
|
|
success: (res) => {
|
|
success: (res) => {
|
|
this.http.request({
|
|
this.http.request({
|
|
url: '/app/relate/add',
|
|
url: '/app/relate/add',
|
|
- data: { companyId: res.result,way:'扫码关联' },
|
|
|
|
|
|
+ data: { companyId: res.result, way: '扫码关联' },
|
|
method: 'POST',
|
|
method: 'POST',
|
|
success: (res) => {
|
|
success: (res) => {
|
|
uni.showModal({
|
|
uni.showModal({
|
|
@@ -83,18 +90,36 @@ export default {
|
|
del(item) {
|
|
del(item) {
|
|
uni.showModal({
|
|
uni.showModal({
|
|
title: '提示',
|
|
title: '提示',
|
|
- content: '确定解除该企业关联?',
|
|
|
|
|
|
+ content: this.current == 0 ? '确定关联该企业?' : '确定解除该企业关联?',
|
|
success: (res) => {
|
|
success: (res) => {
|
|
if (res.confirm) {
|
|
if (res.confirm) {
|
|
- this.http.request({
|
|
|
|
- url: '/app/relate/remove',
|
|
|
|
- data: { companyId: item.companyId },
|
|
|
|
- method: 'POST',
|
|
|
|
- success: (res) => {
|
|
|
|
- uni.showToast({ title: '解除成功' });
|
|
|
|
- this.list.splice(this.list.indexOf(item), 1);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ if (this.current == 0) {
|
|
|
|
+ this.http.request({
|
|
|
|
+ url: '/app/relate/add',
|
|
|
|
+ data: { companyId: item.id, way: '手动关联' },
|
|
|
|
+ method: 'POST',
|
|
|
|
+ success: (res) => {
|
|
|
|
+ uni.showModal({
|
|
|
|
+ title: '提示',
|
|
|
|
+ content: '关联成功',
|
|
|
|
+ showCancel: false,
|
|
|
|
+ success: (res) => {
|
|
|
|
+ this.current = 1;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ this.http.request({
|
|
|
|
+ url: '/app/relate/remove',
|
|
|
|
+ data: { companyId: item.companyId },
|
|
|
|
+ method: 'POST',
|
|
|
|
+ success: (res) => {
|
|
|
|
+ uni.showToast({ title: '解除成功' });
|
|
|
|
+ this.list.splice(this.list.indexOf(item), 1);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -144,6 +169,10 @@ export default {
|
|
float: right;
|
|
float: right;
|
|
color: #f44336;
|
|
color: #f44336;
|
|
}
|
|
}
|
|
|
|
+ .add {
|
|
|
|
+ float: right;
|
|
|
|
+ color: $main-color;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|