用工小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

328 lines
7.5 KiB

6 months ago
  1. <template>
  2. <view class="filter-wrapper"
  3. :style="{ height: height + 'rpx', top: top,'border-top':border?'1rpx solid #f2f2f2':'none' }"
  4. @touchmove.stop.prevent="discard">
  5. <view class="inner-wrapper">
  6. <view class="mask" :class="showMask ? 'show' : 'hide'" @tap="tapMask"></view>
  7. <view class="navs">
  8. <view class="c-flex-align" :class="{ 'c-flex-center': index > 0, actNav: index === actNav }"
  9. v-for="(item, index) in navData" :key="index" @click="navClick(index)">
  10. <view v-for="(child, childx) in item" :key="childx" v-if="child.select">{{ child.text }}</view>
  11. <u-icon class="icon-triangle se-ml-10" color="#FF7A31" v-if="index === actNav" name="arrow-up"></u-icon>
  12. <u-icon class="icon-triangle se-ml-10" v-else name="arrow-down"></u-icon>
  13. </view>
  14. <view class="c-flex-align date" @click="intellectClick()">
  15. <view>智能推荐</view>
  16. <u-icon class="icon-triangle se-ml-10" name="arrow-down"></u-icon>
  17. </view>
  18. </view>
  19. <scroll-view scroll-y="true" class="popup" :class="popupShow ? 'popupShow' : ''">
  20. <view class="item-opt c-flex-align" :class="item.select ? 'actOpt' : ''"
  21. v-for="(item, index) in navData[actNav]" :key="index" @click="handleOpt(index)">
  22. {{ item.text }}
  23. </view>
  24. </scroll-view>
  25. </view>
  26. <u-popup :show="show" :custom-style="{alignItems:'center'}" mode="center" bg-color="transparent">
  27. <view class="se-w-600 se-bgc-white se-br-40 se-p-40">
  28. <view class="se-mb-30" v-for="(items,indexs) in intellectArr" :key="indexs">
  29. <view class="se-flex se-flex-ai-c">
  30. <view class="line-orange"></view>
  31. <view class="se-ml-10">
  32. {{items.name}}
  33. </view>
  34. </view>
  35. <view class="se-flex se-flex-ai-c se-flex-ff-rw se-pt-10">
  36. <view class="se-py-10 se-px-20 se-fs-22 se-br-10 se-ml-15 se-mt-10" :class="item.select ? 'se-bgc-orange se-c-white se-b-orange' : 'se-b se-c-text'" @click="handleIntellect(indexs,index)" v-for="(item,index) in items.arr" :key="index">
  37. {{item.text}}
  38. </view>
  39. </view>
  40. </view>
  41. <view class="se-flex se-flex-h-sb se-mt-40">
  42. <view @click="onCancel" class="se-br-20 se-flex-1 se-flex-h-c se-h-60 se-lh-60 se-ta-c se-fs-26 se-c-66 se-bgc-f5">
  43. <text>取消</text>
  44. </view>
  45. <view @click="onSubmit" class="se-br-20 se-ml-20 se-flex-1 se-flex-h-c se-h-60 se-lh-60 se-ta-c se-fs-26 se-c-white se-bgc-orange">
  46. <text class="se-ml-10">提交</text>
  47. </view>
  48. </view>
  49. </view>
  50. </u-popup>
  51. </view>
  52. </template>
  53. <script>
  54. export default {
  55. props: {
  56. height: {
  57. type: Number,
  58. default: 80
  59. },
  60. top: {
  61. type: String,
  62. default: ''
  63. },
  64. border: {
  65. type: Boolean,
  66. default: false
  67. },
  68. filterData: {
  69. //必填
  70. type: Array,
  71. default: () => {
  72. return [];
  73. }
  74. // default: () => {
  75. // return [
  76. // [{ text: '全部状态', value: '' }, { text: '状态1', value: 1 }, { text: '状态2', value: 2 }, { text: '状态3', value: 3 }],
  77. // [{ text: '全部类型', value: '' }, { text: '类型1', value: 1 }, { text: '类型2', value: 2 }, { text: '类型3', value: 3 }]
  78. // ];
  79. // }
  80. },
  81. defaultIndex: {
  82. //默认选中条件索引,超出一类时必填
  83. type: Array,
  84. default: () => {
  85. return [0];
  86. }
  87. }
  88. },
  89. data() {
  90. return {
  91. show:false,
  92. navData: [],
  93. popupShow: false,
  94. showMask: false,
  95. actNav: null,
  96. selDate: '选择日期',
  97. selIndex: [] ,//选中条件索引
  98. intellectArr:[
  99. {
  100. name:"您希望从事的工种",
  101. arr:[
  102. {
  103. text:"全部",
  104. value:"all",
  105. select:true
  106. },
  107. {
  108. text:"测试1",
  109. value:"1",
  110. select:false
  111. }
  112. ]
  113. },
  114. {
  115. name:"您希望从事的工作性质",
  116. arr:[
  117. {
  118. text:"全部",
  119. value:"all",
  120. select:true
  121. },
  122. {
  123. text:"测试1",
  124. value:"1",
  125. select:false
  126. }
  127. ]
  128. }
  129. ]
  130. };
  131. },
  132. created() {
  133. this.navData = this.filterData;
  134. this.selIndex = this.defaultIndex;
  135. this.keepStatus();
  136. },
  137. mounted() {
  138. },
  139. methods: {
  140. keepStatus() {
  141. this.navData.forEach(itemnavData => {
  142. itemnavData.map(child => {
  143. child.select = false;
  144. });
  145. return itemnavData;
  146. });
  147. for (let i = 0; i < this.selIndex.length; i++) {
  148. let selindex = this.selIndex[i];
  149. this.navData[i][selindex].select = true;
  150. }
  151. },
  152. navClick(index) {
  153. if (index === this.actNav) {
  154. this.tapMask();
  155. return;
  156. }
  157. this.popupShow = true;
  158. this.showMask = true;
  159. this.actNav = index;
  160. },
  161. handleOpt(index) {
  162. this.selIndex[this.actNav] = index;
  163. this.keepStatus();
  164. setTimeout(() => {
  165. this.tapMask();
  166. }, 100);
  167. let data = [];
  168. let res = this.navData.forEach(item => {
  169. let sel = item.filter(child => child.select);
  170. data.push(sel);
  171. });
  172. this.$emit('onSelected', data);
  173. },
  174. handleIntellect(indexs,index){
  175. this.intellectArr[indexs].arr[index].select = !this.intellectArr[indexs].arr[index].select
  176. },
  177. tapMask() {
  178. this.showMask = false;
  179. this.popupShow = false;
  180. this.actNav = null;
  181. },
  182. discard() {},
  183. intellectClick(){
  184. this.show=true
  185. },
  186. onCancel(){
  187. this.show=false
  188. },
  189. onSubmit(){
  190. this.show=false
  191. let data = [];
  192. let res = this.intellectArr.forEach(item => {
  193. let sel = item.arr.filter(child => child.select);
  194. data.push(sel);
  195. });
  196. this.$emit('onIntellect', data);
  197. }
  198. }
  199. };
  200. </script>
  201. <style lang="scss" scoped>
  202. page {
  203. font-size: 28rpx;
  204. }
  205. .c-flex-align {
  206. display: flex;
  207. align-items: center;
  208. }
  209. .c-flex-center {
  210. display: flex;
  211. align-items: center;
  212. justify-content: center;
  213. flex-direction: column;
  214. }
  215. .filter-wrapper {
  216. position: sticky;
  217. background-color: #f5f5f5;
  218. left: 0;
  219. width: 750rpx;
  220. z-index: 999;
  221. .inner-wrapper {
  222. // position: relative;
  223. .navs {
  224. position: relative;
  225. height: 80rpx;
  226. padding: 0 40rpx;
  227. display: flex;
  228. align-items: center;
  229. justify-content: space-between;
  230. // background-color: #fff;
  231. border-bottom: 2rpx solid #f5f6f9;
  232. color: #000;
  233. // font-weight: bold;
  234. z-index: 999;
  235. box-sizing: border-box;
  236. &>view {
  237. flex: 1;
  238. height: 100%;
  239. flex-direction: row;
  240. z-index: 999;
  241. }
  242. .date {
  243. justify-content: flex-end;
  244. }
  245. .actNav {
  246. color: #FF7A31;
  247. font-weight: bold;
  248. }
  249. }
  250. .mask {
  251. z-index: 666;
  252. position: fixed;
  253. top: calc(var(--status-bar-height) + 44px);
  254. left: 0;
  255. right: 0;
  256. bottom: 0;
  257. background-color: #f5f5f5;
  258. transition: background-color 0.15s linear;
  259. &.show {
  260. background-color: transparent;
  261. }
  262. &.hide {
  263. display: none;
  264. }
  265. }
  266. .popup {
  267. position: relative;
  268. max-height: 500rpx;
  269. background-color: #f5f5f5;
  270. border-bottom-left-radius: 20rpx;
  271. border-bottom-right-radius: 20rpx;
  272. overflow: scroll;
  273. z-index: 999;
  274. transition: all 1s linear;
  275. opacity: 0;
  276. display: none;
  277. .item-opt {
  278. height: 100rpx;
  279. padding: 0 40rpx;
  280. color: #111111;
  281. border-bottom: 2rpx solid #f6f6f6;
  282. }
  283. .actOpt {
  284. color: #FF7A31;
  285. font-weight: bold;
  286. position: relative;
  287. &::after {
  288. content: '✓';
  289. font-weight: bold;
  290. font-size: 36rpx;
  291. position: absolute;
  292. right: 40rpx;
  293. }
  294. }
  295. }
  296. .popupShow {
  297. display: block;
  298. opacity: 1;
  299. }
  300. }
  301. .icon-triangle {
  302. width: 16rpx;
  303. height: 16rpx;
  304. margin-left: 10rpx;
  305. }
  306. }
  307. </style>