Browse Source

新增企业

master
parent
commit
cc34e8c535
  1. 11
      api/enterprise/index.js
  2. 186
      sub/invite/addEnterprise.vue
  3. 43
      sub/invite/enterpriseTags.vue
  4. 4
      sub/invite/prove.vue

11
api/enterprise/index.js

@ -23,7 +23,16 @@ export function getEnterPriseList(params) {
params
})
}
/**
* 校验企业名
*/
export function vertifyName(params) {
return request({
url: `/system/enterprise/page`,
method: 'GET',
params
})
}
/**
* 获取企业详情
* @param {Object} id

186
sub/invite/addEnterprise.vue

@ -6,14 +6,17 @@
企业名称
</view>
<view class="value">
<input
class="input-value"
<uni-easyinput
type="text"
placeholder-class="txt"
placeholder="请输入企业名称"
v-model="form.enterpriseName"
:inputBorder="false"
style="text-align: center"
:value="form.enterprisesName"
@blur="proofName"
/>
:clearable="false"
:autoHeight="true"
ref="nameRef"
></uni-easyinput>
<u-icon name="arrow-right"></u-icon>
</view>
</view>
@ -42,8 +45,8 @@
企业介绍
</view>
<view class="value" @tap="goIntruduce">
<view class="input-textarea" v-if="form.introduce">
{{ form.introduce }}
<view class="input-textarea" v-if="form.introduction">
{{ form.introduction }}
</view>
<view class="input-textarea" style="color: #808080" v-else>
请输入企业介绍
@ -85,7 +88,11 @@
</view>
<view class="value" @tap="goTags">
<view class="input-textarea" v-if="Object.keys(form.tags).length">
{{ Object.values(form.tags).map(tag => tag.name).join('、') }}
{{
Object.values(form.tags)
.map(tag => tag.name)
.join('、')
}}
</view>
<view class="input-textarea" style="color: #808080" v-else>
请选择企业标签
@ -100,13 +107,15 @@
企业负责人
</view>
<view class="value">
<input
class="input-value"
<uni-easyinput
type="text"
placeholder-class="txt"
placeholder="请输入企业负责人"
v-model="form.contactName"
/>
:inputBorder="false"
style="text-align: center"
:value="form.contactName"
:clearable="false"
:autoHeight="true"
></uni-easyinput>
<u-icon name="arrow-right"></u-icon>
</view>
</view>
@ -117,21 +126,13 @@
负责人电话
</view>
<view class="value">
<!-- <input
class="input-value"
type="text"
placeholder-class="txt"
placeholder="请输入负责人电话"
v-model="form.environmentalContactPhone"
@blur="proofName"
/> -->
<uni-easyinput
type="text"
placeholder="请输入负责人电话"
:inputBorder="false"
style="text-align: center"
v-model="form.environmentalContactPhone"
@blur="proofName"
:value="form.environmentalContactPhone"
@blur="proofphone"
:clearable="false"
:autoHeight="true"
></uni-easyinput>
@ -203,7 +204,7 @@
<cs-bottom-wrapper>
<view class="operation">
<button class="btn green">提交审核</button>
<button class="btn green" @tap="submit">提交审核</button>
</view>
</cs-bottom-wrapper>
</view>
@ -212,34 +213,27 @@
<script>
import { uploadFile } from '@/api/system/file.js'
import { getDictBatchByType } from '@/api/system/dict.js'
import {
createEnterPrise,
vertifyName,
c
} from '@/api/enterprise/index.js'
export default {
data() {
return {
form: {
enterpiseName: undefined,
enterprisesName: undefined,
address: undefined,
gpsLocation: undefined,
introduce: '',
introduction: '',
photo: [],
tags: {}
tags: {},
environmentalContactPhone: undefined,
contactName: undefined,
id: ''
},
dictMap: {},
prove: [
{
enterpriseAuth: '123',
expiryDate: '2025-02-24',
id: '',
photo: [
{
id: 1890,
message: '',
status: 'success',
url: 'http://60.23.29.213:19001/huanbao/7f71a5ed324fd6d35d61c7b6d68d8e6e06f16557f3150af3dece8ab386f9f189.png'
}
],
qualificationName: '1'
}
],
prove: [],
inviteId: undefined
}
},
@ -249,7 +243,7 @@ export default {
},
onShow() {
uni.$on('enterpriseIntroduce', data => {
this.form.introduce = data.introduce
this.form.introduction = data.introduce
})
uni.$on('enterpriseTag', data => {
this.form.tags = data
@ -260,7 +254,38 @@ export default {
},
methods: {
proofName(v) {
console.log(v.detail.value)
uni.showLoading({
title: '加载中'
})
vertifyName({
pageSize: -1,
pageNo: 1,
onlyEnterprisesName: v.detail.value
}).then(res => {
if (res.data.total > 0) {
uni.showToast({
title: '企业名已存在',
icon: 'none'
})
this.form.enterprisesName = ''
} else {
this.form.enterprisesName = v.detail.value
}
uni.hideLoading()
})
},
proofphone(v) {
//
const mobilePattern = /^1[3-9]\d{9}$/ //
if (!mobilePattern.test(v.detail.value)) {
uni.showToast({
title: '请输入有效的手机号',
icon: 'none'
})
this.form.environmentalContactPhone = ''
} else {
this.form.environmentalContactPhone = v.detail.value
}
},
/**
* 获取字典
@ -283,12 +308,14 @@ export default {
},
goIntruduce() {
uni.navigateTo({
url: `/sub/invite/enterpriseIntroduce?introduce=${this.form.introduce}`
url: `/sub/invite/enterpriseIntroduce?introduce=${this.form.introduction}`
})
},
goTags() {
uni.navigateTo({
url: `/sub/invite/enterpriseTags?tags=${JSON.stringify(this.form.tags)}`
url: `/sub/invite/enterpriseTags?tags=${JSON.stringify(
this.form.tags
)}`
})
},
/**
@ -336,6 +363,71 @@ export default {
uni.navigateTo({
url: `/sub/invite/prove?prove=${JSON.stringify(prove)}`
})
},
async submit() {
const valide = await this.verifyForm()
if (!valide) return
const data = { ...this.form }
console.log(data)
data.region = data.tags.qy.id
// data.type = data.tags.qy.id
data.tagIds = [data.tags.hy.id, data.tags.st.id, data.tags.wr.id]
data.fileIds = data.photo.map(i => i.id)
// data.userId = this.inviteId
data.userId = 162
data.qualis = this.prove.map(i => {
return {
...i,
expiryDate: new Date(i.expiryDate).getTime(),
files: i.photo.map(f => f.id)
}
})
if (this.form.id) {
} else {
createEnterPrise(data).then(res => {
uni.showToast({
icon: 'none',
title: res.msg
})
uni.navigateBack()
})
}
},
async verifyForm() {
const msgMap = {
enterprisesName: '请输入企业名',
address: '请选择企业地址',
gpsLocation: '请选择企业地址',
introduction: '请填写企业介绍',
photo: '最少上传一张企业照片',
tags: '请选择企业标签',
prove: '请填写企业资质',
environmentalContactPhone: '请输入企业负责人',
contactName: '请输入负责人电话'
}
const msg = []
Object.keys(this.form).forEach(i => {
if (!Object.hasOwn(msgMap, i)) {
return
}
if (!this.form[i]) {
msg.push(msgMap[i])
}
if (typeof this.form[i] == 'Object' && this.form[i].length == 0) {
msg.push(msgMap[i])
}
})
if (this.prove.length == 0) {
msg.push(msgMap.prove)
}
if (msg.length > 0) {
uni.showToast({
icon: 'none',
title: msg.join('\n')
})
return false
}
return true
}
}
}

43
sub/invite/enterpriseTags.vue

@ -86,9 +86,7 @@
</template>
<script>
import {
getTagData
} from '@/api/system/dict.js'
import { getTagData, getDictBatchByType } from '@/api/system/dict.js'
export default {
data() {
return {
@ -110,27 +108,34 @@ export default {
}
},
onLoad(res) {
if(res.tags){
if (res.tags) {
this.form = JSON.parse(res.tags)
}
this.getDict()
this.getDict()
},
methods: {
async getDict() {
try {
const tags = await getTagData(['qy', 'hy', 'st', 'wr'].join(','))
const dict = await getDictBatchByType({
type: ['enterprises_area'].join(',')
})
if (tags.code === 0 && tags.data) {
let tagMap = {}
tags.data.forEach(t => {
//
const children = t.children.map(child => ({
name: child.tagName,
value: child.id,
code: child.tagCode
value: child.id
}))
tagMap[t.tagCode] = children
})
tagMap.qy = dict.data.enterprises_area.map(i => {
return {
name: i.label,
value: i.value
}
})
this.dictMap = tagMap
}
} catch (error) {
@ -140,19 +145,17 @@ export default {
})
}
},
/**
/**
* 选择器确认回调
* @param {Object} e
*/
confirmPicker(e) {
confirmPicker(e) {
const { value } = e
//
this.form[this.picker.key] = {
name: value[0].name,
id: value[0].value,
code: value[0].code,
tagCode: this.picker.key //
id: value[0].value
}
this.closePicker()
},
@ -168,21 +171,24 @@ export default {
}
},
showPicker(type) {
console.log(type,this.dictMap[type])
console.log(this.dictMap)
this.picker.data = [this.dictMap[type] || []]
this.picker.key = type
this.picker.show = true
},
submit() {
//
if (!this.form.qy || !this.form.hy || !this.form.st || !this.form.wr) {
if (
!this.form.qy ||
!this.form.hy ||
!this.form.st ||
!this.form.wr
) {
const emptyFields = []
if (!this.form.qy) emptyFields.push('所在区域')
if (!this.form.hy) emptyFields.push('行业类型')
if (!this.form.st) emptyFields.push('所属生态')
if (!this.form.wr) emptyFields.push('污染类型')
uni.showToast({
title: `请选择${emptyFields.join('、')}`,
icon: 'none'
@ -197,7 +203,6 @@ export default {
st: this.form.st,
wr: this.form.wr
}
uni.$emit('enterpriseTag', submitData)
uni.navigateBack()
}

4
sub/invite/prove.vue

@ -176,6 +176,9 @@ export default {
* @param {Object} e
*/
async addPhoto(e) {
uni.showLoading({
title: '正在上传...'
})
this.prove.photo.push({
...e.file,
status: 'uploading',
@ -188,6 +191,7 @@ export default {
status: 'success',
message: ''
})
uni.hideLoading()
})
},
/**

Loading…
Cancel
Save