fund.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. <template>
  2. <view class="switch-roles">
  3. <nav-bar title="福利待遇"></nav-bar>
  4. <view class="roles-content">
  5. <view class="content-card">
  6. <view class="card-title">福利待遇</view>
  7. <view class="other-input-area">
  8. <textarea v-model="otherWelfare" placeholder="请详细描述公司的福利待遇" maxlength="5000" class="other-textarea" />
  9. <view class="input-count flex align-center justify-end">
  10. <text class="hight-light">{{ otherWelfare.length }}</text>
  11. <text>/5000</text>
  12. </view>
  13. </view>
  14. <!-- 福利标签 -->
  15. <view class="tag-list">
  16. <view
  17. class="tag flex"
  18. :class="{ 'tag-active': selectedTags.includes(item) }"
  19. v-for="(item, index) in fundList"
  20. :key="index + item"
  21. @click="toggleTag(item)"
  22. >
  23. {{ item }}
  24. <view style="margin-left: 2px" v-if="index > 11" @click.stop="removeCustomTag(item, index)">
  25. <u-icon name="close" size="16"></u-icon>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="add-tag-wrapper flex">
  30. <view class="tag tag-active flex" @click="showAddModal = true">
  31. <text>自定义标签</text>
  32. <image src="/static/images/svg/add-border.svg" class="add-icon"></image>
  33. </view>
  34. </view>
  35. <view class="tag-count-wrapper">已选 {{ selectedTags.length }} 个</view>
  36. <!-- 已选标签展示区(核心新增) -->
  37. <!-- <view class="selected-tags" v-if="selectedTags.length > 0">
  38. <view class="selected-tag-item" v-for="(tag, index) in selectedTags" :key="index">
  39. <text>{{ tag }}</text>
  40. <u-icon name="close" size="24rpx" color="#999" @click="removeTag(index)"></u-icon>
  41. </view>
  42. </view> -->
  43. <!-- 自定义输入 + 添加按钮区域 -->
  44. <!-- <view class="input-area">
  45. <textarea v-model="customWelfare" placeholder="请输入自定义福利" maxlength="500" class="custom-textarea"></textarea>
  46. <button class="add-btn" @click="addCustomTag">添加</button>
  47. <view class="word-count">
  48. <text>{{ customWelfare.length }}</text> /500
  49. </view>
  50. </view> -->
  51. <!-- 常用标签区域 -->
  52. <!-- <view class="tag-section">
  53. <view class="section-title">常用福利标签</view>
  54. <view class="tag-list">
  55. <view class="tag-item" :class="{ 'tag-selected': selectedTags.includes(item) }" v-for="item in fundList"
  56. :key="item" @click="toggleTag(item)">
  57. {{ item }}
  58. </view>
  59. </view>
  60. <view class="selected-count">已选 {{ selectedTags.length }} 个福利</view>
  61. </view> -->
  62. </view>
  63. </view>
  64. <!-- 添加自定义弹窗 -->
  65. <u-modal v-model="showAddModal" show-cancel-button title="添加自定义" @confirm="confirmAddCustomeWelfare">
  66. <view class="custom-input">
  67. <input v-model="addCustomWelfare" placeholder="请输入自定义福利" maxlength="50" class="input" />
  68. </view>
  69. </u-modal>
  70. <view class="button-section">
  71. <view class="submit-btn" @click="submitWelfare">确定</view>
  72. </view>
  73. </view>
  74. </template>
  75. <script>
  76. import navBar from "@/components/nav-bar/index.vue";
  77. export default {
  78. data() {
  79. return {
  80. fundList: [
  81. "五险一金", "定期体检", "年终奖", "带薪年假",
  82. "员工旅游", "节日福利", "绩效奖金", "零食下午茶",
  83. "住房补贴", "交通补贴", "餐饮补贴", "通讯补贴"
  84. ],
  85. customWelfare: "",
  86. selectedTags: [], // 存储所有选中的标签(系统+自定义)
  87. otherWelfare: '', // 福利描述
  88. showAddModal: false,
  89. addCustomWelfare: ''
  90. };
  91. },
  92. components: { navBar },
  93. onLoad(options) {
  94. if (options.tag&&options.tag.length>0&&options.tag!='undefined') {
  95. this.selectedTags = decodeURIComponent(options.tag).split(';')
  96. }
  97. if (options.text) {
  98. this.otherWelfare = decodeURIComponent(options.text)
  99. }
  100. },
  101. methods: {
  102. // 切换系统标签选中状态
  103. toggleTag(tag) {
  104. if (this.selectedTags.includes(tag)) {
  105. this.selectedTags = this.selectedTags.filter(item => item !== tag);
  106. } else {
  107. if (this.selectedTags.length < 10) {
  108. this.selectedTags.push(tag);
  109. } else {
  110. uni.showToast({ title: '最多选择10个福利', icon: 'none' });
  111. }
  112. }
  113. },
  114. // // 移除已选标签(系统或自定义)
  115. // removeTag(index) {
  116. // this.selectedTags.splice(index, 1);
  117. // },
  118. // // 添加自定义标签
  119. // addCustomTag() {
  120. // const tag = this.customWelfare.trim();
  121. // if (!tag) {
  122. // uni.showToast({ title: '请输入福利内容', icon: 'none' });
  123. // return;
  124. // }
  125. // if (this.selectedTags.includes(tag)) {
  126. // uni.showToast({ title: '该福利已添加', icon: 'none' });
  127. // return;
  128. // }
  129. // if (this.selectedTags.length >= 10) {
  130. // uni.showToast({ title: '最多选择10个福利', icon: 'none' });
  131. // return;
  132. // }
  133. // this.selectedTags.push(tag); // 添加到选中列表
  134. // this.customWelfare = ""; // 清空输入框
  135. // },
  136. // 移除自定义福利
  137. removeCustomTag(tag, index) {
  138. this.fundList.splice(index, 1)
  139. const list = []
  140. this.selectedTags.forEach(item => {
  141. if (item != tag) {
  142. list.push(item)
  143. }
  144. })
  145. console.log(list)
  146. this.selectedTags = list
  147. console.log(this.selectedTags)
  148. },
  149. // 添加自定义福利
  150. confirmAddCustomeWelfare() {
  151. const tag = this.addCustomWelfare.trim();
  152. if (!tag) {
  153. uni.showToast({ title: '请输入福利内容', icon: 'none' });
  154. return;
  155. }
  156. if (this.fundList.includes(tag)) {
  157. uni.showToast({ title: '该福利已添加', icon: 'none' });
  158. return;
  159. }
  160. if (this.fundList.length >= 22) {
  161. uni.showToast({ title: '最多选择10个福利', icon: 'none' });
  162. return;
  163. }
  164. this.fundList.push(tag)
  165. this.selectedTags.push(tag) // 添加到选中列表
  166. this.addCustomWelfare = ''
  167. this.showAddModal = false
  168. },
  169. // 提交回传
  170. submitWelfare() {
  171. const welfareData = this.selectedTags.join(';');
  172. uni.$emit("fundData", {
  173. text: this.otherWelfare,
  174. tagText: welfareData
  175. });
  176. uni.navigateBack();
  177. },
  178. },
  179. };
  180. </script>
  181. <style lang="scss" scoped>
  182. .switch-roles {
  183. background-color: #f5f7fa;
  184. position: absolute;
  185. left: 0;
  186. right: 0;
  187. top: 0;
  188. bottom: 0;
  189. display: flex;
  190. flex-direction: column;
  191. .roles-content {
  192. width: 100%;
  193. flex: 1;
  194. overflow-y: auto;
  195. padding: 32rpx 40rpx;
  196. }
  197. .card-title {
  198. font-size: 48rpx;
  199. font-weight: 700;
  200. line-height: 60rpx;
  201. color: #333;
  202. margin-bottom: 20rpx;
  203. }
  204. .other-input-area {
  205. padding: 40rpx 32rpx 20rpx;
  206. border-radius: 6px;
  207. background: rgba(153, 153, 153, 0.05);
  208. margin-bottom: 20rpx;
  209. .other-textarea {
  210. width: 100%;
  211. height: 340rpx;
  212. font-size: 28rpx;
  213. line-height: 36rpx;
  214. }
  215. .input-count {
  216. font-size: 20rpx;
  217. margin-top: 20rpx;
  218. color: #999;
  219. .hight-light {
  220. color: #016BF6;
  221. }
  222. }
  223. }
  224. // 福利标签
  225. .tag-list {
  226. display: flex;
  227. flex-wrap: wrap;
  228. }
  229. .tag {
  230. color: rgba(102, 102, 102, 1);
  231. font-size: 20rpx;
  232. line-height: 1;
  233. border-radius: 8rpx;
  234. background: rgba(153, 153, 153, 0.1);
  235. margin-right: 12rpx;
  236. margin-bottom: 8rpx;
  237. padding: 8rpx 9rpx;
  238. &.tag-active {
  239. color: rgba(1, 107, 246, 1);
  240. background: rgba(1, 107, 246, 0.1);
  241. }
  242. }
  243. .add-tag-wrapper {
  244. margin: 20rpx 0 10rpx;
  245. .add-icon {
  246. display: inline-block;
  247. width: 20rpx;
  248. height: 20rpx;
  249. margin-left: 4rpx;
  250. }
  251. }
  252. .tag-count-wrapper {
  253. color: #016BF6;
  254. font-size: 20rpx;
  255. line-height: 26rpx;
  256. }
  257. // 添加自定义弹窗
  258. .custom-input {
  259. margin: 40rpx 60rpx;
  260. border: 1px solid #ddd;
  261. border-radius: 4px;
  262. padding: 0 20rpx;
  263. .input {
  264. height: 60rpx;
  265. line-height: 40rpx;
  266. margin: 0 auto;
  267. }
  268. }
  269. /* 已选标签展示区样式 */
  270. // .selected-tags {
  271. // display: flex;
  272. // flex-wrap: wrap;
  273. // gap: 16rpx;
  274. // padding: 10rpx 0;
  275. // margin-bottom: 20rpx;
  276. // min-height: 60rpx;
  277. // border-bottom: 1rpx solid #f0f0f0;
  278. // padding-bottom: 15rpx;
  279. // .selected-tag-item {
  280. // display: inline-flex;
  281. // align-items: center;
  282. // background-color: #f0f7ff;
  283. // border-radius: 60rpx;
  284. // padding: 8rpx 20rpx;
  285. // padding-right: 12rpx;
  286. // font-size: 28rpx;
  287. // color: #007aff;
  288. // gap: 8rpx;
  289. // u-icon {
  290. // margin-left: 5rpx;
  291. // padding: 2rpx;
  292. // &:active {
  293. // background-color: rgba(0, 0, 0, 0.05);
  294. // border-radius: 50%;
  295. // }
  296. // }
  297. // }
  298. // }
  299. // .input-area {
  300. // display: flex;
  301. // flex-direction: column;
  302. // margin-bottom: 30rpx;
  303. // .custom-textarea {
  304. // width: 100%;
  305. // min-height: 120rpx;
  306. // border: 1rpx solid #e5e7eb;
  307. // border-radius: 8rpx;
  308. // padding: 20rpx;
  309. // font-size: 28rpx;
  310. // margin-bottom: 16rpx;
  311. // }
  312. // .add-btn {
  313. // align-self: flex-end;
  314. // background-color: #007aff;
  315. // color: #fff;
  316. // border-radius: 8rpx;
  317. // font-size: 28rpx;
  318. // padding: 10rpx 24rpx;
  319. // margin-bottom: 10rpx;
  320. // }
  321. // .word-count {
  322. // font-size: 26rpx;
  323. // color: #999;
  324. // text-align: right;
  325. // text {
  326. // color: #007aff;
  327. // }
  328. // }
  329. // }
  330. // .tag-section {
  331. // .section-title {
  332. // font-size: 30rpx;
  333. // color: #666;
  334. // margin-bottom: 20rpx;
  335. // }
  336. // .tag-list {
  337. // display: flex;
  338. // flex-wrap: wrap;
  339. // gap: 16rpx;
  340. // margin-bottom: 20rpx;
  341. // .tag-item {
  342. // padding: 12rpx 24rpx;
  343. // border: 1rpx solid #d1d5db;
  344. // border-radius: 60rpx;
  345. // color: #4b5563;
  346. // font-size: 28rpx;
  347. // background-color: #fff;
  348. // }
  349. // .tag-selected {
  350. // border-color: #007aff;
  351. // color: #007aff;
  352. // background-color: #e0f2ff;
  353. // }
  354. // }
  355. // .selected-count {
  356. // font-size: 26rpx;
  357. // color: #666;
  358. // }
  359. // }
  360. .button-section {
  361. padding: 28rpx 40rpx;
  362. box-shadow: 0px -4px 16px 0px rgba(0, 0, 0, 0.04);
  363. }
  364. .submit-btn {
  365. flex-shrink: 0;
  366. border-radius: 999px;
  367. box-shadow: 0px -4px 16px 0px rgba(0, 0, 0, 0.04);
  368. background: linear-gradient(90deg, rgba(13, 39, 247, 1), rgba(19, 193, 234, 1) 100%);
  369. color: rgba(255, 255, 255, 1);
  370. font-family: DM Sans;
  371. font-size: 32rpx;
  372. font-weight: 400;
  373. line-height: 48rpx;
  374. display: flex;
  375. justify-content: center;
  376. align-items: center;
  377. padding: 16rpx 32rpx;
  378. box-sizing: border-box;
  379. }
  380. }
  381. </style>