companyFund.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. <template>
  2. <view class="switch-roles">
  3. <nav-bar title="公司福利"></nav-bar>
  4. <view class="roles-content">
  5. <view class="content">
  6. <view class="progress-num"> <text>3</text>/8 </view>
  7. <view class="title">
  8. <view>公司福利</view>
  9. <view class="check-num">
  10. <text>{{ selectedCount }}</text>/{{ totalCount }}
  11. </view>
  12. </view>
  13. <view class="desc"> 选择公司提供的福利信息,以吸引更多求职者 </view>
  14. <!-- 福利分类 -->
  15. <view class="welfare-category" v-for="(category, categoryIndex) in welfareList" :key="categoryIndex">
  16. <view class="category-title">{{ category.title }}</view>
  17. <view class="check-box">
  18. <view class="check-item" v-for="(item, index) in category.items" :key="index"
  19. @click="checkItem(categoryIndex, index)">
  20. <view class="check-txt">{{ item.name }}</view>
  21. <view class="check-icon" :class="{ 'check-icon-active': item.selected }">
  22. <u-icon name="checkmark" color="#fff" size="18" v-if="item.selected"></u-icon>
  23. <u-icon name="plus" color="#666" size="28" v-else></u-icon>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. <!-- 已选福利 -->
  31. <view class="check-list" v-if="selectedWelfare.length > 0">
  32. 已选:
  33. <view class="check-list-item" v-for="(item, index) in selectedWelfare" :key="index"
  34. @click="removeSelected(item.categoryIndex, item.itemIndex)">
  35. {{ item.name }}
  36. <text class="remove-icon">×</text>
  37. </view>
  38. </view>
  39. <view class="submit-btn" @click="goJobPostingSecond">下一步</view>
  40. </view>
  41. </template>
  42. <script>
  43. import navBar from "@/components/nav-bar/index.vue";
  44. export default {
  45. data() {
  46. return {
  47. welfareList: [{
  48. title: "保险",
  49. items: [{
  50. name: "五险一金",
  51. selected: false
  52. },
  53. {
  54. name: "补充医疗保险",
  55. selected: false
  56. },
  57. {
  58. name: "意外险",
  59. selected: false
  60. },
  61. {
  62. name: "定期体检",
  63. selected: false
  64. },
  65. ],
  66. },
  67. {
  68. title: "薪资期权",
  69. items: [{
  70. name: "年终奖",
  71. selected: false
  72. },
  73. {
  74. name: "绩效奖金",
  75. selected: false
  76. },
  77. {
  78. name: "保底工资",
  79. selected: false
  80. },
  81. {
  82. name: "底薪加提成",
  83. selected: false
  84. },
  85. {
  86. name: "股票期权",
  87. selected: false
  88. },
  89. {
  90. name: "企业年金",
  91. selected: false
  92. },
  93. ],
  94. },
  95. {
  96. title: "补贴",
  97. items: [{
  98. name: "餐补",
  99. selected: false
  100. },
  101. {
  102. name: "交通补贴",
  103. selected: false
  104. },
  105. {
  106. name: "住房补贴",
  107. selected: false
  108. },
  109. {
  110. name: "加班补贴",
  111. selected: false
  112. },
  113. {
  114. name: "团建补贴",
  115. selected: false
  116. },
  117. ],
  118. },
  119. {
  120. title: "休假",
  121. items: [{
  122. name: "带薪年假",
  123. selected: false
  124. },
  125. {
  126. name: "节假日加班费",
  127. selected: false
  128. },
  129. {
  130. name: "法定节假日三薪",
  131. selected: false
  132. },
  133. {
  134. name: "员工购房",
  135. selected: false
  136. },
  137. ],
  138. },
  139. ],
  140. selectedCount: 0,
  141. totalCount: 20,
  142. };
  143. },
  144. components: {
  145. navBar,
  146. },
  147. computed: {
  148. // 计算已选的福利项目
  149. selectedWelfare() {
  150. const selected = [];
  151. this.welfareList.forEach((category, categoryIndex) => {
  152. category.items.forEach((item, itemIndex) => {
  153. if (item.selected) {
  154. selected.push({
  155. name: item.name,
  156. categoryIndex: categoryIndex,
  157. itemIndex: itemIndex,
  158. });
  159. }
  160. });
  161. });
  162. return selected;
  163. },
  164. },
  165. onLoad(options) {
  166. let companyInfo = uni.getStorageSync('companyInfo');
  167. if (companyInfo && companyInfo.welfare) {
  168. let welfareString = companyInfo.welfare;
  169. // 将中文逗号替换为英文逗号,并去除首尾空格
  170. welfareString = welfareString.replace(/,/g, ',').trim();
  171. // 分割字符串为数组
  172. const savedWelfareList = welfareString.split(',').map(item => item.trim()).filter(item => item);
  173. // 直接遍历福利列表,设置选中状态
  174. this.welfareList.forEach(category => {
  175. category.items.forEach(item => {
  176. // 如果当前福利名称在保存的列表中,则设置为选中
  177. item.selected = savedWelfareList.includes(item.name);
  178. });
  179. });
  180. // 更新选中数量
  181. this.updateSelectedCount();
  182. }
  183. },
  184. methods: {
  185. // 选择/取消选择福利项目
  186. checkItem(categoryIndex, itemIndex) {
  187. const item = this.welfareList[categoryIndex].items[itemIndex];
  188. item.selected = !item.selected;
  189. // 更新选中数量
  190. this.updateSelectedCount();
  191. },
  192. // 移除已选项目
  193. removeSelected(categoryIndex, itemIndex) {
  194. this.welfareList[categoryIndex].items[itemIndex].selected = false;
  195. this.updateSelectedCount();
  196. },
  197. // 更新选中数量
  198. updateSelectedCount() {
  199. let count = 0;
  200. this.welfareList.forEach((category) => {
  201. category.items.forEach((item) => {
  202. if (item.selected) count++;
  203. });
  204. });
  205. this.selectedCount = count;
  206. },
  207. goJobPostingSecond() {
  208. if (this.selectedCount === 0) {
  209. uni.showToast({
  210. title: "请至少选择一项福利",
  211. icon: "none",
  212. });
  213. return;
  214. }
  215. const selectedBenefits = this.selectedWelfare.map((item) => item.name);
  216. let companyData = {
  217. companyId: this.$queue.getData('companyId'),
  218. welfare: selectedBenefits.join(',')
  219. }
  220. this.$Request.postJson('/app/company/updateCompany', companyData).then(res => {
  221. if (res.code == 0) {
  222. uni.showToast({
  223. title: '提交成功',
  224. duration: 1500,
  225. });
  226. setTimeout(() => {
  227. uni.switchTab({
  228. url: '/pages/my/index'
  229. });
  230. }, 500)
  231. }
  232. })
  233. // uni.navigateTo({
  234. // url:
  235. // "/my/renzheng/peopleDev?companyData=" +
  236. // encodeURIComponent(JSON.stringify(companyData))+'&update=true',
  237. // });
  238. // console.log(companyData);
  239. },
  240. },
  241. mounted() {
  242. // 初始化总数量
  243. this.totalCount = this.welfareList.reduce(
  244. (total, category) => total + category.items.length,
  245. 0
  246. );
  247. },
  248. };
  249. </script>
  250. <style lang="scss" scoped>
  251. .switch-roles {
  252. background-color: #fff;
  253. position: absolute;
  254. left: 0;
  255. right: 0;
  256. top: 0;
  257. bottom: 0;
  258. display: flex;
  259. flex-direction: column;
  260. .roles-content {
  261. width: 100%;
  262. flex: 1;
  263. overflow: hidden;
  264. overflow-y: auto;
  265. .content {
  266. padding: 40rpx;
  267. box-sizing: border-box;
  268. display: flex;
  269. flex-direction: column;
  270. align-items: center;
  271. justify-content: center;
  272. .progress-num {
  273. color: #016bf6;
  274. font-family: DM Sans;
  275. font-size: 24rpx;
  276. font-weight: 500;
  277. width: 100%;
  278. padding-bottom: 20rpx;
  279. box-sizing: border-box;
  280. text {
  281. font-size: 48rpx;
  282. font-weight: 700;
  283. }
  284. }
  285. .title {
  286. color: #333;
  287. width: 100%;
  288. font-family: DM Sans;
  289. font-size: 48rpx;
  290. font-weight: 700;
  291. display: flex;
  292. justify-content: space-between;
  293. align-items: center;
  294. margin-bottom: 20rpx;
  295. .check-num {
  296. font-family: DM Sans;
  297. font-size: 48rpx;
  298. font-weight: 700;
  299. line-height: 60rpx;
  300. color: #999;
  301. text {
  302. color: #016bf6;
  303. }
  304. }
  305. }
  306. .desc {
  307. color: rgba(102, 102, 102, 1);
  308. width: 100%;
  309. font-family: DM Sans;
  310. font-size: 24rpx;
  311. font-weight: 400;
  312. line-height: 32rpx;
  313. letter-spacing: 0.5%;
  314. text-align: left;
  315. padding: 20rpx 0;
  316. box-sizing: border-box;
  317. margin-bottom: 20rpx;
  318. }
  319. .welfare-category {
  320. width: 100%;
  321. margin-bottom: 40rpx;
  322. .category-title {
  323. color: rgba(31, 44, 55, 1);
  324. font-family: DM Sans;
  325. font-size: 28rpx;
  326. font-weight: 500;
  327. line-height: 44rpx;
  328. padding-bottom: 20rpx;
  329. box-sizing: border-box;
  330. }
  331. .check-box {
  332. width: 100%;
  333. display: grid;
  334. grid-template-columns: repeat(1, 1fr);
  335. gap: 20rpx;
  336. .check-item {
  337. padding: 20rpx 24rpx;
  338. box-sizing: border-box;
  339. border-radius: 16rpx;
  340. display: flex;
  341. align-items: center;
  342. justify-content: space-between;
  343. gap: 20rpx;
  344. .check-icon {
  345. width: 32rpx;
  346. height: 32rpx;
  347. border-radius: 8rpx;
  348. border: 2rpx solid #666;
  349. display: flex;
  350. justify-content: center;
  351. align-items: center;
  352. background: #fff;
  353. flex-shrink: 0;
  354. }
  355. .check-icon-active {
  356. background-color: #016bf6;
  357. border-color: #016bf6;
  358. border-radius: 50%;
  359. }
  360. .check-txt {
  361. border-radius: 4px;
  362. background: rgba(153, 153, 153, 0.1);
  363. padding: 8rpx;
  364. box-sizing: border-box;
  365. color: rgba(102, 102, 102, 1);
  366. font-family: DM Sans;
  367. font-size: 24rpx;
  368. font-weight: 400;
  369. }
  370. }
  371. }
  372. }
  373. }
  374. }
  375. .check-list {
  376. flex-shrink: 0;
  377. padding: 20rpx 40rpx;
  378. box-sizing: border-box;
  379. color: #016bf6;
  380. font-family: DM Sans;
  381. font-size: 16rpx;
  382. font-weight: 400;
  383. display: flex;
  384. flex-wrap: wrap;
  385. align-items: center;
  386. gap: 16rpx;
  387. .check-list-item {
  388. box-sizing: border-box;
  389. border: 1rpx solid #016bf6;
  390. border-radius: 8rpx;
  391. background: rgba(252, 233, 220, 1);
  392. padding: 4rpx 8rpx;
  393. display: flex;
  394. align-items: center;
  395. gap: 8rpx;
  396. .remove-icon {
  397. font-size: 24rpx;
  398. font-weight: bold;
  399. margin-left: 8rpx;
  400. cursor: pointer;
  401. }
  402. }
  403. }
  404. .submit-btn {
  405. flex-shrink: 0;
  406. border-radius: 999px;
  407. background: #ff6600;
  408. color: rgba(255, 255, 255, 1);
  409. font-family: DM Sans;
  410. font-size: 32rpx;
  411. font-weight: 400;
  412. line-height: 48rpx;
  413. display: flex;
  414. justify-content: center;
  415. align-items: center;
  416. padding: 24rpx 32rpx;
  417. box-sizing: border-box;
  418. margin: 30rpx 40rpx;
  419. margin-top: 20rpx;
  420. }
  421. }
  422. </style>