Commit 25cff592 by 李长胜

修改搜索组件

1 parent bd69affe
......@@ -75,7 +75,19 @@ export default {
color: '#999'
}
},
formatter: '{b0}<br/>' + '{a0}: {c0}人<br />{a1}: {c1}%<br />{a2}: {c2}人<br />{a3}: {c3}%'
formatter: function(datas) {
var res = datas[0].name + '<br/>'
for (var i = 0, length = datas.length; i < length; i++) {
if (datas[i].seriesName == '全部客户' || datas[i].seriesName == '企微客户') {
res += datas[i].seriesName + ':' + datas[i].data + '人' + '<br/>'
} else {
res += datas[i].seriesName + ':' + datas[i].data + '%' + '<br/>'
}
}
return res
}
// formatter: '{b0}<br/>' + '{a0}: {c0}人<br />{a1}: {c1}%<br />{a2}: {c2}人<br />{a3}: {c3}%'
},
// toolbox: {
......
<template>
<div>
<el-form
:model="ruleForm"
:rules="rules"
:label-position="labelPosition"
:label-width="labelWidth"
:size="size"
>
<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 :model="ruleForm" :rules="rules" :label-position="labelPosition" :label-width="labelWidth" :size="size">
<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 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>
<el-input
v-else
:type="item.inputText || 'text'"
:readonly="item.readonly || false"
:disabled="item.disabled || false"
v-model="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-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>
<el-input v-else :type="item.inputText || 'text'" :readonly="item.readonly || false" :disabled="item.disabled || false" v-model="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 v-else-if="item.type == 'select'">
<el-select
v-if="item.visibleFunc"
v-model="ruleForm[item.prop]"
:placeholder="item.placeholder || '请选择'"
:filterable="item.filterable || false"
@change="selectChange"
@visible-change="item.visibleFunc"
>
<el-option
v-for="i in item.options"
:key="i[item.value] || i.value"
:label="i[item.key] || i.label"
:value="i[item.value] || i.value"
:disabled="i.disabled"
>
</el-option>
<el-select v-if="item.visibleFunc" v-model="ruleForm[item.prop]" :placeholder="item.placeholder || '请选择'" :filterable="item.filterable || false" @change="selectChange" @visible-change="item.visibleFunc">
<el-option v-for="i in item.options" :key="i[item.value] || i.value" :label="i[item.key] || i.label" :value="i[item.value] || i.value" :disabled="i.disabled"></el-option>
</el-select>
<el-select
v-else
v-model="ruleForm[item.prop]"
:placeholder="item.placeholder || '请选择'"
:filterable="item.filterable || false"
@change="selectChange"
>
<el-option
v-for="i in item.options"
:key="i[item.value] || i.value"
:label="i[item.key] || i.label"
:value="i[item.value] || i.value"
:disabled="i.disabled"
>
</el-option>
<el-select v-else v-model="ruleForm[item.prop]" :placeholder="item.placeholder || '请选择'" :filterable="item.filterable || false" @change="selectChange">
<el-option v-for="i in item.options" :key="i[item.value] || i.value" :label="i[item.key] || i.label" :value="i[item.value] || i.value" :disabled="i.disabled"></el-option>
</el-select>
</template>
<template v-else-if="item.type === 'switch'">
<el-switch
v-model="ruleForm[item.prop]"
:active-text="item.activeText || '开'"
:inactive-text="item.inactiveText || '关'"
></el-switch>
<el-switch v-model="ruleForm[item.prop]" :active-text="item.activeText || '开'" :inactive-text="item.inactiveText || '关'"></el-switch>
</template>
<template v-else-if="item.type === 'radio'">
<el-radio-group
@change="radioChange($event,item.prop)"
v-model="ruleForm[item.prop]"
:disabled="item.disabled"
>
{{ruleForm[item.prop]}}
<el-radio
v-for="(child,childIndex) in item.children"
:key="childIndex"
:label="childIndex"
>{{child}}</el-radio>
<el-radio-group @change="radioChange($event, item.prop)" v-model="ruleForm[item.prop]" :disabled="item.disabled">
{{ ruleForm[item.prop] }}
<el-radio v-for="(child, childIndex) in item.children" :key="childIndex" :label="childIndex">{{ child }}</el-radio>
</el-radio-group>
<el-select
v-if="item.hasSelect"
v-model="ruleForm[item.prop]"
:placeholder="item.placeholder || '请选择'"
@change="selectChange"
>
<el-option
v-for="i in item.options"
:key="i[item.value] || i.value"
:label="i[item.key] || i.label"
:value="i[item.value] || i.value"
:disabled="i.disabled"
>
</el-option>
<el-select v-if="item.hasSelect" v-model="ruleForm[item.prop]" :placeholder="item.placeholder || '请选择'" @change="selectChange">
<el-option v-for="i in item.options" :key="i[item.value] || i.value" :label="i[item.key] || i.label" :value="i[item.value] || i.value" :disabled="i.disabled"></el-option>
</el-select>
</template>
<template v-else-if="item.type == 'customize'">
<slot
:scope="scope"
:name="item.slotName"
>
</slot>
<slot :scope="scope" :name="item.slotName"></slot>
</template>
</template>
</el-form-item>
......@@ -171,8 +80,7 @@ export default {
default: '100px'
}
},
mounted() {
},
mounted() {},
methods: {
selectChange(val) {
this.$emit('selectChange', val)
......@@ -190,4 +98,4 @@ export default {
.pointer input {
cursor: pointer;
}
</style>
\ No newline at end of file
</style>
......@@ -34,7 +34,9 @@
</el-select>
</template>
<template v-else-if="item.type === 'daterange'">
<el-date-picker v-model="formModel[item.prop]" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd" :picker-options="item.pickerOptions || {}"></el-date-picker>
<!-- :default-value="['2021-10-03', '2021-11-03']" -->
<el-date-picker v-if="showDefaultTime" v-model="formModel[item.prop]" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd" :picker-options="item.pickerOptions || {}"></el-date-picker>
<el-date-picker v-else v-model="formModel[item.prop]" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd" :picker-options="item.pickerOptions || {}"></el-date-picker>
</template>
</template>
</el-form-item>
......@@ -96,6 +98,10 @@ export default {
accountLevel: {
type: Number,
default: 0
},
showDefaultTime: {
type: Boolean,
default: false
}
},
data() {
......@@ -106,8 +112,12 @@ export default {
isShowBtns: true
}
},
created() {},
mounted() {
if (this.showDefaultTime) {
//调用默认时间(30天)
this.getPassMonthFormatDate()
}
var sf = document.getElementById('searchForm')
// this.$nextTick(() => {
if (sf.clientWidth < 1280 && this.isHasSyncBtn) {
......@@ -200,6 +210,42 @@ export default {
setTimeout(() => {
this.$emit('setTableHeightEvent')
}, 200)
},
//时间选择器显示默认一月的时间
/* 获取过去时间,并传值给现在时间 */
getPassMonthFormatDate() {
var nowDate = new Date()
var date = new Date(nowDate)
date.setDate(date.getDate() - 30) //7 30 365
var seperator1 = '-'
var year = date.getFullYear()
var month = date.getMonth() + 1
var strDate = date.getDate()
if (month >= 1 && month <= 9) {
month = '0' + month
}
if (strDate >= 0 && strDate <= 9) {
strDate = '0' + strDate
}
var formatDate = year + seperator1 + month + seperator1 + strDate
this.getNowFormatDate(formatDate)
},
/* 获取现在时间,并接受过去时间的值 */
getNowFormatDate(formatDate) {
var date = new Date()
var seperator1 = '-'
var year = date.getFullYear()
var month = date.getMonth() + 1
var strDate = date.getDate()
if (month >= 1 && month <= 9) {
month = '0' + month
}
if (strDate >= 0 && strDate <= 9) {
strDate = '0' + strDate
}
var nowData = year + seperator1 + month + seperator1 + strDate
this.$set(this.formModel, 'daterange', [formatDate, nowData])
// this.formModel['daterange'] = [formatDate, nowData] // 默认赋值一个月时间,不要直接赋值,不是响应式
}
}
}
......
export function debounce(fn, delay, triggerNow) {
var t = null;
console.log('ceshi')
var debounced = function(){
var _self = this,
args = arguments;
......@@ -32,8 +32,40 @@ export function debounce(fn, delay, triggerNow) {
return debounced;
}
//格式化日期
export const formatDate = (date, fmt) => {
  if (!date) {
    date = new Date();
  }
  let o = {
    "M+": date.getMonth() + 1, //月份
    "d+": date.getDate(), //日
    "h+": date.getHours(), //小时
    "m+": date.getMinutes(), //分
    "s+": date.getSeconds(), //秒
    "q+": Math.floor((date.getMonth() + 3) / 3), //季度
    S: date.getMilliseconds(), //毫秒  1-3 位  只能一位占位符
    "U+": date.getMilliseconds() //毫秒   可以1-3位占位符
  };
  fmt = fmt || "yyyy-MM-dd hh:mm";
  if (/(y+)/.test(fmt))
    fmt = fmt.replace(
      RegExp.$1,
      (date.getFullYear() + "").substr(4 - RegExp.$1.length)
    );
  for (let k in o)
    if (new RegExp("(" + k + ")").test(fmt))
      fmt = fmt.replace(
        RegExp.$1,
        RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)
      );
  return fmt;
};
//正则表示式是干什么的? 字符串匹配利器(难,规则多)
export function formatDate(date, fmt) {
export function formatDate2(date, fmt) {
//1.获取年份
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
......
......@@ -31,7 +31,9 @@
</p>
<p>
<span>群管理员</span>
<span class="ellipsis-1">{{ leftPanelList.groupAdmin }}</span>
<el-tooltip class="item" :content="leftPanelList.groupAdmin" placement="top">
<span class="ellipsis-1">{{ leftPanelList.groupAdmin }}</span>
</el-tooltip>
</p>
<p>
<span>创建时间</span>
......@@ -55,7 +57,10 @@
<!-- :tableId="$route.query.id" 去掉,表格组件也应该去掉 -->
<GLTable ref="clientGroupDetail" @setTableFinishFun="setTableFinishFun" :hasNum="true" :pageConf="pageConf" :getListApi="getListApi" :beforeSearchFn="beforeSearchFn" :searchForm="searchForm" :tableParams="tableParams" :headerStyle="{ height: '54px', background: '#F4F6FC', color: '#333333', fontSize: '14px' }" :noDataImg="url">
<span slot="customerName" slot-scope="scope">
<span>{{ scope.scope.customerName }}</span>
<el-tooltip effect="dark" :content="scope.scope.customerName" placement="top">
<span class="ellipsis-1" style="display: inline-block; max-width: 70px; text-align: left">{{ scope.scope.customerName }}</span>
</el-tooltip>
<span class="pure-blue-text">{{ scope.scope.type == 1 ? '@微信' : scope.scope.type == 2 ? '@企微' : '' }}</span>
</span>
<span slot="customerSex" slot-scope="scope">
......@@ -217,6 +222,7 @@ export default {
//content是第一页的数据
console.log(content)
this.clientTableDataNum = this.$refs.clientGroupDetail.total
//接收到的数据为空
if (!this.$refs.clientGroupDetail.data.length) {
this.$refs.clientGroupDetail.setTableHeightFun()
......
......@@ -3,7 +3,7 @@
<div class="scrm-sub-client-container">
<!-- <p class="pageTitle">客户群管理</p> -->
<div class="pageContent">
<search-form class="searchTop border-shadow" :isHasSyncBtn="true" :merchantModel="merchantModel" :accountLevel="accountLevel" :formModel="searchForm" :formList="clientGroupFormList" @setTableHeightEvent="setTableHeightEvent" @resetTable="resetTable" @searchTable="searchTable" @syncClick="syncClick">
<search-form class="searchTop border-shadow" :isHasSyncBtn="true" :showDefaultTime="true" :merchantModel="merchantModel" :accountLevel="accountLevel" :formModel="searchForm" :formList="clientGroupFormList" @setTableHeightEvent="setTableHeightEvent" @resetTable="resetTable" @searchTable="searchTable" @syncClick="syncClick">
<span class="inline-b" slot="form-slot">
<el-button plain @click="resetTable">重置</el-button>
<el-button type="primary" @click="searchTable">查询</el-button>
......@@ -135,7 +135,8 @@ export default {
getListApi: getTableList,
setHeight: '',
merchantModel: 1,
accountLevel: 0 //1,2,3,4工厂,省代,市代,门店
accountLevel: 0, //1,2,3,4工厂,省代,市代,门店
flushTime: false
}
},
created() {
......@@ -173,6 +174,11 @@ export default {
this.$refs.clientGroupManage.setTableHeightFun()
},
setTableFinishFun(content) {
console.log(content, this.$refs.clientGroupManage.data.length, '获取数据')
if (!this.flushTime) {
this.flushTime = true
this.searchTable()
}
//接收到的数据为空
if (!this.$refs.clientGroupManage.data.length) {
this.$refs.clientGroupManage.setTableHeightFun()
......@@ -208,13 +214,6 @@ export default {
groupName: name
}
})
// this.$history.push({
// path: '/clientGroupManage/clientGroupDetail',
// params: {
// id: id,
// groupName: name
// }
// })
}
}
}
......
......@@ -74,7 +74,7 @@
<!-- <el-tooltip effect="dark" :content="leftPanelInfo.addWay | toLabel" placement="top">
<span class="ellipsis-1">{{ leftPanelInfo.addWay | toLabel }}</span>
</el-tooltip> -->
<span class="tag ellipsis-1" v-for="item in tagsList" :key="item.labelId" :title="item.labelName">{{ item.labelName }}</span>
<span class="tag ellipsis-1" v-for="item in tagsList" :key="item.labelId" :title="item.labelValue">{{ item.labelValue }}</span>
<!-- 添加标签 仅对该客户的跟进员工可见(要有登录信息)1--商户 2--员工-->
<span class="tag addTag" @click="btnClick('create')" v-if="userType == 2">添加</span>
</div>
......@@ -113,7 +113,7 @@
</div> -->
</el-table>
<p>
<span>员工跟进</span>
<span>跟进员工</span>
<span>{{ employTableList.length || 0 }}人</span>
</p>
<!-- <div></div> -->
......@@ -272,7 +272,8 @@ export default {
this.userType = this.$globalState.session.userType
}
this.getPageDetail()
this.getSingleClientTag(this.$route.query.id, this.merchantId)
//舍弃调用小龙的获取单用户标签的接口
// this.getSingleClientTag(this.$route.query.id, this.merchantId)
},
methods: {
/* *
......@@ -282,7 +283,7 @@ export default {
len:需要显示多少个汉字,两个英文字母相当于一个汉字
*/
beautySub(value) {
if (value && value.length > 8) {
if (value && value.length >= 7) {
return value.substring(0, 6) + '...'
} else {
return value
......@@ -301,7 +302,7 @@ export default {
}
})
},
//记得把oneId,merchantId去掉,仅为测试用
//oneId,merchantId,仅为测试用
getSingleClientTag(oneId = 14120314541863, merchantId = 10001001) {
let param = {
'req.oneId': oneId,
......@@ -341,6 +342,8 @@ export default {
this.vehicleTableData = res.vehicleInfoList || []
this.employTableList = res.staffFollows || []
this.clientGroupTableList = res.customerBases || []
this.tagsList = res.labels || []
this.labelIdList = res.labels.map(item => item.labelId)
},
goNewTag() {
this.$router.push({ path: '/tagsManage/index' })
......
......@@ -3,7 +3,7 @@
<div class="scrm-sub-client-container">
<!-- <p class="pageTitle">客户管理</p> -->
<div class="pageContent">
<search-form :ploading="sloading" :isHasSyncBtn="true" :merchantModel="merchantModel" :accountLevel="accountLevel" class="searchTop border-shadow" :formModel="searchForm" :formList="clientManageFormList" @resetTable="resetTable" @searchTable="searchTable" @syncClick="syncClick">
<search-form :ploading="sloading" :isHasSyncBtn="true" :showDefaultTime="true" :merchantModel="merchantModel" :accountLevel="accountLevel" class="searchTop border-shadow" :formModel="searchForm" :formList="clientManageFormList" @resetTable="resetTable" @searchTable="searchTable" @syncClick="syncClick">
<span class="inline-b" slot="form-slot">
<el-button plain @click="resetTable">重置</el-button>
<el-button type="primary" @click="searchTable">查询</el-button>
......@@ -217,7 +217,8 @@ export default {
getListApi: getTableList,
sourceList: [],
merchantModel: 1,
accountLevel: 0 //1,2,3,4工厂,省代,市代,门店
accountLevel: 0, //1,2,3,4工厂,省代,市代,门店
flushTime: false
}
},
created() {
......@@ -245,6 +246,11 @@ export default {
this.$refs.clientManage.setTableHeightFun()
},
setTableFinishFun(content) {
if (!this.flushTime) {
this.flushTime = true
this.searchTable()
}
//接收到的数据为空
if (!this.$refs.clientManage.data.length) {
this.$refs.clientManage.setTableHeightFun()
......@@ -253,6 +259,7 @@ export default {
beforeSearchFn() {
return new Promise((resolve, reject) => {
this.searchFormTable = JSON.parse(JSON.stringify(this.searchForm))
console.log(this.searchFormTable.daterange, '时间')
if (this.searchFormTable.daterange) {
this.searchFormTable.beginTime = this.searchForm.daterange[0]
this.searchFormTable.endTime = this.searchForm.daterange[1]
......
<template>
<div class="content-wrap">
<!-- <el-date-picker class="rqxzDatePicker" v-model="dwqdDate" type="date" @change="changeDwqdTime" value-format="yyyy-MM-dd" placeholder="选择日期" :picker-options="pickerDwqdOptions"></el-date-picker> -->
<el-date-picker v-model="timeData" type="daterange" size="mini" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd" class="data-pick" unlink-panels></el-date-picker>
<div :class="['content', expande ? 'expande' : 'close']" ref="content">思路:1、判断当前内容是否超过三行。此处可以给每行设置一个行高line-height,渲染完后超过三倍的行高即认为是内容超过了三行。2、展示/收起状态的切换可以通过data中的参数来绑定。3、在底部使用position:absolute来绝对定位展开该在的位置。4、根据业务需求来设定好展开和收起按钮需要呆的地方。</div>
<div class="expande-button-wrap" v-if="needShowExpande">
<div class="expande-button" @click="expandeClick" v-if="!expande">
......@@ -17,16 +20,63 @@ export default {
data() {
return {
expande: false,
needShowExpande: true
needShowExpande: true,
timeData: []
}
},
created() {
// let date = new Date()
// let y = date.getFullYear()
// let m = date.getMonth() + 1
// m = m < 10 ? '0' + m : m
// let d = date.getDate()
// d = d < 10 ? '0' + d : d
// const time = y + '-' + m + '-' + d
// this.dwqdDate = time
},
methods: {
expandeClick() {
console.log('expandeClick')
this.expande = !this.expande
},
/* 获取过去时间,并传值给现在时间 */
getPassYearFormatDate() {
var nowDate = new Date()
var date = new Date(nowDate)
date.setDate(date.getDate() - 30)
var seperator1 = '-'
var year = date.getFullYear()
var month = date.getMonth() + 1
var strDate = date.getDate()
if (month >= 1 && month <= 9) {
month = '0' + month
}
if (strDate >= 0 && strDate <= 9) {
strDate = '0' + strDate
}
var formatDate = year + seperator1 + month + seperator1 + strDate
this.getNowFormatDate(formatDate)
},
/* 获取现在时间,并接受过去时间的值 */
getNowFormatDate(formatDate) {
var date = new Date()
var seperator1 = '-'
var year = date.getFullYear()
var month = date.getMonth() + 1
var strDate = date.getDate()
if (month >= 1 && month <= 9) {
month = '0' + month
}
if (strDate >= 0 && strDate <= 9) {
strDate = '0' + strDate
}
var nowData = year + seperator1 + month + seperator1 + strDate
this.timeData = [formatDate, nowData] // 默认赋值一年时间
}
},
mounted() {
this.getPassYearFormatDate()
this.$nextTick(() => {
let lineHeight = 22
if (this.$refs.content.offsetHeight > lineHeight * 3) {
......@@ -40,7 +90,7 @@ export default {
}
</script>
<style >
<style>
.content-wrap {
width: 300px;
height: 200px;
......@@ -87,4 +137,3 @@ export default {
line-height: 22px;
}
</style>
......@@ -103,17 +103,28 @@
<img class="editIcon" src="@/assets/tagsManage/edit.png" @click="showInput(item.id)" alt="" v-show="!item.inputVisible" />
</span>
</div>
<!-- @blur="handleInputConfirm" -->
<div class="row-tag" v-for="(item, index) in tagForm.tagsList" :key="index">
<!-- :onkeyup="(item.name = item.name.replace(/\s+/g, ''))" -->
<el-input v-model.trim="item.name" placeholder="添加标签名称(至少添加一个标签)" maxlength="30" show-word-limit></el-input>
<el-input v-model.trim="item.name" placeholder="添加标签名称(至少添加一个标签)" maxlength="30" show-word-limit @input="checkInputContent"></el-input>
<span class="el-icon-circle-close" @click="deleteRow(index)"></span>
</div>
<!-- 需要后台告诉已经创建多少个标签了 -->
<div class="addtagIcon" :style="{ color: tagForm.tagsList.length >= 3000 ? '#EEE' : '' }" @click="addRow">
<div class="addtagIcon" v-if="tagForm.initTagsGroup == 1" :style="{ color: numberObj.bizLabelCount >= 3000 ? '#EEE' : '' }" @click="addRow(tagForm.initTagsGroup)">
<i class="el-icon-circle-plus-outline"></i>
<span class="addTagText">新增标签</span>
</div>
<div class="addtagIcon" v-if="tagForm.initTagsGroup == 2" :style="{ color: numberObj.rcLabelCount >= 3000 ? '#EEE' : '' }" @click="addRow(tagForm.initTagsGroup)">
<i class="el-icon-circle-plus-outline"></i>
<span class="addTagText">新增标签</span>
</div>
<div class="addtagIcon" v-if="tagForm.initTagsGroup == ''" @click="addRow(tagForm.initTagsGroup)">
<i class="el-icon-circle-plus-outline"></i>
<span class="addTagText">新增标签</span>
</div>
<!-- v-if="tagNameRules" -->
<div class="el-form-item__error" v-if="tagNameRules">
请至少添加一个标签
</div>
</div>
</rule-form>
</slot>
......@@ -125,6 +136,7 @@
import { getTableList, getTableTagNum, newAddTag, updateTag, queryLabelListByGroupId } from '@/api/modules/tagsManage'
import { getLoginCount } from '@/api/modules/loginCount'
import url from '@/assets/clientDataOverview/nodata.png'
// import { debounce } from '@/utils/index'
export default {
name: 'tagsManage',
......@@ -139,6 +151,9 @@ export default {
}
}
return {
isAllowCloseDialog: false,
isHasSameTag: false,
tagNameRules: false,
numberObj: {},
url: url,
isFirstShow: false,
......@@ -235,7 +250,8 @@ export default {
label: '标签',
prop: 'tagsList',
type: 'customize',
slotName: 'tagsInput-type'
slotName: 'tagsInput-type',
class: 'is-required' //添加红色标志
}
],
tagRules: {
......@@ -247,6 +263,7 @@ export default {
}
],
initTagsGroup: [{ required: true, message: '请选择标签组类型', trigger: 'change' }]
// tagsList: [{ required: true }]
},
tagsGroupList: [
{ id: 1, name: '企业标签' },
......@@ -290,6 +307,15 @@ export default {
// }, 200)
},
methods: {
checkInputContent(e) {
// console.log(e, '输入框的值')
//确保每个输入框的内容不和已存在的编辑标签相同
let isHasSameTag = this.editTagList.some(ele => ele.name == e)
if (isHasSameTag) {
this.$message.error('不允许输入已存在的标签')
return
}
},
isShowEditBtn(row) {
//集团模式下,只有集团能可以编辑企业,自店,其他只能编辑自店
//单店模式下,仅门店和员工可以编辑
......@@ -370,7 +396,6 @@ export default {
//重置表格
resetTable() {
this.searchForm = { 'labelTreeReq.shopId': this.merchantId, 'labelTreeReq.edition': this.merchantModel }
// searchForm: { 'labelTreeReq.shopId': 10001001 },
this.$refs.tagsManage.refreshTable()
},
......@@ -410,33 +435,60 @@ export default {
console.log(this.$refs.tagForm.$children, 'kkk')
this.$refs.tagForm.$children[0].validate(valid => {
if (!valid) {
if (this.tagForm.tagsList.length <= 0 && this.tagDialogTitle == '添加标签组') {
this.tagNameRules = true
this.$message.error('至少要添加一个标签')
// return
}
return
}
if (this.tagForm.tagsList.length <= 0 && this.tagDialogTitle == '添加标签组') {
this.tagNameRules = true
this.$message.error('至少要添加一个标签')
return
}
if (this.tagDialogTitle == '添加标签组') {
//过滤掉没有输入值得标签输入框
this.tagForm.tagsList = this.tagForm.tagsList.filter(item => item.name != '')
if (this.tagForm.tagsList.length <= 0) {
this.$message.error('不能提交空标签')
return
}
this.newAddTagFun()
this.handleClose()
//this.handleClose() //这里不管
} else {
//修改标签(允许同时增加标签)
let isHasEmpty = this.editTagList.some(ele => ele.name == '')
if (isHasEmpty) {
this.$message.warning('不能提交空标签')
this.$message.error('不能提交空的编辑标签')
return
}
this.updateTagFun()
if (this.tagForm.tagsList.length > 0) {
//过滤掉没有输入值得标签输入框
this.tagForm.tagsList = this.tagForm.tagsList.filter(item => item.name != '')
this.newAddTagFun()
//如果存在添加标签的输入框的内容和可编辑的标签相同则不提交
let ishasSameTagFlag = false
this.editTagList.forEach(item => {
for (let i = 0; i < this.tagForm.tagsList.length; i++) {
if (this.tagForm.tagsList[i].name == item.name) {
ishasSameTagFlag = true
}
}
})
if (ishasSameTagFlag) {
this.$message.error('不能提交已存在的标签,请修改')
return
}
}
this.handleClose()
this.updateTagFun()
this.newAddTagFun()
// this.handleClose()
}
})
},
handleClose() {
this.tagNameRules = false
if (!this.tagVisible && this.$refs.tagForm) {
this.$refs.tagForm.$children[0].resetFields()
this.tagForm.initTagsGroup = ''
......@@ -461,18 +513,22 @@ export default {
params['labelDTO.labelGroup.name'] = this.tagForm.tagsName
params['labelDTO.labelType'] = this.tagForm.initTagsGroup == 1 ? '企业标签' : '自店标签'
params['labelDTO.labelList'] = this.tagForm.tagsList
console.log('tagsForm提交', this.tagForm)
params['labelDTO.isAddLabelGroupEnter'] = this.tagDialogTitle == '添加标签组' ? true : false
console.log(params)
newAddTag(params).then(res => {
if (!res) {
return
}
if (res.code == 0) {
// console.log(res, 'res信息')
if (res.data.code == 0) {
this.$message.success('添加成功')
this.resetTable() //刷新下表格
this.getTableTagNumFun()
this.handleClose()
} else if (res.data.code == 1) {
this.$message.error(`${res.data.message}`)
}
this.resetTable() //刷新下表格
this.getTableTagNumFun()
})
},
updateTagFun() {
......@@ -510,11 +566,17 @@ export default {
this.tagForm.tagsList.splice(index, 1)
},
//添加一行标签
addRow() {
// if (this.tagForm.tagsList && this.tagForm.tagsList.length > 99) {
// this.$message.warning('不允许添加超过100个')
// return
// }
addRow(type) {
this.tagNameRules = false
if (type == 1 && this.numberObj.bizLabelCount >= 3000) {
this.$message.error('企业标签数量已达上限')
return
}
if (type == 2 && this.numberObj.rcLabelCount >= 3000) {
this.$message.error('自店标签数量已达上限')
return
}
this.tagForm.tagsList.push({ name: '' })
},
showInput(id) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!