| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <template id="user-select">
- <el-dialog :visible.sync="edit.visible" width="20%" title="添加分配佣金账户">
- <div>
- <el-form @submit.native.prevent size="small" label-width="150px">
- <el-form-item label="用户昵称">
- <el-autocomplete size="small" v-model="edit.nickname" value-key="nickname"
- @keyup.enter.native="keyUp"
- :fetch-suggestions="querySearchAsync" placeholder="请输入用户昵称/id/手机号"
- @select="agentClick"></el-autocomplete>
- </el-form-item>
- </el-form>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="editCancel" type="default" size="small">取消</el-button>
- <el-button type="primary" :loading="edit.btnLoading" style="margin-bottom: 10px;" size="small"
- @click="editSave">保存</el-button>
- </span>
- </el-dialog>
- </template>
- <script>
- Vue.component('user-select', {
- template: '#user-select',
- props: {
- value: {
- type: Boolean,
- default: false
- }
- },
- data() {
- return {
- edit: {
- visible: false,
- keyword: '',
- nickname: '',
- id: '',
- btnLoading: false,
- },
- row:null,
- }
- },
- watch: {
- value() {
- if (this.value) {
- this.edit.visible = true;
- } else {
- this.edit.id = '';
- this.edit.nickname = '';
- this.edit.keyword = '';
- this.edit.visible = false;
- }
- }
- ,
- 'edit.visible'() {
- if (!this.edit.visible) {
- this.editCancel();
- }
- }
- },
- created() {
- },
- methods: {
- querySearchAsync(queryString, cb) {
- this.edit.keyword = queryString;
- this.get_user(cb);
- },
- get_user(cb) {
- request({
- params: {
- r: 'agent/default/search-user',
- keyword: this.edit.keyword
- }
- }).then(res => {
- if (res.data.code == 0) {
- cb(res.data.data.list)
- } else {
- this.$message.error(res.data.msg);
- }
- });
- },
- agentClick(row) {
- this.edit.id = row.id
- this.row = row;
- },
- editCancel() {
- this.$emit('input', false);
- },
- editSave() {
- this.$emit('success', this.row);
- this.editCancel();
- },
- keyUp() {
- console.log('key up')
- },
- }
- });
- </script>
|