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

400 lines
11 KiB

6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
3 months ago
3 months ago
6 months ago
4 months ago
6 months ago
3 months ago
6 months ago
4 months ago
6 months ago
3 months ago
6 months ago
3 months ago
6 months ago
6 months ago
6 months ago
6 months ago
3 months ago
6 months ago
3 months ago
6 months ago
4 months ago
3 months ago
3 months ago
4 months ago
6 months ago
3 months ago
6 months ago
4 months ago
6 months ago
3 months ago
6 months ago
3 months ago
4 months ago
3 months ago
6 months ago
3 months ago
4 months ago
6 months ago
4 months ago
6 months ago
3 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
3 months ago
3 months ago
3 months ago
6 months ago
3 months ago
4 months ago
6 months ago
4 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 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. sexList: [
  95. {
  96. name: '男',
  97. },
  98. {
  99. name: '女',
  100. }
  101. ],
  102. showType: false,
  103. typeList: [],
  104. fileList: [],
  105. form: {
  106. id:"",
  107. name: '',
  108. password: '',
  109. mobile: '',
  110. address:"",
  111. age: '',
  112. sex: '',
  113. industryId: '',
  114. industryName: "",
  115. salary: '',
  116. salaryMin: '',
  117. salaryMax: '',
  118. introduce: '',
  119. idCardFile: []
  120. },
  121. rules: {
  122. name: [{
  123. type: 'string',
  124. required: true,
  125. message: '请输入姓名名称',
  126. trigger: ['blur', 'change']
  127. }],
  128. nation: [{
  129. type: 'string',
  130. required: true,
  131. message: '请输入名族',
  132. trigger: ['blur', 'change']
  133. }],
  134. industryId: [{
  135. type: 'string',
  136. required: true,
  137. message: '请选择行业',
  138. trigger: ['blur', 'change']
  139. }],
  140. address:[
  141. {
  142. type: 'string',
  143. required: true,
  144. message: '请选择地址',
  145. trigger: ['blur', 'change']
  146. }
  147. ],
  148. // password: [{
  149. // type: 'string',
  150. // required: true,
  151. // message: '请输入您的密码',
  152. // trigger: ['blur', 'change']
  153. // }],
  154. mobile: [{
  155. required: true,
  156. message: '请输入手机号',
  157. trigger: ['change', 'blur'],
  158. },
  159. {
  160. validator: (rule, value, callback) => {
  161. return uni.$u.test.mobile(value);
  162. },
  163. message: '手机号码不正确',
  164. trigger: ['change', 'blur'],
  165. },
  166. ],
  167. age: [{
  168. validator: (rule, value, callback) => {
  169. if (!value) {
  170. callback(new Error('年龄不能为空'));
  171. } else if (isNaN(value)) {
  172. callback(new Error('请输入数字'));
  173. } else if (value < 18 || value > 65) {
  174. callback(new Error('年龄必须在18至65岁之间'));
  175. } else {
  176. callback(); // 验证通过
  177. }
  178. },
  179. trigger: 'blur',
  180. }],
  181. sex: [{
  182. type: 'string',
  183. max: 1,
  184. required: true,
  185. message: '请选择性别',
  186. trigger: ['blur', 'change']
  187. }],
  188. salary: [{
  189. type: 'string',
  190. required: true,
  191. message: '请输入薪资待遇',
  192. trigger: ['blur', 'change']
  193. }],
  194. introduce: [{
  195. type: 'string',
  196. required: true,
  197. message: '请输入个人简介',
  198. trigger: ['blur', 'change']
  199. }],
  200. idCardFile: [{
  201. validator: (rule, value, callback) => {
  202. if (value === null || value === undefined || value === '' || (Array.isArray(
  203. value) && value.length === 0)) {
  204. callback(new Error('请选择身份证'));
  205. } else {
  206. callback();
  207. }
  208. },
  209. trigger: 'blur'
  210. }]
  211. },
  212. }
  213. },
  214. watch: {
  215. 'form.salaryMin': {
  216. handler(newVal, oldVal) {
  217. if (!uni.$u.test.isEmpty(newVal) && !uni.$u.test.isEmpty(this.form.salaryMax)) {
  218. this.form.salary = '有'
  219. } else {
  220. this.form.salary = ''
  221. }
  222. },
  223. immediate: true
  224. },
  225. 'form.salaryMax': {
  226. handler(newVal, oldVal) {
  227. if (!uni.$u.test.isEmpty(newVal) && !uni.$u.test.isEmpty(this.form.salaryMin)) {
  228. this.form.salary = '有'
  229. } else {
  230. this.form.salary = ''
  231. }
  232. },
  233. immediate: true
  234. }
  235. },
  236. mounted() {
  237. // let worker = uni.getStorageSync("worker")
  238. let params = {}
  239. queryResumeById(params).then(response=>{
  240. let worker = response.result;
  241. if(worker){
  242. this.form.id = worker.id
  243. this.form.name = worker.name
  244. this.form.mobile = worker.phone
  245. this.form.age = worker.age
  246. this.form.sex = worker.sex==1?'男':'女'
  247. this.form.nation = worker.nation
  248. this.form.introduce = worker.brief
  249. this.form.address = worker.address
  250. this.form.industryId = worker.categoryOne
  251. this.form.industryName = worker.categoryOneName
  252. this.form.salaryMin = worker.salaryMin
  253. this.form.salaryMax = worker.salaryMax
  254. this.form.idCardFile = this.stringToKeyValueArray(worker.headImage)
  255. }
  256. })
  257. },
  258. methods: {
  259. stringToKeyValueArray(str, delimiter1 = ',') {
  260. if(str){
  261. let arro = str.split(delimiter1);
  262. let arr = [];
  263. arro.forEach(items=>{
  264. let obj = {};
  265. obj["url"] = items
  266. arr.push(obj)
  267. })
  268. console.info(arr)
  269. return arr
  270. }else{
  271. return []
  272. }
  273. },
  274. handleIndChange() {
  275. this.showType = true
  276. },
  277. typeSelect(event) {
  278. console.info("selectIndClick", event)
  279. this.form.industryId = event.id
  280. this.form.industryName = event.name
  281. this.showType = false
  282. },
  283. onIndustryList() {
  284. industryList({}).then(response => {
  285. console.info(response)
  286. this.typeList = response.result
  287. }).catch(error => {
  288. })
  289. },
  290. handleSexChange() {
  291. this.showSex = true
  292. },
  293. sexSelect(e) {
  294. this.form.sex = e.name
  295. this.$refs.uForm.validateField('sex')
  296. },
  297. onRole() {
  298. let that = this
  299. if(this.form.id){
  300. let params = {
  301. "id": that.form.id,
  302. "name": that.form.name,
  303. "categoryOne": that.form.industryId,
  304. "categoryOneName": that.form.industryName,
  305. "address":that.form.address,
  306. "nation": that.form.nation,
  307. "age": that.form.age,
  308. "sex": that.form.sex=="男"?1:2,
  309. "salaryMin": that.form.salaryMin,
  310. "salaryMax": that.form.salaryMax,
  311. "phone": that.form.mobile,
  312. "brief": that.form.introduce,
  313. "headImage": that.form.idCardFile.map(item => item.url).join(','),
  314. }
  315. updateResume(params).then(response=>{
  316. uni.$u.toast("保存成功!")
  317. setTimeout(()=>{
  318. uni.navigateBack({
  319. delta:1
  320. })
  321. },1500)
  322. }).catch(error=>{
  323. })
  324. }else{
  325. let params = {
  326. "name": that.form.name,
  327. "categoryOne": that.form.industryId,
  328. "categoryOneName": that.form.industryName,
  329. "address":that.form.address,
  330. "age": that.form.age,
  331. "nation": that.form.nation,
  332. "sex": that.form.sex=="男"?1:2,
  333. "salaryMin": that.form.salaryMin,
  334. "salaryMax": that.form.salaryMax,
  335. "phone": that.form.mobile,
  336. "brief": that.form.introduce,
  337. "headImage": that.form.idCardFile.map(item => item.url).join(','),
  338. }
  339. addResume(params).then(response => {
  340. uni.$u.toast("提交成功,等待申请")
  341. setTimeout(()=>{
  342. uni.switchTab({
  343. url:"/pages/home/index"
  344. })
  345. },1500)
  346. }).catch(error => {
  347. setTimeout(()=>{
  348. uni.switchTab({
  349. url:"/pages/home/index"
  350. })
  351. },1500)
  352. })
  353. }
  354. },
  355. submit() {
  356. this.$refs.uForm.validate().then(res => {
  357. this.onRole()
  358. }).catch(errors => {
  359. // uni.$u.toast('校验失败')
  360. })
  361. },
  362. deletePic(event) {
  363. this.form.idCardFile.splice(e.index, 1)
  364. },
  365. async afterRead(e) {
  366. let self = this
  367. e.file.forEach(file => {
  368. self.$Oss.ossUpload(file.url).then(url => {
  369. self.form.idCardFile.push({
  370. url
  371. })
  372. })
  373. })
  374. }
  375. },
  376. onReady() {
  377. this.onIndustryList()
  378. this.$refs.uForm.setRules(this.rules)
  379. },
  380. }
  381. </script>
  382. <style lang="scss" scoped>
  383. page {
  384. background-color: #f5f5f5 !important;
  385. }
  386. .line-orange {
  387. width: 8rpx;
  388. height: 32rpx;
  389. background: #ff7a31;
  390. border-radius: 4rpx;
  391. }
  392. </style>