excelPop.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <!-- 点击excel导入之后的弹窗:excel导入 -->
  3. <div class="excel-inputWindow">
  4. <div class="excel-titleWords">
  5. excel导入
  6. <div class="excel-closeIcon">
  7. <i class="el-icon-close" @click="closeExcelWindow"></i>
  8. </div>
  9. </div>
  10. <div class="folder-area">
  11. <div class="name-boxDiv">
  12. 名称
  13. </div>
  14. <el-input class="excelFolder-Input" v-model="fullExcelNameFolder" placeholder=""></el-input>
  15. <el-upload ref="upload" action="#" multiple :limit="1" :file-list="fileList" :auto-upload="false"
  16. :show-file-list="false" accept=".xls,.xlsx" :on-change="handleChange">
  17. <el-button class="excelFolder-search" slot="trigger" type="primary" @click="clearFilesBeforeUpload">浏览
  18. </el-button>
  19. </el-upload>
  20. </div>
  21. <div class="confirmORcancel-button">
  22. <el-button class="excelFolder-confirm-button" type="primary" @click="confirm">确认
  23. </el-button>
  24. <el-button class="excelFolder-cancel-button" type="primary" @click="closeExcelWindow">取消</el-button>
  25. </div>
  26. </div>
  27. </template>
  28. <script>
  29. import { mapState } from 'vuex';
  30. import {
  31. getXQTBListViaExcelSelect
  32. } from '@/api/xqglApi.js';
  33. export default {
  34. name: "excelPop",
  35. components: {},
  36. data() {
  37. return {
  38. fullExcelNameFolder: '',
  39. fileList: [],
  40. };
  41. },
  42. computed: {
  43. ...mapState("xqgl", ['parentId']),
  44. },
  45. watch: {
  46. },
  47. methods: {
  48. closeExcelWindow() {
  49. this.$emit('closePop');
  50. },
  51. confirm() {
  52. getXQTBListViaExcelSelect(this.excelUploadFile).then(res => {
  53. if (res.code === 200) {
  54. this.$emit('comfirm');
  55. this.$emit('closePop');
  56. }
  57. });
  58. },
  59. //excel上传时,为后端传输数据准备该接口的 data
  60. handleChange(file, fileList) {
  61. this.fullExcelNameFolder = file.name
  62. console.log('fileList:', fileList);
  63. let tempExcelFileFormData = new FormData();
  64. let tempExcelFile = file.raw;
  65. tempExcelFileFormData.append("file", tempExcelFile);
  66. tempExcelFileFormData.append("parentId", this.parentId);
  67. this.excelUploadFile = tempExcelFileFormData;
  68. console.log("this.excelUploadFile:", this.excelUploadFile);
  69. },
  70. //excel文件上传时,清空之情的待上传文件
  71. clearFilesBeforeUpload() {
  72. this.$refs.upload.clearFiles()
  73. },
  74. },
  75. mounted() {
  76. }
  77. };
  78. </script>
  79. <style lang='scss' scoped>
  80. .excel-inputWindow {
  81. width: 356px;
  82. height: 194px;
  83. position: absolute;
  84. top: 74px;
  85. left: 100%;
  86. z-index: 1;
  87. background: url('@/assets/ClipImage/dikuang/tanchuang/exceldaoru.png');
  88. background-size: 100% 100%;
  89. .excel-titleWords {
  90. width: 320px;
  91. height: 32px;
  92. line-height: 32px;
  93. text-align: center;
  94. position: relative;
  95. top: 34px;
  96. background-color: #0095ff;
  97. margin: 0px 18px;
  98. font-family: 'SourceHanSansCN-Bold';
  99. font-size: 14px;
  100. color: #fff;
  101. .excel-closeIcon {
  102. float: right;
  103. margin-right: 12px;
  104. cursor: pointer;
  105. }
  106. }
  107. .folder-area {
  108. width: 320px;
  109. height: 64px;
  110. position: relative;
  111. top: 17px;
  112. margin: 17px 18px;
  113. font-family: 'SourceHanSansCN-Regular';
  114. color: #fff;
  115. display: flex;
  116. justify-content: space-between;
  117. align-items: center;
  118. .name-boxDiv {
  119. width: 24px;
  120. height: 12px;
  121. font-size: 12px;
  122. }
  123. // /deep/ .excelFolder-Input {
  124. // width: 210px;
  125. // height: 30px;
  126. // background-color: rgba(299, 299, 299, 0.3);
  127. // // opacity: 0.3;
  128. // /deep/ .el-input__inner {
  129. // height: 30px;
  130. // line-height: 30px;
  131. // border: none;
  132. // color: #fff;
  133. // padding: 0 8px;
  134. // background: transparent;
  135. // }
  136. // }
  137. /deep/ .excelFolder-search {
  138. width: 60px;
  139. height: 30px;
  140. background-color: #006ebb;
  141. border-radius: 4px;
  142. padding: 0;
  143. }
  144. }
  145. .confirmORcancel-button {
  146. width: 320px;
  147. height: 30px;
  148. display: flex;
  149. justify-content: space-around;
  150. align-items: center;
  151. margin: 0 18px;
  152. .excelFolder-confirm-button,
  153. .excelFolder-cancel-button {
  154. width: 92px;
  155. height: 30px;
  156. background: url('@/assets/ClipImage/anniu/quxiao_link.png');
  157. background-size: 100% 100%;
  158. border: none;
  159. padding: 0;
  160. margin: 0;
  161. font-family: SourceHanSansCN-Regular;
  162. }
  163. .excelFolder-confirm-button {
  164. background: url('@/assets/ClipImage/anniu/queren_link.png');
  165. }
  166. .excelFolder-confirm-button:hover {
  167. background: url('@/assets/ClipImage/anniu/queren_hover.png');
  168. }
  169. .excelFolder-confirm-button:focus {
  170. background: url('@/assets/ClipImage/anniu/queren_check.png');
  171. }
  172. .excelFolder-cancel-button {
  173. background: url('@/assets/ClipImage/anniu/quxiao_link.png');
  174. }
  175. .excelFolder-cancel-button:hover {
  176. background: url('@/assets/ClipImage/anniu/quxiao_hover.png');
  177. }
  178. .excelFolder-cancel-button:focus {
  179. background: url('@/assets/ClipImage/anniu/quxiao_check.png');
  180. }
  181. }
  182. }
  183. </style>
  184. <style lang="scss">
  185. .excelFolder-Input {
  186. width: 210px;
  187. height: 30px;
  188. background-color: rgba(299, 299, 299, 0.3);
  189. .el-input__inner {
  190. height: 30px;
  191. line-height: 30px;
  192. border: none;
  193. color: #fff;
  194. padding: 0 8px;
  195. background: transparent;
  196. }
  197. }
  198. </style>