search.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <view>
  3. <view class="search"><u-search placeholder="公司名称" v-model="param.companyName" :animation="true" @search="getData()" @clear="clear()"></u-search></view>
  4. <view class="list">
  5. <view class="item" v-for="(item, index) in list" :key="index" @click="detail(item)">
  6. <text>{{ item.companyName }}</text>
  7. <text class="icon">&#xe62b;</text>
  8. </view>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. data() {
  15. return {
  16. list: [],
  17. param: {}
  18. };
  19. },
  20. methods: {
  21. getData() {
  22. this.http.request({
  23. url: '/app/company/list',
  24. data: this.param,
  25. success: (res) => {
  26. this.list = res.data.data;
  27. }
  28. });
  29. },
  30. detail(item) {
  31. uni.showModal({
  32. title: '提示',
  33. content: '确定关联该企业?',
  34. success: (res) => {
  35. if (res.confirm) {
  36. this.http.request({
  37. url: '/app/relate/add',
  38. data: { companyId: item.id },
  39. method: 'POST',
  40. success: (res) => {
  41. uni.showModal({
  42. title: '提示',
  43. content: '关联成功',
  44. showCancel: false,
  45. success: (res) => {
  46. uni.$emit('company');
  47. uni.navigateBack();
  48. }
  49. });
  50. }
  51. });
  52. }
  53. }
  54. });
  55. },
  56. clear() {
  57. this.list = [];
  58. }
  59. }
  60. };
  61. </script>
  62. <style lang="scss">
  63. .search {
  64. padding: 12px 20px 12px 20px;
  65. background-color: white;
  66. }
  67. .list {
  68. .item {
  69. padding: 17px;
  70. background-color: white;
  71. margin-top: 10px;
  72. .icon {
  73. float: right;
  74. }
  75. }
  76. }
  77. </style>