wordPop.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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. <label
  70. v-if="formData.eduId && formData.businessId && formData.subjectId"
  71. for="mobles"
  72. class="el-button el-button--primary el-button--mini"
  73. >上传Word</label
  74. ><input
  75. style="display: none"
  76. type="file"
  77. id="mobles"
  78. ref="input1"
  79. @change="importMobleadd"
  80. />
  81. </div>
  82. <el-dialog
  83. append-to-body
  84. :visible.sync="dialogERROR"
  85. width="660px"
  86. :show-close="false"
  87. :close-on-click-modal="false"
  88. >
  89. <div slot="title" class="hearders">
  90. <div class="leftTitle">提示</div>
  91. <div class="rightBoxs">
  92. <img
  93. src="@/assets/images/Close@2x.png"
  94. alt=""
  95. @click="dialogERROR = false"
  96. />
  97. </div>
  98. </div>
  99. <div>
  100. <h4 style="margin-top: 0px; font-weight: bold; text-align: center">
  101. 导入失败原因
  102. </h4>
  103. <el-input
  104. readonly
  105. type="textarea"
  106. :autosize="{ minRows: 6, maxRows: 24 }"
  107. v-model="errorData"
  108. >
  109. </el-input>
  110. </div>
  111. <span slot="footer" class="dialog-footer">
  112. <el-button @click="dialogERROR = false">确定</el-button>
  113. </span>
  114. </el-dialog>
  115. </div>
  116. </template>
  117. <script>
  118. import { mapGetters } from "vuex";
  119. import * as baseUrls from "@/utils/request.js";
  120. export default {
  121. data() {
  122. return {
  123. newBusinessLevel: [],
  124. newSujectType: [],
  125. errorData: "",
  126. formData: {
  127. eduId: "",
  128. businessId: "",
  129. subjectId: "",
  130. projectId: "",
  131. },
  132. dialogERROR: false,
  133. };
  134. },
  135. computed: {
  136. ...mapGetters(["educationType"]),
  137. },
  138. watch: {
  139. "formData.eduId"() {
  140. this.formData.businessId = "";
  141. this.formData.projectId = "";
  142. },
  143. "formData.businessId"(v) {
  144. if (v) {
  145. for (let i = 0; i < this.newBusinessLevel.length; i++) {
  146. if (this.newBusinessLevel[i].id === v) {
  147. this.formData.projectId = this.newBusinessLevel[i].projectId;
  148. break;
  149. }
  150. }
  151. }
  152. this.formData.subjectId = "";
  153. },
  154. },
  155. methods: {
  156. changeEducationType(v) {
  157. this.$api
  158. .inquirebusinessList({ status: 1, educationId: v })
  159. .then((res) => {
  160. this.newBusinessLevel = res.rows;
  161. });
  162. },
  163. changeBusinessLevel(v) {
  164. this.$api
  165. .inquireCourseSubject({ status: 1, businessId: v })
  166. .then((res) => {
  167. this.newSujectType = res.rows;
  168. });
  169. },
  170. getDowm() {
  171. let url =
  172. baseUrls.BASE_IMG_URL + "/oss/images/file/20220324/1648102107588.docx" +
  173. `?time=${this.$methodsTools.getNewTime()}`;;
  174. let link = document.createElement("a");
  175. let fileName = "导入模板" + ".docx";
  176. document.body.appendChild(link);
  177. link.href = url;
  178. link.dowmload = fileName;
  179. link.click();
  180. link.remove();
  181. },
  182. importMobleadd(e) {
  183. var self = this;
  184. var file = e.target.files[0];
  185. let formData = new FormData();
  186. formData.append("file", file);
  187. formData.append("eduId", this.formData.eduId);
  188. formData.append("projectId", this.formData.projectId);
  189. formData.append("businessId", this.formData.businessId);
  190. formData.append("subjectId", this.formData.subjectId);
  191. this.$api
  192. .bankquestionimportWordData(formData)
  193. .then((res) => {
  194. if (res.code === 200) {
  195. if (!res.msg) {
  196. self.$message.success("导入成功");
  197. this.$parent.$parent.dialogDRword = false;
  198. } else {
  199. self.errorData = res.msg;
  200. self.dialogERROR = true;
  201. }
  202. }
  203. })
  204. .finally(() => {
  205. e.target.value = "";
  206. self.$emit("search", 2);
  207. });
  208. },
  209. },
  210. };
  211. </script>
  212. <style lang="less" scoped>
  213. /deep/.el-button {
  214. border-radius: 8px;
  215. }
  216. /deep/.el-dialog {
  217. border-radius: 8px;
  218. .el-dialog__header {
  219. padding: 0;
  220. .hearders {
  221. height: 40px;
  222. display: flex;
  223. align-items: center;
  224. justify-content: space-between;
  225. padding: 0px 18px 0px 20px;
  226. border-bottom: 1px solid #e2e2e2;
  227. .leftTitle {
  228. font-size: 14px;
  229. font-weight: bold;
  230. color: #2f4378;
  231. }
  232. .rightBoxs {
  233. display: flex;
  234. align-items: center;
  235. img {
  236. width: 14px;
  237. height: 14px;
  238. margin-left: 13px;
  239. cursor: pointer;
  240. }
  241. }
  242. }
  243. }
  244. .el-dialog__footer {
  245. padding: 0;
  246. .dialog-footer {
  247. padding: 0px 40px;
  248. height: 70px;
  249. border-top: 1px solid #e2e2e2;
  250. display: flex;
  251. align-items: center;
  252. justify-content: flex-end;
  253. }
  254. }
  255. }
  256. .swq {
  257. text-align: center;
  258. border-bottom: 1px solid #eee;
  259. }
  260. .dowmStys {
  261. color: blue;
  262. cursor: pointer;
  263. }
  264. .imgBox {
  265. width: 100%;
  266. // height: 210px;
  267. border: 1px solid #e2e2e2;
  268. border-radius: 8px;
  269. padding: 8px 8px 3px;
  270. display: flex;
  271. flex-direction: column;
  272. align-items: center;
  273. .imgLabel {
  274. flex: 1;
  275. width: 100%;
  276. border: 1px dotted #e2e2e2;
  277. color: #999;
  278. font-size: 14px;
  279. cursor: pointer;
  280. border-radius: 8px;
  281. .msPhoto {
  282. display: flex;
  283. justify-content: center;
  284. align-items: center;
  285. max-width: 100%;
  286. max-height: 270px;
  287. img {
  288. max-width: 100%;
  289. max-height: 270px;
  290. }
  291. }
  292. .imgbbx {
  293. display: flex;
  294. flex-direction: column;
  295. align-items: center;
  296. justify-content: center;
  297. width: 100%;
  298. height: 100%;
  299. i {
  300. font-weight: bold;
  301. margin: 14px 0;
  302. font-size: 24px;
  303. }
  304. }
  305. }
  306. p {
  307. margin: 5px 0px;
  308. }
  309. }
  310. </style>