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

313 lines
8.5 KiB

7 months ago
4 months ago
7 months ago
4 months ago
7 months ago
4 months ago
7 months ago
4 months ago
7 months ago
4 months ago
7 months ago
7 months ago
7 months ago
7 months ago
4 months ago
7 months ago
4 months ago
7 months ago
4 months ago
7 months ago
4 months ago
7 months ago
4 months ago
7 months ago
4 months ago
7 months ago
4 months ago
7 months ago
4 months ago
7 months ago
4 months ago
7 months ago
4 months ago
7 months ago
4 months ago
7 months ago
4 months ago
7 months ago
4 months ago
7 months ago
4 months ago
7 months ago
4 months ago
7 months ago
4 months ago
7 months ago
4 months ago
7 months ago
4 months ago
7 months ago
4 months ago
7 months ago
4 months ago
7 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="sex" @click="handleSexChange">
  19. <u--input @click="handleSexChange" readonly v-model="form.sex" placeholder="请选择性别"
  20. border="none"></u--input>
  21. <u-icon @click="handleSexChange" slot="right" name="arrow-right"></u-icon>
  22. </u-form-item>
  23. <u-form-item label="工种" prop="industryId" @click="handleIndChange">
  24. <u--input v-model="form.industryName" readonly placeholder="请选择工种" border="none"></u--input>
  25. <u-icon slot="right" name="arrow-right"></u-icon>
  26. </u-form-item>
  27. <u-form-item label="薪资待遇" prop="salary">
  28. <view class="se-flex se-flex-h-c">
  29. <u--input v-model="form.salaryMin" class="se-w-200" placeholder="最小值"></u--input>
  30. <text class="se-mx-10">~</text>
  31. <u--input v-model="form.salaryMax" class="se-w-200" placeholder="最大值"></u--input>
  32. </view>
  33. </u-form-item>
  34. <u-form-item label="个人介绍" prop="introduce">
  35. <u--textarea v-model="form.introduce" count class="se-bgc-f5"
  36. placeholder="请选择个人介绍"></u--textarea>
  37. </u-form-item>
  38. </view>
  39. </view>
  40. <view class="se-p-20">
  41. <view class="se-px-20 se-pb-20 se-bgc-white se-br-10 se-fs-20">
  42. <u-form-item prop="idCardFile" labelWidth="2">
  43. <view class="se-flex se-flex-v-sa">
  44. <view class="se-py-20 se-w-p-100 se-flex">
  45. <view class="line-orange"></view>
  46. <view class="se-ml-10">
  47. 身份证上传正反面
  48. </view>
  49. </view>
  50. <view class="se-py-20 se-w-p-100">
  51. <u-upload :fileList="form.idCardFile" @afterRead="afterRead" @delete="deletePic"
  52. name="1" multiple :maxCount="10"></u-upload>
  53. </view>
  54. </view>
  55. </u-form-item>
  56. </view>
  57. </view>
  58. <view class="se-px-20 se-pt-20">
  59. <view class="se-px-20 se-pb-80 se-fs-20 se-flex">
  60. <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">
  61. <text>保存</text>
  62. </view>
  63. <!-- <view
  64. 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">
  65. <text>联系我们</text>
  66. </view> -->
  67. </view>
  68. </view>
  69. </u--form>
  70. <!-- 性别 -->
  71. <u-action-sheet :show="showSex" :actions="sexList" title="请选择性别" @close="showSex = false" @select="sexSelect">
  72. </u-action-sheet>
  73. <!-- 种类 -->
  74. <u-action-sheet :show="showType" :actions="typeList" title="请选择种类" @close="showType = false"
  75. @select="typeSelect">
  76. </u-action-sheet>
  77. </view>
  78. </template>
  79. <script>
  80. import {
  81. role,
  82. industryList
  83. } from "@/common/api.js"
  84. export default {
  85. data() {
  86. return {
  87. showSex: false,
  88. sexList: [{
  89. name: '男',
  90. },
  91. {
  92. name: '女',
  93. }
  94. ],
  95. showType: false,
  96. typeList: [],
  97. fileList: [],
  98. form: {
  99. name: '张三',
  100. password: '',
  101. mobile: '13189698114',
  102. age: '23',
  103. sex: '男',
  104. industryId: '1865037318519398402',
  105. industryName: "餐饮",
  106. salary: '',
  107. salaryMin: '1800',
  108. salaryMax: '2400',
  109. introduce: '张三的个人简介',
  110. idCard: '',
  111. idCardFile: [
  112. {
  113. url:"https://tennis-oss.xzaiyp.top/2024-12-22/7af6b40f-96f9-4656-9eff-98dce2223699.png"
  114. }
  115. ]
  116. },
  117. rules: {
  118. name: [{
  119. type: 'string',
  120. required: true,
  121. message: '请输入姓名名称',
  122. trigger: ['blur', 'change']
  123. }],
  124. industryId: [{
  125. type: 'string',
  126. required: true,
  127. message: '请选择行业',
  128. trigger: ['blur', 'change']
  129. }],
  130. // password: [{
  131. // type: 'string',
  132. // required: true,
  133. // message: '请输入您的密码',
  134. // trigger: ['blur', 'change']
  135. // }],
  136. mobile: [{
  137. required: true,
  138. message: '请输入手机号',
  139. trigger: ['change', 'blur'],
  140. },
  141. {
  142. validator: (rule, value, callback) => {
  143. return uni.$u.test.mobile(value);
  144. },
  145. message: '手机号码不正确',
  146. trigger: ['change', 'blur'],
  147. },
  148. ],
  149. age: [{
  150. validator: (rule, value, callback) => {
  151. if (!value) {
  152. callback(new Error('年龄不能为空'));
  153. } else if (isNaN(value)) {
  154. callback(new Error('请输入数字'));
  155. } else if (value < 18 || value > 65) {
  156. callback(new Error('年龄必须在18至65岁之间'));
  157. } else {
  158. callback(); // 验证通过
  159. }
  160. },
  161. trigger: 'blur',
  162. }],
  163. sex: [{
  164. type: 'string',
  165. max: 1,
  166. required: true,
  167. message: '请选择性别',
  168. trigger: ['blur', 'change']
  169. }],
  170. salary: [{
  171. type: 'string',
  172. required: true,
  173. message: '请输入薪资待遇',
  174. trigger: ['blur', 'change']
  175. }],
  176. introduce: [{
  177. type: 'string',
  178. required: true,
  179. message: '请输入个人简介',
  180. trigger: ['blur', 'change']
  181. }],
  182. idCardFile: [{
  183. validator: (rule, value, callback) => {
  184. if (value === null || value === undefined || value === '' || (Array.isArray(
  185. value) && value.length === 0)) {
  186. callback(new Error('请选择身份证'));
  187. } else {
  188. callback();
  189. }
  190. },
  191. trigger: 'blur'
  192. }]
  193. },
  194. }
  195. },
  196. watch: {
  197. 'form.salaryMin': {
  198. handler(newVal, oldVal) {
  199. if (!uni.$u.test.isEmpty(newVal) && !uni.$u.test.isEmpty(this.form.salaryMax)) {
  200. this.form.salary = '有'
  201. } else {
  202. this.form.salary = ''
  203. }
  204. },
  205. immediate: true
  206. },
  207. 'form.salaryMax': {
  208. handler(newVal, oldVal) {
  209. if (!uni.$u.test.isEmpty(newVal) && !uni.$u.test.isEmpty(this.form.salaryMin)) {
  210. this.form.salary = '有'
  211. } else {
  212. this.form.salary = ''
  213. }
  214. },
  215. immediate: true
  216. }
  217. },
  218. methods: {
  219. handleIndChange() {
  220. this.showType = true
  221. },
  222. typeSelect(event) {
  223. console.info("selectIndClick", event)
  224. this.form.industryId = event.id
  225. this.form.industryName = event.name
  226. this.showType = false
  227. },
  228. onIndustryList() {
  229. industryList({}).then(response => {
  230. console.info(response)
  231. this.typeList = response.result
  232. }).catch(error => {
  233. })
  234. },
  235. handleSexChange() {
  236. this.showSex = true
  237. },
  238. sexSelect(e) {
  239. this.form.sex = e.name
  240. this.$refs.uForm.validateField('sex')
  241. },
  242. onRole() {
  243. let that = this
  244. let params = {
  245. userName: that.form.name,
  246. industryId: that.form.industryId,
  247. industryName: that.form.industryName,
  248. age: that.form.age,
  249. gender: that.form.sex=="男"?1:2,
  250. moneyMin: that.form.salaryMin,
  251. moneyMax: that.form.salaryMax,
  252. phone: that.form.mobile,
  253. detail: that.form.introduce,
  254. idCard: that.form.idCardFile.map(item => item.url).join(','),
  255. }
  256. role(params).then(response => {
  257. uni.$u.toast("提交成功,等待申请")
  258. setTimeout(()=>{
  259. uni.switchTab({
  260. url:"/pages/home/index"
  261. })
  262. },1500)
  263. }).catch(error => {
  264. setTimeout(()=>{
  265. uni.switchTab({
  266. url:"/pages/home/index"
  267. })
  268. },1500)
  269. })
  270. },
  271. submit() {
  272. this.$refs.uForm.validate().then(res => {
  273. this.onRole()
  274. }).catch(errors => {
  275. // uni.$u.toast('校验失败')
  276. })
  277. },
  278. deletePic(event) {
  279. this.form.idCardFile.splice(e.index, 1)
  280. },
  281. async afterRead(e) {
  282. let self = this
  283. e.file.forEach(file => {
  284. self.$Oss.ossUpload(file.url).then(url => {
  285. self.form.idCardFile.push({
  286. url
  287. })
  288. })
  289. })
  290. }
  291. },
  292. onReady() {
  293. this.onIndustryList()
  294. this.$refs.uForm.setRules(this.rules)
  295. },
  296. }
  297. </script>
  298. <style lang="scss" scoped>
  299. page {
  300. background-color: #f5f5f5 !important;
  301. }
  302. .line-orange {
  303. width: 8rpx;
  304. height: 32rpx;
  305. background: #ff7a31;
  306. border-radius: 4rpx;
  307. }
  308. </style>