|
@@ -1163,14 +1163,18 @@ $(function(){
|
|
|
<!-- 自定义标签弹框 -->
|
|
|
<div class="tags-box">
|
|
|
<div class="tags-inputs">
|
|
|
- <input type="hidden" class="tag-input-hidden" value="">
|
|
|
<div class="tag-input">
|
|
|
<div class="tag-labels"></div>
|
|
|
<input type="text" class="clear-input">
|
|
|
<div class="tag-placeholder">新增标签回车保存</div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ <div class="add-tag-button">添加并使用</div>
|
|
|
+ </div>
|
|
|
<div class="tags-list clearfix"></div>
|
|
|
+ <div class="tags-footer">
|
|
|
+ <div class="tags-button button-confirm">确认添加</div>
|
|
|
+ <div class="tags-button button-cancel">暂不添加</div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<!--分页-->
|
|
@@ -1402,42 +1406,6 @@ $(function(){
|
|
|
$(document).click(function() {
|
|
|
$('.custom-select').css("border-color", '#e0e0e0').children('.icon-arrow').removeClass('up')
|
|
|
$('.custom-select').siblings().hide()
|
|
|
- // console.log('标签弹框是否隐藏',$('.tags-box').is(':hidden'))
|
|
|
- // 自定义标签弹框消失时执行保存标签动作
|
|
|
- if (!$('.tags-box').is(':hidden')){
|
|
|
- var lids = ""
|
|
|
- var lname = ""
|
|
|
- $('.tags-item.tags-active').each(function() {
|
|
|
- if ($(this).attr('data-id')){
|
|
|
- if(lids != ""){
|
|
|
- lids += ",";
|
|
|
- }
|
|
|
- if(lname != "") {
|
|
|
- lname+= ",";
|
|
|
- }
|
|
|
- lids += $(this).attr('data-id');
|
|
|
- lname += $(this).text()
|
|
|
- }
|
|
|
- })
|
|
|
- var params = {
|
|
|
- lids: lids,
|
|
|
- laction: 'S',
|
|
|
- binfo: JSON.parse(sessionStorage.getItem('$save-tags-binfo'))
|
|
|
- }
|
|
|
- // console.log(params)
|
|
|
- $('.tags-box').hide(function() {
|
|
|
- // 执行保存绑定标签操作
|
|
|
- if (params.lids !== '') {
|
|
|
- saveChooseTags(params)
|
|
|
- }
|
|
|
- // 标签弹框消失时 清除上次选择的标签分类
|
|
|
- activeTags = []
|
|
|
- $('.tag-labels').empty()
|
|
|
- $('.clear-input').val('')
|
|
|
- $('.tags-list').find('.tags-item').removeClass('tags-active')
|
|
|
- $('.tag-placeholder').show()
|
|
|
- })
|
|
|
- }
|
|
|
})
|
|
|
// 全选
|
|
|
$('.custom-checkbox.check-all').on('change', function() {
|
|
@@ -1465,9 +1433,8 @@ $(function(){
|
|
|
$('.tag-input .clear-input').keydown(function(event){
|
|
|
event.stopPropagation()
|
|
|
if (event.keyCode == 13) {
|
|
|
- if($(this).val().length >= 2 && $(this).val().length < 6) {
|
|
|
- // ajax提交自定义标签
|
|
|
- addTagsAjax($(this).val())
|
|
|
+ if (!$('.tags-box').is(':hidden')) {
|
|
|
+ $('.tags-inputs .add-tag-button').trigger('click')
|
|
|
}
|
|
|
}
|
|
|
})
|
|
@@ -1477,7 +1444,56 @@ $(function(){
|
|
|
$('.tag-placeholder').show()
|
|
|
}
|
|
|
})
|
|
|
+ // 添加标签按钮事件
|
|
|
+ $('.tags-inputs .add-tag-button').on('click', function () {
|
|
|
+ var input = $('.tag-input .clear-input')
|
|
|
+ if(input.val().length >= 2 && input.val().length < 6) {
|
|
|
+ // ajax提交自定义标签
|
|
|
+ addTagsAjax(input.val())
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // 点击确定按钮,绑定标签
|
|
|
+ $('.tags-footer .button-confirm').on('click', function () {
|
|
|
+ if (!$('.tags-box').is(':hidden')){
|
|
|
+ var lids = ""
|
|
|
+ var lname = ""
|
|
|
+ $('.tags-item.tags-active').each(function() {
|
|
|
+ if ($(this).attr('data-id')){
|
|
|
+ if(lids != ""){
|
|
|
+ lids += ",";
|
|
|
+ }
|
|
|
+ if(lname != "") {
|
|
|
+ lname+= ",";
|
|
|
+ }
|
|
|
+ lids += $(this).attr('data-id');
|
|
|
+ lname += $(this).text()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ var params = {
|
|
|
+ lids: lids,
|
|
|
+ laction: 'S',
|
|
|
+ binfo: JSON.parse(sessionStorage.getItem('$save-tags-binfo'))
|
|
|
+ }
|
|
|
|
|
|
+ // 执行保存绑定标签操作
|
|
|
+ if (params.lids !== '') {
|
|
|
+ saveChooseTags(params, function () {
|
|
|
+ $('.tags-footer .button-cancel').trigger('click')
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ $('.tags-footer .button-cancel').on('click', function () {
|
|
|
+ $('.tags-box').hide(function() {
|
|
|
+ // 标签弹框消失时 清除上次选择的标签分类
|
|
|
+ activeTags = []
|
|
|
+ $('.tag-labels').empty()
|
|
|
+ $('.clear-input').val('')
|
|
|
+ $('.tags-list').find('.tags-item').removeClass('tags-active')
|
|
|
+ $('.tag-placeholder').show()
|
|
|
+ })
|
|
|
+ })
|
|
|
// 查询标讯是否收藏
|
|
|
getBidIsColl()
|
|
|
})
|
|
@@ -1505,6 +1521,7 @@ function inputTagList () {
|
|
|
if ($('.tag-labels').children('.tag-label').length > 0) {
|
|
|
$('.tag-placeholder').hide()
|
|
|
}
|
|
|
+ checkTagDisabled()
|
|
|
}
|
|
|
// 渲染标签列表数据
|
|
|
function renderTagsList (data) {
|
|
@@ -1519,6 +1536,7 @@ function renderTagsList (data) {
|
|
|
})
|
|
|
$('.tags-item').click(function(e) {
|
|
|
e.stopPropagation()
|
|
|
+ if ($(this).hasClass('disabled')) return
|
|
|
var id = $(this).attr('data-id');
|
|
|
var name = $(this).text()
|
|
|
$(this).toggleClass('tags-active')
|
|
@@ -1547,8 +1565,8 @@ function getUserTags () {
|
|
|
type:'post',
|
|
|
url:'/publicapply/bidcoll/getLabel?t=' + Date.now(),
|
|
|
success: function(r){
|
|
|
- if (r.error_code == 0 && r.data) {
|
|
|
- renderTagsList(r.data)
|
|
|
+ if (r.error_code == 0 && $.isArray(r.data)) {
|
|
|
+ renderTagsList(r.data.reverse())
|
|
|
}
|
|
|
}
|
|
|
})
|
|
@@ -1566,7 +1584,7 @@ function getUserTags () {
|
|
|
2:lids不为空;laction=”S”;binfo数组不为空->收藏信息绑定标签
|
|
|
3:lids不为空;laction=”D”;->删除标签 并解绑收藏的信息
|
|
|
*/
|
|
|
-function saveChooseTags(params) {
|
|
|
+function saveChooseTags(params, callback) {
|
|
|
$.ajax({
|
|
|
type:'post',
|
|
|
url:'/publicapply/bidcoll/label',
|
|
@@ -1576,6 +1594,7 @@ function saveChooseTags(params) {
|
|
|
success: function(r){
|
|
|
if (r.data) {
|
|
|
toastFn("标签绑定成功", 1000)
|
|
|
+ callback && callback()
|
|
|
}
|
|
|
}
|
|
|
})
|
|
@@ -1593,10 +1612,12 @@ function addTagsAjax (name) {
|
|
|
if (r.data) {
|
|
|
$('.tag-input .clear-input').val('')
|
|
|
// 添加标签成功后 绑定标签
|
|
|
- activeTags.push({
|
|
|
- lid: r.data,
|
|
|
- lname: name
|
|
|
- })
|
|
|
+ if (activeTags.length < 3) {
|
|
|
+ activeTags.push({
|
|
|
+ lid: r.data,
|
|
|
+ lname: name
|
|
|
+ })
|
|
|
+ }
|
|
|
getUserTags()
|
|
|
} else {
|
|
|
toastFn(r.error_msg, 1000)
|
|
@@ -1631,6 +1652,15 @@ function collBidAction (baction, binfo, callback) {
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
+function checkTagDisabled () {
|
|
|
+ if (activeTags.length >= 3) {
|
|
|
+ // 禁用标签
|
|
|
+ $('.tags-list').find('.tags-item:not(.tags-active)').addClass('disabled')
|
|
|
+ } else {
|
|
|
+ // 解除禁用
|
|
|
+ $('.tags-list').find('.disabled').removeClass('disabled')
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
//
|
|
|
function NullSuperSearch(){
|