choose.vue 9.9 KB

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