| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- <template id="agent-edit">
- <el-dialog :visible.sync="pull.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="pull.nickname" value-key="nickname"
- @keyup.enter.native="keyUp"
- :fetch-suggestions="querySearchAsync" placeholder="请输入用户昵称/id/手机号"
- @select="agentClick"></el-autocomplete>
- </el-form-item>
- </el-form>
- </div>
- <div>
- <el-form @submit.native.prevent size="small" label-width="150px">
- <el-form-item label="绑定上级用户">
- <el-autocomplete size="small" v-model="push.nickname" value-key="nickname"
- @keyup.enter.native="keyUp"
- :fetch-suggestions="querySearchAsync" placeholder="请输入用户昵称/id/手机号"
- @select="agentClickPush"></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="pull.btnLoading" style="margin-bottom: 10px;" size="small"
- @click="editSave">保存</el-button>
- <el-button :loading="btnLoading" type="primary" @click="changePlatform">修改成平台</el-button>
- </span>
- </el-dialog>
- </template>
- <script>
- Vue.component('agent-edit', {
- template: '#agent-edit',
- props: {
- value: {
- type: Boolean,
- default: false
- }
- },
- data() {
- return {
- pull: {
- visible: false,
- keyword: '',
- nickname: '',
- id: '',
- btnLoading: false,
- },
- push: {
- visible: false,
- keyword: '',
- nickname: '',
- id: '',
- },
- }
- },
- watch: {
- value() {
- if (this.value) {
- this.pull.visible = true;
- } else {
- this.pull.id = '';
- this.pull.nickname = '';
- this.pull.keyword = '';
- this.pull.visible = false;
- this.push.id = '';
- this.push.nickname = '';
- this.push.keyword = '';
- }
- }
- ,
- 'pull.visible'() {
- if (!this.pull.visible) {
- this.editCancel();
- }
- }
- },
- created() {
- },
- methods: {
- querySearchAsync(queryString, cb) {
- this.pull.keyword = queryString;
- this.get_user(cb);
- },
- get_user(cb) {
- request({
- params: {
- r: 'double-copy/default/search-user',
- keyword: this.pull.keyword
- }
- }).then(res => {
- if (res.data.code == 0) {
- cb(res.data.data.list)
- } else {
- this.$message.error(res.data.msg);
- }
- });
- },
- agentClick(row) {
- this.pull.id = row.id
- },
- agentClickPush(row) {
- this.push.id = row.id
- },
- editCancel() {
- this.$emit('input', false);
- navigateTo({
- r: 'double-copy/spread/index',
- })
- },
- editSave() {
- this.pull.btnLoading = true;
- if(!this.pull.id){
- this.$message.error('选择下级用户');
- this.pull.btnLoading = false;
- return false;
- }
- if(!this.push.id){
- this.$message.error('绑定上级用户');
- this.pull.btnLoading = false;
- return false;
- }
- if(this.pull.id == this.push.id){
- this.$message.error('选择下级用户和绑定上级用户不能相同');
- this.pull.btnLoading = false;
- return false;
- }
- request({
- params: {
- r: 'double-copy/spread/edit',
- },
- method: 'post',
- data: {
- pull_user_id: this.pull.id,
- push_user_id: this.push.id,
- }
- }).then(response => {
- this.pull.btnLoading = false;
- if (response.data.code == 0) {
- this.$message.success('添加成功');
- this.editCancel();
- } else {
- this.$message.error(response.data.msg);
- }
- }).catch(response => {
- this.pull.btnLoading = false;
- });
- },
- keyUp() {
- console.log('key up')
- },
- changePlatform(){
- this.pull.btnLoading = true;
- if(!this.pull.id){
- this.$message.error('选择下级用户');
- this.pull.btnLoading = false;
- return false;
- }
- this.$confirm('是否把推荐人修改成平台?', '警告', {type: 'warning'}).then(() => {
- this.btnLoading = true;
- request({
- params: {
- r: 'double-copy/spread/edit-platform'
- },
- method: 'post',
- data: {
- pull_user_id: this.pull.id,
- }
- }).then(res => {
- this.pull.btnLoading = false;
- if (res.data.code == 0) {
- this.$message.success(res.data.msg);
- this.editCancel();
- } else {
- this.$message.error(response.data.msg);
- }
- }).catch(err => {
- this.pull.btnLoading = false;
- })
- });
- },
- }
- });
- </script>
|