123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- <template>
- <div>
-
- </div>
- </template>
- <script>
- import {
- sysDeptDemoList,
- selectCustomerLabelInfo,
- addAndDelCustomerLabel,
- selectPhoneList,
- selectNotCustomerLabelInfo,
- } from "@/api/label/label";
- export default {
- name: "Label_SetLabel",
- data() {
- return {
- activeNames: undefined,
- labelList: {},
- notCustomerLabelList: [],
- customerLabelList: [],
- loading: false,
- error: false,
- currentLabelId: undefined,
- pageStatus: 4,
- timer: null,
- leftData: [],
- rightData: [],
- leftTotal:100,
- rightTotal:100,
- leftQuery: {
- pageNum: 1,
- pageSize: 10,
- labelId:null,
- customerName: null,
- phone:null
- },
- rightQuery: {
- pageNum: 1,
- pageSize: 10,
- labelId:null,
- customerName: null,
- phone:null
- },
- };
- },
- created() {
- this.init();
- },
- methods: {
- getLeftData(){
- // this.leftData = [];
- selectNotCustomerLabelInfo(this.leftQuery)
- .then((res) => {
- if (res.code == 200) {
- this.leftData = res.rows;
- this.leftTotal = res.total
- } else {
- throw new Error("");
- }
- })
- .catch((err) => {
- this.leftData = [];
- this.leftTotal = 0;
- this.msgError("拉取左边标签用户失败,请刷新~");
- });
-
- },
- getRightData(){
- // this.rightData = [];
- selectPhoneList(this.rightQuery)
- .then((res) => {
- if (res.code == 200) {
- this.rightData = res.rows;
- this.rightTotal = res.total;
- } else {
- throw new Error("");
- }
- })
- .catch(() => {
- this.rightData = [];
- this.rightTotal = 0;
- this.msgError("拉取右边标签用户失败,请刷新~");
- });
- },
- handleMoveLabel(direction = 'right', type = 1, row, labelIdArr){ // type 1 传row type 2 idArr direction right 向右转移 left 向左转移
- const changeArr = []
- if(type == 1){
- changeArr.push(row.phone)
- }else if(type == 2){
- changeArr = labelIdArr
- }
- const query = {
- labelId: direction == 'right' ? this.leftQuery.labelId : this.rightQuery.labelId,
- flag: "1",
- phoneList: changeArr,
- };
- if (direction == "right") {
- query.flag = "0";
- } else if (direction == "left") {
- query.flag = "1";
- }
- addAndDelCustomerLabel(query).then((res) => {
- if (res.code == 200) {
- this.getLeftData();
- this.getRightData();
- } else {
- throw new Error("");
- }
- }).catch((err)=>{
-
- });
- },
- clearLeftQuery(labelId = this.leftQuery.labelId){
- this.leftQuery = {
- pageNum: 1,
- pageSize: 10,
- labelId,
- customerName: null,
- phone:null
- }
- },
- clearRightQuery(labelId = this.rightQuery.labelId){
- console.log(this.rightQuery);
- this.rightQuery = {
- pageNum: 1,
- pageSize: 10,
- labelId,
- customerName: null,
- phone:null
- }
- },
- handleSelectionChange(val) {
- let changeArr = [];
- val.map((ele) => {
- changeArr.push(ele.phone);
- });
- },
- init() {
- this.getLabelList();
- },
- setPageStatus() {
- this.queryPageStatus([2]).then((res) => {
- this.pageStatus = res;
- });
- },
- openLabel(id) {
- this.clearLeftQuery(id);
- this.clearRightQuery(id);
- this.getLeftData();
- this.getRightData();
- },
- // getLabelUser(id) {
- // this.loading = true;
- // selectCustomerLabelInfo({
- // labelId: id,
- // })
- // .then((res) => {
- // if (res.code == 200) {
- // this.notCustomerLabelList = res.data.notCustomerLabelList;
- // this.customerLabelList = res.data.phoneList;
- // } else {
- // throw new Error("");
- // }
- // })
- // .catch(() => {
- // this.loading = false;
- // this.error = true;
- // this.msgError("拉取标签下用户信息失败");
- // });
- // },
- toggleLabel(){
- console.log('hahaha');
- },
- getLabelList() {
- return sysDeptDemoList().then((res) => {
- if (res.code == 200) {
- this.labelList = res.data;
- } else {
- this.msgError("初始化数据失败");
- }
- });
- },
- // transfer(originlArr, direction, changeArr) {
-
- // const query = {
- // labelId: this.activeNames,
- // flag: "1",
- // phoneList: changeArr,
- // };
- // if (direction == "right") {
- // query.flag = "0";
- // } else if (direction == "left") {
- // query.flag = "1";
- // }
- // addAndDelCustomerLabel(query).then((res) => {
- // if (res.code == 200) {
- // this.getRightUser();
- // } else {
- // }
- // });
- // },
- },
- };
- </script>
- <style lang="scss">
- .Label_AddUser {
- .collapse {
- width: 1200px;
- margin: 0 auto;
- //.el-collapse-item__wrap {
- // border-bottom: 1px solid;
- //}
- .el-transfer-panel {
- width: 300px;
- height: 600px;
- }
- .el-transfer-panel__list.is-filterable {
- height: 465px;
- }
- }
- }
- </style>
|