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

240 lines
6.5 KiB

  1. <template>
  2. <!-- 企业 -->
  3. <view>
  4. <u--form labelPosition="left" :model="form" :rules="rules" ref="uForm" labelWidth="80">
  5. <view class="se-p-20">
  6. <view class="se-p-20 se-bgc-white se-br-10 se-fs-20">
  7. <u-form-item label="姓名" prop="name">
  8. <u--input v-model="form.name" class="se-bgc-f5" placeholder="请输入姓名"></u--input>
  9. </u-form-item>
  10. <!-- <u-form-item label="密码" prop="password">
  11. <u--input v-model="form.password" class="se-bgc-f5" placeholder="请输入您的密码"></u--input>
  12. </u-form-item> -->
  13. <u-form-item label="联系电话" prop="mobile">
  14. <u--input v-model="form.mobile" class="se-bgc-f5" placeholder="请输入联系方式"></u--input>
  15. </u-form-item>
  16. <u-form-item label="公司名称" prop="company">
  17. <u--input v-model="form.company" class="se-bgc-f5" placeholder="请输入公司名称"></u--input>
  18. </u-form-item>
  19. <u-form-item label="公司地址" prop="address">
  20. <u--input v-model="form.address" class="se-bgc-f5" placeholder="请输入公司地址"></u--input>
  21. </u-form-item>
  22. <u-form-item label="行业" prop="industryId" @click="handleIndChange()">
  23. <u--input readonly v-model="form.industryName" placeholder="请选择行业" border="bottom"></u--input>
  24. <u-icon slot="right" name="arrow-right"></u-icon>
  25. </u-form-item>
  26. </view>
  27. </view>
  28. <view class="se-p-20">
  29. <view class="se-px-20 se-pb-20 se-bgc-white se-br-10 se-fs-20">
  30. <u-form-item prop="file" labelWidth="2">
  31. <view class="se-flex se-flex-v-sa">
  32. <view class="se-py-20 se-w-p-100 se-flex">
  33. <view class="line-orange"></view>
  34. <view class="se-ml-10">
  35. 营业执照上传
  36. </view>
  37. </view>
  38. <view class="se-py-20 se-w-p-100">
  39. <u-upload :fileList="form.businessLicenseFile" @afterRead="afterRead" @delete="deletePic" name="1"
  40. multiple :maxCount="10"></u-upload>
  41. </view>
  42. </view>
  43. </u-form-item>
  44. </view>
  45. </view>
  46. <view class="se-px-20 se-pt-20">
  47. <view class="se-px-20 se-pb-80 se-fs-20 se-flex">
  48. <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">
  49. <text>提交审核</text>
  50. </view>
  51. <!-- <view
  52. 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">
  53. <text>联系我们</text>
  54. </view> -->
  55. </view>
  56. </view>
  57. </u--form>
  58. <u-action-sheet :actions="indList" @select="selectIndClick" title="行业" :show="show" @close="show=false"></u-action-sheet>
  59. </view>
  60. </template>
  61. <script>
  62. import {roleBoss,industryList} from "@/common/api.js"
  63. export default{
  64. data(){
  65. return{
  66. show:false,
  67. indList: [],
  68. form: {
  69. role:1,
  70. name: 'jerryxiao',
  71. password: '',
  72. mobile: '13189698114',
  73. company:'小小公司',
  74. idCard:'',
  75. address:'湖南长沙岳麓区',
  76. industryId:'1865294357074157570',
  77. industryName:'建筑',
  78. businessLicense: '',
  79. businessLicenseFile:[
  80. {
  81. url:"https://tennis-oss.xzaiyp.top/2024-12-22/cf84422d-dcf7-4efa-82e7-371454eafbee.png"
  82. }
  83. ]
  84. },
  85. rules: {
  86. name: [{
  87. type: 'string',
  88. required: true,
  89. message: '请输入姓名名称',
  90. trigger: ['blur', 'change']
  91. }],
  92. password: [{
  93. type: 'string',
  94. required: true,
  95. message: '请输入您的密码',
  96. trigger: ['blur', 'change']
  97. }],
  98. mobile: [
  99. {
  100. required: true,
  101. message: '请输入手机号',
  102. trigger: ['change','blur'],
  103. },
  104. {
  105. validator: (rule, value, callback) => {
  106. return uni.$u.test.mobile(value);
  107. },
  108. message: '手机号码不正确',
  109. trigger: ['change','blur'],
  110. },
  111. ],
  112. company: [{
  113. type: 'string',
  114. required: true,
  115. message: '请输入公司名称',
  116. trigger: ['blur', 'change']
  117. }],
  118. address: [{
  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. businessLicenseFile:[
  131. {
  132. validator: (rule, value, callback) => {
  133. if (value === null || value === undefined || value === '' || (Array.isArray(value) && value.length === 0)) {
  134. callback(new Error('请选择营业执照'));
  135. } else {
  136. callback();
  137. }
  138. },
  139. trigger: 'blur'
  140. }
  141. ]
  142. },
  143. }
  144. },
  145. watch: {
  146. fileList(newValue, oldValue) {
  147. if (newValue.length > 0) {
  148. this.form.file = '有'
  149. } else {
  150. this.form.file = ''
  151. }
  152. }
  153. },
  154. onReady() {
  155. this.onIndustryList()
  156. this.$refs.uForm.setRules(this.rules)
  157. },
  158. methods: {
  159. handleIndChange(){
  160. this.show = true
  161. },
  162. selectIndClick(event){
  163. console.info("selectIndClick",event)
  164. this.form.industryId = event.id
  165. this.form.industryName = event.name
  166. this.show = false
  167. },
  168. onIndustryList(){
  169. industryList({}).then(response=>{
  170. console.info(response)
  171. this.indList = response.result
  172. }).catch(error=>{
  173. })
  174. },
  175. onRoleBoss(){
  176. let that = this
  177. let params={
  178. userName:that.form.name,
  179. role:that.form.role,
  180. phone:that.form.mobile,
  181. companyName:that.form.company,
  182. companyAddress:that.form.companyAddress,
  183. industryId:that.form.industryId,
  184. industryName:that.form.industryName,
  185. businessLicense:that.form.businessLicenseFile.map(item => item.url).join(','),
  186. }
  187. roleBoss(params).then(response=>{
  188. uni.$u.toast("提交成功,等待申请")
  189. setTimeout(()=>{
  190. uni.switchTab({
  191. url:"/pages/home/index"
  192. })
  193. },1500)
  194. }).catch(error=>{
  195. // uni.$u.toast("提交成功,等待申请")
  196. setTimeout(()=>{
  197. uni.switchTab({
  198. url:"/pages/home/index"
  199. })
  200. },1500)
  201. })
  202. },
  203. submit() {
  204. let that = this
  205. that.$refs.uForm.validate().then(res => {
  206. that.onRoleBoss()
  207. }).catch(errors => {
  208. // uni.$u.toast('校验失败')
  209. })
  210. },
  211. deletePic(event) {
  212. this.form.businessLicenseFile.splice(event.index, 1)
  213. },
  214. async afterRead(e) {
  215. let self = this
  216. e.file.forEach(file => {
  217. self.$Oss.ossUpload(file.url).then(url => {
  218. console.info(url)
  219. self.form.businessLicenseFile.push({
  220. url
  221. })
  222. })
  223. })
  224. }
  225. }
  226. }
  227. </script>
  228. <style lang="scss" scoped>
  229. .line-orange {
  230. width: 8rpx;
  231. height: 32rpx;
  232. background: #ff7a31;
  233. border-radius: 4rpx;
  234. }
  235. </style>