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

256 lines
6.9 KiB

3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
  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. id:"",
  70. role:1,
  71. name: '',
  72. password: '',
  73. mobile: '',
  74. company:'',
  75. idCard:'',
  76. address:'',
  77. industryId:'',
  78. industryName:'',
  79. businessLicenseFile:[]
  80. },
  81. rules: {
  82. name: [{
  83. type: 'string',
  84. required: true,
  85. message: '请输入姓名名称',
  86. trigger: ['blur', 'change']
  87. }],
  88. password: [{
  89. type: 'string',
  90. required: true,
  91. message: '请输入您的密码',
  92. trigger: ['blur', 'change']
  93. }],
  94. mobile: [
  95. {
  96. required: true,
  97. message: '请输入手机号',
  98. trigger: ['change','blur'],
  99. },
  100. {
  101. validator: (rule, value, callback) => {
  102. return uni.$u.test.mobile(value);
  103. },
  104. message: '手机号码不正确',
  105. trigger: ['change','blur'],
  106. },
  107. ],
  108. company: [{
  109. type: 'string',
  110. required: true,
  111. message: '请输入公司名称',
  112. trigger: ['blur', 'change']
  113. }],
  114. address: [{
  115. type: 'string',
  116. required: true,
  117. message: '请输入公司地址',
  118. trigger: ['blur', 'change']
  119. }],
  120. industryId: [{
  121. type: 'string',
  122. required: true,
  123. message: '请选择行业',
  124. trigger: ['blur', 'change']
  125. }],
  126. businessLicenseFile:[
  127. {
  128. validator: (rule, value, callback) => {
  129. if (value === null || value === undefined || value === '' || (Array.isArray(value) && value.length === 0)) {
  130. callback(new Error('请选择营业执照'));
  131. } else {
  132. callback();
  133. }
  134. },
  135. trigger: 'blur'
  136. }
  137. ]
  138. },
  139. }
  140. },
  141. watch: {
  142. },
  143. onReady() {
  144. this.onIndustryList()
  145. this.$refs.uForm.setRules(this.rules)
  146. },
  147. mounted() {
  148. let company = uni.getStorageSync("company")
  149. if(company){
  150. this.form.id = company.id
  151. this.form.name = company.userName
  152. this.form.mobile = company.phone
  153. this.form.company = company.companyName
  154. this.form.address = company.companyAddress
  155. this.form.industryId = company.industryId
  156. this.form.industryName = company.industryName
  157. this.form.businessLicenseFile = this.stringToKeyValueArray(company.businessLicense)
  158. }
  159. },
  160. methods: {
  161. stringToKeyValueArray(str, delimiter1 = ',') {
  162. if(str){
  163. let arro = str.split(delimiter1);
  164. let arr = [];
  165. arro.forEach(items=>{
  166. let obj = {};
  167. obj["url"] = items
  168. arr.push(obj)
  169. })
  170. console.info(arr)
  171. return arr
  172. }else{
  173. return []
  174. }
  175. },
  176. handleIndChange(){
  177. this.show = true
  178. },
  179. selectIndClick(event){
  180. this.form.industryId = event.id
  181. this.form.industryName = event.name
  182. this.show = false
  183. },
  184. onIndustryList(){
  185. industryList({}).then(response=>{
  186. console.info(response)
  187. this.indList = response.result
  188. }).catch(error=>{
  189. })
  190. },
  191. onRoleBoss(){
  192. let that = this
  193. let params={
  194. userName:that.form.name,
  195. role:that.form.role,
  196. phone:that.form.mobile,
  197. companyName:that.form.company,
  198. companyAddress:that.form.address,
  199. industryId:that.form.industryId,
  200. industryName:that.form.industryName,
  201. businessLicense:that.form.businessLicenseFile.map(item => item.url).join(','),
  202. }
  203. roleBoss(params).then(response=>{
  204. uni.$u.toast("提交成功,等待申请")
  205. setTimeout(()=>{
  206. uni.switchTab({
  207. url:"/pages/home/index"
  208. })
  209. },1500)
  210. }).catch(error=>{
  211. // uni.$u.toast("提交成功,等待申请")
  212. setTimeout(()=>{
  213. uni.switchTab({
  214. url:"/pages/home/index"
  215. })
  216. },1500)
  217. })
  218. },
  219. submit() {
  220. let that = this
  221. that.$refs.uForm.validate().then(res => {
  222. that.onRoleBoss()
  223. }).catch(errors => {
  224. // uni.$u.toast('校验失败')
  225. })
  226. },
  227. deletePic(event) {
  228. this.form.businessLicenseFile.splice(event.index, 1)
  229. },
  230. async afterRead(e) {
  231. let self = this
  232. e.file.forEach(file => {
  233. self.$Oss.ossUpload(file.url).then(url => {
  234. console.info(url)
  235. self.form.businessLicenseFile.push({
  236. url
  237. })
  238. })
  239. })
  240. }
  241. }
  242. }
  243. </script>
  244. <style lang="scss" scoped>
  245. .line-orange {
  246. width: 8rpx;
  247. height: 32rpx;
  248. background: #ff7a31;
  249. border-radius: 4rpx;
  250. }
  251. </style>