user-select.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template id="user-select">
  2. <el-dialog :visible.sync="edit.visible" width="20%" title="添加分配佣金账户">
  3. <div>
  4. <el-form @submit.native.prevent size="small" label-width="150px">
  5. <el-form-item label="用户昵称">
  6. <el-autocomplete size="small" v-model="edit.nickname" value-key="nickname"
  7. @keyup.enter.native="keyUp"
  8. :fetch-suggestions="querySearchAsync" placeholder="请输入用户昵称/id/手机号"
  9. @select="agentClick"></el-autocomplete>
  10. </el-form-item>
  11. </el-form>
  12. </div>
  13. <span slot="footer" class="dialog-footer">
  14. <el-button @click="editCancel" type="default" size="small">取消</el-button>
  15. <el-button type="primary" :loading="edit.btnLoading" style="margin-bottom: 10px;" size="small"
  16. @click="editSave">保存</el-button>
  17. </span>
  18. </el-dialog>
  19. </template>
  20. <script>
  21. Vue.component('user-select', {
  22. template: '#user-select',
  23. props: {
  24. value: {
  25. type: Boolean,
  26. default: false
  27. }
  28. },
  29. data() {
  30. return {
  31. edit: {
  32. visible: false,
  33. keyword: '',
  34. nickname: '',
  35. id: '',
  36. btnLoading: false,
  37. },
  38. row:null,
  39. }
  40. },
  41. watch: {
  42. value() {
  43. if (this.value) {
  44. this.edit.visible = true;
  45. } else {
  46. this.edit.id = '';
  47. this.edit.nickname = '';
  48. this.edit.keyword = '';
  49. this.edit.visible = false;
  50. }
  51. }
  52. ,
  53. 'edit.visible'() {
  54. if (!this.edit.visible) {
  55. this.editCancel();
  56. }
  57. }
  58. },
  59. created() {
  60. },
  61. methods: {
  62. querySearchAsync(queryString, cb) {
  63. this.edit.keyword = queryString;
  64. this.get_user(cb);
  65. },
  66. get_user(cb) {
  67. request({
  68. params: {
  69. r: 'agent/default/search-user',
  70. keyword: this.edit.keyword
  71. }
  72. }).then(res => {
  73. if (res.data.code == 0) {
  74. cb(res.data.data.list)
  75. } else {
  76. this.$message.error(res.data.msg);
  77. }
  78. });
  79. },
  80. agentClick(row) {
  81. this.edit.id = row.id
  82. this.row = row;
  83. },
  84. editCancel() {
  85. this.$emit('input', false);
  86. },
  87. editSave() {
  88. this.$emit('success', this.row);
  89. this.editCancel();
  90. },
  91. keyUp() {
  92. console.log('key up')
  93. },
  94. }
  95. });
  96. </script>