Browse Source

标签

master
赵鹏 1 month ago
parent
commit
3077085e82
  1. 51
      api/taglibrary/index.js
  2. 6
      sub/invite/addEnterprise.vue
  3. 169
      sub/invite/enterpriseTags.vue

51
api/taglibrary/index.js

@ -0,0 +1,51 @@
import request from '@/utils/request'
// 企业标签 API
export const TagLibraryApi = {
// 查询企业标签分页
getTagLibraryPage(params) {
return request({
method: 'get',
url: '/system/tag-library/page',
params: params
})
},
// 查询企业标签详情
getTagLibrary(id) {
return request({
method: 'get',
url: '/system/tag-library/get?id=' + id
})
},
// 新增企业标签
createTagLibrary(data) {
return request({
method: 'post',
url: '/system/tag-library/create',
data: data
})
},
// 修改企业标签
updateTagLibrary(data) {
return request({
method: 'put',
url: '/system/tag-library/update',
data: data
})
},
// 删除企业标签
deleteTagLibrary(id) {
return request({
method: 'delete',
url: '/system/tag-library/delete?id=' + id
})
},
}

6
sub/invite/addEnterprise.vue

@ -84,8 +84,8 @@
企业标签
</view>
<view class="value" @tap="goTags">
<view class="input-textarea" v-if="form.introduce">
{{ form.tags }}
<view class="input-textarea" v-if="Object.keys(form.tags).length">
{{ Object.values(form.tags).map(tag => tag.name).join('、') }}
</view>
<view class="input-textarea" style="color: #808080" v-else>
请选择企业标签
@ -288,7 +288,7 @@ export default {
},
goTags() {
uni.navigateTo({
url: `/sub/invite/enterpriseTags?tags=${this.form.tags}`
url: `/sub/invite/enterpriseTags?tags=${JSON.stringify(this.form.tags)}`
})
},
/**

169
sub/invite/enterpriseTags.vue

@ -1,20 +1,72 @@
<template>
<view class="view">
<view class="block" v-for="(tag, index) in data" :key="index">
<view style="">
<view class="block">
<view>
<text style="color: #f8285a; margin-right: 4px">*</text>
{{ tag.name }}
所在区域
</view>
<view class="value" @click="showPicker(tag)">
<view class="input-value" v-if="form[tag.name]">
{{ form[tag.name].name }}
<view class="value" @click="showPicker('qy')">
<view class="input-value" v-if="form.qy">
{{ form.qy.name }}
</view>
<view class="input-value" style="color: #808080" v-else>
{{ `请选择${tag.name}` }}
请选择所在区域
</view>
<u-icon name="arrow-right"></u-icon>
</view>
</view>
<!-- 行业类型 -->
<view class="block">
<view>
<text style="color: #f8285a; margin-right: 4px">*</text>
行业类型
</view>
<view class="value" @click="showPicker('hy')">
<view class="input-value" v-if="form.hy">
{{ form.hy.name }}
</view>
<view class="input-value" style="color: #808080" v-else>
请选择行业类型
</view>
<u-icon name="arrow-right"></u-icon>
</view>
</view>
<!-- 省厅类型 -->
<view class="block">
<view>
<text style="color: #f8285a; margin-right: 4px">*</text>
所属生态
</view>
<view class="value" @click="showPicker('st')">
<view class="input-value" v-if="form.st">
{{ form.st.name }}
</view>
<view class="input-value" style="color: #808080" v-else>
请选择所属生态
</view>
<u-icon name="arrow-right"></u-icon>
</view>
</view>
<!-- 污染类型 -->
<view class="block">
<view>
<text style="color: #f8285a; margin-right: 4px">*</text>
污染类型
</view>
<view class="value" @click="showPicker('wr')">
<view class="input-value" v-if="form.wr">
{{ form.wr.name }}
</view>
<view class="input-value" style="color: #808080" v-else>
请选择污染类型
</view>
<u-icon name="arrow-right"></u-icon>
</view>
</view>
<u-picker
:show="picker.show"
:columns="picker.data"
@ -34,11 +86,20 @@
</template>
<script>
import {
getTagData
} from '@/api/system/dict.js'
export default {
data() {
return {
data: [],
form: {},
form: {
qy: '',
hy: '',
st: '',
wr: ''
},
dictMap: {},
//
picker: {
show: false,
@ -49,35 +110,53 @@ export default {
}
},
onLoad(res) {
this.getData()
if(res.tags){
this.form = JSON.parse(res.tags)
}
this.getDict()
},
methods: {
getData() {
this.data = new Array(5).fill(1).map((i, index) => {
this.form[`Tag${index + 1}`] = ''
return {
name: `Tag${index + 1}`,
label: `标签${index + 1}`,
value: index,
children: new Array(10).fill(1).map((c, cIndex) => {
return {
name: `subTag${cIndex + 1}`,
value: cIndex * 10
}
async getDict() {
try {
const tags = await getTagData(['qy', 'hy', 'st', 'wr'].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
}))
tagMap[t.tagCode] = children
})
this.dictMap = tagMap
}
})
console.log(this.data)
} catch (error) {
uni.showToast({
title: '获取数据失败',
icon: 'none'
})
}
},
/**
/**
* 选择器确认回调
* @param {Object} e
*/
confirmPicker(e) {
confirmPicker(e) {
const { value } = e
this.form[this.picker.key] = value[0].value
//
this.form[this.picker.key] = {
name: value[0].name,
id: value[0].value,
code: value[0].code,
tagCode: this.picker.key //
}
this.closePicker()
},
/**
* 关闭选择器
*/
@ -88,26 +167,38 @@ export default {
data: []
}
},
showPicker(tag) {
this.picker.data.push(tag.children)
this.picker.key = tag.name
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() {
const msg = Object.keys(this.form).filter(k => {
if (this.form[k] == '') {
return this.data.find(d => d.name == k).label
}
})
if (msg.length > 0) {
//
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({
icon: 'none',
title: `${msg.join('\n')}不能为空`
title: `请选择${emptyFields.join('、')}`,
icon: 'none'
})
return
}
uni.$emit('enterpriseTag', this.form)
console.log(this.form)
//
const submitData = {
qy: this.form.qy,
hy: this.form.hy,
st: this.form.st,
wr: this.form.wr
}
uni.$emit('enterpriseTag', submitData)
uni.navigateBack()
}
}

Loading…
Cancel
Save