Commit c50b3fd6 by 李长胜

之前标签管理和客户详情的代码优化

1 parent e649731c
import Vue from 'vue' import Vue from 'vue'
import { message } from '../plugins/element.js'
// import { Message, MessageBox, Loading } from 'element-ui'; // import { Message, MessageBox, Loading } from 'element-ui';
// import moment from 'moment' // import moment from 'moment'
let loadingInstance = '' let loadingInstance = ''
...@@ -152,6 +152,50 @@ export const Util = { ...@@ -152,6 +152,50 @@ export const Util = {
} }
return n return n
},
/**
* 处理输入框只能输入30个字符,一个汉字2个字符,字母数字1个字符,超过截取最大数量字符
*/
cutMaxCharStr:function(e){//e为传入字符串
let str = e
var len = 0
var singleNum = 0
var doubleNum = 0
for (var i = 0; i < e.length; i++) {
var c = e.charCodeAt(i)
//单字节加1
if ((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) {
len++
} else {
len += 2
}
}
if (len > 30) {
message.error('字数已达上限')
var subLen = 0
var subLen1 = 0
var subLen2 = 0
for (var v = 0; v < e.length; v++) {
var ch = e.charCodeAt(v)
//单字节
if ((ch >= 0x0001 && ch <= 0x007e) || (0xff60 <= ch && ch <= 0xff9f)) {
singleNum += 1
subLen1++
} else {
doubleNum += 2
subLen2++
}
if (singleNum + doubleNum >= 30) {
subLen = subLen1 + subLen2
console.log(subLen1, subLen2, subLen)
console.log(singleNum, singleNum, '单双数')
break
}
}
return str.substr(0, subLen)
}
return str
} }
} }
...@@ -160,4 +204,5 @@ export const validationTel = Util.validationTel; ...@@ -160,4 +204,5 @@ export const validationTel = Util.validationTel;
export const checkPhone = Util.checkPhone; export const checkPhone = Util.checkPhone;
export const getExplorer=Util.getExplorer; export const getExplorer=Util.getExplorer;
export const exportFn=Util.exportFn; export const exportFn=Util.exportFn;
export const cutMaxCharStr=Util.cutMaxCharStr;
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
<el-form-item v-for="(item, index) in ruleData" :key="index" :label="item.label" :prop="item.prop || ''" :class="item.class" v-show="!item.hidden"> <el-form-item v-for="(item, index) in ruleData" :key="index" :label="item.label" :prop="item.prop || ''" :class="item.class" v-show="!item.hidden">
<template slot-scope="scope"> <template slot-scope="scope">
<template v-if="item.type === 'input'"> <template v-if="item.type === 'input'">
<el-input v-if="item.clickFunc" :type="item.inputText || 'text'" :readonly="item.readonly || false" @click.native="item.clickFunc" :class="item.clickFunc ? 'pointer' : ''" :ref="item.ref" v-model="ruleForm[item.prop]" @input="update($event)"></el-input> <!-- @keyup.enter.native="ruleForm[item.prop]=handClick" -->
<el-input v-if="item.clickFunc" :type="item.inputText || 'text'" :readonly="item.readonly || false" :disabled="item.disabled || false" @click.native="item.clickFunc" :class="item.clickFunc ? 'pointer' : ''" :placeholder="item.placeholder || '请输入'" :ref="item.ref" v-model.trim="ruleForm[item.prop]" @input="ruleForm[item.prop] = update($event)"></el-input>
<el-input v-else :type="item.inputText || 'text'" :readonly="item.readonly || false" :disabled="item.disabled || false" v-model.trim="ruleForm[item.prop]" :maxlength="item.maxlength" :minlength="item.minlength" :placeholder="item.placeholder || '请输入'" :show-password="item.showPassword || false" :clearable="item.clearable" :show-word-limit="item.showWordLimit || false"></el-input> <el-input v-else :type="item.inputText || 'text'" :readonly="item.readonly || false" :disabled="item.disabled || false" v-model.trim="ruleForm[item.prop]" :maxlength="item.maxlength" :minlength="item.minlength" :placeholder="item.placeholder || '请输入'" :show-password="item.showPassword || false" :clearable="item.clearable" :show-word-limit="item.showWordLimit || false"></el-input>
</template> </template>
<template v-else-if="item.type == 'select'"> <template v-else-if="item.type == 'select'">
...@@ -89,7 +90,8 @@ export default { ...@@ -89,7 +90,8 @@ export default {
this.$emit('radioChange', event, prop) this.$emit('radioChange', event, prop)
}, },
update(e) { update(e) {
this.$forceUpdate() // this.$forceUpdate()
return this.$Utils.cutMaxCharStr(e)
} }
} }
} }
......
...@@ -130,7 +130,7 @@ ...@@ -130,7 +130,7 @@
<!-- //提示面板组件 --> <!-- //提示面板组件 -->
<tip-panel panelWidth="666px" panelMinHeight="45px" :panelContent="panelContent"></tip-panel> <tip-panel panelWidth="666px" panelMinHeight="45px" :panelContent="panelContent"></tip-panel>
<!-- v-if="userType == 2" --> <!-- v-if="userType == 2" -->
<el-button type="primary" class="addTagBtn" size="small" @click="btnClick('create')" v-if="userType == 2" >添加标签</el-button> <el-button type="primary" class="addTagBtn" size="small" @click="btnClick('create')" v-if="userType == 2">添加标签</el-button>
<GLTable ref="clientTagsListRef" :hasNum="false" :noDataImg="url" noDataText="客户暂无已添加的标签" :tableData="clientTagsList" :hasPage="false" :tableParams="tagsParams" :headerStyle="{ height: '54px' }"> <GLTable ref="clientTagsListRef" :hasNum="false" :noDataImg="url" noDataText="客户暂无已添加的标签" :tableData="clientTagsList" :hasPage="false" :tableParams="tagsParams" :headerStyle="{ height: '54px' }">
<span slot="labelGroupInfo" slot-scope="scope"> <span slot="labelGroupInfo" slot-scope="scope">
<span>{{ scope.scope.labelGroupInfo.labelGroupName }}</span> <span>{{ scope.scope.labelGroupInfo.labelGroupName }}</span>
...@@ -158,7 +158,7 @@ ...@@ -158,7 +158,7 @@
</div> </div>
</div> </div>
</div> </div>
<basic-dialog class="tags" :title="tagsDialogTitle" :width="'712px'" :isShowThirdBtn="true" @btnEvent="goNewTag" :isVisible="tagsVisible" @confirmDialog="handleConfirm" @closeDialog="handleClose"> <basic-dialog class="tags" :title="tagsDialogTitle" :width="'712px'" :btnLoading="sloading" :isShowThirdBtn="true" @btnEvent="goNewTag" :isVisible="tagsVisible" @confirmDialog="handleConfirm" @closeDialog="handleClose">
<slot> <slot>
<p class="dialogSubTitle">企业标签</p> <p class="dialogSubTitle">企业标签</p>
<div class="companyRowData" v-for="(item, index) in companyTagsList" :key="index"> <div class="companyRowData" v-for="(item, index) in companyTagsList" :key="index">
...@@ -196,6 +196,7 @@ export default { ...@@ -196,6 +196,7 @@ export default {
}, },
data() { data() {
return { return {
sloading: false,
panelContent: '说明:标签信息包含跟进员工标记的企业标签和自店标签,以及通过大数据算法生成的系统标签', panelContent: '说明:标签信息包含跟进员工标记的企业标签和自店标签,以及通过大数据算法生成的系统标签',
url: url, url: url,
leftPanelInfo: {}, leftPanelInfo: {},
...@@ -533,7 +534,7 @@ export default { ...@@ -533,7 +534,7 @@ export default {
} }
}, },
getAllTags() { getAllTags() {
getAllTagTree({ 'labelTreeReq.shopId': this.merchantId, 'labelTreeReq.edition': this.merchantModel ,'labelTreeReq.pageNum':1,'labelTreeReq.pageSize':3000}) getAllTagTree({ 'labelTreeReq.shopId': this.merchantId, 'labelTreeReq.edition': this.merchantModel, 'labelTreeReq.pageNum': 1, 'labelTreeReq.pageSize': 3000 })
.then(res => { .then(res => {
if (res.code == 0) { if (res.code == 0) {
console.log(res.data.labelTreeRets, '标签树') console.log(res.data.labelTreeRets, '标签树')
...@@ -579,6 +580,7 @@ export default { ...@@ -579,6 +580,7 @@ export default {
handleConfirm() { handleConfirm() {
//后台要求循环掉接口 //后台要求循环掉接口
//满足条件进行提交 //满足条件进行提交
this.sloading = true
this.submitTagsList.forEach((item, index) => { this.submitTagsList.forEach((item, index) => {
let param = { let param = {
'req.OneId': this.$route.query.id, 'req.OneId': this.$route.query.id,
...@@ -597,19 +599,24 @@ export default { ...@@ -597,19 +599,24 @@ export default {
.then(res => { .then(res => {
if (res.data.code == 0) { if (res.data.code == 0) {
if (index == this.submitTagsList.length - 1) { if (index == this.submitTagsList.length - 1) {
this.sloading = false
this.$message.success('添加成功') this.$message.success('添加成功')
this.handleClose() this.handleClose()
// this.getSingleClientTag(this.$route.query.id, this.merchantId) // this.getSingleClientTag(this.$route.query.id, this.merchantId)
this.getPageDetail() //刷新当前页面 this.getPageDetail() //刷新当前页面
} }
} else { } else {
this.sloading = false
this.$message.error(res.data.message) this.$message.error(res.data.message)
} }
}) })
.catch(err => { .catch(err => {
this.sloading = false
console.error(err, '错误捕获') console.error(err, '错误捕获')
}) })
.finally(() => {
this.sloading = false
})
}) })
}, },
handleClose() { handleClose() {
...@@ -617,6 +624,7 @@ export default { ...@@ -617,6 +624,7 @@ export default {
this.companyTagsList = [] this.companyTagsList = []
this.ownShopTagsList = [] this.ownShopTagsList = []
} }
console.log('进来')
// this.roleForm.tagsList = [] //取消时清空新增标签 // this.roleForm.tagsList = [] //取消时清空新增标签
this.tagsVisible = !this.tagsVisible this.tagsVisible = !this.tagsVisible
}, },
...@@ -636,7 +644,7 @@ export default { ...@@ -636,7 +644,7 @@ export default {
return { return {
...item, ...item,
labelList: item.labelList.filter(e => { labelList: item.labelList.filter(e => {
if (e.checked && !original) { if (e.checked && !e.original) {
return e return e
} }
}) })
......
...@@ -273,7 +273,8 @@ export default { ...@@ -273,7 +273,8 @@ export default {
placeholder: '最多30个字符,1个汉字为2个字符', placeholder: '最多30个字符,1个汉字为2个字符',
// maxlength: 30, // maxlength: 30,
// showWordLimit: true, // showWordLimit: true,
disabled: false disabled: false,
clickFunc:this.watchInput
}, },
{ {
label: '标签组类型', label: '标签组类型',
...@@ -293,10 +294,10 @@ export default { ...@@ -293,10 +294,10 @@ export default {
tagRules: { tagRules: {
tagsName: [ tagsName: [
{ required: true, message: '请输入名称', trigger: 'blur' }, { required: true, message: '请输入名称', trigger: 'blur' },
{ // {
validator: checkName, // this.$Commons.checkName, // validator: checkName,
trigger: 'blur' // trigger: 'change'
} // }
], ],
initTagsGroup: [{ required: true, message: '请选择标签组类型', trigger: 'change' }] initTagsGroup: [{ required: true, message: '请选择标签组类型', trigger: 'change' }]
// tagsList: [{ required: true }] // tagsList: [{ required: true }]
...@@ -367,6 +368,9 @@ export default { ...@@ -367,6 +368,9 @@ export default {
// }, 200) // }, 200)
}, },
methods: { methods: {
watchInput(){
console.log('点击标签组名称输入框')
},
showTagArray(list) { showTagArray(list) {
if (list.length == 0) { if (list.length == 0) {
return [] return []
...@@ -375,51 +379,14 @@ export default { ...@@ -375,51 +379,14 @@ export default {
return list.slice(0, 9) return list.slice(0, 9)
}, },
checkInputContent(e) { checkInputContent(e) {
let str = e //确保每个输入框的内容不和已存在的编辑标签相同
var len = 0
var singleNum = 0
var doubleNum = 0
for (var i = 0; i < e.length; i++) {
var c = e.charCodeAt(i)
//单字节加1
if ((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) {
len++
} else {
len += 2
}
}
if (len > 30) {
this.$message.error('字数已达上限')
var subLen = 0
var subLen1 = 0
var subLen2 = 0
for (var v = 0; v < e.length; v++) {
var ch = e.charCodeAt(v)
//单字节
if ((ch >= 0x0001 && ch <= 0x007e) || (0xff60 <= ch && ch <= 0xff9f)) {
singleNum += 1
subLen1++
} else {
doubleNum += 2
subLen2++
}
if (singleNum + doubleNum >= 30) {
subLen = subLen1 + subLen2
console.log(subLen1, subLen2, subLen)
console.log(singleNum, singleNum, '单双数')
break
}
}
return str.substr(0, subLen)
}
//确保每个输入框的内容不和已存在的编辑标签相同
let isHasSameTag = this.editTagList.some(ele => ele.name == e) let isHasSameTag = this.editTagList.some(ele => ele.name == e)
if (isHasSameTag) { if (isHasSameTag) {
this.$message.error('不允许输入已存在的标签') this.$message.error('不允许输入已存在的标签')
return str return e
} }
return str return this.$Utils.cutMaxCharStr(e)
}, },
isShowEditBtn(row) { isShowEditBtn(row) {
//集团模式下,只有集团能可以编辑企业,自店,其他只能编辑自店 //集团模式下,只有集团能可以编辑企业,自店,其他只能编辑自店
...@@ -729,44 +696,7 @@ export default { ...@@ -729,44 +696,7 @@ export default {
i.inputVisible = false i.inputVisible = false
} }
}) })
let str = inputValue return this.$Utils.cutMaxCharStr(inputValue)
var len = 0
var singleNum = 0
var doubleNum = 0
for (var i = 0; i < inputValue.length; i++) {
var c = inputValue.charCodeAt(i)
//单字节加1
if ((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) {
len++
} else {
len += 2
}
}
if (len > 30) {
this.$message.error('字数已达上限')
var subLen = 0
var subLen1 = 0
var subLen2 = 0
for (var v = 0; v < inputValue.length; v++) {
var ch = inputValue.charCodeAt(v)
if ((ch >= 0x0001 && ch <= 0x007e) || (0xff60 <= ch && ch <= 0xff9f)) {
singleNum += 1
subLen1++
} else {
doubleNum += 2
subLen2++
}
if (singleNum + doubleNum >= 30) {
subLen = subLen1 + subLen2
// console.log(subLen1, subLen2, subLen)
// console.log(singleNum, singleNum, '单双数')
break
}
}
return str.substr(0, subLen)
}
return str
}, },
handleSelect(value) { handleSelect(value) {
console.log('值内容', value) console.log('值内容', value)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!