Transfer.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <template>
  2. <div>
  3. <slot name="header">
  4. <el-row class="radio">
  5. <el-radio-group v-model="region">
  6. <el-radio label="0">全部经销商</el-radio>
  7. <el-radio label="1">地区</el-radio>
  8. <el-radio label="2">指定</el-radio>
  9. </el-radio-group>
  10. </el-row>
  11. <el-row type="flex">
  12. <el-col>
  13. <el-input
  14. v-model="keyword"
  15. placeholder="查找经销商"
  16. size="small"
  17. ></el-input>
  18. </el-col>
  19. <el-col
  20. ><el-button size="small" @click="getcList">确定</el-button></el-col
  21. >
  22. </el-row>
  23. </slot>
  24. <div>
  25. <el-row type="flex" align="moddle" class="transfer">
  26. <el-col class="left_box" :span="9">
  27. <div>
  28. <h4 class="transfer_title">可选经销商</h4>
  29. <el-checkbox-group
  30. v-model="leftData"
  31. class="left_box_flex"
  32. @change="handleLeft"
  33. >
  34. <el-checkbox
  35. v-for="(item, index) in dataL"
  36. :key="index"
  37. :label="item.id"
  38. >
  39. {{ item.name }}</el-checkbox
  40. >
  41. </el-checkbox-group>
  42. </div>
  43. <!-- 分页 -->
  44. <div>
  45. <el-pagination
  46. @size-change="handleSizeChange"
  47. @current-change="handleCurrentChange"
  48. :current-page="currentPage"
  49. :page-sizes="[10]"
  50. :page-size="10"
  51. layout="total, sizes, prev, pager, next, jumper"
  52. :total="listTotal"
  53. >
  54. </el-pagination>
  55. </div>
  56. </el-col>
  57. <el-col class="middle_box" :span="6">
  58. <el-row>
  59. <el-col>
  60. <el-button
  61. size="small"
  62. @click="handleAllAdd"
  63. :disabled="type == 2 || !dataL.length"
  64. >全部添加</el-button
  65. ></el-col
  66. >
  67. <el-col>
  68. <el-button
  69. size="small"
  70. @click="handleAdd"
  71. :disabled="type == 2 || !dataL.length"
  72. >增加</el-button
  73. ></el-col
  74. >
  75. <el-col>
  76. <el-button
  77. size="small"
  78. :disabled="type == 1 || !dataR.length"
  79. @click="handleDelete"
  80. >删除</el-button
  81. ></el-col
  82. >
  83. <el-col>
  84. <el-button
  85. size="small"
  86. :disabled="type == 1 || !dataR.length"
  87. @click="handleAllDelete"
  88. >全部删除</el-button
  89. ></el-col
  90. >
  91. </el-row>
  92. </el-col>
  93. <el-col class="right_box" :span="9">
  94. <h4 class="transfer_title">已选经销商</h4>
  95. <el-checkbox-group
  96. v-model="rightData"
  97. class="right_box_flex"
  98. @change="handleRight"
  99. >
  100. <el-checkbox
  101. v-for="(item, index) in dataR"
  102. :key="index"
  103. :label="item.id"
  104. >
  105. {{ item.name }}</el-checkbox
  106. >
  107. </el-checkbox-group>
  108. </el-col>
  109. </el-row>
  110. </div>
  111. <slot name="footer">
  112. <el-row>
  113. <el-button type="primary" size="small" @click="handleSubmit"
  114. >提交审核</el-button
  115. >
  116. <el-button type="primary" size="small" @click="">重置</el-button>
  117. </el-row>
  118. </slot>
  119. </div>
  120. </template>
  121. <script>
  122. import Minxin from "@/mixin";
  123. import { getCrList } from "@/api/supply/sales";
  124. export default {
  125. mixins: [Minxin],
  126. data() {
  127. return {
  128. type: "",
  129. radio: "0",
  130. leftData: [],
  131. dataL: [],
  132. dataR: [],
  133. rightData: [],
  134. options: [
  135. {
  136. value: "选项1",
  137. label: "黄金糕",
  138. },
  139. ],
  140. value: "",
  141. region: "0",
  142. keyword: "",
  143. };
  144. },
  145. methods: {
  146. getList() {
  147. this.getcList();
  148. },
  149. getcList() {
  150. const customerParams = {
  151. pageNum: this.currentPage,
  152. pageSize: this.pageSize,
  153. keyword: this.keyword,
  154. region: this.region,
  155. };
  156. console.log(555);
  157. // 获取经销商列表
  158. getCrList(customerParams).then((res) => {
  159. this.dataL = res.data.records;
  160. this.listTotal = res.data.total;
  161. });
  162. },
  163. handleLeft(e) {
  164. this.type = 1;
  165. },
  166. handleRight(e) {
  167. this.type = 2;
  168. },
  169. handleAllAdd() {
  170. this.dataR = this.dataL;
  171. },
  172. handleAllDelete() {
  173. this.dataR = [];
  174. },
  175. handleAdd() {
  176. if (this.type == 1) {
  177. for (let i = 0; i < this.dataL.length; i++) {
  178. for (let k = 0; k < this.leftData.length; k++) {
  179. if (this.dataL[i].id == this.leftData[k]) {
  180. this.dataR = [...new Set([this.dataL[i], ...this.dataR])];
  181. }
  182. }
  183. }
  184. this.leftData = [];
  185. }
  186. },
  187. handleDelete() {
  188. if (this.type == 2) {
  189. for (let i = 0; i < this.dataR.length; i++) {
  190. for (let k = 0; k < this.rightData.length; k++) {
  191. if (this.dataR[i].id == this.rightData[k]) {
  192. this.dataR.splice(i, 1);
  193. }
  194. }
  195. }
  196. }
  197. },
  198. handleSubmit() {
  199. this.$emit("handleAddPolicy", this.dataR);
  200. },
  201. },
  202. };
  203. </script>
  204. <style lang="scss" scoped>
  205. // 穿梭框
  206. .transfer {
  207. margin: 20px 0;
  208. &_title {
  209. margin: 20px 20px 0 20px;
  210. }
  211. .left_box {
  212. display: flex;
  213. flex-direction: column;
  214. justify-content: space-between;
  215. width: 440px;
  216. height: 450px;
  217. border: 1px solid #eee;
  218. &_flex {
  219. display: flex;
  220. flex-direction: column;
  221. margin: 20px;
  222. .el-checkbox {
  223. padding: 10px 0;
  224. }
  225. }
  226. }
  227. .right_box {
  228. width: 440px;
  229. height: 450px;
  230. border: 1px solid #eee;
  231. &_flex {
  232. display: flex;
  233. flex-direction: column;
  234. margin: 20px;
  235. .el-checkbox {
  236. padding: 10px 0;
  237. }
  238. }
  239. }
  240. }
  241. .middle_box {
  242. text-align: center;
  243. height: 430px;
  244. display: flex;
  245. align-content: center;
  246. justify-content: center;
  247. align-items: center;
  248. }
  249. .el-row .el-col {
  250. margin: 20px 0;
  251. }
  252. .select_height {
  253. width: 100%;
  254. }
  255. </style>