select-class-import.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="年级名称" prop="gradeName">
  5. <el-input v-model="queryParams.gradeName" placeholder="请输入年级名称" clearable size="small"
  6. @keyup.enter.native="handleQuery"/>
  7. </el-form-item>
  8. <el-form-item label="班级名称" prop="className">
  9. <el-input v-model="queryParams.className" placeholder="请输入班级名称" clearable size="small"
  10. @keyup.enter.native="handleQuery"/>
  11. </el-form-item>
  12. <el-form-item>
  13. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  14. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  15. </el-form-item>
  16. </el-form>
  17. <el-row :gutter="10" class="mb8">
  18. <el-col :span="1.5">
  19. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
  20. v-hasPermi="['mxjb:mxjbSelectedClassImport:add']">新增
  21. </el-button>
  22. </el-col>
  23. <el-col :span="1.5">
  24. <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
  25. v-hasPermi="['mxjb:mxjbSelectedClassImport:edit']">修改
  26. </el-button>
  27. </el-col>
  28. <el-col :span="1.5">
  29. <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
  30. v-hasPermi="['mxjb:mxjbSelectedClassImport:remove']">删除
  31. </el-button>
  32. </el-col>
  33. <el-col :span="1.5">
  34. <el-button type="info" plain icon="el-icon-upload2" size="mini" @click="handleImport"
  35. v-hasPermi="['mxjb:mxjbSelectedScore:import']">导入
  36. </el-button>
  37. </el-col>
  38. <el-col :span="1.5">
  39. <el-button type="warning" plain icon="el-icon-download" size="mini" :loading="exportLoading"
  40. @click="handleExport" v-hasPermi="['mxjb:mxjbSelectedClassImport:export']">导出
  41. </el-button>
  42. </el-col>
  43. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  44. </el-row>
  45. <el-table v-loading="loading" :data="mxjbSelectedClassImportList" @selection-change="handleSelectionChange">
  46. <el-table-column type="selection" width="55" align="center"/>
  47. <el-table-column label="导入文件" align="center" prop="importId"/>
  48. <el-table-column label="学校名称" align="center" prop="schoolName"/>
  49. <el-table-column label="年级名称" align="center" prop="gradeName"/>
  50. <el-table-column label="班级名称" align="center" prop="className"/>
  51. <el-table-column label="班级数量" align="center" prop="validCount"/>
  52. <el-table-column label="记录总数" align="center" prop="totalCount"/>
  53. <el-table-column label="导入时间" align="center" prop="createdTime"/>
  54. <el-table-column label="更新时间" align="center" prop="updatedTime"/>
  55. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  56. <template slot-scope="scope">
  57. <el-button size="mini" type="text" icon="el-icon-view" @click="handleDetail(scope.row)"
  58. v-hasPermi="['mxjb:mxjbSelectedClassDetail:list']">详情
  59. </el-button>
  60. <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
  61. v-hasPermi="['mxjb:mxjbSelectedClassImport:edit']">修改
  62. </el-button>
  63. <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
  64. v-hasPermi="['mxjb:mxjbSelectedClassImport:remove']">删除
  65. </el-button>
  66. </template>
  67. </el-table-column>
  68. </el-table>
  69. <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
  70. @pagination="getList"/>
  71. <!-- 添加或修改选班导入文件对话框 -->
  72. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  73. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  74. <el-form-item label="年级名称" prop="gradeName">
  75. <el-input v-model="form.gradeName" placeholder="请输入年级名称"/>
  76. </el-form-item>
  77. <el-form-item label="班级名称" prop="className">
  78. <el-input v-model="form.className" placeholder="请输入班级名称"/>
  79. </el-form-item>
  80. </el-form>
  81. <div slot="footer" class="dialog-footer">
  82. <el-button type="primary" @click="submitForm">确 定</el-button>
  83. <el-button @click="cancel">取 消</el-button>
  84. </div>
  85. </el-dialog>
  86. <!-- 用户导入对话框 -->
  87. <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" v-loading="upload.isUploading"
  88. append-to-body>
  89. <el-upload
  90. ref="upload"
  91. :limit="1"
  92. accept=".xlsx, .xls"
  93. :headers="upload.headers"
  94. :action="upload.url + '?updateSupport=' + upload.updateSupport"
  95. :disabled="upload.isUploading"
  96. :on-progress="handleFileUploadProgress"
  97. :on-success="handleFileSuccess"
  98. :auto-upload="false"
  99. drag
  100. >
  101. <i class="el-icon-upload"></i>
  102. <div class="el-upload__text">
  103. 将文件拖到此处,或
  104. <em>点击上传</em>
  105. </div>
  106. <div class="el-upload__tip" slot="tip">
  107. <el-checkbox v-model="upload.updateSupport"/>
  108. 是否更新已经存在的数据
  109. <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
  110. </div>
  111. <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
  112. </el-upload>
  113. <div slot="footer" class="dialog-footer">
  114. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  115. <el-button @click="upload.open = false">取 消</el-button>
  116. </div>
  117. </el-dialog>
  118. <!-- 详情抽屉 -->
  119. <el-drawer v-if="detailVisible" :visible.sync="detailVisible" title="导入详情" size="60%">
  120. <select-class-import-detail :import-id="detailImportId"></select-class-import-detail>
  121. </el-drawer>
  122. </div>
  123. </template>
  124. <script>
  125. import {
  126. listMxjbSelectedClassImport,
  127. getMxjbSelectedClassImport,
  128. delMxjbSelectedClassImport,
  129. addMxjbSelectedClassImport,
  130. updateMxjbSelectedClassImport,
  131. exportMxjbSelectedClassImport,
  132. importTemplate
  133. } from '@/api/webApi/mxjbSelectedClassImport'
  134. import auth from '@/utils/auth'
  135. import SelectClassImportDetail from '@/views/permission/components/select-class-import-detail'
  136. export default {
  137. name: 'MxjbSelectedClassImport',
  138. components: { SelectClassImportDetail },
  139. data() {
  140. return {
  141. // 遮罩层
  142. loading: true,
  143. // 导出遮罩层
  144. exportLoading: false,
  145. // 选中数组
  146. ids: [],
  147. // 非单个禁用
  148. single: true,
  149. // 非多个禁用
  150. multiple: true,
  151. // 显示搜索条件
  152. showSearch: true,
  153. // 总条数
  154. total: 0,
  155. // 选班导入文件表格数据
  156. mxjbSelectedClassImportList: [],
  157. // 弹出层标题
  158. title: '',
  159. // 是否显示弹出层
  160. open: false,
  161. // 用户导入参数
  162. upload: {
  163. // 是否显示弹出层(用户导入)
  164. open: false,
  165. // 弹出层标题(用户导入)
  166. title: '',
  167. // 是否禁用上传
  168. isUploading: false,
  169. // 是否更新已经存在的用户数据
  170. updateSupport: 0,
  171. // 设置上传的请求头部
  172. headers: { Authorization: 'Bearer ' + auth.getToken() },
  173. // 上传的地址
  174. url: process.env.VUE_APP_BASE_API + '/mxjb/mxjbSelectedClassImport/importData'
  175. },
  176. // 查询参数
  177. queryParams: {
  178. pageNum: 1,
  179. pageSize: 10,
  180. state: null,
  181. schoolId: null,
  182. schoolName: null,
  183. gradeName: null,
  184. classId: null,
  185. className: null,
  186. validCount: null,
  187. totalCount: null,
  188. createdTime: null,
  189. updatedTime: null
  190. },
  191. // 表单参数
  192. form: {},
  193. // 表单校验
  194. rules: {},
  195. // 详情
  196. detailVisible: false,
  197. detailImportId: 0
  198. }
  199. },
  200. created() {
  201. this.getList()
  202. },
  203. methods: {
  204. /** 查询选班导入文件列表 */
  205. getList() {
  206. this.loading = true
  207. listMxjbSelectedClassImport(this.queryParams).then(response => {
  208. this.mxjbSelectedClassImportList = response.rows
  209. this.total = response.total
  210. this.loading = false
  211. })
  212. },
  213. // 取消按钮
  214. cancel() {
  215. this.open = false
  216. this.reset()
  217. },
  218. // 表单重置
  219. reset() {
  220. this.form = {
  221. importId: null,
  222. state: null,
  223. schoolId: null,
  224. schoolName: null,
  225. gradeName: null,
  226. classId: null,
  227. className: null,
  228. validCount: null,
  229. totalCount: null,
  230. createdTime: null,
  231. updatedTime: null
  232. }
  233. this.resetForm('form')
  234. },
  235. /** 搜索按钮操作 */
  236. handleQuery() {
  237. this.queryParams.pageNum = 1
  238. this.getList()
  239. },
  240. /** 重置按钮操作 */
  241. resetQuery() {
  242. this.resetForm('queryForm')
  243. this.handleQuery()
  244. },
  245. // 多选框选中数据
  246. handleSelectionChange(selection) {
  247. this.ids = selection.map(item => item.importId)
  248. this.single = selection.length !== 1
  249. this.multiple = !selection.length
  250. },
  251. /** 新增按钮操作 */
  252. handleAdd() {
  253. this.reset()
  254. this.open = true
  255. this.title = '添加选班导入文件'
  256. },
  257. /** 修改按钮操作 */
  258. handleUpdate(row) {
  259. this.reset()
  260. const importId = row.importId || this.ids
  261. getMxjbSelectedClassImport(importId).then(response => {
  262. this.form = response.data
  263. this.open = true
  264. this.title = '修改选班导入文件'
  265. })
  266. },
  267. /** 提交按钮 */
  268. submitForm() {
  269. this.$refs['form'].validate(valid => {
  270. if (valid) {
  271. if (this.form.importId != null) {
  272. updateMxjbSelectedClassImport(this.form).then(response => {
  273. this.msgSuccess('修改成功')
  274. this.open = false
  275. this.getList()
  276. })
  277. } else {
  278. addMxjbSelectedClassImport(this.form).then(response => {
  279. this.msgSuccess('新增成功')
  280. this.open = false
  281. this.getList()
  282. })
  283. }
  284. }
  285. })
  286. },
  287. /** 删除按钮操作 */
  288. handleDelete(row) {
  289. const importIds = row.importId || this.ids
  290. this.$confirm('是否确认删除选班导入文件编号为"' + importIds + '"的数据项?', '警告', {
  291. confirmButtonText: '确定',
  292. cancelButtonText: '取消',
  293. type: 'warning'
  294. }).then(function() {
  295. return delMxjbSelectedClassImport(importIds)
  296. }).then(() => {
  297. this.getList()
  298. this.msgSuccess('删除成功')
  299. })
  300. },
  301. /** 导出按钮操作 */
  302. handleExport() {
  303. const queryParams = this.queryParams
  304. this.$confirm('是否确认导出所有选班导入文件数据项?', '警告', {
  305. confirmButtonText: '确定',
  306. cancelButtonText: '取消',
  307. type: 'warning'
  308. }).then(() => {
  309. this.exportLoading = true
  310. return exportMxjbSelectedClassImport(queryParams)
  311. }).then(response => {
  312. this.download(response.msg)
  313. this.exportLoading = false
  314. })
  315. },
  316. /** 导入按钮操作 */
  317. handleImport() {
  318. this.upload.title = '成绩导入'
  319. this.upload.open = true
  320. },
  321. /** 下载模板操作 */
  322. importTemplate() {
  323. importTemplate().then(response => {
  324. this.download(response['msg'])
  325. })
  326. },
  327. // 文件上传中处理
  328. handleFileUploadProgress(event, file, fileList) {
  329. this.upload.isUploading = true
  330. },
  331. // 文件上传成功处理
  332. handleFileSuccess(response, file, fileList) {
  333. this.upload.open = false
  334. this.upload.isUploading = false
  335. this.$refs.upload.clearFiles()
  336. this.$alert(response.msg || '导入成功', '导入结果', { dangerouslyUseHTMLString: true })
  337. this.getList()
  338. },
  339. // 提交上传文件
  340. submitFileForm() {
  341. this.upload.isUploading = true
  342. this.$refs.upload.submit()
  343. },
  344. /* 查看详情 */
  345. handleDetail(row) {
  346. this.detailImportId = row.importId
  347. this.detailVisible = true
  348. }
  349. }
  350. }
  351. </script>