addDialog.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <div>
  3. <a-modal
  4. v-model:visible="modalVisible"
  5. :title="modeTag.value == 'add'?'添加课时':'修改课时'"
  6. :footer="null"
  7. width="700px"
  8. class="add-class-hours-modal"
  9. >
  10. <a-tabs v-model:activeKey="activeKey" type="card" @change="handleChange">
  11. <a-tab-pane key="1" tab="课时">
  12. <addClassHours ref="addClassHoursRef" @handlerSelect="handlerSelect" @handlerUpSelect="handlerUpSelect"></addClassHours>
  13. </a-tab-pane>
  14. <a-tab-pane key="2" tab="作业" >
  15. <div>这里是作业的内容</div>
  16. </a-tab-pane>
  17. <a-tab-pane key="3" tab="考试" >
  18. <div>这里是考试的内容</div>
  19. </a-tab-pane>
  20. </a-tabs>
  21. <div class="footer-btns">
  22. <a-button @click="handleCancel">取消</a-button>
  23. <a-button type="primary" @click="handleOk">确定</a-button>
  24. </div>
  25. </a-modal>
  26. <resListDialog ref="resListDialogRef" @handleSelectFile="handleSelectFile"></resListDialog>
  27. <resourceUpload ref="resourceUploadRef"></resourceUpload>
  28. </div>
  29. </template>
  30. <script setup>
  31. import { ref, reactive, watch, defineProps, defineEmits } from 'vue'
  32. import { message } from 'ant-design-vue'
  33. import addClassHours from './addClassHours.vue'
  34. import resListDialog from './resListDialog.vue'
  35. import resourceUpload from './resourceUpload.vue'
  36. import { add } from '@/api/hour/index'
  37. const addClassHoursRef = ref(null)
  38. const resListDialogRef = ref(null)
  39. const resourceUploadRef = ref(null)
  40. const activeKey = ref('1')
  41. const modeTag = ref('add')
  42. const emit = defineEmits(['update:visible', 'ok','onAddChapter'])
  43. const props = defineProps({
  44. //课程id
  45. courseInfoId: {
  46. type: Number,
  47. required: true,
  48. default: null
  49. },
  50. // visible: Boolean
  51. })
  52. const form = ref({
  53. id : ''
  54. })
  55. const modalVisible = ref(false)
  56. // watch(
  57. // () => props.visible,
  58. // (v) => {
  59. // modalVisible.value = v
  60. // }
  61. // )
  62. // watch(modalVisible, (v) => {
  63. // emit('update:visible', v)
  64. // })
  65. const open = () =>{
  66. activeKey.value = '1'
  67. modalVisible.value = true
  68. modeTag.value = 'add'
  69. }
  70. const handleChange = (activeKey) =>{
  71. }
  72. const setData = (data) => {
  73. console.log('进来的章节信息',data)
  74. form.value.id = data.id
  75. }
  76. const edit = (item) => {
  77. activeKey.value = '1'
  78. console.log('进来的章节信息',item)
  79. // form.value.id = data.id
  80. modalVisible.value = true
  81. modeTag.value = 'edit'
  82. console.log('有没有',addClassHoursRef.value)
  83. nextTick(()=>{
  84. addClassHoursRef.value.edit(item)
  85. })
  86. }
  87. const handlerSelect = () =>{
  88. resListDialogRef.value.open()
  89. }
  90. const handlerUpSelect = () =>{
  91. resourceUploadRef.value.open()
  92. }
  93. const handleSelectFile = (item) =>{
  94. resListDialogRef.value.close()
  95. addClassHoursRef.value.setFile(item)
  96. }
  97. const handleOk = () =>{
  98. console.log('有没有',addClassHoursRef)
  99. addClassHoursRef.value.getData((data)=>{
  100. //设置章节id
  101. data.chapterId = form.value.id
  102. // props.courseInfoId
  103. console.log('提交的参数',data)
  104. add(data).then((res)=>{
  105. modalVisible.value = false
  106. emit('onAddChapter')
  107. }).catch((err) => {
  108. })
  109. })
  110. // formRef.value.validate().then(() => {
  111. // emit('ok', { ...form })
  112. // modalVisible.value = false
  113. // })
  114. }
  115. function handleCancel() {
  116. modalVisible.value = false
  117. }
  118. defineExpose({ open ,setData,edit})
  119. </script>
  120. <style lang="less" scoped>
  121. .add-class-hours-modal {
  122. .ant-modal-content {
  123. border-radius: 10px;
  124. }
  125. .ant-modal-header {
  126. border-radius: 10px 10px 0 0;
  127. }
  128. .ant-form-item {
  129. margin-bottom: 24px;
  130. }
  131. .video-select-row {
  132. display: flex;
  133. align-items: center;
  134. }
  135. .cover-upload-row {
  136. display: flex;
  137. align-items: center;
  138. .cover-upload-box {
  139. width: 120px;
  140. height: 120px;
  141. background: #f7f8fa;
  142. border-radius: 8px;
  143. display: flex;
  144. align-items: center;
  145. justify-content: center;
  146. margin-right: 24px;
  147. border: 1px dashed #d9d9d9;
  148. cursor: pointer;
  149. .cover-img {
  150. width: 100%;
  151. height: 100%;
  152. object-fit: cover;
  153. border-radius: 8px;
  154. }
  155. .cover-placeholder {
  156. display: flex;
  157. align-items: center;
  158. justify-content: center;
  159. width: 100%;
  160. height: 100%;
  161. color: #bbb;
  162. font-size: 32px;
  163. }
  164. }
  165. .cover-tip {
  166. color: #888;
  167. font-size: 13px;
  168. }
  169. }
  170. .upload-tip {
  171. color: #888;
  172. font-size: 13px;
  173. margin-left: 12px;
  174. }
  175. .footer-btns {
  176. display: flex;
  177. justify-content: flex-end;
  178. gap: 16px;
  179. margin-top: 24px;
  180. }
  181. }
  182. </style>