mirror of
https://github.com/chatopera/cosin.git
synced 2025-08-01 16:38:02 +08:00
Closed #66 在管理联系人模块中添加标签管理
This commit is contained in:
parent
7ad2b903c9
commit
cfcddb414e
@ -22,7 +22,7 @@ function httpRequest(opts) {
|
|||||||
|
|
||||||
payload.data = JSON.stringify(opts.data);
|
payload.data = JSON.stringify(opts.data);
|
||||||
|
|
||||||
var index = layer.msg('查询中,请稍候',{icon: 16,time:false,shade:0.8});
|
var index = layer.msg('执行中,请稍候',{icon: 16,time:false,shade:0.8});
|
||||||
|
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
$.ajax(payload)
|
$.ajax(payload)
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
<div class="box-body ukefu-im-theme">
|
<div class="box-body ukefu-im-theme">
|
||||||
<div class="uk-layui-form">
|
<div class="uk-layui-form">
|
||||||
<input hidden value="${contacts.id!''}" id="contactsId"/>
|
<input hidden value="${contacts.id!''}" id="contactsId"/>
|
||||||
|
<input hidden value="${contacts.creater!''}" id="creater"/>
|
||||||
<div class="layui-collapse">
|
<div class="layui-collapse">
|
||||||
<div class="layui-colla-item">
|
<div class="layui-colla-item">
|
||||||
<h2 class="layui-colla-title">基本信息</h2>
|
<h2 class="layui-colla-title">基本信息</h2>
|
||||||
@ -140,6 +141,22 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="box-body ukefu-im-theme" style="margin-top: 20px;">
|
||||||
|
<div class="uk-layui-form">
|
||||||
|
<div class="layui-collapse">
|
||||||
|
<h2 class="layui-colla-title">标签</h2>
|
||||||
|
<div class="layui-colla-content layui-show">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<div class="layui-inline">
|
||||||
|
<label class="layui-form-label" style="text-align: left;">已有标签:</label>
|
||||||
|
<div id="contactTags" class="layui-input-inline" style="width: 100%;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="box-body ukefu-im-theme" style="margin-top: 20px;">
|
<div class="box-body ukefu-im-theme" style="margin-top: 20px;">
|
||||||
<div class="uk-layui-form">
|
<div class="uk-layui-form">
|
||||||
<div class="layui-collapse">
|
<div class="layui-collapse">
|
||||||
@ -178,7 +195,7 @@
|
|||||||
<div class="layui-colla-item">
|
<div class="layui-colla-item">
|
||||||
<h2 class="layui-colla-title">往来历史</h2>
|
<h2 class="layui-colla-title">往来历史</h2>
|
||||||
<div class="layui-colla-content layui-show">
|
<div class="layui-colla-content layui-show">
|
||||||
<div id="timeline" class="timeline-container" type="text" style="height: 1060px; overflow-y: auto;">
|
<div id="timeline" class="timeline-container" type="text" style="height: 1243px; overflow-y: auto;">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -191,44 +208,25 @@
|
|||||||
</div>
|
</div>
|
||||||
<link rel="stylesheet" href="/js/timelineMe/jquery.timelineMe.css" type="text/css">
|
<link rel="stylesheet" href="/js/timelineMe/jquery.timelineMe.css" type="text/css">
|
||||||
<script type="text/javascript" src="/js/timelineMe/jquery.timelineMe.js"></script>
|
<script type="text/javascript" src="/js/timelineMe/jquery.timelineMe.js"></script>
|
||||||
<script src="/js/jquery.cookie.min.js"></script>
|
<script src="/js/CSKeFu_Rest_Request.v1.js"></script>
|
||||||
<script>
|
<style>
|
||||||
function httpRequest(opts) {
|
.unselectedClass {
|
||||||
var localUrl = 'http://localhost:8035';
|
display: inline-block;
|
||||||
var devUrl = 'http://47.104.19.187:8035';
|
font-weight: 400;
|
||||||
var proUrl = 'http://pro';
|
color: #000000;
|
||||||
|
text-align: center;
|
||||||
var postfix = '/api/';
|
white-space: nowrap;
|
||||||
|
vertical-align: baseline;
|
||||||
var urlPath = opts.path || '';
|
border-radius: .25em;
|
||||||
var query = opts.query || '';
|
background-color: #FFFFFF !important;
|
||||||
|
height: 22px;
|
||||||
var apiHost = window.location.origin;
|
line-height: 22px;
|
||||||
|
padding: 0 5px;
|
||||||
var payload = {};
|
font-size: 14px;
|
||||||
payload.url = apiHost + postfix + urlPath + query;
|
border: solid 1px #CCCCCC;
|
||||||
payload.method = payload.method || 'POST';
|
|
||||||
payload.contentType = 'application/json;charset=UTF-8';
|
|
||||||
payload.headers = {
|
|
||||||
authorization: $.cookie('authorization')
|
|
||||||
};
|
|
||||||
payload.dataType = 'json';
|
|
||||||
|
|
||||||
payload.data = JSON.stringify(opts.data);
|
|
||||||
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
$.ajax(payload)
|
|
||||||
.done(function (data) {
|
|
||||||
console.log('Rest api 返回的值:', data);
|
|
||||||
resolve(data);
|
|
||||||
})
|
|
||||||
.fail(function (jqXHR, textStatus ) {
|
|
||||||
console.error('Rest api 返回error:', jqXHR);
|
|
||||||
reject(jqXHR)
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
// save time line datas
|
// save time line datas
|
||||||
var items = [];
|
var items = [];
|
||||||
|
|
||||||
@ -243,6 +241,7 @@
|
|||||||
// remove a click event and set color to gray
|
// remove a click event and set color to gray
|
||||||
// AUTH_ERROR
|
// AUTH_ERROR
|
||||||
if(data.status && data.status === "AUTH_ERROR"){
|
if(data.status && data.status === "AUTH_ERROR"){
|
||||||
|
openFail(data.status);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,11 +283,112 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function () {
|
// unselect tag
|
||||||
|
function unOrselectTag(id) {
|
||||||
|
var el = $("#tag_" + id);
|
||||||
|
var xid = el.attr("name");
|
||||||
|
|
||||||
|
if(xid){
|
||||||
|
// unselected tag
|
||||||
|
var payload = {
|
||||||
|
path: 'contacts/tags',
|
||||||
|
data: {
|
||||||
|
ops: "remove",
|
||||||
|
xid: xid,
|
||||||
|
|
||||||
|
},
|
||||||
|
};
|
||||||
|
httpRequest(payload).then(function (data) {
|
||||||
|
if(data.status && data.status === "AUTH_ERROR"){
|
||||||
|
openFail(data.status);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(data.rc === 0){
|
||||||
|
console.log(data.data);
|
||||||
|
el.removeClass("ukefu-label").addClass("unselectedClass").attr("name", "");
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
}, function (err) {
|
||||||
|
console.log(err)
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// select tag
|
||||||
|
var contactid = $('#contactsId').val();
|
||||||
|
var payload = {
|
||||||
|
path: 'contacts/tags',
|
||||||
|
data: {
|
||||||
|
ops: "create",
|
||||||
|
contactid: contactid,
|
||||||
|
tagId: id,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
httpRequest(payload).then(function (data) {
|
||||||
|
if(data.status && data.status === "AUTH_ERROR"){
|
||||||
|
openFail(data.status);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(data.rc === 0){
|
||||||
|
console.log(data.data);
|
||||||
|
el.removeClass("unselectedClass").addClass("ukefu-label").attr("name", data.data.id);
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
}, function (err) {
|
||||||
|
console.log(err)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// get tags
|
||||||
|
function getTags(){
|
||||||
|
var id = $('#contactsId').val();
|
||||||
|
var payload = {
|
||||||
|
path: 'contacts/tags',
|
||||||
|
data: {
|
||||||
|
ops: "fetch",
|
||||||
|
contactid: id,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
httpRequest(payload).then(function (data) {
|
||||||
|
if(data.status && data.status === "AUTH_ERROR"){
|
||||||
|
openFail(data.status);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(data.rc === 0){
|
||||||
|
var tagsData = data.data;
|
||||||
|
|
||||||
|
for (var item of tagsData){
|
||||||
|
if(item.tagged){
|
||||||
|
$("#contactTags").append(
|
||||||
|
'<small name="' + item.xid + '" id="tag_' + item.id + '" class="ukefu-label" style="margin: 0 6px 5px 0;cursor: pointer;" onclick="unOrselectTag(\'' + item.id + '\')">' + item.name + '</small>'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$("#contactTags").append(
|
||||||
|
'<small name="" id="tag_' + item.id + '" class="unselectedClass" style="margin: 0 6px 5px 0; cursor: pointer;" onclick="unOrselectTag(\'' + item.id + '\')">' + item.name + '</small>'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
}, function (err) {
|
||||||
|
console.log(err)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
layui.use('layer', function() {
|
||||||
|
layer = layui.layer;
|
||||||
|
|
||||||
// get all notes by contact id.
|
// get all notes by contact id.
|
||||||
getNotesByContactId();
|
getNotesByContactId();
|
||||||
|
|
||||||
|
// get tags
|
||||||
|
getTags()
|
||||||
|
|
||||||
|
// add notes
|
||||||
$('#notesAddBtn').on('click', function(){
|
$('#notesAddBtn').on('click', function(){
|
||||||
var content = $('#notesContent').val() || '';
|
var content = $('#notesContent').val() || '';
|
||||||
if(!content) return;
|
if(!content) return;
|
||||||
@ -309,6 +409,7 @@
|
|||||||
};
|
};
|
||||||
httpRequest(payload).then(function (data) {
|
httpRequest(payload).then(function (data) {
|
||||||
if(data.status && data.status === "AUTH_ERROR"){
|
if(data.status && data.status === "AUTH_ERROR"){
|
||||||
|
openFail(data.status);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,4 +434,3 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user