wordPop.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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>第二步:选择必填项</p>
  17. <div>
  18. <!-- 教育类型 -->
  19. <el-select
  20. v-model="formData.eduId"
  21. placeholder="请选择教育类型(必填)"
  22. size="mini"
  23. @change="changeEducationType"
  24. >
  25. <el-option
  26. v-for="(items, indexs) in educationType"
  27. :key="indexs"
  28. :label="items.educationName"
  29. :value="items.id"
  30. ></el-option>
  31. </el-select>
  32. <!-- 业务层次 -->
  33. <el-select
  34. v-if="formData.eduId"
  35. v-model="formData.businessId"
  36. placeholder="请选择业务层次(必填)"
  37. size="mini"
  38. @change="changeBusinessLevel"
  39. >
  40. <el-option
  41. v-for="(items, indexs) in newBusinessLevel"
  42. :key="indexs"
  43. :label="items.projectName + '-' + items.businessName"
  44. :value="items.id"
  45. ></el-option>
  46. </el-select>
  47. <!-- 科目 -->
  48. <el-select
  49. v-if="formData.businessId"
  50. v-model="formData.subjectId"
  51. placeholder="请选择科目(必填)"
  52. size="mini"
  53. >
  54. <el-option
  55. v-for="(items, indexs) in newSujectType"
  56. :key="indexs"
  57. :label="items.subjectName"
  58. :value="items.id"
  59. ></el-option>
  60. </el-select>
  61. </div>
  62. <p>
  63. 第三步:(批量新增):点击“上传Word”完成导入<span
  64. v-if="!(formData.eduId && formData.businessId && formData.subjectId)"
  65. style="color: red; margin-left: 14px"
  66. >请完成第二步选择必填项</span
  67. >
  68. </p>
  69. <div
  70. v-if="formData.eduId && formData.businessId && formData.subjectId"
  71. v-loading="loading"
  72. element-loading-text="正在处理中"
  73. style="margin: 0 0 0 50px; width: 130px; height: 40px"
  74. >
  75. <label
  76. v-show="!loading"
  77. for="mobles"
  78. class="el-button el-button--primary el-button--mini"
  79. >上传Word</label
  80. ><input
  81. style="display: none"
  82. type="file"
  83. id="mobles"
  84. ref="input1"
  85. @change="importMobleadd"
  86. />
  87. </div>
  88. </div>
  89. <el-dialog
  90. append-to-body
  91. :visible.sync="dialogERROR"
  92. width="660px"
  93. :show-close="false"
  94. :close-on-click-modal="false"
  95. >
  96. <div slot="title" class="hearders">
  97. <div class="leftTitle">提示</div>
  98. <div class="rightBoxs">
  99. <img
  100. src="@/assets/images/Close@2x.png"
  101. alt=""
  102. @click="dialogERROR = false"
  103. />
  104. </div>
  105. </div>
  106. <div>
  107. <h4 style="margin-top: 0px; font-weight: bold; text-align: center">
  108. 导入失败原因
  109. </h4>
  110. <el-input
  111. readonly
  112. type="textarea"
  113. :autosize="{ minRows: 6, maxRows: 24 }"
  114. v-model="errorData"
  115. >
  116. </el-input>
  117. </div>
  118. <span slot="footer" class="dialog-footer">
  119. <el-button @click="dialogERROR = false">确定</el-button>
  120. </span>
  121. </el-dialog>
  122. </div>
  123. </template>
  124. <script>
  125. import { mapGetters } from "vuex";
  126. import * as baseUrls from "@/utils/request.js";
  127. export default {
  128. data() {
  129. return {
  130. newBusinessLevel: [],
  131. newSujectType: [],
  132. errorData: "",
  133. formData: {
  134. eduId: "",
  135. businessId: "",
  136. subjectId: "",
  137. projectId: "",
  138. },
  139. dialogERROR: false,
  140. loading: false,
  141. };
  142. },
  143. computed: {
  144. ...mapGetters(["educationType"]),
  145. },
  146. watch: {
  147. "formData.eduId"() {
  148. this.formData.businessId = "";
  149. this.formData.projectId = "";
  150. },
  151. "formData.businessId"(v) {
  152. if (v) {
  153. for (let i = 0; i < this.newBusinessLevel.length; i++) {
  154. if (this.newBusinessLevel[i].id === v) {
  155. this.formData.projectId = this.newBusinessLevel[i].projectId;
  156. break;
  157. }
  158. }
  159. }
  160. this.formData.subjectId = "";
  161. },
  162. },
  163. methods: {
  164. changeEducationType(v) {
  165. this.$api
  166. .inquirebusinessList({ status: 1, educationId: v })
  167. .then((res) => {
  168. this.newBusinessLevel = res.rows;
  169. });
  170. },
  171. changeBusinessLevel(v) {
  172. this.$api
  173. .inquireCourseSubject({ status: 1, businessId: v })
  174. .then((res) => {
  175. this.newSujectType = res.rows;
  176. });
  177. },
  178. getDowm() {
  179. let url =
  180. baseUrls.BASE_IMG_URL +
  181. "/oss/images/file/20220324/1648102107588.docx" +
  182. `?time=${this.$methodsTools.getNewTime()}`;
  183. let link = document.createElement("a");
  184. let fileName = "导入模板" + ".docx";
  185. document.body.appendChild(link);
  186. link.href = url;
  187. link.dowmload = fileName;
  188. link.click();
  189. link.remove();
  190. },
  191. importMobleadd(e) {
  192. var self = this;
  193. var file = e.target.files[0];
  194. if (file === undefined) {
  195. e.target.value = "";
  196. return;
  197. }
  198. var type = e.target.value.toLowerCase().split(".").splice(-1);
  199. if (type[0] != "docx") {
  200. self.$message.error("请上传word文件,且上传格式需为:.docx");
  201. return;
  202. }
  203. this.loading = true;
  204. let formData = new FormData();
  205. formData.append("file", file);
  206. formData.append("eduId", this.formData.eduId);
  207. formData.append("projectId", this.formData.projectId);
  208. formData.append("businessId", this.formData.businessId);
  209. formData.append("subjectId", this.formData.subjectId);
  210. this.$api
  211. .bankquestionimportWordData(formData)
  212. .then((res) => {
  213. if (res.code === 200) {
  214. if (!res.msg) {
  215. self.$message.success("导入成功");
  216. this.$parent.$parent.dialogDRword = false;
  217. } else {
  218. self.errorData = res.msg;
  219. self.dialogERROR = true;
  220. }
  221. }
  222. })
  223. .finally(() => {
  224. e.target.value = "";
  225. self.$emit("search", 2);
  226. this.loading = false;
  227. });
  228. },
  229. },
  230. };
  231. </script>
  232. <style lang="less" scoped>
  233. /deep/.el-button {
  234. border-radius: 8px;
  235. }
  236. /deep/.el-dialog {
  237. border-radius: 8px;
  238. .el-dialog__header {
  239. padding: 0;
  240. .hearders {
  241. height: 40px;
  242. display: flex;
  243. align-items: center;
  244. justify-content: space-between;
  245. padding: 0px 18px 0px 20px;
  246. border-bottom: 1px solid #e2e2e2;
  247. .leftTitle {
  248. font-size: 14px;
  249. font-weight: bold;
  250. color: #2f4378;
  251. }
  252. .rightBoxs {
  253. display: flex;
  254. align-items: center;
  255. img {
  256. width: 14px;
  257. height: 14px;
  258. margin-left: 13px;
  259. cursor: pointer;
  260. }
  261. }
  262. }
  263. }
  264. .el-dialog__footer {
  265. padding: 0;
  266. .dialog-footer {
  267. padding: 0px 40px;
  268. height: 70px;
  269. border-top: 1px solid #e2e2e2;
  270. display: flex;
  271. align-items: center;
  272. justify-content: flex-end;
  273. }
  274. }
  275. }
  276. .swq {
  277. text-align: center;
  278. border-bottom: 1px solid #eee;
  279. }
  280. .dowmStys {
  281. color: blue;
  282. cursor: pointer;
  283. }
  284. .imgBox {
  285. width: 100%;
  286. // height: 210px;
  287. border: 1px solid #e2e2e2;
  288. border-radius: 8px;
  289. padding: 8px 8px 3px;
  290. display: flex;
  291. flex-direction: column;
  292. align-items: center;
  293. .imgLabel {
  294. flex: 1;
  295. width: 100%;
  296. border: 1px dotted #e2e2e2;
  297. color: #999;
  298. font-size: 14px;
  299. cursor: pointer;
  300. border-radius: 8px;
  301. .msPhoto {
  302. display: flex;
  303. justify-content: center;
  304. align-items: center;
  305. max-width: 100%;
  306. max-height: 270px;
  307. img {
  308. max-width: 100%;
  309. max-height: 270px;
  310. }
  311. }
  312. .imgbbx {
  313. display: flex;
  314. flex-direction: column;
  315. align-items: center;
  316. justify-content: center;
  317. width: 100%;
  318. height: 100%;
  319. i {
  320. font-weight: bold;
  321. margin: 14px 0;
  322. font-size: 24px;
  323. }
  324. }
  325. }
  326. p {
  327. margin: 5px 0px;
  328. }
  329. }
  330. </style>