wordPop.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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 +
  84. "/oss/images/file/20220324/1648102107588.docx" +
  85. `?time=${this.$methodsTools.getNewTime()}`;
  86. let link = document.createElement("a");
  87. let fileName = "导入模板" + ".docx";
  88. document.body.appendChild(link);
  89. link.href = url;
  90. link.dowmload = fileName;
  91. link.click();
  92. link.remove();
  93. },
  94. importMobleadd(e) {
  95. var self = this;
  96. let arr = this.$parent.$parent.businObj;
  97. var file = e.target.files[0];
  98. let formData = new FormData();
  99. formData.append("file", file);
  100. formData.append("eduId", arr.educationTypeId);
  101. formData.append("projectId", arr.projectId);
  102. formData.append("businessId", arr.businessId);
  103. formData.append("subjectId", arr.subjectId);
  104. this.$api
  105. .bankquestionimportWordQuestionList(formData)
  106. .then((res) => {
  107. if (res.code === 200) {
  108. self.$message.success("导入成功");
  109. let numList = self.$parent.$parent.tableData;
  110. if (numList.length) {
  111. let numIndex = 0;
  112. let childrenIndex = 0;
  113. numList.forEach((items) => {
  114. if (items.sort > numIndex) {
  115. numIndex = items.sort;
  116. }
  117. if (items.index > childrenIndex) {
  118. childrenIndex = items.index;
  119. }
  120. });
  121. res.data.forEach((items, indexs) => {
  122. numIndex++;
  123. childrenIndex++;
  124. items.sort = numIndex;
  125. items.index = childrenIndex;
  126. items.jsonStr = JSON.stringify(items.optionsList);
  127. });
  128. } else {
  129. res.data.forEach((items, indexs) => {
  130. items.sort = 1 + indexs;
  131. items.index = indexs;
  132. items.jsonStr = JSON.stringify(items.optionsList);
  133. });
  134. }
  135. self.$parent.$parent.tableData =
  136. self.$parent.$parent.tableData.concat(res.data);
  137. self.$parent.$parent.dialogDRword = false;
  138. }
  139. })
  140. .finally(() => {
  141. e.target.value = "";
  142. });
  143. },
  144. },
  145. };
  146. </script>
  147. <style lang="less" scoped>
  148. /deep/.el-button {
  149. border-radius: 8px;
  150. }
  151. /deep/.el-dialog {
  152. border-radius: 8px;
  153. .el-dialog__header {
  154. padding: 0;
  155. .hearders {
  156. height: 40px;
  157. display: flex;
  158. align-items: center;
  159. justify-content: space-between;
  160. padding: 0px 18px 0px 20px;
  161. border-bottom: 1px solid #e2e2e2;
  162. .leftTitle {
  163. font-size: 14px;
  164. font-weight: bold;
  165. color: #2f4378;
  166. }
  167. .rightBoxs {
  168. display: flex;
  169. align-items: center;
  170. img {
  171. width: 14px;
  172. height: 14px;
  173. margin-left: 13px;
  174. cursor: pointer;
  175. }
  176. }
  177. }
  178. }
  179. .el-dialog__footer {
  180. padding: 0;
  181. .dialog-footer {
  182. padding: 0px 40px;
  183. height: 70px;
  184. border-top: 1px solid #e2e2e2;
  185. display: flex;
  186. align-items: center;
  187. justify-content: flex-end;
  188. }
  189. }
  190. }
  191. .swq {
  192. text-align: center;
  193. border-bottom: 1px solid #eee;
  194. }
  195. .dowmStys {
  196. color: blue;
  197. cursor: pointer;
  198. }
  199. .imgBox {
  200. width: 100%;
  201. // height: 210px;
  202. border: 1px solid #e2e2e2;
  203. border-radius: 8px;
  204. padding: 8px 8px 3px;
  205. display: flex;
  206. flex-direction: column;
  207. align-items: center;
  208. .imgLabel {
  209. flex: 1;
  210. width: 100%;
  211. border: 1px dotted #e2e2e2;
  212. color: #999;
  213. font-size: 14px;
  214. cursor: pointer;
  215. border-radius: 8px;
  216. .msPhoto {
  217. display: flex;
  218. justify-content: center;
  219. align-items: center;
  220. max-width: 100%;
  221. max-height: 270px;
  222. img {
  223. max-width: 100%;
  224. max-height: 270px;
  225. }
  226. }
  227. .imgbbx {
  228. display: flex;
  229. flex-direction: column;
  230. align-items: center;
  231. justify-content: center;
  232. width: 100%;
  233. height: 100%;
  234. i {
  235. font-weight: bold;
  236. margin: 14px 0;
  237. font-size: 24px;
  238. }
  239. }
  240. }
  241. p {
  242. margin: 5px 0px;
  243. }
  244. }
  245. </style>