cat-transfer.php 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <?php
  2. /**
  3. * @link:http://www.gdqijianshi.com/
  4. * copyright: Copyright (c) 2020 广东七件事集团
  5. * author: zal
  6. */
  7. ?>
  8. <style>
  9. .cat-transfer .transfer {
  10. width: 280px;
  11. height: 500px;
  12. }
  13. .cat-transfer .transfer .cat-header {
  14. padding: 0 16px;
  15. height: 40px;
  16. line-height: 40px;
  17. border-bottom: 1px solid #ebeef5;
  18. background-color: #f5f7fa;
  19. }
  20. .cat-transfer .transfer .cat-body {
  21. overflow-y: auto;
  22. height: 460px;
  23. padding: 16px;
  24. width: 100%;
  25. }
  26. .cat-transfer .transfer .cat-next {
  27. color: #353535;
  28. text-align: right;
  29. font-size: 10px;
  30. padding: 0;
  31. }
  32. .cat-transfer .middle {
  33. border-radius: 36px;
  34. width: 36px;
  35. height: 36px;
  36. margin: 0 30px;
  37. font-size: 10px;
  38. }
  39. </style>
  40. <template id="cat-transfer">
  41. <div class="cat-transfer">
  42. <el-form ref="form" :data="form">
  43. <el-input size="small" style="display: none"></el-input>
  44. <div flex="dir:left">
  45. <template v-for="(item, index) in list">
  46. <div v-if="index == 'middle'" flex="dir:left cross:center">
  47. <el-button class="middle" type="text" icon="el-icon-arrow-right" :disabled="true"
  48. :style="middleStyle()"></el-button>
  49. </div>
  50. <el-card class="transfer" shadow="never" v-loading="item.loading" v-else
  51. body-style="height: 100%;padding: 0">
  52. <div class="cat-header" v-if="item.grandParent">
  53. <el-button type="text" @click="next(0, index)" style="margin: 0;">
  54. 分类/
  55. </el-button>
  56. <el-button type="text" @click="next(item.grandParent.id, index)" style="margin: 0;">
  57. {{item.grandParent.name}}/
  58. </el-button>
  59. {{item.parent.name}}
  60. </div>
  61. <div class="cat-header" v-else-if="item.parent">
  62. <el-button type="text" @click="next(0, index)" style="margin: 0;">
  63. 分类/
  64. </el-button>
  65. {{item.parent.name}}
  66. </div>
  67. <div class="cat-header" v-else>分类</div>
  68. <div class="cat-body">
  69. <el-input size="small" suffix-icon="el-icon-search" v-model="item.keyword"
  70. @keyup.enter.native="search(index)"></el-input>
  71. <div style="width: 100%;margin-top: 16px;" v-for="cat in item.list"
  72. flex="dir:left box:first">
  73. <com-ellipsis :line="1">
  74. <el-radio :label="cat.id" v-model="item.selectCat"
  75. style="max-width: 140px;font-size: 14px;color: #303133">{{cat.name}}
  76. </el-radio>
  77. </com-ellipsis>
  78. <el-button class="cat-next" type="text" icon="el-icon-arrow-right"
  79. v-if="cat.child.length > 0" @click="next(cat.id, index)"></el-button>
  80. </div>
  81. </div>
  82. </el-card>
  83. </template>
  84. </div>
  85. <el-form-item>
  86. <el-button type="primary" size="mini" @click="submit" :loading="btnLoading">开始转移</el-button>
  87. </el-form-item>
  88. </el-form>
  89. </div>
  90. </template>
  91. <script>
  92. Vue.component('cat-transfer', {
  93. template: '#cat-transfer',
  94. props: {
  95. },
  96. data() {
  97. return {
  98. form: {},
  99. btnLoading: false,
  100. selectCat: '',
  101. list: {
  102. before: {
  103. keyword: '',
  104. selectCat: 0,
  105. list: [],
  106. pagination: null,
  107. loading: false,
  108. parent: null,
  109. grandParent: null,
  110. },
  111. middle: {
  112. },
  113. after: {
  114. keyword: '',
  115. selectCat: 0,
  116. list: [],
  117. pagination: null,
  118. loading: false,
  119. parent: null,
  120. grandParent: null,
  121. },
  122. },
  123. url: 'mall/cate/transfer',
  124. }
  125. },
  126. created() {
  127. this.getCatList({
  128. r: this.url,
  129. id: 0
  130. });
  131. },
  132. methods: {
  133. getCatList(params) {
  134. if (this.selectCat == '') {
  135. for (let i in this.list) {
  136. this.list[i].loading = true;
  137. this.list[i].list = [];
  138. }
  139. } else {
  140. this.list[this.selectCat].loading = true;
  141. this.list[this.selectCat].list = [];
  142. }
  143. request({
  144. params: params,
  145. method: 'get',
  146. }).then(response => {
  147. if (this.selectCat == '') {
  148. for (let i in this.list) {
  149. this.list[i].loading = false;
  150. }
  151. } else {
  152. this.list[this.selectCat].loading = false;
  153. }
  154. if (response.data.code == 0) {
  155. if (this.selectCat == '') {
  156. for (let i in this.list) {
  157. this.list[i].list = response.data.data.list;
  158. this.list[i].pagination = response.data.data.pagination;
  159. if (typeof params.keyword === 'undefined') {
  160. this.list[i].parent = response.data.data.parent;
  161. this.list[i].grandParent = response.data.data.grandParent;
  162. }
  163. }
  164. } else {
  165. this.list[this.selectCat].list = response.data.data.list;
  166. this.list[this.selectCat].pagination = response.data.data.pagination;
  167. if (typeof params.keyword === 'undefined') {
  168. this.list[this.selectCat].parent = response.data.data.parent;
  169. this.list[this.selectCat].grandParent = response.data.data.grandParent;
  170. }
  171. }
  172. } else {
  173. this.$message.error(response.data.msg);
  174. }
  175. }).catch(response => {
  176. console.log(response);
  177. });
  178. },
  179. submit() {
  180. this.btnLoading = true;
  181. request({
  182. params: {
  183. r: 'mall/cate/transfer',
  184. },
  185. method: 'post',
  186. data: {
  187. before: this.list.before.selectCat,
  188. after: this.list.after.selectCat,
  189. }
  190. }).then(response => {
  191. this.btnLoading = false;
  192. if (response.data.code == 0) {
  193. this.$message.success(response.data.msg);
  194. } else {
  195. this.$message.error(response.data.msg);
  196. }
  197. });
  198. },
  199. search(param) {
  200. let id = this.list[param].grandParent ?
  201. this.list[param].grandParent.id :
  202. (this.list[param].parent ? this.list[param].parent.id : 0);
  203. this.list[param].selectCat = 0;
  204. this.selectCat = param;
  205. this.getCatList({
  206. r: this.url,
  207. id: id,
  208. keyword: this.list[param].keyword
  209. });
  210. },
  211. next(id, param) {
  212. this.selectCat = param;
  213. this.list[param].keyword = '';
  214. this.list[param].selectCat = 0;
  215. this.getCatList({
  216. r: this.url,
  217. id: id
  218. });
  219. },
  220. middleStyle() {
  221. if (this.list.before.selectCat > 0 && this.list.after.selectCat > 0) {
  222. return `background-color: #409EFF;color: #fff`;
  223. } else {
  224. return `background-color: #f7f5fa;color: rgba(0, 0, 0, 0.5);`;
  225. }
  226. }
  227. }
  228. })
  229. </script>