com-export-dialog-syn.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?php
  2. /**
  3. * @link:http://www.goodmall.com/
  4. * @copyright: Copyright (c) 2020
  5. * Created by PhpStorm
  6. * Author: ganxiaohao
  7. * Date: 2020-04-24
  8. * Time: 16:21
  9. */
  10. //$url = Yii::$app->urlManager->createUrl(Yii::$app->controller->route);
  11. $url = Yii::$app->urlManager->createUrl(\Yii::$app->requestedRoute);
  12. ?>
  13. <style>
  14. .com-export-dialog-syn .el-dialog__body .el-checkbox + .el-checkbox {
  15. margin-left: 0;
  16. }
  17. .com-export-dialog-syn .el-date-editor .el-range-separator {
  18. padding: 0;
  19. }
  20. .com-export-dialog-syn .modal-body {
  21. border: 1px solid #F0F2F7;
  22. }
  23. .com-export-dialog-syn .all-choose {
  24. height: 50px;
  25. line-height: 50px;
  26. background-color: #F3F5F6;
  27. width: 100%;
  28. padding-left: 20px;
  29. }
  30. .com-export-dialog-syn .choose-list {
  31. padding: 10px 25px 20px;
  32. }
  33. .com-export-dialog-syn .choose-list .export-checkbox {
  34. width: 135px;
  35. height: 30px;
  36. line-height: 30px;
  37. }
  38. </style>
  39. <template id="com-export-dialog-syn">
  40. <div class="com-export-dialog-syn" style="display: inline-block">
  41. <el-button @click="confirm" type="primary" size="small" style="padding: 9px 15px !important;">批量导出</el-button>
  42. <el-dialog
  43. title="选择导出信息"
  44. :visible.sync="dialogVisible"
  45. :modal-append-to-body='false'
  46. :append-to-body='true'
  47. width="50%">
  48. <form target="_blank" :action="action_url" method="post">
  49. <div class="modal-body">
  50. <input name="_csrf" type="hidden" id="_csrf" value="<?= Yii::$app->request->csrfToken ?>">
  51. <input name="flag" value="EXPORT" type="hidden">
  52. <input name="fields" :value="checkedFields" type="hidden">
  53. <input v-for="(value,key,index) in params" :name="key" :value="value" type="hidden">
  54. <el-checkbox class="all-choose" :indeterminate="isIndeterminate" v-model="checkAll"
  55. @change="exportCheckAll">全选
  56. </el-checkbox>
  57. <el-checkbox-group class="choose-list" v-model="checkedFields" @change="exportCheck">
  58. <el-checkbox class="export-checkbox" v-for="(item,index) in field_list" :key="index"
  59. :label="index">{{item}}
  60. </el-checkbox>
  61. </el-checkbox-group>
  62. </div>
  63. <div flex="dir:right" style="margin-top: 20px;">
  64. <button type="submit" class="el-button el-button--primary el-button--small">导出</button>
  65. </div>
  66. </form>
  67. </el-dialog>
  68. </div>
  69. </template>
  70. <script>
  71. Vue.component('com-export-dialog-syn', {
  72. template: '#com-export-dialog-syn',
  73. props: {
  74. count: {
  75. type: Object,
  76. default: null,
  77. },
  78. field_list: Object,
  79. params: Object,
  80. action_url: {
  81. type: String,
  82. default:'<?= $url ?>'
  83. },//跳转路由
  84. },
  85. data() {
  86. return {
  87. dialogVisible: false,
  88. isIndeterminate: false,
  89. checkAll: false,
  90. checkedFields: [],
  91. }
  92. },
  93. computed: {},
  94. watch: {
  95. params: {
  96. deep: true,
  97. handler(newVal, oldVal) {
  98. this.data = newVal;
  99. if(newVal.exportUrl){
  100. this.action_url = newVal.exportUrl;
  101. console.log(this.action_url);
  102. }
  103. },
  104. },
  105. },
  106. methods: {
  107. exportCheckAll(val) {
  108. if (val) {
  109. this.checkedFields = objectKeys(this.field_list);
  110. } else {
  111. this.checkedFields = [];
  112. }
  113. this.isIndeterminate = false;
  114. },
  115. exportCheck(value) {
  116. let checkedCount = value.length;
  117. this.checkAll = checkedCount === this.field_list.length;
  118. this.isIndeterminate = checkedCount > 0 && checkedCount < this.field_list.length;
  119. },
  120. confirm() {
  121. // 父级未传参 不判断
  122. if (typeof(this.count) == 'object' && this.count != null) {
  123. var total_count = this.count.totalCount
  124. var limit = 3000
  125. if (total_count > limit) {
  126. this.$message({
  127. message: '当前导出数量大于' + limit + ',请重新按条件筛选,当前数量:' + total_count,
  128. type: 'error'
  129. });
  130. return
  131. }
  132. }
  133. // 未加载完成 不弹出
  134. if (this.field_list.length == 0) {
  135. return
  136. }
  137. this.dialogVisible = true;
  138. this.$emit('selected');
  139. }
  140. },
  141. created() {
  142. // TODO 此处需获取网址上的所有参数、且需考虑参数名重复问题
  143. // TODO 已无作用
  144. this.params.status = getQuery('status');
  145. }
  146. });
  147. </script>