用工小程序前端代码
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.

429 lines
12 KiB

11 months ago
9 months ago
11 months ago
9 months ago
11 months ago
8 months ago
8 months ago
11 months ago
9 months ago
11 months ago
8 months ago
11 months ago
9 months ago
11 months ago
8 months ago
11 months ago
8 months ago
11 months ago
11 months ago
11 months ago
11 months ago
8 months ago
11 months ago
8 months ago
11 months ago
9 months ago
8 months ago
8 months ago
9 months ago
11 months ago
8 months ago
11 months ago
9 months ago
11 months ago
8 months ago
11 months ago
8 months ago
9 months ago
8 months ago
11 months ago
8 months ago
8 months ago
9 months ago
11 months ago
9 months ago
11 months ago
8 months ago
9 months ago
11 months ago
9 months ago
11 months ago
9 months ago
11 months ago
9 months ago
11 months ago
9 months ago
11 months ago
9 months ago
11 months ago
9 months ago
11 months ago
9 months ago
11 months ago
8 months ago
8 months ago
8 months ago
11 months ago
8 months ago
9 months ago
11 months ago
9 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
11 months ago
9 months ago
11 months ago
9 months ago
11 months ago
9 months ago
11 months ago
11 months ago
9 months ago
11 months ago
  1. <template>
  2. <view>
  3. <u--form labelPosition="left" :model="form" :rules="rules" ref="uForm" labelWidth="80">
  4. <view class="se-p-20">
  5. <view class="se-p-20 se-bgc-white se-br-10 se-fs-20">
  6. <u-form-item label="姓名" prop="name">
  7. <u--input v-model="form.name" class="se-bgc-f5" placeholder="请输入姓名名称"></u--input>
  8. </u-form-item>
  9. <!-- <u-form-item label="密码" prop="password">
  10. <u--input v-model="form.password" class="se-bgc-f5" placeholder="请输入您的密码"></u--input>
  11. </u-form-item> -->
  12. <u-form-item label="联系电话" prop="mobile">
  13. <u--input v-model="form.mobile" class="se-bgc-f5" placeholder="请输入联系方式"></u--input>
  14. </u-form-item>
  15. <u-form-item label="年龄" prop="age">
  16. <u--input v-model="form.age" class="se-bgc-f5" placeholder="请输入年龄"></u--input>
  17. </u-form-item>
  18. <u-form-item label="民族" prop="nation">
  19. <u--input v-model="form.nation" class="se-bgc-f5" placeholder="请输入民族"></u--input>
  20. </u-form-item>
  21. <u-form-item label="地址" prop="address">
  22. <u--input v-model="form.address" class="se-bgc-f5" placeholder="请输入地址"></u--input>
  23. </u-form-item>
  24. <u-form-item label="性别" prop="sex" @click="handleSexChange">
  25. <u--input @click="handleSexChange" readonly v-model="form.sex" placeholder="请选择性别"
  26. border="none"></u--input>
  27. <u-icon @click="handleSexChange" slot="right" name="arrow-right"></u-icon>
  28. </u-form-item>
  29. <u-form-item label="工种" prop="industryId" @click="handleIndChange">
  30. <u--input v-model="form.industryName" readonly placeholder="请选择工种" border="none"></u--input>
  31. <u-icon slot="right" name="arrow-right"></u-icon>
  32. </u-form-item>
  33. <u-form-item label="薪资待遇" prop="salary">
  34. <view class="se-flex se-flex-h-c">
  35. <u--input v-model="form.salaryMin" class="se-w-200" placeholder="最小值"></u--input>
  36. <text class="se-mx-10">~</text>
  37. <u--input v-model="form.salaryMax" class="se-w-200" placeholder="最大值"></u--input>
  38. </view>
  39. </u-form-item>
  40. <u-form-item label="个人介绍" prop="introduce">
  41. <u--textarea v-model="form.introduce" height="100" count maxlength="300" class="se-bgc-f5"
  42. placeholder="请选择个人介绍"></u--textarea>
  43. </u-form-item>
  44. </view>
  45. </view>
  46. <view class="se-p-20">
  47. <view class="se-px-20 se-pb-20 se-bgc-white se-br-10 se-fs-20">
  48. <u-form-item prop="idCardFile" labelWidth="2">
  49. <view class="se-flex se-flex-v-sa">
  50. <view class="se-py-20 se-w-p-100 se-flex">
  51. <view class="line-orange"></view>
  52. <view class="se-ml-10">
  53. 个人照片
  54. </view>
  55. </view>
  56. <view class="se-py-20 se-w-p-100">
  57. <u-upload :fileList="form.idCardFile" @afterRead="afterRead" @delete="deletePic" name="1" multiple :maxCount="10"></u-upload>
  58. </view>
  59. </view>
  60. </u-form-item>
  61. </view>
  62. </view>
  63. <view class="se-px-20 se-pt-20">
  64. <view class="se-px-20 se-pb-80 se-fs-20 se-flex">
  65. <view @click="submit" class="se-mx-10 se-flex-1 se-br-40 se-flex-h-c se-h-60 se-lh-60 se-ta-c se-fs-28 se-c-white se-bgc-orange">
  66. <text>保存</text>
  67. </view>
  68. <!-- <view
  69. class="se-mx-10 se-flex-1 se-b se-br-40 se-flex-h-c se-h-60 se-lh-60 se-ta-c se-fs-28 se-c-66 se-bgc-f5">
  70. <text>联系我们</text>
  71. </view> -->
  72. </view>
  73. </view>
  74. </u--form>
  75. <!-- 性别 -->
  76. <u-action-sheet :show="showSex" :actions="sexList" title="请选择性别" @close="showSex = false" @select="sexSelect"></u-action-sheet>
  77. <!-- 种类 -->
  78. <u-action-sheet :show="showType" :actions="typeList" title="请选择种类" @close="showType = false" @select="typeSelect"></u-action-sheet>
  79. </view>
  80. </template>
  81. <script>
  82. import {
  83. role,
  84. industryList,
  85. updateRole,
  86. queryResumeById,
  87. updateResume,
  88. addResume
  89. } from "@/common/api.js"
  90. export default {
  91. data() {
  92. return {
  93. showSex: false,
  94. callback: '', // 回调类型
  95. callbackStatus: '', // 回调状态参数
  96. sexList: [
  97. {
  98. name: '男',
  99. },
  100. {
  101. name: '女',
  102. }
  103. ],
  104. showType: false,
  105. typeList: [],
  106. fileList: [],
  107. form: {
  108. id:"",
  109. name: '',
  110. password: '',
  111. mobile: '',
  112. address:"",
  113. age: '',
  114. sex: '',
  115. industryId: '',
  116. industryName: "",
  117. salary: '',
  118. salaryMin: '',
  119. salaryMax: '',
  120. introduce: '',
  121. idCardFile: []
  122. },
  123. rules: {
  124. name: [{
  125. type: 'string',
  126. required: true,
  127. message: '请输入姓名名称',
  128. trigger: ['blur', 'change']
  129. }],
  130. nation: [{
  131. type: 'string',
  132. required: true,
  133. message: '请输入民族',
  134. trigger: ['blur', 'change']
  135. }],
  136. industryId: [{
  137. type: 'string',
  138. required: true,
  139. message: '请选择行业',
  140. trigger: ['blur', 'change']
  141. }],
  142. address:[
  143. {
  144. type: 'string',
  145. required: true,
  146. message: '请选择地址',
  147. trigger: ['blur', 'change']
  148. }
  149. ],
  150. // password: [{
  151. // type: 'string',
  152. // required: true,
  153. // message: '请输入您的密码',
  154. // trigger: ['blur', 'change']
  155. // }],
  156. mobile: [{
  157. required: true,
  158. message: '请输入手机号',
  159. trigger: ['change', 'blur'],
  160. },
  161. {
  162. validator: (rule, value, callback) => {
  163. return uni.$u.test.mobile(value);
  164. },
  165. message: '手机号码不正确',
  166. trigger: ['change', 'blur'],
  167. },
  168. ],
  169. age: [{
  170. validator: (rule, value, callback) => {
  171. if (!value) {
  172. callback(new Error('年龄不能为空'));
  173. } else if (isNaN(value)) {
  174. callback(new Error('请输入数字'));
  175. } else if (value < 18 || value > 65) {
  176. callback(new Error('年龄必须在18至65岁之间'));
  177. } else {
  178. callback(); // 验证通过
  179. }
  180. },
  181. trigger: 'blur',
  182. }],
  183. sex: [{
  184. type: 'string',
  185. max: 1,
  186. required: true,
  187. message: '请选择性别',
  188. trigger: ['blur', 'change']
  189. }],
  190. salary: [{
  191. type: 'string',
  192. required: true,
  193. message: '请输入薪资待遇',
  194. trigger: ['blur', 'change']
  195. }],
  196. introduce: [{
  197. type: 'string',
  198. required: true,
  199. message: '请输入个人简介',
  200. trigger: ['blur', 'change']
  201. }],
  202. idCardFile: [{
  203. validator: (rule, value, callback) => {
  204. if (value === null || value === undefined || value === '' || (Array.isArray(
  205. value) && value.length === 0)) {
  206. callback(new Error('请选择身份证'));
  207. } else {
  208. callback();
  209. }
  210. },
  211. trigger: 'blur'
  212. }]
  213. },
  214. }
  215. },
  216. watch: {
  217. 'form.salaryMin': {
  218. handler(newVal, oldVal) {
  219. if (!uni.$u.test.isEmpty(newVal) && !uni.$u.test.isEmpty(this.form.salaryMax)) {
  220. this.form.salary = '有'
  221. } else {
  222. this.form.salary = ''
  223. }
  224. },
  225. immediate: true
  226. },
  227. 'form.salaryMax': {
  228. handler(newVal, oldVal) {
  229. if (!uni.$u.test.isEmpty(newVal) && !uni.$u.test.isEmpty(this.form.salaryMin)) {
  230. this.form.salary = '有'
  231. } else {
  232. this.form.salary = ''
  233. }
  234. },
  235. immediate: true
  236. }
  237. },
  238. mounted() {
  239. // let worker = uni.getStorageSync("worker")
  240. let params = {}
  241. queryResumeById(params).then(response=>{
  242. let worker = response.result;
  243. if(worker){
  244. this.form.id = worker.id
  245. this.form.name = worker.name
  246. this.form.mobile = worker.phone
  247. this.form.age = worker.age
  248. this.form.sex = worker.sex==1?'男':'女'
  249. this.form.nation = worker.nation
  250. this.form.introduce = worker.brief
  251. this.form.address = worker.address
  252. this.form.industryId = worker.categoryOne
  253. this.form.industryName = worker.categoryOneName
  254. this.form.salaryMin = worker.salaryMin
  255. this.form.salaryMax = worker.salaryMax
  256. this.form.idCardFile = this.stringToKeyValueArray(worker.headImage)
  257. }
  258. })
  259. },
  260. methods: {
  261. stringToKeyValueArray(str, delimiter1 = ',') {
  262. if(str){
  263. let arro = str.split(delimiter1);
  264. let arr = [];
  265. arro.forEach(items=>{
  266. let obj = {};
  267. obj["url"] = items
  268. arr.push(obj)
  269. })
  270. console.info(arr)
  271. return arr
  272. }else{
  273. return []
  274. }
  275. },
  276. handleIndChange() {
  277. this.showType = true
  278. },
  279. typeSelect(event) {
  280. console.info("selectIndClick", event)
  281. this.form.industryId = event.id
  282. this.form.industryName = event.name
  283. this.showType = false
  284. },
  285. onIndustryList() {
  286. industryList({}).then(response => {
  287. console.info(response)
  288. this.typeList = response.result
  289. }).catch(error => {
  290. })
  291. },
  292. handleSexChange() {
  293. this.showSex = true
  294. },
  295. sexSelect(e) {
  296. this.form.sex = e.name
  297. this.$refs.uForm.validateField('sex')
  298. },
  299. onRole() {
  300. let that = this
  301. if(this.form.id){
  302. let params = {
  303. "id": that.form.id,
  304. "name": that.form.name,
  305. "categoryOne": that.form.industryId,
  306. "categoryOneName": that.form.industryName,
  307. "address":that.form.address,
  308. "nation": that.form.nation,
  309. "age": that.form.age,
  310. "sex": that.form.sex=="男"?1:2,
  311. "salaryMin": that.form.salaryMin,
  312. "salaryMax": that.form.salaryMax,
  313. "phone": that.form.mobile,
  314. "brief": that.form.introduce,
  315. "headImage": that.form.idCardFile.map(item => item.url).join(','),
  316. }
  317. updateResume(params).then(response=>{
  318. uni.$u.toast("保存成功!")
  319. setTimeout(()=>{
  320. // 根据回调参数决定跳转页面
  321. if (this.callback === 'release' && this.callbackStatus) {
  322. // 跳转到发布页面
  323. uni.navigateTo({
  324. url: "/pages_subpack/release/index?status=" + this.callbackStatus
  325. })
  326. } else {
  327. // 默认返回上一页
  328. uni.navigateBack({
  329. delta:1
  330. })
  331. }
  332. },1500)
  333. }).catch(error=>{
  334. })
  335. }else{
  336. let params = {
  337. "name": that.form.name,
  338. "categoryOne": that.form.industryId,
  339. "categoryOneName": that.form.industryName,
  340. "address":that.form.address,
  341. "age": that.form.age,
  342. "nation": that.form.nation,
  343. "sex": that.form.sex=="男"?1:2,
  344. "salaryMin": that.form.salaryMin,
  345. "salaryMax": that.form.salaryMax,
  346. "phone": that.form.mobile,
  347. "brief": that.form.introduce,
  348. "headImage": that.form.idCardFile.map(item => item.url).join(','),
  349. }
  350. addResume(params).then(response => {
  351. uni.$u.toast("提交成功,等待申请")
  352. setTimeout(()=>{
  353. // 根据回调参数决定跳转页面
  354. if (this.callback === 'release' && this.callbackStatus) {
  355. // 跳转到发布页面
  356. uni.navigateTo({
  357. url: "/pages_subpack/release/index?status=" + this.callbackStatus
  358. })
  359. } else {
  360. // 默认跳转到首页
  361. uni.switchTab({
  362. url:"/pages/home/index"
  363. })
  364. }
  365. },1500)
  366. }).catch(error => {
  367. setTimeout(()=>{
  368. uni.switchTab({
  369. url:"/pages/home/index"
  370. })
  371. },1500)
  372. })
  373. }
  374. },
  375. submit() {
  376. this.$refs.uForm.validate().then(res => {
  377. this.onRole()
  378. }).catch(errors => {
  379. // uni.$u.toast('校验失败')
  380. })
  381. },
  382. deletePic(event) {
  383. this.form.idCardFile.splice(e.index, 1)
  384. },
  385. async afterRead(e) {
  386. let self = this
  387. e.file.forEach(file => {
  388. self.$Oss.ossUpload(file.url).then(url => {
  389. self.form.idCardFile.push({
  390. url
  391. })
  392. })
  393. })
  394. }
  395. },
  396. onLoad(options) {
  397. // 接收页面参数
  398. if (options.callback) {
  399. this.callback = options.callback
  400. }
  401. if (options.status) {
  402. this.callbackStatus = options.status
  403. }
  404. },
  405. onReady() {
  406. this.onIndustryList()
  407. this.$refs.uForm.setRules(this.rules)
  408. },
  409. }
  410. </script>
  411. <style lang="scss" scoped>
  412. page {
  413. background-color: #f5f5f5 !important;
  414. }
  415. .line-orange {
  416. width: 8rpx;
  417. height: 32rpx;
  418. background: #ff7a31;
  419. border-radius: 4rpx;
  420. }
  421. </style>