km-fullsearch-classify.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <div :class="[$style.searchclassify, { [$style.collapse]: fold }]">
  3. <div :class="$style.search">
  4. <!-- 创建时间 -->
  5. <a-card
  6. v-for="(item, index) in KmFullsearchData"
  7. :key="index"
  8. :bordered="false"
  9. :title="item.title"
  10. >
  11. <a slot="extra" @click="changeexpand(item)">
  12. <a-icon :type="item.expand ? 'up' : 'down'" />
  13. </a>
  14. <a-radio-group
  15. v-show="item.key === 0 && item.expand === true"
  16. v-model="conditionsParams.creationTime"
  17. :name="item.title + 'Radio'"
  18. :options="item.options"
  19. @change="onRadioChange"
  20. />
  21. <!-- 创建时间 自定义 -->
  22. <a-range-picker
  23. v-if="item.key === 0 && isYourself"
  24. v-model="yourselfTime"
  25. @change="onDateChange"
  26. >
  27. <a-icon slot="suffixIcon" type="calendar" />
  28. </a-range-picker>
  29. <!-- 知识分类 -->
  30. <km-tree-select
  31. v-show="item.key === 1 && item.expand === true"
  32. v-model="conditionsParams.category"
  33. :class="$style.category"
  34. :editable="true"
  35. tree-data-url="api/xcoa-mobile/v1/km-knowledge-category/knowledge-category-tree?pageId=kmKnowledge"
  36. @change="categoryChange"
  37. ></km-tree-select>
  38. <!-- 知识标签 -->
  39. <km-tag-picker
  40. v-show="item.key === 2 && item.expand === true"
  41. v-model="conditionsParams.label"
  42. :class="$style.category"
  43. :editable="true"
  44. @change="tagChange"
  45. />
  46. <!-- 业务领域 -->
  47. <km-business-area-picker
  48. v-show="item.key === 3 && item.expand === true"
  49. v-model="conditionsParams.businessArea"
  50. :read-only="false"
  51. :class="$style.category"
  52. @change="businessAreaChange"
  53. />
  54. <!-- 搜索范围 -->
  55. <a-checkbox-group
  56. v-show="item.key === 4 && item.expand === true"
  57. v-model="conditionsParams.searchRange"
  58. :name="item.title + 'Radio'"
  59. :options="item.options"
  60. @change="(e) => onRangeChange(e, item.title)"
  61. />
  62. <!-- 搜索范围 发起人 -->
  63. <div v-if="item.key === 4" :class="$style.hor">
  64. <span :class="$style.label"> 发起人:</span>
  65. <sd-user-picker
  66. v-model="creatorArr"
  67. placeholder="请选择"
  68. @change="userChange"
  69. ></sd-user-picker>
  70. </div>
  71. <!-- 搜索范围 发起部门 -->
  72. <div v-if="item.key === 4" :class="$style.hor">
  73. <span :class="$style.label"> 发起部门:</span>
  74. <sd-group-picker v-model="createDeptArr" @change="groupChange"></sd-group-picker>
  75. </div>
  76. </a-card>
  77. <div :class="$style.reset">
  78. <a-button type="primary" @click="reset">
  79. 重置
  80. </a-button>
  81. </div>
  82. </div>
  83. <a-button type="primary" :class="$style.fold" @click="foldClick">
  84. <a-icon :type="icontype" />
  85. </a-button>
  86. </div>
  87. </template>
  88. <script>
  89. import KmFullsearchData from './km-fullsearch-data.js'
  90. import components from './_import-components/km-fullsearch-classify-import'
  91. export default {
  92. name: 'KmFullsearchClassify',
  93. components,
  94. props: {},
  95. data() {
  96. return {
  97. KmFullsearchData,
  98. isYourself: false,
  99. fold: false,
  100. icontype: 'left',
  101. conditionsParams: {
  102. creationTime: [],
  103. flowStatus: [],
  104. searchRange: [],
  105. category: '',
  106. label: '',
  107. businessArea: '',
  108. },
  109. creatorArr: [],
  110. createDeptArr: [],
  111. yourselfTime: [],
  112. }
  113. },
  114. methods: {
  115. // 展开或收起
  116. changeexpand(item) {
  117. KmFullsearchData.forEach((k) => {
  118. if (k.key === item.key) {
  119. item.expand = !item.expand
  120. }
  121. })
  122. this.expand = !this.expand
  123. },
  124. // 单选按钮 创建时间
  125. onRadioChange(e) {
  126. if (e.target.value === 'yourself') {
  127. this.isYourself = true
  128. } else {
  129. this.isYourself = false
  130. }
  131. this.$emit('onSearch', e.target.value, 'searchDateType')
  132. },
  133. // 自定义时间
  134. onDateChange(date, dateString) {
  135. this.$emit('onSearch', dateString[0], 'startDate')
  136. this.$emit('onSearch', dateString[1], 'endDate')
  137. },
  138. // 知识分类
  139. categoryChange(val) {
  140. let arrId = ['all']
  141. if (val) {
  142. arrId = val.map((item) => item.id)
  143. }
  144. this.$emit('onSearch', arrId, 'typeIds')
  145. },
  146. // 知识标签
  147. tagChange(val) {
  148. if (val.length === 0) {
  149. val = ['all']
  150. }
  151. this.$emit('onSearch', val, 'tagNames')
  152. },
  153. // 业务领域
  154. businessAreaChange(val) {
  155. let arrId = ['all']
  156. if (val.length > 0) {
  157. arrId = val.map((item) => item.id)
  158. }
  159. this.$emit('onSearch', arrId, 'domainIds')
  160. },
  161. // 搜索范围
  162. onRangeChange(val, title) {
  163. this.$emit('onSearch', val, 'searchFields')
  164. },
  165. // 发起人
  166. userChange(val) {
  167. const ids = []
  168. if (val.length > 0) {
  169. val.forEach((item) => {
  170. ids.push(item.code)
  171. })
  172. this.$emit('onSearch', ids, 'creatorAccounts')
  173. } else {
  174. this.$emit('onSearch', ['all'], 'creatorAccounts')
  175. }
  176. },
  177. // 发起部门
  178. groupChange(val) {
  179. const ids = []
  180. if (val.length > 0) {
  181. val.forEach((item) => {
  182. ids.push(item.code)
  183. })
  184. this.$emit('onSearch', ids, 'createDeptIds')
  185. } else {
  186. this.$emit('onSearch', ['all'], 'createDeptIds')
  187. }
  188. },
  189. // 重置
  190. reset() {
  191. this.conditionsParams = {}
  192. this.creatorArr = []
  193. this.createDeptArr = []
  194. this.yourselfTime = []
  195. this.$emit('onSearch', '', 'reset')
  196. },
  197. // 小箭头点击事件
  198. foldClick() {
  199. this.fold = !this.fold
  200. if (this.fold) {
  201. this.icontype = 'right'
  202. } else {
  203. this.icontype = 'left'
  204. }
  205. },
  206. },
  207. }
  208. </script>
  209. <style module lang="scss">
  210. @use '@/common/design' as *;
  211. .searchclassify {
  212. position: relative;
  213. display: flex;
  214. margin-right: 1rem;
  215. margin-left: 1rem;
  216. transition: width 0.2s;
  217. .search {
  218. width: 100%;
  219. :global(.ant-radio-wrapper) {
  220. margin: 5px 0.4rem;
  221. }
  222. :global(.ant-checkbox-wrapper) {
  223. min-width: 100px;
  224. margin: 5px 0.4rem;
  225. }
  226. .hor {
  227. display: flex;
  228. align-items: center;
  229. margin-top: 0.6rem;
  230. > div {
  231. width: 100%;
  232. }
  233. .label {
  234. min-width: 70px;
  235. margin-right: 0.5rem;
  236. }
  237. .label + span {
  238. width: 100%;
  239. }
  240. :global(.ant-select) {
  241. width: 100%;
  242. }
  243. }
  244. .reset {
  245. display: flex;
  246. justify-content: flex-end;
  247. width: 100%;
  248. padding-bottom: 1rem;
  249. background: #fff;
  250. }
  251. :global(.ant-btn-primary) {
  252. margin-right: 15px;
  253. }
  254. }
  255. .fold {
  256. position: absolute;
  257. top: calc(50% - 30px);
  258. right: -15px;
  259. z-index: 2;
  260. width: 15px;
  261. height: 75px;
  262. padding: 0;
  263. border-radius: 0 10px 10px 0;
  264. }
  265. .category {
  266. width: 260px;
  267. :global(.ant-select-selection) {
  268. width: 260px;
  269. }
  270. }
  271. }
  272. .collapse {
  273. background: transparent;
  274. .search {
  275. display: none;
  276. }
  277. }
  278. </style>