1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <template>
- <view>
- <view class="search"><u-search placeholder="公司名称" v-model="companyName" :showAction="false" @search="getData()" @clear="clear()"></u-search></view>
- <view class="list">
- <view class="item" v-for="(item, index) in list" :key="index" @click="detail(item)">
- <text>{{ item.companyName }}</text>
- <text class="icon"></text>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- list: [],
- companyName: ''
- };
- },
- watch: {
- companyName(val) {
- if (val.length > 3) {
- this.getData();
- }
- }
- },
- methods: {
- getData() {
- this.http.request({
- url: '/app/company/list',
- data: { companyName: this.companyName },
- success: (res) => {
- this.list = res.data.data;
- }
- });
- },
- detail(item) {
- uni.showModal({
- title: '提示',
- content: '确定关联该企业?',
- success: (res) => {
- if (res.confirm) {
- this.http.request({
- url: '/app/relate/add',
- data: { companyId: item.id, way: '手动关联' },
- method: 'POST',
- success: (res) => {
- uni.showModal({
- title: '提示',
- content: '关联成功',
- showCancel: false,
- success: (res) => {
- uni.$emit('company');
- uni.navigateBack();
- }
- });
- }
- });
- }
- }
- });
- },
- clear() {
- this.list = [];
- }
- }
- };
- </script>
- <style lang="scss">
- .search {
- padding: 12px 20px 12px 20px;
- background-color: white;
- }
- .list {
- .item {
- padding: 17px;
- background-color: white;
- margin-top: 10px;
- .icon {
- float: right;
- }
- }
- }
- </style>
|