peopleDev.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <template>
  2. <view class="page-container">
  3. <nav-bar title="公司信息"></nav-bar>
  4. <view class="content">
  5. <view class="num-title">
  6. <text class="current-num">6</text>
  7. <text>/6</text>
  8. </view>
  9. <view class="main-title">人才发展</view>
  10. <view>介绍公司可提供的员工培养&晋升制度,良好的职业成长空间对人才更有吸引力</view>
  11. <view class="section">
  12. <view class="title">晋升制度</view>
  13. <view class="tags">
  14. <view
  15. class="tag"
  16. :class="{ 'active-tag': selectedUp.includes(index) }"
  17. v-for="(item, index) in upList"
  18. :key="index"
  19. @click="checkUp(index)"
  20. >{{ item }}</view>
  21. </view>
  22. </view>
  23. <view class="section">
  24. <view class="title">人才激励</view>
  25. <view class="tags">
  26. <view
  27. class="tag"
  28. :class="{ 'active-tag': selectedPeople.includes(index) }"
  29. v-for="(item, index) in peopleList"
  30. :key="index"
  31. @click="checkPeople(index)"
  32. >{{ item }}</view>
  33. </view>
  34. </view>
  35. <view class="section">
  36. <view class="title">能力培养</view>
  37. <view class="tags">
  38. <view
  39. class="tag"
  40. :class="{ 'active-tag': selectedPower.includes(index) }"
  41. v-for="(item, index) in powerList"
  42. :key="index"
  43. @click="checkPower(index)"
  44. >{{ item }}</view>
  45. </view>
  46. </view>
  47. </view>
  48. <view class="fixed-button">
  49. <view class="button" @click="goJobPostingSecond">保存</view>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. import navBar from "@/components/nav-bar/index.vue";
  55. export default {
  56. data() {
  57. return {
  58. companyId: '',
  59. loading: false,
  60. upList: ["考核晋升", "定期晋升", "完善的晋升机制"],
  61. selectedUp: [], // 改为数组存储多个选择
  62. peopleList: [
  63. "定期普调",
  64. "定期绩效调薪",
  65. "晋级涨薪",
  66. "项目奖金",
  67. "团队奖金",
  68. "个人奖金",
  69. "绩效提成",
  70. "股票期权",
  71. "人才补贴",
  72. ],
  73. selectedPeople: [], // 改为数组存储多个选择
  74. powerList: [
  75. "老员工带新",
  76. "导师一对一",
  77. "岗前带薪培训",
  78. "内部定期培训",
  79. "专业技能培训",
  80. "内部课程资源",
  81. "大牛带队",
  82. "人脉积累",
  83. "国内外进修",
  84. "校招培养",
  85. ],
  86. selectedPower: [], // 改为数组存储多个选择
  87. // companyData: {},
  88. companyPeopleDevelop: [],
  89. isUpdateMode: false // 新增:标记是否为编辑模式
  90. };
  91. },
  92. components: {
  93. navBar,
  94. },
  95. onLoad(options) {
  96. this.getCompanyInfo()
  97. },
  98. methods: {
  99. // 获取公司信息
  100. getCompanyInfo() {
  101. uni.showLoading({ title: '加载中' })
  102. this.$Request.get('/app/company/selectCompanyByUserId')
  103. .then((res) => {
  104. if (res.code != 0) {
  105. uni.showToast({
  106. title: res.msg || '查询状态失败',
  107. icon: 'none'
  108. });
  109. return
  110. }
  111. this.companyId = res.data.companyId
  112. this.initData(res.data)
  113. uni.hideLoading()
  114. })
  115. .catch((err) => {
  116. uni.hideLoading()
  117. uni.showToast({
  118. title: '网络异常',
  119. icon: 'none'
  120. })
  121. })
  122. },
  123. initData(companyInfo) {
  124. if (companyInfo?.companyPeopleDevelop) {
  125. // 处理字符串并分割为数组
  126. const savedPeopleDevelop = companyInfo.companyPeopleDevelop
  127. .replace(/,/g, ',') // 替换中文逗号
  128. .split(',') // 分割
  129. .map(item => item.trim()) // 去除空格
  130. .filter(item => item); // 过滤空值
  131. console.log('加载的人才发展数据:', savedPeopleDevelop);
  132. // 清空之前的选中
  133. this.selectedUp = [];
  134. this.selectedPeople = [];
  135. this.selectedPower = [];
  136. // 恢复晋升制度选择
  137. this.upList.forEach((item, index) => {
  138. if (savedPeopleDevelop.includes(item)) {
  139. this.selectedUp.push(index);
  140. }
  141. });
  142. // 恢复人才激励选择
  143. this.peopleList.forEach((item, index) => {
  144. if (savedPeopleDevelop.includes(item)) {
  145. this.selectedPeople.push(index);
  146. }
  147. });
  148. // 恢复能力培养选择
  149. this.powerList.forEach((item, index) => {
  150. if (savedPeopleDevelop.includes(item)) {
  151. this.selectedPower.push(index);
  152. }
  153. });
  154. console.log('人才发展数据已加载完成');
  155. }
  156. },
  157. // 晋升制度多选
  158. checkUp(index) {
  159. const idx = this.selectedUp.indexOf(index);
  160. if (idx > -1) {
  161. // 如果已选中,则取消选中
  162. this.selectedUp.splice(idx, 1);
  163. } else {
  164. // 如果未选中,则添加
  165. this.selectedUp.push(index);
  166. }
  167. },
  168. // 人才激励多选
  169. checkPeople(index) {
  170. const idx = this.selectedPeople.indexOf(index);
  171. if (idx > -1) {
  172. this.selectedPeople.splice(idx, 1);
  173. } else {
  174. this.selectedPeople.push(index);
  175. }
  176. },
  177. // 能力培养多选
  178. checkPower(index) {
  179. const idx = this.selectedPower.indexOf(index);
  180. if (idx > -1) {
  181. this.selectedPower.splice(idx, 1);
  182. } else {
  183. this.selectedPower.push(index);
  184. }
  185. },
  186. goJobPostingSecond() {
  187. if (this.loading) return
  188. // 清空之前的数组
  189. this.companyPeopleDevelop = [];
  190. // 添加选中的晋升制度
  191. this.selectedUp.forEach(index => {
  192. if (this.upList[index]) {
  193. this.companyPeopleDevelop.push(this.upList[index]);
  194. }
  195. });
  196. // 添加选中的人才激励
  197. this.selectedPeople.forEach(index => {
  198. if (this.peopleList[index]) {
  199. this.companyPeopleDevelop.push(this.peopleList[index]);
  200. }
  201. });
  202. // 添加选中的能力培养
  203. this.selectedPower.forEach(index => {
  204. if (this.powerList[index]) {
  205. this.companyPeopleDevelop.push(this.powerList[index]);
  206. }
  207. });
  208. // 验证是否至少选择了一项
  209. if (this.companyPeopleDevelop.length === 0) {
  210. uni.showToast({
  211. title: "请至少选择一项人才发展方向",
  212. icon: "none",
  213. });
  214. return;
  215. }
  216. this.loading = true
  217. uni.showLoading({ title: '保存中' })
  218. let companyData = {
  219. companyId: this.companyId,
  220. companyPeopleDevelop: this.companyPeopleDevelop.join(',')
  221. }
  222. this.$Request.postJson('/app/company/updateCompany', companyData)
  223. .then(res => {
  224. if (res.code == 0) {
  225. uni.showToast({
  226. title: '提交成功',
  227. duration: 1500,
  228. });
  229. setTimeout(() => {
  230. uni.$emit('updateCompanyInfo')
  231. uni.navigateBack()
  232. }, 500)
  233. }
  234. this.loading = false
  235. uni.hideLoading()
  236. })
  237. .catch(() => {
  238. this.loading = false
  239. uni.hideLoading()
  240. })
  241. // 如果是编辑模式,同时更新缓存
  242. // if (this.isUpdateMode) {
  243. // try {
  244. // let companyInfo = uni.getStorageSync('companyInfo');
  245. // if (companyInfo) {
  246. // companyInfo.companyPeopleDevelop = companyData.companyPeopleDevelop;
  247. // uni.setStorageSync('companyInfo', companyInfo);
  248. // console.log('已更新缓存中的人才发展数据');
  249. // }
  250. // } catch (error) {
  251. // console.error('更新缓存失败:', error);
  252. // }
  253. // }
  254. // 跳转到下一步
  255. // uni.navigateTo({
  256. // url: "/my/renzheng/editCompanyDesc?companyData=" +
  257. // encodeURIComponent(JSON.stringify(companyData)) +
  258. // (this.isUpdateMode ? "&update=true" : "")
  259. // });
  260. }
  261. },
  262. };
  263. </script>
  264. <style lang="scss" scoped>
  265. @import './company.scss';
  266. </style>