瑶都万能墙
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

516 lines
11 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
10 months ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
11 months ago
11 months ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
11 months ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
11 months ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
1 year ago
  1. <template>
  2. <view class="page">
  3. <navbar :title="isEdit ? '编辑招工' : '发布招工'" leftClick @leftClick="$utils.navigateBack" />
  4. <view class="form">
  5. <view class="help-issue">
  6. <text>招工标题</text>
  7. <text style="color: #BD3624;">*</text>
  8. </view>
  9. <view class="form-sheet-cell">
  10. <input type="text"
  11. v-model="form.title"
  12. class="title-input"/>
  13. </view>
  14. <!-- <uv-cell
  15. title="学历要求"
  16. rightIconStyle="fontSize: 30rpx;"
  17. :value="form.school || '请选择学历要求'"
  18. @click="openPicker('school')"
  19. isLink
  20. ></uv-cell> -->
  21. <!-- <uv-cell
  22. title="工作地点"
  23. rightIconStyle="fontSize: 30rpx;"
  24. :value="form.address || '请选择招工地点'"
  25. @click="selectAddr"
  26. isLink
  27. ></uv-cell> -->
  28. <uv-cell
  29. title="工龄要求"
  30. rightIconStyle="fontSize: 30rpx;"
  31. :value="form.workYear || '请选择工龄要求'"
  32. @click="openPicker('workYear')"
  33. isLink
  34. ></uv-cell>
  35. <!-- <view class="form-sheet-cell">
  36. <view class="label">
  37. 薪资范围
  38. </view>
  39. <view class="price">
  40. <input placeholder="最小薪资" v-model="form.minPrice" />
  41. ~
  42. <input placeholder="最大薪资" v-model="form.maxPrice" />
  43. </view>
  44. </view> -->
  45. <view class="form-sheet-cell">
  46. <view class="label">
  47. 招聘公司
  48. </view>
  49. <input placeholder="请输入招聘公司" v-model="form.company" />
  50. </view>
  51. <view class="form-sheet-cell">
  52. <view class="label">
  53. 薪资范围
  54. </view>
  55. <input placeholder="请输入薪资范围" v-model="form.minPrice" />
  56. </view>
  57. <!-- <view class="form-sheet-cell">
  58. <view class="label">
  59. 结算方式
  60. </view>
  61. <uv-radio-group v-model="radiovalue">
  62. <view class="price">
  63. <uv-radio
  64. :customStyle="{margin: '8px'}"
  65. v-for="(item, index) in priceList"
  66. :key="index"
  67. iconSize="30rpx"
  68. size="40rpx"
  69. labelSize="26rpx"
  70. :label="item.name"
  71. :name="item.name">
  72. </uv-radio>
  73. </view>
  74. </uv-radio-group>
  75. </view>
  76. <view class="form-sheet-cell">
  77. <view class="label">
  78. 工作性质
  79. </view>
  80. <uv-radio-group v-model="radiovalue">
  81. <view class="price">
  82. <uv-radio
  83. :customStyle="{margin: '8px'}"
  84. v-for="(item, index) in jopList"
  85. :key="index"
  86. iconSize="30rpx"
  87. size="40rpx"
  88. labelSize="26rpx"
  89. :label="item.name"
  90. :name="item.name">
  91. </uv-radio>
  92. </view>
  93. </uv-radio-group>
  94. </view> -->
  95. <view class="form-sheet-cell">
  96. <view class="label">
  97. 标签
  98. </view>
  99. <input placeholder="请输入标签(多个用,号分割)" v-model="form.iconText" />
  100. </view>
  101. <!-- <view class="form-sheet-cell">
  102. <view class="label">
  103. 联系人
  104. </view>
  105. <input placeholder="请输入联系人" v-model="form.userName" />
  106. </view> -->
  107. <view class="form-sheet-cell">
  108. <view class="label">
  109. 联系人
  110. </view>
  111. <input placeholder="请输入联系人" v-model="form.userName" />
  112. </view>
  113. <view class="form-sheet-cell">
  114. <view class="label">
  115. 联系电话
  116. </view>
  117. <input placeholder="请输入联系电话" v-model="form.userPhone" />
  118. </view>
  119. <view class="category">
  120. <view class="title">
  121. 选择地区
  122. </view>
  123. <view class="tagList">
  124. <view
  125. :class="{act : t.id == form.addId}"
  126. @click="form.addId = t.id"
  127. v-for="(t, i) in cityList"
  128. :key="i">
  129. {{ t.name }}
  130. </view>
  131. </view>
  132. </view>
  133. <view class=""
  134. style="margin-top: 20rpx;">
  135. <uv-textarea
  136. v-model="form.jobContext"
  137. count
  138. :maxlength="300"
  139. autoHeight
  140. placeholder="请输入职位描述"></uv-textarea>
  141. </view>
  142. <view class=""
  143. style="margin-top: 20rpx;">
  144. <uv-textarea
  145. v-model="form.school"
  146. count
  147. :maxlength="300"
  148. autoHeight
  149. placeholder="请输入岗位要求"></uv-textarea>
  150. </view>
  151. <view class=""
  152. style="margin-top: 20rpx;">
  153. <uv-textarea
  154. v-model="form.jobDetails"
  155. count
  156. :maxlength="300"
  157. autoHeight
  158. placeholder="请输入岗位详细介绍"></uv-textarea>
  159. </view>
  160. <view class=""
  161. style="margin-top: 20rpx;">
  162. <uv-textarea
  163. v-model="form.gsContext"
  164. count
  165. :maxlength="300"
  166. autoHeight
  167. placeholder="请输入公司介绍"></uv-textarea>
  168. </view>
  169. <view class="uni-color-btn"
  170. @click="submit">
  171. {{ isEdit ? '保存修改' : '发布' }}
  172. </view>
  173. <!-- 编辑模式下显示删除按钮 -->
  174. <view v-if="isEdit" class="delete-btn"
  175. @click="deleteJob">
  176. 删除招工
  177. </view>
  178. </view>
  179. <uv-picker ref="picker"
  180. :columns="columns"
  181. @confirm="pickerConfirm"></uv-picker>
  182. </view>
  183. </template>
  184. <script>
  185. import { mapState } from 'vuex'
  186. import { subscribeBeforePublish } from '@/utils/subscribeMessage.js'
  187. export default {
  188. data() {
  189. return {
  190. jobId: '', // 工作ID,用于编辑模式
  191. isEdit: false, // 是否为编辑模式
  192. form : {
  193. title: '', // 招工标题
  194. school : '', // 岗位要求
  195. workYear : '', // 工龄要求
  196. minPrice : '', // 薪资范围
  197. maxPrice : '', // 最大薪资(保留字段)
  198. address : '', // 工作地点(保留字段)
  199. addId : '', // 地区ID
  200. company : '', // 招聘公司
  201. gsContext : '', // 公司介绍
  202. jobContext : '', // 职位描述
  203. jobDetails: '', // 岗位详细介绍
  204. iconText: '', // 标签
  205. userName: '', // 联系人
  206. userPhone: '', // 联系电话
  207. },
  208. radiovalue : '',
  209. priceList : [
  210. {
  211. name : '日结',
  212. },
  213. {
  214. name : '月结',
  215. },
  216. ],
  217. jopList : [
  218. {
  219. name : '正式工',
  220. },
  221. {
  222. name : '临时工',
  223. },
  224. ],
  225. picker : {
  226. workYear : [
  227. '不限',
  228. ],
  229. school : [
  230. '不限',
  231. '初中',
  232. '高中',
  233. '专科',
  234. '本科',
  235. '研究生',
  236. '博士',
  237. ],
  238. },
  239. pickerKey : 'workYear',
  240. }
  241. },
  242. onLoad(options) {
  243. // 初始化工龄选项
  244. for (var i = 0; i < 30; i++) {
  245. this.picker.workYear.push((i + 1) + '年')
  246. }
  247. // 检查是否是编辑模式
  248. if (options.id) {
  249. this.jobId = options.id
  250. this.isEdit = true
  251. this.getJobDetail()
  252. } else {
  253. // 新增模式,设置默认地区
  254. if (this.cityList && this.cityList.length > 0) {
  255. this.form.addId = this.cityList[0].id
  256. }
  257. }
  258. },
  259. computed : {
  260. columns(){
  261. return [this.picker[this.pickerKey]]
  262. },
  263. ...mapState(['cityList', 'category']),
  264. },
  265. watch: {
  266. // 监听cityList变化,用于处理异步加载的城市数据
  267. cityList: {
  268. handler(newVal) {
  269. if (newVal && newVal.length > 0 && !this.isEdit && !this.form.addId) {
  270. this.form.addId = newVal[0].id
  271. }
  272. },
  273. immediate: true
  274. }
  275. },
  276. methods: {
  277. // 获取工作详情数据
  278. getJobDetail() {
  279. this.$api('getJobDetail', { id: this.jobId }, res => {
  280. if (res.code == 200) {
  281. const data = res.result
  282. // 回显基本信息
  283. this.form = {
  284. ...this.form,
  285. title: data.title || '',
  286. school: data.school || '',
  287. workYear: data.workYear || '',
  288. minPrice: data.minPrice || '',
  289. maxPrice: data.maxPrice || '',
  290. address: data.address || '',
  291. addId: data.addId || (this.cityList.length > 0 ? this.cityList[0].id : ''),
  292. company: data.company || '',
  293. gsContext: data.gsContext || '',
  294. jobContext: data.jobContext || '',
  295. jobDetails: data.jobDetails || '',
  296. iconText: data.iconText || '',
  297. userName: data.userName || '',
  298. userPhone: data.userPhone || '',
  299. }
  300. } else {
  301. uni.showToast({
  302. title: res.msg || '获取工作信息失败',
  303. icon: 'none'
  304. })
  305. }
  306. })
  307. },
  308. openPicker(key){
  309. this.pickerKey = key
  310. this.$refs.picker.open()
  311. },
  312. pickerConfirm(e){
  313. this.form[this.pickerKey] = e.value[0]
  314. },
  315. // 提交
  316. async submit(){
  317. if (this.$utils.verificationAll(this.form, {
  318. title: '请输入招工标题',
  319. workYear : '请选择工龄要求',
  320. company : '请输入招聘公司',
  321. minPrice : '请输入薪资范围',
  322. iconText: '请输入标签',
  323. userName: '请输入联系人',
  324. userPhone: '请输入联系电话',
  325. jobContext : '请输入职位描述',
  326. school : '请输入岗位要求',
  327. jobDetails: '请输入岗位详细介绍',
  328. gsContext : '请输入公司介绍',
  329. })) {
  330. return
  331. }
  332. // 只有在新发布时才订阅消息通知,编辑时不需要
  333. if (!this.isEdit) {
  334. await subscribeBeforePublish()
  335. }
  336. // 根据是否是编辑模式调用不同的API
  337. const apiName = this.isEdit ? 'editMyJob' : 'publishJob'
  338. const params = this.isEdit ? { ...this.form, id: this.jobId } : this.form
  339. this.$api(apiName, params, res => {
  340. if(res.code == 200){
  341. uni.showToast({
  342. title: this.isEdit ? '修改成功!' : '发布成功!',
  343. icon: 'none'
  344. })
  345. setTimeout(() => {
  346. uni.navigateBack()
  347. }, 1000)
  348. } else {
  349. uni.showToast({
  350. title: res.msg || (this.isEdit ? '修改失败' : '发布失败'),
  351. icon: 'none'
  352. })
  353. }
  354. })
  355. },
  356. // 删除招工
  357. deleteJob() {
  358. uni.showModal({
  359. title: '确认删除',
  360. content: '确定要删除这个招工信息吗?删除后无法恢复。',
  361. confirmColor: '#ff4757',
  362. success: (res) => {
  363. if (res.confirm) {
  364. this.$api('deleteMyJob', { id: this.jobId }, res => {
  365. if (res.code == 200) {
  366. uni.showToast({
  367. title: '删除成功!',
  368. icon: 'none'
  369. })
  370. setTimeout(() => {
  371. uni.navigateBack()
  372. }, 1000)
  373. } else {
  374. uni.showToast({
  375. title: res.msg || '删除失败',
  376. icon: 'none'
  377. })
  378. }
  379. })
  380. }
  381. }
  382. })
  383. },
  384. }
  385. }
  386. </script>
  387. <style scoped lang="scss">
  388. .page{
  389. background-color: #fff;
  390. min-height: 100vh;
  391. box-sizing: border-box;
  392. color: #333333;
  393. font-size: 28rpx;
  394. /deep/ text{
  395. font-size: 28rpx !important;
  396. }
  397. input{
  398. width: 450rpx;
  399. }
  400. .form{
  401. padding: 30rpx;
  402. .help-issue {
  403. margin: 20rpx;
  404. }
  405. .title-input{
  406. border: 1px solid $uni-color;
  407. width: 100%;
  408. border-radius: 10rpx;
  409. padding: 10rpx 20rpx;
  410. box-sizing: border-box;
  411. height: 65rpx;
  412. }
  413. .form-sheet-cell{
  414. display: flex;
  415. background-color: #fff;
  416. padding: 20rpx 30rpx;
  417. align-items: center;
  418. .label{
  419. width: 160rpx;
  420. }
  421. .price{
  422. display: flex;
  423. text-align: center;
  424. input{
  425. width: 150rpx;
  426. border: 1px solid $uni-color;
  427. margin: 0 10rpx;
  428. }
  429. }
  430. .right-icon{
  431. margin-left: auto;
  432. }
  433. }
  434. }
  435. .category{
  436. padding: 20rpx;
  437. .title{
  438. // font-weight: 900;
  439. // font-size: 30rpx;
  440. }
  441. .tagList{
  442. display: flex;
  443. flex-wrap: wrap;
  444. padding: 10rpx 0;
  445. view{
  446. background: rgba($uni-color, 0.1);
  447. padding: 10rpx 20rpx;
  448. margin: 10rpx;
  449. border-radius: 10rpx;
  450. font-size: 26rpx;
  451. }
  452. .act{
  453. color: #fff;
  454. background: $uni-color;
  455. }
  456. }
  457. }
  458. .delete-btn {
  459. background: #ff4757;
  460. color: white;
  461. text-align: center;
  462. padding: 20rpx;
  463. margin: 30rpx;
  464. border-radius: 40rpx;
  465. font-size: 28rpx;
  466. font-weight: bold;
  467. &:active {
  468. background: #ff3742;
  469. }
  470. }
  471. }
  472. </style>