wordPop.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <div>
  3. <div class="swq">
  4. <img
  5. style="width: 182px; height: 168px"
  6. src="@/assets/images/dr.png"
  7. alt=""
  8. />
  9. </div>
  10. <div style="padding-left: 100px">
  11. <p>第一步:下载word导入模板</p>
  12. <p style="padding-left: 50px">
  13. <i class="el-icon-upload"></i
  14. ><span class="dowmStys" @click="getDowm">下载模板</span>
  15. </p>
  16. <p>第二步:点击“上传Word”完成导入</p>
  17. <label
  18. for="mobles"
  19. style="margin-left: 50px"
  20. class="el-button el-button--primary el-button--mini"
  21. >上传Word</label
  22. ><input
  23. style="display: none"
  24. type="file"
  25. id="mobles"
  26. ref="input1"
  27. @change="importMobleadd"
  28. />
  29. </div>
  30. <el-dialog
  31. append-to-body
  32. :visible.sync="dialogERROR"
  33. width="660px"
  34. :show-close="false"
  35. :close-on-click-modal="false"
  36. >
  37. <div slot="title" class="hearders">
  38. <div class="leftTitle">提示</div>
  39. <div class="rightBoxs">
  40. <img
  41. src="@/assets/images/Close@2x.png"
  42. alt=""
  43. @click="dialogERROR = false"
  44. />
  45. </div>
  46. </div>
  47. <div>
  48. <h4 style="margin-top: 0px; font-weight: bold; text-align: center">
  49. 导入失败原因
  50. </h4>
  51. <el-input
  52. readonly
  53. type="textarea"
  54. :autosize="{ minRows: 6, maxRows: 24 }"
  55. v-model="errorData"
  56. >
  57. </el-input>
  58. </div>
  59. <span slot="footer" class="dialog-footer">
  60. <el-button @click="dialogERROR = false">确定</el-button>
  61. </span>
  62. </el-dialog>
  63. </div>
  64. </template>
  65. <script>
  66. import * as baseUrls from "@/utils/request.js";
  67. export default {
  68. data() {
  69. return {
  70. errorData: "",
  71. formData: {
  72. eduId: "",
  73. businessId: "",
  74. subjectId: "",
  75. projectId: "",
  76. },
  77. dialogERROR: false,
  78. };
  79. },
  80. methods: {
  81. getDowm() {
  82. let url =
  83. baseUrls.BASE_IMG_URL + "/oss/images/file/20220324/1648102107588.docx" +
  84. `?time=${this.$methodsTools.getNewTime()}`;;
  85. let link = document.createElement("a");
  86. let fileName = "导入模板" + ".docx";
  87. document.body.appendChild(link);
  88. link.href = url;
  89. link.dowmload = fileName;
  90. link.click();
  91. link.remove();
  92. },
  93. importMobleadd(e) {
  94. var self = this;
  95. let arr = this.$parent.$parent.businObj;
  96. var file = e.target.files[0];
  97. let formData = new FormData();
  98. formData.append("file", file);
  99. formData.append("eduId", arr.educationTypeId);
  100. formData.append("projectId", arr.projectId);
  101. formData.append("businessId", arr.businessId);
  102. formData.append("subjectId", arr.subjectId);
  103. this.$api
  104. .bankquestionimportWordQuestionList(formData)
  105. .then((res) => {
  106. if (res.code === 200) {
  107. self.$message.success("导入成功");
  108. let numList = self.$parent.$parent.tableData;
  109. if (numList.length) {
  110. let numIndex = 0;
  111. let childrenIndex = 0;
  112. numList.forEach((items) => {
  113. if (items.sort > numIndex) {
  114. numIndex = items.sort;
  115. }
  116. if (items.index > childrenIndex) {
  117. childrenIndex = items.index;
  118. }
  119. });
  120. res.data.forEach((items, indexs) => {
  121. numIndex++
  122. childrenIndex++
  123. items.sort = numIndex;
  124. items.index = childrenIndex;
  125. });
  126. } else {
  127. res.data.forEach((items, indexs) => {
  128. items.sort = 1 + indexs;
  129. items.index = indexs;
  130. });
  131. }
  132. self.$parent.$parent.tableData =
  133. self.$parent.$parent.tableData.concat(res.data);
  134. self.$parent.$parent.dialogDRword = false;
  135. }
  136. })
  137. .finally(() => {
  138. e.target.value = "";
  139. });
  140. },
  141. },
  142. };
  143. </script>
  144. <style lang="less" scoped>
  145. /deep/.el-button {
  146. border-radius: 8px;
  147. }
  148. /deep/.el-dialog {
  149. border-radius: 8px;
  150. .el-dialog__header {
  151. padding: 0;
  152. .hearders {
  153. height: 40px;
  154. display: flex;
  155. align-items: center;
  156. justify-content: space-between;
  157. padding: 0px 18px 0px 20px;
  158. border-bottom: 1px solid #e2e2e2;
  159. .leftTitle {
  160. font-size: 14px;
  161. font-weight: bold;
  162. color: #2f4378;
  163. }
  164. .rightBoxs {
  165. display: flex;
  166. align-items: center;
  167. img {
  168. width: 14px;
  169. height: 14px;
  170. margin-left: 13px;
  171. cursor: pointer;
  172. }
  173. }
  174. }
  175. }
  176. .el-dialog__footer {
  177. padding: 0;
  178. .dialog-footer {
  179. padding: 0px 40px;
  180. height: 70px;
  181. border-top: 1px solid #e2e2e2;
  182. display: flex;
  183. align-items: center;
  184. justify-content: flex-end;
  185. }
  186. }
  187. }
  188. .swq {
  189. text-align: center;
  190. border-bottom: 1px solid #eee;
  191. }
  192. .dowmStys {
  193. color: blue;
  194. cursor: pointer;
  195. }
  196. .imgBox {
  197. width: 100%;
  198. // height: 210px;
  199. border: 1px solid #e2e2e2;
  200. border-radius: 8px;
  201. padding: 8px 8px 3px;
  202. display: flex;
  203. flex-direction: column;
  204. align-items: center;
  205. .imgLabel {
  206. flex: 1;
  207. width: 100%;
  208. border: 1px dotted #e2e2e2;
  209. color: #999;
  210. font-size: 14px;
  211. cursor: pointer;
  212. border-radius: 8px;
  213. .msPhoto {
  214. display: flex;
  215. justify-content: center;
  216. align-items: center;
  217. max-width: 100%;
  218. max-height: 270px;
  219. img {
  220. max-width: 100%;
  221. max-height: 270px;
  222. }
  223. }
  224. .imgbbx {
  225. display: flex;
  226. flex-direction: column;
  227. align-items: center;
  228. justify-content: center;
  229. width: 100%;
  230. height: 100%;
  231. i {
  232. font-weight: bold;
  233. margin: 14px 0;
  234. font-size: 24px;
  235. }
  236. }
  237. }
  238. p {
  239. margin: 5px 0px;
  240. }
  241. }
  242. </style>