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

264 lines
7.1 KiB

3 months ago
3 months ago
3 months ago
3 months ago
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>{{form.id?'保存':'提交审核'}}</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,updateRoleBoss} 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. id:that.form.id,
  195. userName:that.form.name,
  196. role:that.form.role,
  197. phone:that.form.mobile,
  198. companyName:that.form.company,
  199. companyAddress:that.form.address,
  200. industryId:that.form.industryId,
  201. industryName:that.form.industryName,
  202. businessLicense:that.form.businessLicenseFile.map(item => item.url).join(','),
  203. }
  204. if(that.form.id){
  205. updateRoleBoss(params).then(response=>{
  206. uni.$u.toast("保存成功!")
  207. setTimeout(()=>{
  208. uni.navigateBack({
  209. delta:1
  210. })
  211. },1500)
  212. }).catch(error=>{
  213. })
  214. }else{
  215. roleBoss(params).then(response=>{
  216. uni.$u.toast("提交成功,等待申请")
  217. setTimeout(()=>{
  218. uni.switchTab({
  219. url:"/pages/home/index"
  220. })
  221. },1500)
  222. }).catch(error=>{
  223. })
  224. }
  225. },
  226. submit() {
  227. let that = this
  228. that.$refs.uForm.validate().then(res => {
  229. that.onRoleBoss()
  230. }).catch(errors => {
  231. // uni.$u.toast('校验失败')
  232. })
  233. },
  234. deletePic(event) {
  235. this.form.businessLicenseFile.splice(event.index, 1)
  236. },
  237. async afterRead(e) {
  238. let self = this
  239. e.file.forEach(file => {
  240. self.$Oss.ossUpload(file.url).then(url => {
  241. console.info(url)
  242. self.form.businessLicenseFile.push({
  243. url
  244. })
  245. })
  246. })
  247. }
  248. }
  249. }
  250. </script>
  251. <style lang="scss" scoped>
  252. .line-orange {
  253. width: 8rpx;
  254. height: 32rpx;
  255. background: #ff7a31;
  256. border-radius: 4rpx;
  257. }
  258. </style>