SelectCompany.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <!--
  2. * @Author: liuzhenlin 461480418@qq.ocm
  3. * @Date: 2023-02-15 10:34:49
  4. * @LastEditors: liuzhenlin
  5. * @LastEditTime: 2023-02-23 10:57:44
  6. * @Description: file content
  7. * @FilePath: \oms\components\SelectCustomer.vue
  8. -->
  9. <template>
  10. <view>
  11. <u-popup :show="selectVisible" @close="close">
  12. <view class="select-header">
  13. <view class="tit">选择公司</view>
  14. <view class="flex">
  15. <!-- <view class="save-btn" @click="handleAdd()">新增</view> -->
  16. <view class="save-btn" @click="close()">保存</view>
  17. </view>
  18. </view>
  19. <view class="search-container">
  20. <view class="search-input">
  21. <u-input
  22. clearable
  23. placeholderStyle="font-size:26rpx"
  24. :customStyle="{ height: '66rpx' }"
  25. v-model="queryForm.partnerName"
  26. prefixIcon="search"
  27. prefixIconStyle="font-size: 22px;color: #909399"
  28. placeholder="请输入公司名称"
  29. shape="circle"
  30. @input="getUserList()"
  31. border="surround"></u-input>
  32. </view>
  33. </view>
  34. <u-empty mode="list" v-if="userList.length == 0"></u-empty>
  35. <view class="concat-list" v-else>
  36. <u-radio-group v-model="userValue" placement="column">
  37. <view class="radio-item" v-for="item in userList" :key="item.id">
  38. <u-radio :label="item.label" :name="item.id" @change="radioChange"></u-radio>
  39. </view>
  40. </u-radio-group>
  41. </view>
  42. </u-popup>
  43. <u-overlay :show="showAdd" zIndex="999999">
  44. <view class="add-warp">
  45. <view class="tit">创建公司</view>
  46. <u-input v-model="value"></u-input>
  47. <view class="flex flex-between" style="margin-top: 10px">
  48. <view style="width: 100px">
  49. <u-button type="primary" size="small" text="取消" @click="handleCloseAdd"></u-button>
  50. </view>
  51. <view style="width: 100px">
  52. <u-button type="primary" size="small" text="提交" @click="handleAddSub"></u-button>
  53. </view>
  54. </view>
  55. </view>
  56. </u-overlay>
  57. </view>
  58. </template>
  59. <script>
  60. import partnerApi from '@/api/partner'
  61. import to from 'await-to-js'
  62. export default {
  63. name: 'OmsCustomerContact',
  64. props: {
  65. queryParams: {
  66. type: Object,
  67. default() {
  68. return {}
  69. },
  70. },
  71. },
  72. data() {
  73. return {
  74. showAdd: false,
  75. value: '',
  76. selectVisible: false,
  77. userList: [],
  78. queryForm: {
  79. partnerName: '',
  80. pageNum: 1,
  81. pageSize: 999,
  82. },
  83. // u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
  84. userValue: null,
  85. selected: null,
  86. }
  87. },
  88. methods: {
  89. handleCloseAdd() {
  90. this.showAdd = false
  91. },
  92. handleAddSub() {},
  93. handleAdd() {
  94. this.value = ''
  95. this.showAdd = true
  96. },
  97. async getUserList() {
  98. let params = Object.assign(this.queryForm, this.queryParams)
  99. const [err, res] = await to(partnerApi.getCompanyList(params))
  100. if (err) return
  101. if (res.code == 200) {
  102. if (res.data.list && res.data.list.length > 0) {
  103. this.userList = res.data.list.map((item) => ({
  104. id: item.id,
  105. label: item.partnerName,
  106. name: item.partnerName,
  107. }))
  108. } else {
  109. this.userList = []
  110. }
  111. }
  112. },
  113. open() {
  114. this.selectVisible = true
  115. this.getUserList()
  116. },
  117. close() {
  118. this.selectVisible = false
  119. this.$emit('close', this.selected)
  120. },
  121. radioChange(n) {
  122. this.selected = this.userList.find((item) => item.id == n)
  123. },
  124. },
  125. }
  126. </script>
  127. <style lang="scss" scoped>
  128. .search-container {
  129. padding: 30rpx 30rpx 0 30rpx;
  130. display: flex;
  131. align-items: center;
  132. .search-input {
  133. flex: 1;
  134. }
  135. .search-btn {
  136. text-align: center;
  137. line-height: 60rpx;
  138. border-radius: 12rpx;
  139. width: 100rpx;
  140. height: 60rpx;
  141. font-size: 26rpx;
  142. margin: 0 0 0 12rpx;
  143. background: $u-primary;
  144. color: #ffffff;
  145. }
  146. }
  147. .concat-list {
  148. padding: 0 0 20rpx 0;
  149. width: 100%;
  150. height: 900rpx;
  151. overflow: auto;
  152. margin-top: 20rpx;
  153. .radio-item {
  154. padding: 20rpx 30rpx;
  155. border-bottom: 1px solid #ccc;
  156. }
  157. }
  158. .add-warp {
  159. width: 80%;
  160. height: 150px;
  161. position: fixed;
  162. left: 0;
  163. right: 0;
  164. margin: auto;
  165. top: 0;
  166. bottom: 0;
  167. background: #fff;
  168. border-radius: 20px;
  169. padding: 20px;
  170. .tit {
  171. margin-bottom: 10px;
  172. }
  173. }
  174. </style>