QueryView.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <div style="display: flex; justify-content: space-between; align-items: center">
  3. <div>
  4. <a-form layout="inline" :model="formState">
  5. <a-form-item label="" style="width: 200px">
  6. <a-input v-model:value="formState.courseName" placeholder="请输入课程名称" allowClear />
  7. </a-form-item>
  8. <a-form-item label="" style="width: 200px">
  9. <a-cascader
  10. v-model:value="formState.loacl"
  11. :options="options"
  12. placeholder="选择院校/专业"
  13. change-on-select
  14. allowClear
  15. :field-names="{ label: 'name', value: 'id', children: 'children' }"
  16. />
  17. </a-form-item>
  18. <a-form-item label="" style="width: 200px">
  19. <!-- <a-input v-model:value="formState.type" placeholder="选择课程类型" allowClear />-->
  20. <a-select
  21. ref="select"
  22. placeholder="选择课程类型"
  23. v-model:value="formState.courseType"
  24. :fieldNames="{ label: 'dictLabel', value: 'dictValue' }"
  25. :options="COURSE_TYPE"
  26. allowClear
  27. ></a-select>
  28. </a-form-item>
  29. <a-form-item label="" style="width: 300px">
  30. <a-range-picker v-model:value="formState.time" allowClear />
  31. </a-form-item>
  32. </a-form>
  33. </div>
  34. <div>
  35. <a-button type="primary" @click="handleSearch">
  36. <template #icon><SearchOutlined /></template>
  37. 查询
  38. </a-button>
  39. <a-button style="margin-left: 10px" @click="handleReset">
  40. <template #icon><ReloadOutlined /></template>
  41. 重置
  42. </a-button>
  43. </div>
  44. </div>
  45. </template>
  46. <script setup>
  47. import { ref, onMounted } from 'vue'
  48. import { SearchOutlined, ReloadOutlined } from '@ant-design/icons-vue'
  49. import { useRouter } from 'vue-router'
  50. import collegeApi from '@/api/college'
  51. import tool from '@/utils/tool'
  52. const emit = defineEmits([])
  53. const router = useRouter()
  54. //发布按钮状态
  55. const releaseVisible = ref(false)
  56. const loading = ref(false) // 列表loading
  57. const COURSE_TYPE = tool.dictTypeList('COURSE_TYPE')
  58. const formState = ref({
  59. courseName: undefined,
  60. collegeId: undefined,
  61. majorId: undefined,
  62. courseType: undefined,
  63. time : [],
  64. loacl: []
  65. }) // 列表loading
  66. const options = ref([
  67. // {
  68. // value: 'zhejiang',
  69. // label: 'Zhejiang',
  70. // isLeaf: false
  71. // },
  72. // {
  73. // value: 'jiangsu',
  74. // label: 'Jiangsu',
  75. // isLeaf: false
  76. // }
  77. ])
  78. // 搜索值
  79. const searchValue = ref('')
  80. const pagination = reactive({
  81. pageSize: 10,
  82. pageNum: 1,
  83. total: 0
  84. })
  85. const onChangeCurrent = (current) => {
  86. router.push({
  87. path: '/' + current
  88. })
  89. }
  90. const publishedData = ref()
  91. //发布确定
  92. // 上传资源模态框
  93. const uploadModalVisible = ref(false)
  94. const loadData = (selectedOptions) => {
  95. const targetOption = selectedOptions[selectedOptions.length - 1]
  96. targetOption.loading = true
  97. // load options lazily
  98. setTimeout(() => {
  99. targetOption.loading = false
  100. targetOption.children = [
  101. {
  102. label: `${targetOption.label} Dynamic 1`,
  103. value: 'dynamic1'
  104. },
  105. {
  106. label: `${targetOption.label} Dynamic 2`,
  107. value: 'dynamic2'
  108. }
  109. ]
  110. options.value = [...options.value]
  111. }, 1000)
  112. }
  113. const getList = () => {
  114. collegeApi.treeAll().then((data) => {
  115. options.value = data
  116. })
  117. }
  118. const handleSearch = () => {
  119. console.log('执行查询操作', formState.value,COURSE_TYPE)
  120. // 在这里添加查询逻辑
  121. let newJson = JSON.parse(JSON.stringify(formState.value))
  122. console.log('执行查询操作123 ', newJson.loacl.length)
  123. for (let i = 0; i < newJson.loacl.length; i++) {
  124. let item = newJson.loacl[i]
  125. if(i == 0){
  126. newJson.collegeId = item
  127. }
  128. if(i == 1){
  129. newJson.collegeTwoId = item
  130. }
  131. if(i == 2){
  132. newJson.collegeThreeId = item
  133. }
  134. }
  135. newJson.loacl = undefined
  136. if(newJson.time.length == 2){
  137. let beginTime = tool.formatTimesYearMonthDay(newJson.time[0])
  138. let endTime= tool.formatTimesYearMonthDay(newJson.time[1])
  139. newJson.beginTime = beginTime
  140. newJson.endTime = endTime
  141. newJson.time= undefined
  142. }
  143. emit('handlerSearch', newJson)
  144. }
  145. // 重置按钮点击事件
  146. const handleReset = () => {
  147. formState.value = {
  148. courseName: undefined,
  149. collegeId: undefined,
  150. majorId: undefined,
  151. courseType: undefined,
  152. time : [],
  153. loacl: []
  154. // 其他需要重置的字段
  155. }
  156. emit('handlerSearch', formState.value)
  157. }
  158. onMounted(() => {
  159. // getListData()
  160. getList()
  161. })
  162. </script>
  163. <style scoped>
  164. .desc p {
  165. margin-bottom: 1em;
  166. }
  167. </style>