occdb_interestcode.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <div class="occdb_interestcode">
  3. <head-component :headinfo=headinfo @childEvent="backTo" ref="headinfoRef"></head-component>
  4. <div class="page-content">
  5. <div class="content">
  6. <div class="result-box">
  7. <div class="two-page-result">
  8. <div v-for="(item,index) in interestcode"
  9. :class="{
  10. itemResultBoxActive: item.isSelected,
  11. itemResultBox: !item.isSelected
  12. }"
  13. @click="addSelected(item,index)">
  14. <div>{{item.label}} {{item.value}}</div>
  15. </div>
  16. </div>
  17. </div>
  18. <div class="search-btn">
  19. <p v-show="conditions">
  20. <span style="margin-right: 3px;margin-left: 3px">已选择条件:</span>
  21. <span style="margin-left: 3px" v-for="item in conditions">{{item}}</span>
  22. </p>
  23. <img @click="jumpToList()" style="z-index:10" src="@/assets/images/environment/search-btn.png">
  24. </div>
  25. </div>
  26. </div>
  27. <!-- <drag_component></drag_component>-->
  28. </div>
  29. </template>
  30. <script setup>
  31. import headComponent from '@/views/xjc-integratedmachine/components/head_component.vue'
  32. import Drag_component from "@/views/xjc-integratedmachine/components/drag_component.vue";
  33. import {handleThemeStyle} from "@/utils/theme.js";
  34. import useSettingsStore from "@/store/modules/settings.js";
  35. import {getCurrentInstance, ref} from 'vue';
  36. const instance = getCurrentInstance();
  37. const {proxy} = getCurrentInstance()
  38. const {interestcode} = proxy.useDict('interestcode')
  39. const router = useRouter()
  40. const route = useRoute()
  41. const headinfo = ref({})
  42. const headinfoRef = ref(null);
  43. const interestData = ref([])
  44. const conditions = ref([])
  45. function setHeadinfo() {
  46. headinfo.value = {
  47. title: '行业分类列表',
  48. user: {
  49. avatar: '头像路径',
  50. nickName: '张三'
  51. },
  52. backUrl: '/xjc-integratedmachine/environment/index',
  53. homeUrl: '/xjc-integratedmachine/environment/index',
  54. interestcodePage:true,
  55. contrast:true,
  56. contrastType:3
  57. }
  58. }
  59. onMounted(() => {
  60. setHeadinfo()
  61. nextTick(() => {
  62. getData()
  63. })
  64. setTimeout(() => {
  65. if (headinfoRef.value) {
  66. headinfoRef.value.getCompareSizeData(3); // 调用子组件的 sayHello 函数
  67. }
  68. }, 500)
  69. })
  70. function getData (){
  71. let lettersToFindArray = JSON.parse(sessionStorage.getItem('conditionsList'))
  72. if(!lettersToFindArray){
  73. interestcode.value = interestcode.value.map((item,index)=>{
  74. item.isSelected = false;
  75. })
  76. }
  77. // interestcode.push({});
  78. // interestcode.pop();
  79. let obj = {};
  80. if(lettersToFindArray){
  81. // 遍历对象数组
  82. interestcode.value.forEach(obj => {
  83. // 重置selected属性(如果需要的话,可以根据实际情况决定是否需要这一步)
  84. obj.selected = false; // 这里我们先重置为false,稍后再根据查找结果设置
  85. // 遍历要查找的字符数组
  86. lettersToFindArray.forEach(letter => {
  87. // 检查对象的value属性是否包含当前要查找的字母
  88. if (obj.value.includes(letter)) {
  89. obj.selected = true; // 只要有一个字母匹配,就将selected设置为true
  90. }
  91. });
  92. });
  93. console.log("interestcode",interestcode.value,lettersToFindArray)
  94. conditions.value = lettersToFindArray;
  95. }
  96. }
  97. function jumpToList(item){
  98. interestcode.value.map(item =>{
  99. item.isSelected = false;
  100. })
  101. router.push({
  102. path : '/xjc-integratedmachine/environment/occdb_interestcode_list',
  103. query:{
  104. code : conditions.value.join('')
  105. }
  106. })
  107. }
  108. let list = [];
  109. function addSelected(item,index){
  110. const button = interestcode.value[index];
  111. // 如果按钮已经被选中,则取消选中
  112. if (button.isSelected) {
  113. // button.isSelected = false;
  114. } else {
  115. // 计算当前选中的按钮数量
  116. const selectedCount = interestcode.value.filter(b => b.isSelected).length;
  117. // 如果选中按钮数量已经达到3个,则取消第一个选中的按钮
  118. if (selectedCount === 3) {
  119. const firstSelectedIndex = interestcode.value.findIndex(b => b.isSelected);
  120. if (firstSelectedIndex !== -1) {
  121. interestcode.value[firstSelectedIndex].isSelected = false
  122. list.shift();
  123. }
  124. }
  125. // 选中当前按钮
  126. button.isSelected = true;
  127. list.push(item.value);
  128. }
  129. conditions.value = list;
  130. // sessionStorage.setItem('conditionsList',JSON.stringify(conditions.value));
  131. }
  132. function backTo(){
  133. // sessionStorage.removeItem('conditionsList');
  134. interestcode.value.map(item =>{
  135. item.isSelected = false;
  136. })
  137. }
  138. </script>
  139. <style scoped lang="scss">
  140. div,p{
  141. margin: 0;
  142. padding: 0;
  143. }
  144. .occdb_interestcode {
  145. background: url('@/assets/images/login/login-home-background.png') no-repeat;
  146. background-size: 1920px 1080px;
  147. z-index: 10;
  148. width: 100%;
  149. height: 1080px;
  150. .page-content {
  151. width: 100%;
  152. position: absolute;
  153. top: 100px;
  154. bottom: 0;
  155. display: flex;
  156. justify-content: center;
  157. .content{
  158. width: 1832px;
  159. height: 922px;
  160. background: #FFFFFF;
  161. border-radius: 35px 35px 35px 35px;
  162. margin-top:13px;
  163. }
  164. .result-box {
  165. width: 100%;
  166. height: 750px;
  167. overflow: auto;
  168. display: flex;
  169. justify-content: center;
  170. flex-direction: column;
  171. align-items: center;
  172. .two-page-result {
  173. width: 1280px;
  174. height: 400px;
  175. display: flex;
  176. flex-wrap: wrap;
  177. margin-top: 100px;
  178. .itemResultBoxActive {
  179. min-width: 320px;
  180. height: 92px;
  181. background: linear-gradient(180deg, #B6FFEF 0%, #C5EEFF 100%);
  182. box-shadow: inset 0px -2px 7px 0px #1E410E;
  183. border-radius: 5px 5px 5px 5px;
  184. border: 1px solid #A2F57F;
  185. font-weight: 400;
  186. font-size: 30px;
  187. color: #0DE6A1;
  188. line-height: 90px;
  189. text-align: center;
  190. margin-left: 50px;
  191. margin-right: 50px;
  192. margin-top: 32px;
  193. padding-left: 20px;
  194. padding-right: 20px;
  195. }
  196. .itemResultBox {
  197. width: 320px;
  198. height: 92px;
  199. background: #E0EEF4;
  200. border-radius: 5px 5px 5px 5px;
  201. font-weight: 400;
  202. font-size: 30px;
  203. color: #000000;
  204. line-height: 90px;
  205. text-align: center;
  206. margin-left: 50px;
  207. margin-right: 50px;
  208. margin-top: 32px;
  209. padding-left: 20px;
  210. padding-right: 20px;
  211. }
  212. .itemResultBox:hover {
  213. min-width: 320px;
  214. height: 92px;
  215. background: linear-gradient(180deg, #B6FFEF 0%, #C5EEFF 100%);
  216. box-shadow: inset 0px -2px 7px 0px #1E410E;
  217. border-radius: 5px 5px 5px 5px;
  218. border: 1px solid #A2F57F;
  219. font-weight: 400;
  220. font-size: 30px;
  221. color: #000000;
  222. line-height: 90px;
  223. text-align: center;
  224. margin-left: 50px;
  225. margin-top: 32px;
  226. padding-left: 20px;
  227. padding-right: 20px;
  228. }
  229. }
  230. }
  231. .search-btn {
  232. display: flex;
  233. align-items: center;
  234. flex-direction: column;
  235. justify-content: space-around;
  236. margin-top: 54px;
  237. img {
  238. width: 244px;
  239. height: 100px;
  240. }
  241. p{
  242. }
  243. span{
  244. margin-left: 3px;
  245. }
  246. }
  247. }
  248. }
  249. </style>