mainWorkIntro.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <view class="page-container">
  3. <nav-bar title="公司信息">
  4. <view class="nav-bar-right-btn" slot="right" @click="toNext">跳过</view>
  5. </nav-bar>
  6. <view class="content">
  7. <view class="num-title">
  8. <text class="current-num">4</text>
  9. <text>/6</text>
  10. </view>
  11. <view class="main-title">主营业务介绍</view>
  12. <view>介绍公司主营业务及旗下的产品信息,可有效提升求职者对公司及品牌的认知</view>
  13. <view class="section">
  14. <view class="title">主营产品</view>
  15. <view class="tags">
  16. <view
  17. class="tag"
  18. :class="{ 'active-tag': selectedProducts.includes(item) }"
  19. v-for="(item, index) in productList"
  20. :key="index"
  21. @click="toggleProduct(item)"
  22. >{{ item }}</view>
  23. </view>
  24. </view>
  25. <view class="section">
  26. <view class="title">自定义</view>
  27. <view class="tags">
  28. <view
  29. class="tag"
  30. :class="{ 'active-tag': selectedCustomTags.includes(tag) }"
  31. v-for="(tag, index) in customTags"
  32. :key="'custom-' + index"
  33. @click="toggleCustomTag(tag)"
  34. >{{ tag }}<text class="delete-tag" @click.stop="deleteCustomTag(index)">×</text></view>
  35. <view class="tag custom-tag" @click="showAddDialog">
  36. 添加<image class="add-icon" src="@/static/images/my/my/add.svg" mode="aspectFix" />
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="fixed-button">
  42. <view class="button" @click="goJobPostingSecond">保存</view>
  43. </view>
  44. <!-- 添加标签弹框 -->
  45. <c-modal :value="showDialog" title="添加标签" @confirm="confirmAddTag" @cancel="cancelAddTag">
  46. <view class="dialog-content">
  47. <u-input v-model="tempTag" type="text" :border="true" :clearable="true" input-align="left"
  48. placeholder="请输入标签内容, 最多输入20个字符" maxlength="20" @confirm="confirmAddTag" />
  49. </view>
  50. </c-modal>
  51. </view>
  52. </template>
  53. <script>
  54. import navBar from "@/components/nav-bar/index.vue";
  55. import cModal from '@/components/c-modal.vue'
  56. export default {
  57. data() {
  58. return {
  59. loading: false,
  60. companyId: '',
  61. // 主营产品列表
  62. productList: [
  63. "3C数码",
  64. "美妆日化",
  65. "智能家居",
  66. "宠物相机",
  67. "监控摄像头",
  68. "家装产品",
  69. "耗材",
  70. "装修材料",
  71. "卫浴产品",
  72. ],
  73. // 选中的产品
  74. selectedProducts: [],
  75. // 自定义标签列表
  76. customTags: [],
  77. // 选中的自定义标签
  78. selectedCustomTags: [],
  79. // 弹框显示控制
  80. showDialog: false,
  81. // 临时标签输入
  82. tempTag: ""
  83. };
  84. },
  85. components: {
  86. navBar,
  87. cModal
  88. },
  89. onLoad(options) {
  90. this.getCompanyInfo()
  91. },
  92. methods: {
  93. toNext() {
  94. uni.redirectTo({
  95. url: '/my/renzheng/companyImg'
  96. })
  97. },
  98. // 获取公司信息
  99. getCompanyInfo() {
  100. uni.showLoading({ title: '加载中' })
  101. this.$Request.get('/app/company/selectCompanyByUserId')
  102. .then((res) => {
  103. if (res.code != 0) {
  104. uni.showToast({
  105. title: res.msg || '查询状态失败',
  106. icon: 'none'
  107. });
  108. return
  109. }
  110. this.companyId = res.data.companyId
  111. this.processCompanyScope(res.data.companyScope);
  112. uni.hideLoading()
  113. })
  114. .catch((err) => {
  115. uni.hideLoading()
  116. uni.showToast({
  117. title: '网络异常',
  118. icon: 'none'
  119. })
  120. })
  121. },
  122. // 处理业务范围数据
  123. processCompanyScope(scopeString) {
  124. if (!scopeString) return;
  125. // 处理字符串:替换中文逗号,分割,过滤空值
  126. const scopeItems = scopeString
  127. .replace(/,/g, ',')
  128. .split(',')
  129. .map(item => item.trim())
  130. .filter(item => item);
  131. console.log('解析后的业务范围:', scopeItems);
  132. // 清空当前选择
  133. this.selectedProducts = [];
  134. this.customTags = [];
  135. this.selectedCustomTags = [];
  136. // 分离标准产品和自定义标签
  137. scopeItems.forEach(item => {
  138. if (this.productList.includes(item)) {
  139. // 是标准产品
  140. this.selectedProducts.push(item);
  141. } else {
  142. // 是自定义标签
  143. this.customTags.push(item);
  144. this.selectedCustomTags.push(item); // 自定义标签默认都是选中的
  145. }
  146. });
  147. },
  148. // 切换产品选择
  149. toggleProduct(product) {
  150. const index = this.selectedProducts.indexOf(product);
  151. if (index > -1) {
  152. this.selectedProducts.splice(index, 1);
  153. } else {
  154. this.selectedProducts.push(product);
  155. }
  156. },
  157. // 显示添加标签弹框
  158. showAddDialog() {
  159. this.tempTag = "";
  160. this.showDialog = true;
  161. },
  162. // 确认添加标签
  163. confirmAddTag() {
  164. if (this.tempTag.trim() === "") {
  165. uni.showToast({
  166. title: "请输入标签内容",
  167. icon: "none",
  168. });
  169. return;
  170. }
  171. if (this.customTags.includes(this.tempTag.trim())) {
  172. uni.showToast({
  173. title: "标签已存在",
  174. icon: "none",
  175. });
  176. return;
  177. }
  178. // 检查是否与标准产品重复
  179. if (this.productList.includes(this.tempTag.trim())) {
  180. uni.showToast({
  181. title: "该标签已存在于主营产品列表中",
  182. icon: "none",
  183. });
  184. return;
  185. }
  186. const newTag = this.tempTag.trim();
  187. this.customTags.push(newTag);
  188. this.selectedCustomTags.push(newTag); // 新增的自定义标签默认选中
  189. this.showDialog = false;
  190. this.tempTag = "";
  191. },
  192. // 取消添加标签
  193. cancelAddTag() {
  194. this.showDialog = false;
  195. this.tempTag = "";
  196. },
  197. // 切换自定义标签选择
  198. toggleCustomTag(tag) {
  199. const index = this.selectedCustomTags.indexOf(tag);
  200. if (index > -1) {
  201. this.selectedCustomTags.splice(index, 1);
  202. } else {
  203. this.selectedCustomTags.push(tag);
  204. }
  205. },
  206. // 删除自定义标签
  207. deleteCustomTag(index) {
  208. const tag = this.customTags[index];
  209. // 如果这个标签被选中了,先从选中列表中移除
  210. const selectedIndex = this.selectedCustomTags.indexOf(tag);
  211. if (selectedIndex > -1) {
  212. this.selectedCustomTags.splice(selectedIndex, 1);
  213. }
  214. // 删除标签
  215. this.customTags.splice(index, 1);
  216. },
  217. goJobPostingSecond() {
  218. if (this.loading) return
  219. // 获取所有选中的标签
  220. const allSelectedTags = [...this.selectedProducts, ...this.selectedCustomTags];
  221. if (allSelectedTags.length === 0) {
  222. uni.showToast({
  223. title: "请至少选择一个业务标签",
  224. icon: "none",
  225. });
  226. return;
  227. }
  228. console.log("选中的业务标签:", allSelectedTags);
  229. this.loading = true
  230. uni.showLoading({ title: '保存中' })
  231. let companyData = {
  232. companyId: this.companyId,
  233. companyScope: allSelectedTags.join(',')
  234. }
  235. this.$Request.postJson('/app/company/updateCompany', companyData)
  236. .then(res => {
  237. if (res.code == 0) {
  238. uni.showToast({
  239. title: '提交成功',
  240. duration: 1500,
  241. });
  242. setTimeout(() => {
  243. uni.$emit('updateCompanyInfo')
  244. uni.navigateBack()
  245. }, 500)
  246. }
  247. this.loading = false
  248. uni.hideLoading()
  249. })
  250. .catch(() => {
  251. this.loading = false
  252. uni.hideLoading()
  253. })
  254. },
  255. },
  256. };
  257. </script>
  258. <style lang="scss" scoped>
  259. @import './company.scss';
  260. .delete-tag {
  261. margin-left: 6rpx;
  262. }
  263. .add-icon {
  264. width: 16rpx;
  265. height: 16rpx;
  266. margin-left: 8rpx;
  267. }
  268. .custom-tag {
  269. color: rgba(1, 107, 246, 1) !important;
  270. }
  271. .dialog-content {
  272. padding-top: 20rpx;
  273. }
  274. </style>