selectUserByDept.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <!-- 选择人员对话框 -->
  3. <el-dialog style="z-index: 2093 !important;" :title="this.title" :visible.sync="childOpen" width="1000px" append-to-body destroy-on-close="true" >
  4. <SelectRen ref="renlist" :userIds="receiverAccount" @fatherFunction = "selectChange" @removeFunction="removeSelectuser"/>
  5. <div slot="footer" class="dialog-footer">
  6. <el-button @click="cancel">取 消</el-button>
  7. <el-button type="primary" @click="submitRen">选 定</el-button>
  8. </div>
  9. </el-dialog>
  10. </template>
  11. <script>
  12. import SelectRen from '@/components/SelectRen'
  13. export default {
  14. name: "selectUserByDept",
  15. components: {
  16. SelectRen
  17. },
  18. props: ['title','open','inputAccount','inputName'],
  19. data() {
  20. return {
  21. childOpen: false,
  22. receiverName: "", // 收件人的昵称
  23. receiverAccount: "", // 收件人的账号
  24. };
  25. },
  26. methods:{
  27. // 人员选择器----取消按钮
  28. cancel() {
  29. this.open = false;
  30. this.childOpen=false;
  31. this.filterText='';
  32. // alert("取消前"+this.receiverAccount);
  33. // alert("取消input:"+this.inputAccount);
  34. this.receiverAccount =this.inputAccount;
  35. this.receiverName = this.inputName;
  36. },
  37. /** 人员选择器中的 选定按钮操作 */
  38. submitRen(){
  39. this.$emit('ok', this.receiverAccount, this.receiverName);
  40. this.childOpen = false;
  41. },
  42. /** 人员选中 */
  43. selectChange(zh,xm){
  44. let zhArr=[];
  45. let xmArr=[];
  46. if(this.receiverAccount!="")
  47. zhArr = this.receiverAccount.split(',');
  48. if(this.receiverName!="")
  49. xmArr = this.receiverName.split(',');
  50. let selzhArr=[];
  51. let selxmArr=[];
  52. if(zh!="")
  53. selzhArr = zh.split(',');
  54. if(xm!="")
  55. selxmArr = xm.split(',');
  56. for (let i = 0, len = selzhArr.length; i < len; i++) {
  57. if (!zhArr.includes(selzhArr[i])) {
  58. //放一起的目的是 解决重名引起的 账号和名称不对应 问题
  59. zhArr.push(selzhArr[i]);
  60. xmArr.push(selxmArr[i]);
  61. }
  62. }
  63. this.receiverAccount =zhArr.join(',');
  64. this.receiverName = xmArr.join(',');
  65. },
  66. /** 人员取消选择 */
  67. removeSelectuser(zh,xm){
  68. console.log("去除已选择的数据=="+zh+"=="+xm);
  69. let zhArr = this.receiverAccount.split(',');
  70. let xmArr = this.receiverName.split(',');
  71. for (var i = 0; i < zhArr.length; i++) {
  72. if (zhArr[i] == zh) {
  73. //放一起的目的是 解决重名引起的 账号和名称不对应 问题
  74. zhArr.splice(i, 1);
  75. xmArr.splice(i, 1);
  76. break;
  77. }
  78. }
  79. this.receiverAccount =zhArr.join(',');
  80. this.receiverName =xmArr.join(',');
  81. }
  82. },
  83. watch:{
  84. open(val) {
  85. this.childOpen = this.open;
  86. },
  87. inputAccount(val) {
  88. this.receiverAccount = this.inputAccount;
  89. //alert("监听ry后:"+this.receiverAccount);
  90. }
  91. }
  92. }
  93. </script>
  94. <style scoped>
  95. /*.v-modal{*/
  96. /* z-index: 1800 !important;*/
  97. /*}*/
  98. /*.el-dialog__wrapper{*/
  99. /* z-index: 2093 !important;*/
  100. /*}*/
  101. </style>