agent-batch.php 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <style>
  2. .agent-batch {
  3. }
  4. .agent-batch .batch-box {
  5. margin-left: 10px;
  6. }
  7. .agent-batch .batch-remark {
  8. margin-top: 5px;
  9. color: #999999;
  10. font-size: 14px;
  11. }
  12. .agent-batch .select-count {
  13. font-size: 14px;
  14. margin-left: 10px;
  15. }
  16. .agent-batch .batch-title {
  17. font-size: 18px;
  18. }
  19. .agent-batch .batch-box-left {
  20. width: 120px;
  21. border-right: 1px solid #e2e2e2;
  22. padding: 0 20px;
  23. }
  24. .agent-batch .batch-box-left div {
  25. padding: 5px 0;
  26. margin: 5px 0;
  27. cursor: pointer;
  28. -webkit-border-radius: 5px;
  29. -moz-border-radius: 5px;
  30. border-radius: 5px;
  31. }
  32. .agent-batch .batch-div-active {
  33. background-color: #e2e2e2;
  34. }
  35. .agent-batch .el-dialog__body {
  36. padding: 15px 20px;
  37. }
  38. .agent-batch .batch-box-right {
  39. padding: 5px 20px;
  40. }
  41. .agent-batch .express-dialog .el-dialog {
  42. min-width: 250px;
  43. }
  44. </style>
  45. <template id="agent-batch">
  46. <div class="agent-batch" flex="dir:left cross:center">
  47. <el-button type="primary" size="small" @click="batchSetting" style="padding: 9px 15px !important;">批量设置</el-button>
  48. <el-dialog
  49. :visible.sync="dialogVisible"
  50. width="50%">
  51. <div slot="title">
  52. <div flex="dir:left">
  53. <div class="batch-title">批量修改</div>
  54. <div flex="cross:center" class="select-count">{{dialogTitle}}</div>
  55. </div>
  56. <div class="batch-remark">注:每次只能修改一项,修改后点击确定即可生效。如需修改多项,需多次操作。</div>
  57. </div>
  58. <div flex="dir:left box:first">
  59. <div class="batch-box-left" flex="dir:top">
  60. <div v-for="(item, index) in newBatchList"
  61. :key='item.key'
  62. :class="{'batch-div-active': currentBatch === item.key ? true : false}"
  63. @click="currentBatch = item.key"
  64. flex="main:center">
  65. {{item.name}}
  66. </div>
  67. </div>
  68. <div class="batch-box-right">
  69. <el-form>
  70. <el-form-item hidden>
  71. <el-input></el-input>
  72. </el-form-item>
  73. <template v-if="currentBatch === 'level'">
  74. <el-form-item label="经销商等级">
  75. <el-select size="small" v-model="level" class="select">
  76. <el-option :key="index" :label="item.name" :value="item.level"
  77. v-for="(item, index) in agentLevelList"></el-option>
  78. </el-select>
  79. </el-form-item>
  80. </template>
  81. </el-form>
  82. </div>
  83. </div>
  84. <div slot="footer">
  85. <el-button size="small" @click="dialogVisible = false">取 消</el-button>
  86. <el-button size="small" :loading="btnLoading" type="primary" @click="dialogSubmit">确 定
  87. </el-button>
  88. </div>
  89. </el-dialog>
  90. </div>
  91. </template>
  92. <script>
  93. Vue.component('agent-batch', {
  94. template: '#agent-batch',
  95. props: {
  96. // 列表选中的数据
  97. chooseList: {
  98. type: Array,
  99. default: function () {
  100. return [];
  101. }
  102. },
  103. batchLevelUrl: {
  104. type: String,
  105. default: 'agent/default/batch-level',
  106. },
  107. agentLevelList: Array,
  108. },
  109. data() {
  110. return {
  111. isAllChecked: false,
  112. btnLoading: false,
  113. dialogVisible: false,
  114. currentBatch: '',
  115. dialogTitle: '',
  116. newBatchList: [],
  117. baseBatchList: [
  118. {
  119. name: '经销商等级',
  120. key: 'level',// 唯一
  121. },
  122. ],
  123. level: 0
  124. }
  125. },
  126. created(){
  127. console.log(this.agentLevelList);
  128. },
  129. methods: {
  130. // 打开批量设置框
  131. batchSetting() {
  132. let self = this;
  133. if (!self.checkChooseList()) {
  134. return false;
  135. }
  136. self.newBatchList = [];
  137. self.baseBatchList.forEach(function (item) {
  138. self.newBatchList.push(item);
  139. });
  140. self.currentBatch = self.newBatchList[0].key;
  141. self.dialogVisible = true;
  142. },
  143. checkChooseList() {
  144. if (this.isAllChecked) {
  145. this.dialogTitle = '已选所有经销商';
  146. return true;
  147. }
  148. if (this.chooseList.length > 0) {
  149. this.dialogTitle = '已选经销商' + this.chooseList.length + '个';
  150. return true;
  151. }
  152. this.$message.warning('请先勾选要设置的经销商');
  153. return false;
  154. },
  155. batchAction(data) {
  156. let self = this;
  157. self.$confirm(data.content, '提示', {
  158. confirmButtonText: '确定',
  159. cancelButtonText: '取消',
  160. type: 'warning'
  161. }).then(() => {
  162. self.btnLoading = true
  163. request({
  164. params: {
  165. r: data.url
  166. },
  167. data: data.params,
  168. method: 'post'
  169. }).then(e => {
  170. self.btnLoading = false;
  171. if (e.data.code === 0) {
  172. self.dialogVisible = false;
  173. self.$message.success(e.data.msg);
  174. self.getList();
  175. } else {
  176. self.$message.error(e.data.msg);
  177. }
  178. }).catch(e => {
  179. self.$message.error(e.data.msg);
  180. self.btnLoading = false;
  181. });
  182. }).catch(() => {
  183. });
  184. },
  185. getList() {
  186. this.isAllChecked = false;
  187. this.$emit('to-search')
  188. },
  189. dialogSubmit() {
  190. let self = this;
  191. let params = {
  192. batch_ids: this.chooseList,
  193. is_all: this.isAllChecked ? 1 : 0,
  194. };
  195. switch (this.currentBatch) {
  196. case 'level':
  197. if (this.level === '') {
  198. self.$message.warning('请选择经销商等级');
  199. return false;
  200. }
  201. params.level = this.level;
  202. this.batchAction({
  203. url: self.batchLevelUrl,
  204. content: '批量设置经销商等级,是否继续',
  205. params: params
  206. });
  207. break;
  208. default:
  209. break;
  210. }
  211. },
  212. },
  213. })
  214. </script>