peopleDev.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. <template>
  2. <view class="switch-roles">
  3. <nav-bar title="公司信息" color="#000"></nav-bar>
  4. <view class="roles-content">
  5. <view class="content">
  6. <view class="progress-num"> <text>4</text>/8 </view>
  7. <view class="title">
  8. <view>人才发展</view>
  9. </view>
  10. <view class="desc">
  11. 介绍公司可提供的员工培养&晋升制度,良好的职业成长空间对人才更有吸引力</view>
  12. <view class="content-index">
  13. <view class="content-item">
  14. <view class="content-item-title">晋升制度</view>
  15. <view class="check-box">
  16. <view class="check-item" :class="{ 'check-active': selectedUp.includes(index) }"
  17. v-for="(item, index) in upList" :key="index" @click="checkUp(index)">{{ item }}</view>
  18. </view>
  19. </view>
  20. <view class="content-item">
  21. <view class="content-item-title">人才激励</view>
  22. <view class="check-box">
  23. <view class="check-item" :class="{ 'check-active': selectedPeople.includes(index) }"
  24. v-for="(item, index) in peopleList" :key="index" @click="checkPeople(index)">{{ item }}</view>
  25. </view>
  26. </view>
  27. <view class="content-item">
  28. <view class="content-item-title">能力培养</view>
  29. <view class="check-box">
  30. <view class="check-item" :class="{ 'check-active': selectedPower.includes(index) }"
  31. v-for="(item, index) in powerList" :key="index" @click="checkPower(index)">{{ item }}</view>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="submit-btn" @click="goJobPostingSecond">下一步</view>
  38. </view>
  39. </template>
  40. <script>
  41. import navBar from "@/components/nav-bar/index.vue";
  42. export default {
  43. data() {
  44. return {
  45. upList: ["考核晋升", "定期晋升", "完善的晋升机制"],
  46. selectedUp: [], // 改为数组存储多个选择
  47. peopleList: [
  48. "定期普调",
  49. "定期绩效调薪",
  50. "晋级涨薪",
  51. "项目奖金",
  52. "团队奖金",
  53. "个人奖金",
  54. "绩效提成",
  55. "股票期权",
  56. "人才补贴",
  57. ],
  58. selectedPeople: [], // 改为数组存储多个选择
  59. powerList: [
  60. "老员工带新",
  61. "导师一对一",
  62. "岗前带薪培训",
  63. "内部定期培训",
  64. "专业技能培训",
  65. "内部课程资源",
  66. "大牛带队",
  67. "人脉积累",
  68. "国内外进修",
  69. "校招培养",
  70. ],
  71. selectedPower: [], // 改为数组存储多个选择
  72. companyData: {},
  73. companyPeopleDevelop: [],
  74. isUpdateMode: false // 新增:标记是否为编辑模式
  75. };
  76. },
  77. components: {
  78. navBar,
  79. },
  80. onLoad(options) {
  81. // 判断是否为编辑模式
  82. if (options.update == 'true') {
  83. this.isUpdateMode = true;
  84. this.loadSavedPeopleDevelop();
  85. }
  86. if (options.companyData) {
  87. this.companyData = JSON.parse(options.companyData);
  88. // 如果之前有保存的数据,恢复选择状态
  89. this.restoreSelections();
  90. }
  91. },
  92. methods: {
  93. // 加载已保存的人才发展数据(从缓存)
  94. loadSavedPeopleDevelop() {
  95. try {
  96. let companyInfo = uni.getStorageSync('companyInfo');
  97. if (companyInfo?.companyPeopleDevelop) {
  98. // 处理字符串并分割为数组
  99. const savedPeopleDevelop = companyInfo.companyPeopleDevelop
  100. .replace(/,/g, ',') // 替换中文逗号
  101. .split(',') // 分割
  102. .map(item => item.trim()) // 去除空格
  103. .filter(item => item); // 过滤空值
  104. console.log('加载的人才发展数据:', savedPeopleDevelop);
  105. // 清空之前的选中
  106. this.selectedUp = [];
  107. this.selectedPeople = [];
  108. this.selectedPower = [];
  109. // 恢复晋升制度选择
  110. this.upList.forEach((item, index) => {
  111. if (savedPeopleDevelop.includes(item)) {
  112. this.selectedUp.push(index);
  113. }
  114. });
  115. // 恢复人才激励选择
  116. this.peopleList.forEach((item, index) => {
  117. if (savedPeopleDevelop.includes(item)) {
  118. this.selectedPeople.push(index);
  119. }
  120. });
  121. // 恢复能力培养选择
  122. this.powerList.forEach((item, index) => {
  123. if (savedPeopleDevelop.includes(item)) {
  124. this.selectedPower.push(index);
  125. }
  126. });
  127. console.log('人才发展数据已加载完成');
  128. } else {
  129. console.log('缓存中没有人才发展数据');
  130. }
  131. } catch (error) {
  132. console.error('加载人才发展数据失败:', error);
  133. }
  134. },
  135. // 晋升制度多选
  136. checkUp(index) {
  137. const idx = this.selectedUp.indexOf(index);
  138. if (idx > -1) {
  139. // 如果已选中,则取消选中
  140. this.selectedUp.splice(idx, 1);
  141. } else {
  142. // 如果未选中,则添加
  143. this.selectedUp.push(index);
  144. }
  145. },
  146. // 人才激励多选
  147. checkPeople(index) {
  148. const idx = this.selectedPeople.indexOf(index);
  149. if (idx > -1) {
  150. this.selectedPeople.splice(idx, 1);
  151. } else {
  152. this.selectedPeople.push(index);
  153. }
  154. },
  155. // 能力培养多选
  156. checkPower(index) {
  157. const idx = this.selectedPower.indexOf(index);
  158. if (idx > -1) {
  159. this.selectedPower.splice(idx, 1);
  160. } else {
  161. this.selectedPower.push(index);
  162. }
  163. },
  164. // 恢复之前的选择(编辑时使用)
  165. restoreSelections() {
  166. if (this.companyData.companyPeopleDevelop) {
  167. const savedData = this.companyData.companyPeopleDevelop.split(',');
  168. // 恢复晋升制度选择
  169. this.upList.forEach((item, index) => {
  170. if (savedData.includes(item)) {
  171. this.selectedUp.push(index);
  172. }
  173. });
  174. // 恢复人才激励选择
  175. this.peopleList.forEach((item, index) => {
  176. if (savedData.includes(item)) {
  177. this.selectedPeople.push(index);
  178. }
  179. });
  180. // 恢复能力培养选择
  181. this.powerList.forEach((item, index) => {
  182. if (savedData.includes(item)) {
  183. this.selectedPower.push(index);
  184. }
  185. });
  186. }
  187. },
  188. goJobPostingSecond() {
  189. // 清空之前的数组
  190. this.companyPeopleDevelop = [];
  191. // 添加选中的晋升制度
  192. this.selectedUp.forEach(index => {
  193. if (this.upList[index]) {
  194. this.companyPeopleDevelop.push(this.upList[index]);
  195. }
  196. });
  197. // 添加选中的人才激励
  198. this.selectedPeople.forEach(index => {
  199. if (this.peopleList[index]) {
  200. this.companyPeopleDevelop.push(this.peopleList[index]);
  201. }
  202. });
  203. // 添加选中的能力培养
  204. this.selectedPower.forEach(index => {
  205. if (this.powerList[index]) {
  206. this.companyPeopleDevelop.push(this.powerList[index]);
  207. }
  208. });
  209. // 验证是否至少选择了一项
  210. if (this.companyPeopleDevelop.length === 0) {
  211. uni.showToast({
  212. title: "请至少选择一项人才发展方向",
  213. icon: "none",
  214. });
  215. return;
  216. }
  217. // 保存到 companyData
  218. const companyData = {
  219. ...this.companyData,
  220. companyPeopleDevelop: this.companyPeopleDevelop.join(',')
  221. };
  222. // 如果是编辑模式,同时更新缓存
  223. if (this.isUpdateMode) {
  224. try {
  225. let companyInfo = uni.getStorageSync('companyInfo');
  226. if (companyInfo) {
  227. companyInfo.companyPeopleDevelop = companyData.companyPeopleDevelop;
  228. uni.setStorageSync('companyInfo', companyInfo);
  229. console.log('已更新缓存中的人才发展数据');
  230. }
  231. } catch (error) {
  232. console.error('更新缓存失败:', error);
  233. }
  234. }
  235. // 跳转到下一步
  236. uni.navigateTo({
  237. url: "/my/renzheng/editCompanyDesc?companyData=" +
  238. encodeURIComponent(JSON.stringify(companyData)) +
  239. (this.isUpdateMode ? "&update=true" : "")
  240. });
  241. }
  242. },
  243. };
  244. </script>
  245. <style lang="scss" scoped>
  246. /* 样式保持不变 */
  247. .switch-roles {
  248. background-color: #fff;
  249. position: absolute;
  250. left: 0;
  251. right: 0;
  252. top: 0;
  253. bottom: 0;
  254. display: flex;
  255. flex-direction: column;
  256. .roles-content {
  257. width: 100%;
  258. flex: 1;
  259. overflow: hidden;
  260. overflow-y: auto;
  261. .content {
  262. padding: 40rpx;
  263. box-sizing: border-box;
  264. display: flex;
  265. flex-direction: column;
  266. align-items: center;
  267. justify-content: center;
  268. .progress-num {
  269. color: #016bf6;
  270. font-family: DM Sans;
  271. font-size: 24rpx;
  272. font-weight: 500;
  273. width: 100%;
  274. padding-bottom: 20rpx;
  275. box-sizing: border-box;
  276. text {
  277. font-size: 48rpx;
  278. font-weight: 700;
  279. }
  280. }
  281. .title {
  282. color: #333;
  283. width: 100%;
  284. font-family: DM Sans;
  285. font-size: 48rpx;
  286. font-weight: 700;
  287. display: flex;
  288. justify-content: space-between;
  289. align-items: center;
  290. margin-bottom: 20rpx;
  291. }
  292. .desc {
  293. color: rgba(102, 102, 102, 1);
  294. width: 100%;
  295. font-family: DM Sans;
  296. font-size: 24rpx;
  297. font-weight: 400;
  298. line-height: 32rpx;
  299. letter-spacing: 0.5%;
  300. text-align: left;
  301. padding: 20rpx 0;
  302. box-sizing: border-box;
  303. margin-bottom: 20rpx;
  304. }
  305. .content-index {
  306. width: 100%;
  307. .content-item {
  308. margin-bottom: 40rpx;
  309. .content-item-title {
  310. color: rgba(34, 37, 42, 1);
  311. font-family: DM Sans;
  312. font-size: 32rpx;
  313. font-weight: 400;
  314. line-height: 48rpx;
  315. padding-bottom: 12rpx;
  316. box-sizing: border-box;
  317. }
  318. .check-box {
  319. display: flex;
  320. gap: 12rpx;
  321. flex-wrap: wrap;
  322. align-items: center;
  323. .check-item {
  324. flex-shrink: 0;
  325. padding: 8rpx;
  326. border-radius: 8rpx;
  327. background: #9999991a;
  328. border: 1rpx solid #9999991a;
  329. box-sizing: border-box;
  330. color: rgba(102, 102, 102, 1);
  331. font-family: DM Sans;
  332. font-size: 16rpx;
  333. font-weight: 400;
  334. cursor: pointer;
  335. transition: all 0.3s;
  336. }
  337. .check-active {
  338. box-sizing: border-box;
  339. border: 1rpx solid #016bf6;
  340. border-radius: 8rpx;
  341. background: rgba(252, 233, 220, 1);
  342. color: #016bf6;
  343. }
  344. }
  345. }
  346. }
  347. }
  348. }
  349. .submit-btn {
  350. flex-shrink: 0;
  351. border-radius: 999px;
  352. background: #ff6600;
  353. color: rgba(255, 255, 255, 1);
  354. font-family: DM Sans;
  355. font-size: 32rpx;
  356. font-weight: 400;
  357. line-height: 48rpx;
  358. display: flex;
  359. justify-content: center;
  360. align-items: center;
  361. padding: 24rpx 32rpx;
  362. box-sizing: border-box;
  363. margin: 30rpx 40rpx;
  364. margin-top: 20rpx;
  365. }
  366. }
  367. </style>