paper-work-publish.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <div>
  3. <el-card>
  4. <mx-condition :query-params="condition" use-alias-mapping @query="handleQuery"></mx-condition>
  5. <mx-search-group justify="end" v-model="queryParams.keyword"
  6. @search="queryParams.pageNum=1,getList()">
  7. </mx-search-group>
  8. </el-card>
  9. <el-card>
  10. <dynamic-table :rows="rows" :columns="columns">
  11. <template #index="{$index}">
  12. {{ (queryParams.pageNum - 1) * queryParams.pageSize + $index + 1 }}
  13. </template>
  14. <template #type="{display}">
  15. {{ translateType(display) }}
  16. </template>
  17. <template #action="{row}">
  18. <div>
  19. <el-button v-if="row.type == paperWorkType.value" type="text" icon="el-icon-edit"
  20. @click="clickEditPaper(row)">编辑
  21. </el-button>
  22. <el-button type="text" icon="el-icon-connection" @click="clickPublish(row)">
  23. 发布
  24. <template v-if="row.publishedCount">({{ row.publishedCount }})</template>
  25. </el-button>
  26. </div>
  27. </template>
  28. </dynamic-table>
  29. <pagination v-if="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
  30. @pagination="getList"></pagination>
  31. <upload-dialog
  32. v-if="uploadOption.dialogVisible"
  33. scene="发布"
  34. :title="uploadOption.title"
  35. :pageName="uploadOption.pageName"
  36. :isZdy="false"
  37. :selectType="uploadOption.selectType"
  38. :dialogVisible="uploadOption.dialogVisible"
  39. :default-selected="uploadOption.defaultSelected"
  40. @handleClose="handleUploadReady"
  41. @dialogVisibleClose="uploadOption.dialogVisible=false"
  42. ></upload-dialog>
  43. </el-card>
  44. </div>
  45. </template>
  46. <script>
  47. import DynamicTable from '@/components/dynamic-table/index'
  48. import { getHomeworks, getHomeworkStudents, publicStudentHomework } from '@/api/webApi/homework'
  49. import consts from '@/common/mx-const'
  50. import { download, listCustomerPaperQeustions } from '@/api/webApi/webQue'
  51. import { mapGetters } from 'vuex'
  52. import MxCondition from '@/components/MxCondition/mx-condition'
  53. import MxSearchGroup from '@/components/MxSearch/mx-search-group'
  54. export default {
  55. name: 'paper-work-publish',
  56. components: { MxSearchGroup, MxCondition, DynamicTable },
  57. data() {
  58. return {
  59. extraData: { type: consts.enum.generateScene.paperWork.value },
  60. paperWorkType: Object.freeze(consts.enum.homeworkTypes.find(t => t.value == 1)),
  61. condition: { homeworkType: '' },
  62. conditionOutput: null,
  63. queryParams: {
  64. pageNum: 1,
  65. pageSize: 20,
  66. keyword: '',
  67. type: ''
  68. },
  69. columns: [
  70. { prop: 'id', label: '序号', width: '80px', slotBody: 'index' },
  71. { prop: 'type', label: '类型', width: '120px', slotBody: 'type' },
  72. { prop: 'title', label: '标题' },
  73. { prop: 'createTime', label: '创建时间', width: '180px' },
  74. { prop: 'action', label: '操作', width: '180px', slotBody: 'action' }],
  75. rows: [],
  76. total: 0,
  77. uploadWork: null,
  78. uploadOption: {
  79. title: '发布作业',
  80. pageName: '',
  81. selectType: '',
  82. defaultSelected: [],
  83. dialogVisible: false
  84. }
  85. }
  86. },
  87. computed: {
  88. ...mapGetters(['period'])
  89. },
  90. mounted() {
  91. this.getList()
  92. },
  93. methods: {
  94. handleQuery(model) {
  95. this.queryParams.pageNum = 1
  96. this.conditionOutput = model
  97. this.getList()
  98. },
  99. async getList() {
  100. const query = Object.assign(this.queryParams, this.conditionOutput)
  101. const res = await getHomeworks(query)
  102. this.rows = res.rows || res.data
  103. this.total = res.total || this.rows.length
  104. },
  105. translateType(type) {
  106. const enumType = consts.enum.homeworkTypes.find(t => t.value == type)
  107. return enumType?.label || type
  108. },
  109. clickEditPaper(paper) {
  110. listCustomerPaperQeustions(paper.content).then((res) => {
  111. localStorage.setItem(
  112. 'paperData',
  113. JSON.stringify({
  114. paperId: paper.content,
  115. paperTitle: paper.name || paper.title,
  116. subjectId: paper.subjectid
  117. })
  118. )
  119. localStorage.setItem('questionList', JSON.stringify(res.rows))
  120. this.$router.push({
  121. path: '/question-center/generatingPaperCenter/paper',
  122. query: this.extraData
  123. })
  124. })
  125. },
  126. clickDownloadPaper(paperId) {
  127. download(paperId, this.period)
  128. },
  129. async clickPublish(work) {
  130. const res = await getHomeworkStudents({ workId: work.id })
  131. this.uploadWork = work
  132. this.uploadOption.selectType = 'student'
  133. this.uploadOption.defaultSelected = res.data.map(item => item.customerCode) || []
  134. this.uploadOption.dialogVisible = true
  135. },
  136. async handleUploadReady(type, name, selectData) {
  137. const commit = {
  138. workId: this.uploadWork.id,
  139. stuIds: selectData.checkedStudent,
  140. remark: selectData.remark
  141. }
  142. await publicStudentHomework(commit)
  143. this.uploadOption.dialogVisible = false
  144. this.msgSuccess('发布成功')
  145. await this.getList()
  146. }
  147. }
  148. }
  149. </script>
  150. <style scoped>
  151. </style>