choose.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. <template>
  2. <view class="pur-list">
  3. <view class="pur-hadder">
  4. <uni-search-bar style="width: 100%;" placeholder="请输入姓名" @confirm="search" @clear="clear" @blur="blur"
  5. clearButton="auto" cancelButton="none" />
  6. </view>
  7. <view class="pur-body">
  8. <!-- 面包屑 -->
  9. <view class="bread" v-if='isShow'
  10. style='display: flex;align-items:center; margin-left: 5px;height: 100rpx;width: 750rpx;'>
  11. <view style='margin-right:5rpx;' @click='goBigBread()'>
  12. 通讯录
  13. </view>
  14. <view v-for='(it, i) in breadList' @click='goBread(it, i)' :key='i'>
  15. <text style='margin-left: 5px;margin-right: 5px;'>></text>
  16. <text style='margin-left: 5px;margin-right: 5px;'>{{ it.name }}</text>
  17. </view>
  18. </view>
  19. <view v-if='isShow' class="" style='width: 750rpx;height: 15rpx;background-color:#f1f0f5;'>
  20. </view>
  21. <view class="" style='padding-bottom: 160rpx;width: 750rpx;' :style='{ marginTop: isShow ? "0px" : "80rpx" }'>
  22. <view class="list" v-if='deptIdTree.length'>
  23. <view
  24. style="display: flex;flex-direction: row;justify-content: space-between;margin-left: 40rpx;margin-right: 40rpx;height: 110rpx;border-bottom: 1px solid #f0f0f0;"
  25. v-for="(it, i) in deptIdTree" :key='i' @click='godept(it)'>
  26. <view v-if='it.name' style='display: flex;height: 110rpx;flex-direction: row;'>
  27. <text style='font-size: 36rpx;line-height: 110rpx;'>{{ it.name }} </text>
  28. <!-- <text style='color:#ccc;line-height: 110rpx;'>({{it.children.length}})</text> -->
  29. </view>
  30. <view class="" v-if='it.children' style='padding-top: 40rpx;'>
  31. <text style='color: #ccc;'>></text>
  32. </view>
  33. </view>
  34. </view>
  35. <view v-if='userList.length'>
  36. <view class="" v-for='(it, i) in userList' :key='it.id'
  37. style='display: flex;flex-direction: row;height: 110rpx;margin-left: 5px;padding-top: 20px;padding-left: 10px;position: relative;border-bottom: 1px solid #f0f0f0;'>
  38. <label class="radio" v-if='selectType' @click="isChecked($event, i, it)">
  39. <radio :value='it.id.toString()' :checked="it.checked" />
  40. </label>
  41. <text class="avatar" style='position: absolute;top:12px;left:40px'
  42. :style='{ left: selectType ? "40px" : "10px" }'>{{ it.name.length > 2 ? it.name.substr(it.name.length - 2) : it.name }}</text>
  43. <view style='margin-left: 90rpx;'>
  44. <text style='font-size: 36rpx;'>{{ it.name }}</text>
  45. </view>
  46. </view>
  47. </view>
  48. <view v-if="!userList.length" style='width: 750rpx;text-align: center;padding-top: 100rpx;'>
  49. 暂无数据
  50. </view>
  51. </view>
  52. </view>
  53. <view class="list-bottom">
  54. <view class="list-bottom-lianxi" @click='open'>
  55. <text>已选择</text>
  56. <text class="list-bottom-queding" v-if='checkList.length'>{{ checkList.length }}个</text>
  57. <text>联系人</text>
  58. </view>
  59. <view @click="determine" v-if='checkList.length'>
  60. <text class="list-bottom-queding">确定</text>
  61. </view>
  62. <view v-else>
  63. <text class="list-bottom-queding" style="color: #8F8F94;">确定</text>
  64. </view>
  65. </view>
  66. <!-- 底部弹框 -->
  67. <my-popup id="popup" ref="popup" type="bottom" :animation="false" @change="change">
  68. <view class="popup-content" :style='{ height: checkList.length > 3 ? "auto" : "500rpx" }'
  69. style='padding-bottom: 100rpx;'>
  70. <view class="" style='display: flex;flex-direction: row;justify-content: space-between;height: 100rpx;'>
  71. <view class="" style='display: flex;flex-direction: row;margin-top: 20rpx;margin-left: 40rpx;'>
  72. <text style='color: #333;'>已选择</text>
  73. <text style='color:#007AFF;font-size: 36rpx;'>{{ checkList.length }}</text>人
  74. </view>
  75. <view class="" style='margin-right: 20rpx;margin-top: 20rpx;' @click='submit'>
  76. <text style='margin-right:10px;color:#007AFF;font-size: 36rpx;line-height: 50rpx;'>关闭</text>
  77. </view>
  78. </view>
  79. <view class="" v-for='(it, i) in checkList' :key='i'
  80. style='display: flex;flex-direction: row;border-bottom: 1px solid #f0f0f0;width: 750rpx;justify-content: space-between;height: 100rpx;'>
  81. <view class="" style='position: relative;'>
  82. <text class="avatar" v-if='it.name'
  83. style='position: absolute;top:8px;left:20px'>{{ it.name.length > 2 ? it.name.substr(it.name.length - 2) : it.name }}</text>
  84. <view style='margin-left: 130rpx;margin-top: 15px;color: #333;font-size: 36rpx;'>{{ it.name }}
  85. </view>
  86. </view>
  87. <view class="" style='margin-right: 20px;padding-top: 35rpx;'>
  88. <text
  89. style='color:#C9C9C9;font-size: 30rpx;text-align: center;border-radius: 10rpx;width: 100rpx;height: 50rpx;line-height: 50rpx;border-width: 1px;border-color: #C9C9C9;'
  90. @click='deleteUser(it)'>删除</text>
  91. </view>
  92. </view>
  93. </view>
  94. </my-popup>
  95. </view>
  96. </template>
  97. <script>
  98. import {
  99. listSimpleDepts,
  100. listForSelectEmployee
  101. } from "@/api/peopleSelect/index"
  102. import myPopup from '../../components/my-popup/my-popup.vue';
  103. export default {
  104. props: {
  105. type: {
  106. type: String,
  107. default: 'single' //single or multiple
  108. },
  109. },
  110. data() {
  111. return {
  112. // 查询参数
  113. queryParams: {
  114. name: undefined,
  115. deptId: undefined,
  116. auth: undefined
  117. },
  118. deptIdTree: [],
  119. userList: [],
  120. breadList: [],
  121. selectType: true,
  122. active: null,
  123. checkList: [],
  124. breadId: null,
  125. isShow: true, //是否显示面包屑
  126. }
  127. },
  128. components: {
  129. myPopup
  130. },
  131. onLoad() {
  132. this.getInfoData();
  133. },
  134. onShow() {
  135. this.getInfoData();
  136. },
  137. methods: {
  138. getInfoData() {
  139. if (this.type == 'multiple') {
  140. this.queryParams.auth = 0;
  141. } else {
  142. this.queryParams.auth = 1;
  143. }
  144. this.getDeptTree()
  145. this.getList()
  146. },
  147. /** 查询部门下拉树结构 */
  148. getDeptTree() {
  149. listSimpleDepts().then(response => {
  150. // 处理 deptIdTree 参数
  151. this.deptIdTree = [];
  152. this.deptIdTree.push(...this.handleTree(response.data, "id"));
  153. console.log(this.deptIdTree);
  154. });
  155. },
  156. /** 查询用户列表 */
  157. getList() {
  158. listForSelectEmployee(this.queryParams).then(response => {
  159. this.userList = response.data
  160. console.log(this.userList);
  161. })
  162. },
  163. search(res) {
  164. console.log('----search:', res)
  165. this.queryParams.name = res.value;
  166. this.getList();
  167. },
  168. clear(res) {
  169. console.log('----clear:', res)
  170. this.queryParams.name = '';
  171. this.getList();
  172. },
  173. blur(res) {
  174. console.log('----blur:', res)
  175. this.queryParams.name = res.value;
  176. this.getList();
  177. },
  178. // 弹窗确认
  179. submit() {
  180. this.$refs.popup.close()
  181. },
  182. deleteUser(it) {
  183. this.userList.forEach(its => {
  184. if (its.id == it.id) {
  185. its.checked = false
  186. }
  187. })
  188. this.checkList = this.checkList.filter(item => {
  189. let itId = it.id.toString();
  190. let itemId = item.id.toString();
  191. return !itId.includes(itemId);
  192. })
  193. },
  194. change() { },
  195. open() {
  196. let that = this;
  197. that.$refs.popup.open();
  198. },
  199. goBread(it, i) {
  200. if (it.it.children) {
  201. this.deptIdTree = it.it.children
  202. } else {
  203. this.deptIdTree = []
  204. }
  205. this.breadId = it
  206. this.breadList = this.breadList.slice(0, i + 1)
  207. this.queryParams.deptId = it.id;
  208. this.getList();
  209. },
  210. goBigBread() {
  211. this.queryParams.deptId = undefined;
  212. this.getDeptTree();
  213. this.getList();
  214. this.breadList = []
  215. },
  216. isChecked(e, i, it) {
  217. this.active = i;
  218. console.log("12")
  219. // #ifdef APP-NVUE
  220. console.log("123")
  221. e.stopPropagation()
  222. // #endif
  223. this.userList[i].checked = !this.userList[i].checked
  224. if (this.selectType) {
  225. if (this.userList[i].checked) {
  226. console.log('push进去', this.checkList)
  227. this.checkList.push(it)
  228. } else {
  229. this.checkList.splice(this.checkList.indexOf(it), 1);
  230. }
  231. } else {
  232. }
  233. },
  234. godept(it) {
  235. console.log('人员', it)
  236. if (it.name) {
  237. this.breadId = it.id
  238. this.breadList.push({
  239. name: it.name,
  240. id: it.id,
  241. it: it,
  242. color: '#0066CC'
  243. })
  244. }
  245. if (!it.children) {
  246. this.deptIdTree = []
  247. } else {
  248. this.deptIdTree = it.children
  249. }
  250. this.queryParams.deptId = it.id;
  251. this.getList();
  252. },
  253. //获取选中的人员昵称列表
  254. getNickNameList(uns) {
  255. let result = []
  256. uns.forEach(item => {
  257. result.push(item.name)
  258. })
  259. return result
  260. },
  261. //获取选中的人员ID列表
  262. getUserIdList(uns) {
  263. let result = []
  264. uns.forEach(item => {
  265. result.push(item.id)
  266. })
  267. return result
  268. },
  269. // 确认
  270. determine() {
  271. if (this.type == 'single') {
  272. if(this.checkList.length>1){
  273. uni.showModal({
  274. content: "请选择一个成员!",
  275. showCancel: false,
  276. confirmText: "确定",
  277. })
  278. }else{
  279. this.$emit('submit', this.checkList, this.getNickNameList(this.checkList), this.getUserIdList(this.checkList))
  280. }
  281. } else {
  282. this.$emit('submit', this.checkList, this.getNickNameList(this.checkList), this.getUserIdList(this.checkList))
  283. }
  284. },
  285. }
  286. }
  287. </script>
  288. <style></style>
  289. <style lang="scss">
  290. .pur-list {
  291. background-color: #fff;
  292. height: 100%;
  293. overflow: hidden;
  294. .pur-hadder {
  295. background-color: #ffffff;
  296. height: 55px;
  297. font-size: 14px;
  298. display: flex;
  299. position: -webkit-sticky;
  300. position: sticky;
  301. box-sizing: border-box;
  302. min-width: 100%;
  303. overflow-x: auto;
  304. }
  305. .pur-body {
  306. height: calc(100% - 88upx);
  307. overflow: auto
  308. }
  309. }
  310. .avatar {
  311. width: 70rpx;
  312. height: 70rpx;
  313. background: #3489ff;
  314. text-align: center;
  315. line-height: 70rpx;
  316. border-radius: 15rpx;
  317. font-size: 26rpx;
  318. color: #fff;
  319. }
  320. .popup-content {
  321. width: 750rpx;
  322. height: 500rpx;
  323. z-index: 99999;
  324. background-color: #fff
  325. }
  326. .list-bottom {
  327. position: fixed;
  328. height: 150rpx;
  329. background-color: #FFFFFF;
  330. width: 760rpx;
  331. bottom: 0;
  332. left: 0;
  333. display: flex;
  334. flex-direction: row;
  335. flex-wrap: nowrap;
  336. font-size: 35rpx;
  337. justify-content: space-between;
  338. padding: 50rpx 30rpx;
  339. }
  340. .list-bottom-queding {
  341. color: #007AFF;
  342. }
  343. .list-bottom-lianxi {
  344. display: flex;
  345. flex-direction: row;
  346. }
  347. .search {
  348. position: relative;
  349. width: 700rpx;
  350. height: 80rpx;
  351. box-sizing: border-box;
  352. line-height: 80rpx;
  353. background: #f1f0f5;
  354. border-radius: 26rpx;
  355. margin-left: 15%;
  356. }
  357. .fdj {
  358. position: absolute;
  359. top: 35rpx;
  360. transform: translateY(-50%);
  361. right: 70rpx;
  362. color: #999;
  363. font-size: 40rpx;
  364. }
  365. .list {
  366. width: 750rpx;
  367. }
  368. </style>