ComplexChoices.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <template>
  2. <div class="filter-bar">
  3. <!-- 所选院系 -->
  4. <div class="filter-group">
  5. <span class="filter-group-title">所选院系:</span>
  6. <!-- <a-radio-group v-model:value="selectedDept" >
  7. <a-radio-button v-for="dept in selectedDepts" :key="dept" :value="dept">{{ dept }}</a-radio-button>
  8. </a-radio-group> -->
  9. <div style="display: flex; flex-direction: column">
  10. <MyRadioButtonGroup ref="Dept" v-model="selectedDept" @change="handleSelectedDept">
  11. <MyRadioButtonOffOut
  12. v-for="(item, index) in selectedDepts"
  13. :key="index"
  14. :value="index"
  15. :label="item.name"
  16. :index="index"
  17. ></MyRadioButtonOffOut>
  18. </MyRadioButtonGroup>
  19. <div style="height: 10px"></div>
  20. <MyRadioButtonGroup ref="Big" v-model="selectedDeptBig" @change="handleSelectedCourses">
  21. <MyRadioButton
  22. v-for="(item, index) in selectedDeptBigs"
  23. :key="index"
  24. :value="index"
  25. :label="item.name"
  26. :index="index"
  27. ></MyRadioButton>
  28. </MyRadioButtonGroup>
  29. <div style="height: 10px"></div>
  30. <MyRadioButtonGroup ref="Smail" v-model="selectedDeptSmail" @change="handleSelectedCourses">
  31. <MyRadioButton
  32. v-for="(item, index) in selectedDeptSmails"
  33. :key="index"
  34. :value="index"
  35. :label="item.name"
  36. :index="index"
  37. ></MyRadioButton>
  38. </MyRadioButtonGroup>
  39. </div>
  40. </div>
  41. <div style="height: 10px"></div>
  42. <div class="line"></div>
  43. <div style="height: 10px"></div>
  44. <!-- 所属课程 -->
  45. <div class="filter-group">
  46. <span class="filter-group-title">所选课程:</span>
  47. <!-- <a-radio-group v-model:value="selectedCourse" @change="handleSelectedCourses">
  48. <a-radio-button v-for="dept in selectedCourses" :key="dept" :value="dept">{{ dept }}</a-radio-button>
  49. 其他课程选项
  50. </a-radio-group> -->
  51. <MyRadioButtonGroup ref="Course" v-model="selectedCourse" @change="handleSelectedCourses">
  52. <MyRadioButton
  53. v-for="(item, index) in selectedCourses"
  54. :key="index"
  55. :value="item"
  56. :label="item"
  57. :index="index"
  58. ></MyRadioButton>
  59. </MyRadioButtonGroup>
  60. </div>
  61. <div style="height: 10px"></div>
  62. <div class="line"></div>
  63. <div style="height: 10px"></div>
  64. <!-- 课程类型和课件格式(联动单选) -->
  65. <div class="filter-group">
  66. <span class="filter-group-title">资源类型:</span>
  67. <!-- <a-radio-group v-model:value="selectedType" @change="handleTypeChange">
  68. <a-radio-button v-for="dept in selectedTypes" :key="dept" :value="dept">{{ dept }}</a-radio-button>
  69. </a-radio-group> -->
  70. <div style="display: flex; flex-direction: column">
  71. <MyRadioButtonGroup ref="Type" v-model="selectedTypeBig" @change="handleTypeChange">
  72. <MyRadioButton
  73. v-for="(item, index) in selectedTypesBig"
  74. :key="index"
  75. :value="item"
  76. :label="item"
  77. :index="index"
  78. ></MyRadioButton>
  79. </MyRadioButtonGroup>
  80. <MyRadioButtonGroup ref="Type" v-model="selectedType" @change="handleTypeChange">
  81. <MyRadioButton
  82. v-for="(item, index) in selectedTypes"
  83. :key="index"
  84. :value="item"
  85. :label="item"
  86. :index="index"
  87. ></MyRadioButton>
  88. </MyRadioButtonGroup>
  89. </div>
  90. </div>
  91. <div style="height: 10px"></div>
  92. <div class="line"></div>
  93. <div style="height: 10px"></div>
  94. <div class="filter-group">
  95. <span class="filter-group-title">课件格式:</span>
  96. <!-- <a-radio-group v-model:value="selectedFormat" @change="handleFormatChange">
  97. <a-radio-button v-for="dept in selectedFormats" :key="dept" :value="dept">{{ dept }}</a-radio-button>
  98. </a-radio-group> -->
  99. <MyRadioButtonGroup ref="Format" v-model="selectedFormat" @change="handleFormatChange">
  100. <MyRadioButton
  101. v-for="(item, index) in selectedFormats"
  102. :key="item"
  103. :value="item"
  104. :label="item"
  105. :index="index"
  106. ></MyRadioButton>
  107. </MyRadioButtonGroup>
  108. </div>
  109. <div style="height: 10px"></div>
  110. <div class="line"></div>
  111. <div style="height: 10px"></div>
  112. <!-- 已选条件 -->
  113. <div class="filter-group">
  114. <span class="filter-group-title">已选条件:</span>
  115. <div style="display: flex; align-items: center; margin-top: 7px">
  116. <a-tag
  117. v-for="tag in selectedTags"
  118. style="display: flex; justify-content: center; align-items: center"
  119. :key="tag"
  120. closable
  121. @close="handleTagClose(tag)"
  122. >
  123. {{ tag }}
  124. </a-tag>
  125. <span v-if="selectedTags.length > 0" class="clean" @click="handleClean">清除筛选</span>
  126. </div>
  127. </div>
  128. </div>
  129. </template>
  130. <script setup>
  131. import { ref, computed } from 'vue'
  132. import MyRadioButtonGroup from '../components/MyRadioButtonGroup.vue'
  133. import MyRadioButton from '../components/MyRadioButton.vue'
  134. import MyRadioButtonOffOut from '../components/MyRadioButtonOffOut.vue'
  135. import collegeApi from '@/api/college'
  136. import orgApi from '@/api/resourceType/resourceType'
  137. const selectedDept = ref('')
  138. const selectedDeptBig = ref('')
  139. const selectedDeptSmail = ref('')
  140. const selectedCourse = ref('')
  141. const selectedTypeBig = ref('')
  142. const selectedType = ref('')
  143. const selectedFormat = ref('')
  144. const Dept = ref(null)
  145. const Big = ref(null)
  146. const Smail = ref(null)
  147. const Course = ref(null)
  148. const Type = ref(null)
  149. const Format = ref(null)
  150. const selectedTags = ref([])
  151. const selectedTagKeys = ref([])
  152. const selectedDepts = ref(['不限', '学校本级', '一旅', '二旅', '三旅', '四旅', '五旅', '维修厂'])
  153. const selectedDeptBigs = ref([
  154. '参谋部',
  155. '政治工作部',
  156. '保障部',
  157. '理论训练系',
  158. '轰运飞行人员改装系',
  159. '职业教育中心',
  160. '教学考评中心',
  161. '教研保障中心',
  162. '服务保障中心',
  163. '教学评价办公室'
  164. ])
  165. const selectedDeptBigsList= ref([
  166. ])
  167. const selectedDeptSmailsList= ref([
  168. ])
  169. const selectedDeptSmails = ref([
  170. '三级架构a',
  171. '三级架构b',
  172. '三级架构c',
  173. '三级架构d',
  174. '三级架构e',
  175. '三级架构f',
  176. '三级架构g',
  177. '三级架构h'
  178. ])
  179. const selectedCourses = ref([
  180. '全部',
  181. '初级飞行训练',
  182. '高级飞行训练',
  183. '实弹训练',
  184. '低空战术飞行',
  185. '跨区转场训练',
  186. '空气动力学',
  187. '航空气象学',
  188. '航空电子设备',
  189. '飞机结构与系统',
  190. '空军作战指挥',
  191. '战场态势感知',
  192. '模拟对抗训练',
  193. '军队政治工作',
  194. '军事理论',
  195. '战斗精神培育',
  196. '机型改装训练',
  197. '应急程序训练'
  198. ])
  199. const selectedTypesBig = ref(['全部大', '热门资源大', '名师资源大', '必修大大', '选修大'])
  200. const selectedTypes = ref(['全部', '热门资源', '名师资源', '必修', '选修'])
  201. const selectedFormats = ref(['全部', 'ppt', 'word', 'excel', 'pdf', 'mp4', 'zip', 'rar'])
  202. const handleSelectedDept = (e) => {
  203. selectedDeptBigs.value=selectedDeptBigsList.value[e]
  204. Big.value.setClean(selectedDeptBigs.value[0])
  205. Smail.value.setClean(selectedDeptSmails.value[0])
  206. updateSelectedTags()
  207. }
  208. const handleSelectedCourses = (e) => {
  209. selectedDeptSmails.value=selectedDeptSmailsList.value[e]
  210. updateSelectedTags()
  211. }
  212. // 处理课程类型选择变化
  213. const handleTypeChange = (e) => {
  214. // selectedFormat.value = undefined // 选择课程类型时,重置课件格式
  215. updateSelectedTags()
  216. }
  217. // 处理课件格式选择变化
  218. const handleFormatChange = (e) => {
  219. // selectedType.value = undefined // 选择课件格式时,重置课程类型
  220. updateSelectedTags()
  221. }
  222. // 更新已选条件
  223. const updateSelectedTags = () => {
  224. selectedTags.value = []
  225. selectedTagKeys.value = []
  226. // selectedTags.value = [
  227. // ...(selectedDept.value !== '全部' ? { key: 'Dept', list: [selectedDept.value] } : []),
  228. // ...(selectedCourse.value !== '全部' ? { key: 'Course', list: [selectedCourse.value] } : []),
  229. // ...(selectedType.value !== '全部' ? { key: 'Type', list: [selectedType.value] } : []),
  230. // ...(selectedFormat.value !== '全部' ? { key: 'Format', list: [selectedFormat.value] } : [])
  231. // ]
  232. if (selectedDept.value !== '不限') {
  233. selectedTags.value.push(...[selectedDept.value])
  234. selectedTagKeys.value.push('Dept')
  235. }
  236. if (selectedCourse.value !== '全部') {
  237. selectedTags.value.push(...[selectedCourse.value])
  238. selectedTagKeys.value.push('Course')
  239. }
  240. if (selectedDeptBig.value !== '全部') {
  241. selectedTags.value.push(...[selectedDeptBig.value])
  242. selectedTagKeys.value.push('Course1')
  243. }
  244. if (selectedDeptSmail.value !== '全部') {
  245. selectedTags.value.push(...[selectedDeptSmail.value])
  246. selectedTagKeys.value.push('Course2')
  247. }
  248. if (selectedType.value !== '全部') {
  249. selectedTags.value.push(...[selectedType.value])
  250. selectedTagKeys.value.push('Type')
  251. }
  252. if (selectedFormat.value !== '全部') {
  253. selectedTags.value.push(...[selectedFormat.value])
  254. selectedTagKeys.value.push('Format')
  255. }
  256. console.log('筛选条件', selectedTags.value, selectedTagKeys.value)
  257. }
  258. // 删除已选条件
  259. const handleTagClose = (tag) => {
  260. if (tag === selectedDept.value) {
  261. selectedDept.value = '不限'
  262. } else if (tag === selectedCourse.value) {
  263. selectedCourse.value = '全部'
  264. } else if (tag === selectedType.value) {
  265. selectedType.value = '全部'
  266. } else if (tag === selectedFormat.value) {
  267. selectedFormat.value = '全部'
  268. }
  269. updateSelectedTags()
  270. }
  271. const handleClean = () => {
  272. selectedTags.value = []
  273. selectedDept.value = '不限'
  274. selectedCourse.value = '全部'
  275. selectedType.value = '全部'
  276. selectedFormat.value = '全部'
  277. selectedDeptBigs.value=[]
  278. Dept.value.setClean('不限')
  279. Big.value.setClean(selectedDeptBigs.value[0])
  280. Smail.value.setClean(selectedDeptSmails.value[0])
  281. Course.value.setClean('全部')
  282. Type.value.setClean('全部')
  283. Format.value.setClean('全部')
  284. collegeApi.tree().then((data) => {
  285. selectedDepts.value=data;
  286. selectedDepts.value.forEach((item)=>{
  287. selectedDeptBigsList.value.push(item.children);
  288. item.children.forEach((item)=>{
  289. selectedDeptSmailsList.value.push(item.children);
  290. })
  291. })
  292. handleSelectedDept(0);
  293. handleSelectedCourses(0);
  294. })
  295. updateSelectedTags()
  296. }
  297. onMounted(() => {
  298. // 初始化已选条件
  299. handleClean()
  300. })
  301. </script>
  302. <style scoped>
  303. .filter-bar {
  304. border: 1px solid #00000011; /* 灰色细边框 */
  305. padding-left: 20px;
  306. padding-right: 20px;
  307. padding-top: 5px;
  308. padding-bottom: 20px;
  309. }
  310. .filter-group {
  311. display: flex;
  312. }
  313. .filter-group-title {
  314. color: rgba(0, 0, 0, 0.521);
  315. font-size: 12px;
  316. min-width: 80px;
  317. margin-top: 10px;
  318. }
  319. .line {
  320. width: 100%;
  321. height: 0.25px;
  322. background-color: #00000013;
  323. }
  324. .clean {
  325. color: rgb(133, 183, 224);
  326. cursor: pointer;
  327. }
  328. </style>