Label_AddUser.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <div>
  3. </div>
  4. </template>
  5. <script>
  6. import {
  7. sysDeptDemoList,
  8. selectCustomerLabelInfo,
  9. addAndDelCustomerLabel,
  10. selectPhoneList,
  11. selectNotCustomerLabelInfo,
  12. } from "@/api/label/label";
  13. export default {
  14. name: "Label_SetLabel",
  15. data() {
  16. return {
  17. activeNames: undefined,
  18. labelList: {},
  19. notCustomerLabelList: [],
  20. customerLabelList: [],
  21. loading: false,
  22. error: false,
  23. currentLabelId: undefined,
  24. pageStatus: 4,
  25. timer: null,
  26. leftData: [],
  27. rightData: [],
  28. leftTotal:100,
  29. rightTotal:100,
  30. leftQuery: {
  31. pageNum: 1,
  32. pageSize: 10,
  33. labelId:null,
  34. customerName: null,
  35. phone:null
  36. },
  37. rightQuery: {
  38. pageNum: 1,
  39. pageSize: 10,
  40. labelId:null,
  41. customerName: null,
  42. phone:null
  43. },
  44. };
  45. },
  46. created() {
  47. this.init();
  48. },
  49. methods: {
  50. getLeftData(){
  51. // this.leftData = [];
  52. selectNotCustomerLabelInfo(this.leftQuery)
  53. .then((res) => {
  54. if (res.code == 200) {
  55. this.leftData = res.rows;
  56. this.leftTotal = res.total
  57. } else {
  58. throw new Error("");
  59. }
  60. })
  61. .catch((err) => {
  62. this.leftData = [];
  63. this.leftTotal = 0;
  64. this.msgError("拉取左边标签用户失败,请刷新~");
  65. });
  66. },
  67. getRightData(){
  68. // this.rightData = [];
  69. selectPhoneList(this.rightQuery)
  70. .then((res) => {
  71. if (res.code == 200) {
  72. this.rightData = res.rows;
  73. this.rightTotal = res.total;
  74. } else {
  75. throw new Error("");
  76. }
  77. })
  78. .catch(() => {
  79. this.rightData = [];
  80. this.rightTotal = 0;
  81. this.msgError("拉取右边标签用户失败,请刷新~");
  82. });
  83. },
  84. handleMoveLabel(direction = 'right', type = 1, row, labelIdArr){ // type 1 传row type 2 idArr direction right 向右转移 left 向左转移
  85. const changeArr = []
  86. if(type == 1){
  87. changeArr.push(row.phone)
  88. }else if(type == 2){
  89. changeArr = labelIdArr
  90. }
  91. const query = {
  92. labelId: direction == 'right' ? this.leftQuery.labelId : this.rightQuery.labelId,
  93. flag: "1",
  94. phoneList: changeArr,
  95. };
  96. if (direction == "right") {
  97. query.flag = "0";
  98. } else if (direction == "left") {
  99. query.flag = "1";
  100. }
  101. addAndDelCustomerLabel(query).then((res) => {
  102. if (res.code == 200) {
  103. this.getLeftData();
  104. this.getRightData();
  105. } else {
  106. throw new Error("");
  107. }
  108. }).catch((err)=>{
  109. });
  110. },
  111. clearLeftQuery(labelId = this.leftQuery.labelId){
  112. this.leftQuery = {
  113. pageNum: 1,
  114. pageSize: 10,
  115. labelId,
  116. customerName: null,
  117. phone:null
  118. }
  119. },
  120. clearRightQuery(labelId = this.rightQuery.labelId){
  121. console.log(this.rightQuery);
  122. this.rightQuery = {
  123. pageNum: 1,
  124. pageSize: 10,
  125. labelId,
  126. customerName: null,
  127. phone:null
  128. }
  129. },
  130. handleSelectionChange(val) {
  131. let changeArr = [];
  132. val.map((ele) => {
  133. changeArr.push(ele.phone);
  134. });
  135. },
  136. init() {
  137. this.getLabelList();
  138. },
  139. setPageStatus() {
  140. this.queryPageStatus([2]).then((res) => {
  141. this.pageStatus = res;
  142. });
  143. },
  144. openLabel(id) {
  145. this.clearLeftQuery(id);
  146. this.clearRightQuery(id);
  147. this.getLeftData();
  148. this.getRightData();
  149. },
  150. // getLabelUser(id) {
  151. // this.loading = true;
  152. // selectCustomerLabelInfo({
  153. // labelId: id,
  154. // })
  155. // .then((res) => {
  156. // if (res.code == 200) {
  157. // this.notCustomerLabelList = res.data.notCustomerLabelList;
  158. // this.customerLabelList = res.data.phoneList;
  159. // } else {
  160. // throw new Error("");
  161. // }
  162. // })
  163. // .catch(() => {
  164. // this.loading = false;
  165. // this.error = true;
  166. // this.msgError("拉取标签下用户信息失败");
  167. // });
  168. // },
  169. toggleLabel(){
  170. console.log('hahaha');
  171. },
  172. getLabelList() {
  173. return sysDeptDemoList().then((res) => {
  174. if (res.code == 200) {
  175. this.labelList = res.data;
  176. } else {
  177. this.msgError("初始化数据失败");
  178. }
  179. });
  180. },
  181. // transfer(originlArr, direction, changeArr) {
  182. // const query = {
  183. // labelId: this.activeNames,
  184. // flag: "1",
  185. // phoneList: changeArr,
  186. // };
  187. // if (direction == "right") {
  188. // query.flag = "0";
  189. // } else if (direction == "left") {
  190. // query.flag = "1";
  191. // }
  192. // addAndDelCustomerLabel(query).then((res) => {
  193. // if (res.code == 200) {
  194. // this.getRightUser();
  195. // } else {
  196. // }
  197. // });
  198. // },
  199. },
  200. };
  201. </script>
  202. <style lang="scss">
  203. .Label_AddUser {
  204. .collapse {
  205. width: 1200px;
  206. margin: 0 auto;
  207. //.el-collapse-item__wrap {
  208. // border-bottom: 1px solid;
  209. //}
  210. .el-transfer-panel {
  211. width: 300px;
  212. height: 600px;
  213. }
  214. .el-transfer-panel__list.is-filterable {
  215. height: 465px;
  216. }
  217. }
  218. }
  219. </style>