| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- <template id="group-edit">
- <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('group-edit', {
- template: '#group-edit',
- props: {
- value: {
- type: Boolean,
- default: false
- }
- },
- data() {
- return {
- edit: {
- visible: false,
- keyword: '',
- nickname: '',
- user_id: '',
- btnLoading: false,
- },
- level_list: [],
- level: 0
- }
- },
- watch: {
- value() {
- if (this.value) {
- this.edit.visible = true;
- } else {
- this.edit.user_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: 'lucky-group/group-team/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.user_id = row.id
- },
-
- editCancel() {
- this.$emit('input', false);
- navigateTo({
- r: 'lucky-group/group-team/index',
- })
- },
- editSave() {
- this.edit.btnLoading = true;
- request({
- params: {
- r: 'lucky-group/group-team/add-group-user',
- },
- method: 'post',
- data: {
- user_id: this.edit.user_id,
- level: this.level
- }
- }).then(response => {
- this.edit.btnLoading = false;
- if (response.data.code == 0) {
- this.$message.success('添加成功');
- this.editCancel();
- } else {
- this.$message.error(response.data.msg);
- }
- }).catch(response => {
- this.edit.btnLoading = false;
- });
- },
- keyUp() {
- console.log('key up')
- }
- }
- });
- </script>
|