company_contact.blade.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. @extends('module.layouts.company')
  2. @push('meta')
  3. @endpush
  4. @push('css')
  5. <link rel="stylesheet" type="text/css" href="{{ theme_asset('app/css/company/common.css') }}"/>
  6. <link rel="stylesheet" type="text/css" href="{{ theme_asset('app/css/company/company_user.css')}}"/>
  7. <link rel="stylesheet" type="text/css" href="{{ theme_asset('app/css/company/company_ajax_dialog.css')}}"/>
  8. @endpush
  9. @section('content')
  10. <div class="user_main">
  11. <div class="mleft">
  12. @include('module.section.company_left')
  13. </div>
  14. <div class="mright">
  15. <div class="user_pagetitle pms_user_pagetitle" style="position: relative;">
  16. <div class="pat_l">联系信息</div>
  17. <div class="clear"></div>
  18. <div class="btnbox" style="position: absolute;right:0px;top:0px">
  19. <div class="btn_yellow J_hoverbut btn_add J_contact_add" style="margin-right:0px;">
  20. 添加联系人
  21. </div>
  22. </div>
  23. </div>
  24. <div class="user_tab">
  25. <a href="{{ route('com.contact') }}" class="tabli select">联系信息</a>
  26. <div class="clear"></div>
  27. </div>
  28. <div class="pms_wrap J_allListBox">
  29. @if($contacts->isNotEmpty())
  30. <div class="pms_th">
  31. <div class="th1" style="width: 140px;">联系人</div>
  32. <div class="th1" style="width: 120px;padding-left: 10px;">联系电话</div>
  33. <div class="th1" style="width: 200px;">邮箱</div>
  34. <div class="th4" style="width: 160px;text-align: center">操作</div>
  35. <div class="clear"></div>
  36. </div>
  37. @foreach($contacts as $k=>$v)
  38. <div class="pms J_hoverbut contact" contact_id="{{$v->id}}">
  39. <div class="td1 substring nowrap link_blue" style="padding-right: 0px;width: 160px;">
  40. <input class="J_allList chk" type="checkbox" name="id[]" value="{{$v->id}}">
  41. {{$v->contact}}
  42. </div>
  43. <div class="td2 substring" style="width: 160px;">
  44. @if($v->telephone)
  45. {{$v->telephone}}
  46. @else
  47. {{dealContactPhone($v->landline_tel)}}
  48. @endif
  49. </div>
  50. <div class="td2 substring" style="width: 230px;">{{$v->email}}</div>
  51. <div class="td2 link_blue" style="width: 160px;text-align: center;">
  52. <a href="javascript:;" class="J_contact_check">查看</a>&nbsp;&nbsp;
  53. <a href="javascript:;" class="J_contact_edit">编辑</a>&nbsp;&nbsp;
  54. <a href="javascript:;" url="{{ route('com.contact.del') }}" class="delete">删除</a>
  55. </div>
  56. <div class="clear"></div>
  57. </div>
  58. @endforeach
  59. <div class="pms_btn">
  60. <div class="allSelWrap">
  61. <input name="" class="allSel J_allSelected" type="checkbox">
  62. </div>
  63. <div class="btn_lightgray J_hoverbut btn_inline btn_border J_delall">删除</div>
  64. <div class="clear"></div>
  65. </div>
  66. {{ $contacts->links('module.widgets.pagination') }}
  67. @else
  68. <div style="text-align: center;">暂无联系人信息</div>
  69. @endif
  70. </div>
  71. </div>
  72. <div class="clear"></div>
  73. </div>
  74. @endsection
  75. @section('script')
  76. <script type="text/javascript" src="{{ theme_asset('app/js/jquery.dropdown.js') }}"></script>
  77. <script type="text/javascript" src="{{ theme_asset('app/js/jquery.listitem.js')}}"></script>
  78. <script type="text/javascript" src="{{ theme_asset('app/js/jquery.disappear.tooltip.js') }}"></script>
  79. <script type="text/javascript" src="{{ theme_asset('app/js/company/jquery.common.js') }}"></script>
  80. <script type="text/javascript" src="{{ theme_asset('app/js/jquery.allselected.js') }}"></script>
  81. <script type="text/javascript" src="{{ theme_asset('app/js/regular.js') }}"></script>
  82. <script type="text/javascript">
  83. function checkForm() {
  84. var contactValue = $.trim($('#contact').val());
  85. var telephoneValue = $.trim($('#telephone').val());
  86. var telfirstValue = $.trim($('#tel_first').val());
  87. var telnextValue = $.trim($('#tel_next').val());
  88. var tellastValue = $.trim($('#tel_last').val());
  89. var landlinetelValue = telfirstValue+'-'+telnextValue+'-'+tellastValue;
  90. var emailValue = $.trim($('#email').val());
  91. var addressValue = $.trim($('#address').val());
  92. if (contactValue == "") {
  93. disapperTooltip('remind','请输入联系人');
  94. return false;
  95. }
  96. if (contactValue != "" && contactValue.length > 10) {
  97. disapperTooltip('remind','联系人1-10个字');
  98. return false;
  99. }
  100. if(telnextValue=="" && telephoneValue=="") {
  101. disapperTooltip('remind','手机号码和固定电话至少填写一项');
  102. return false;
  103. } else {
  104. if (telephoneValue != "" && !regularMobile.test(telephoneValue)) {
  105. disapperTooltip('remind','手机号码格式不正确');
  106. return false;
  107. }
  108. }
  109. //电话号码填写的某个不为空
  110. /**
  111. * 分机号可以为空
  112. */
  113. if(telfirstValue!="" || telnextValue!="" || tellastValue!=""){
  114. if (!regularTelFirst.test(telfirstValue)) {
  115. disapperTooltip("remind", "请填写正确的区号");
  116. return false;
  117. }
  118. if (!regularTelNext.test(telnextValue)) {
  119. disapperTooltip("remind", "电话号码为6-11位数字");
  120. return false;
  121. }
  122. if ((!regularTelLast.test(tellastValue) || tellastValue.length > 4) && tellastValue!="") {
  123. disapperTooltip("remind", "分机号码为数字且不能超出4位");
  124. return false;
  125. }
  126. }
  127. if (emailValue != "" && !regularEmail.test(emailValue) || emailValue.split("@")[0].length > 20) {
  128. disapperTooltip('remind','邮箱格式不正确');
  129. return false;
  130. }
  131. if (addressValue == "") {
  132. disapperTooltip('remind','联系地址不能为空');
  133. return false;
  134. }
  135. if (addressValue != "" && addressValue.length > 30) {
  136. disapperTooltip('remind','联系地址不能大于30个字');
  137. return false;
  138. }
  139. return true;
  140. }
  141. //添加联系人
  142. $('.J_contact_add').click(function(){
  143. var qsDialog = $(this).dialog({
  144. title: '添加联系人',
  145. loading: true,
  146. btns: ['确定', '取消'],
  147. showFooter: false,
  148. yes: function() {
  149. qsDialog.setCloseDialog(false);
  150. var form_data = $('#contact_content').serialize();
  151. if (checkForm()) {
  152. $.post("{{ route('com.contact.add') }}",form_data,function(result){
  153. if(result.status == 1){
  154. disapperTooltip('success',result.msg);
  155. setTimeout(function(){
  156. window.location.reload();
  157. },2000);
  158. }else{
  159. disapperTooltip('remind',result.msg);
  160. }
  161. },'json');
  162. }
  163. }
  164. });
  165. $.getJSON("{{ route('com.contact.add') }}",function(result){
  166. if(result.status == 1){
  167. qsDialog.setContent(result.data);
  168. qsDialog.showFooter(true);
  169. }else{
  170. qsDialog.setContent('<div class="confirm">' + result.msg + '</div>');
  171. }
  172. });
  173. });
  174. //编辑联系人
  175. $('.J_contact_edit').click(function(){
  176. var f = $(this).closest('.contact');
  177. var id = f.attr('contact_id');
  178. var qsDialog = $(this).dialog({
  179. title: '编辑联系人',
  180. loading: true,
  181. btns: ['确定', '取消'],
  182. showFooter: false,
  183. yes: function() {
  184. qsDialog.setCloseDialog(false);
  185. if (checkForm()) {
  186. var form_data = $('#contact_content').serialize();
  187. $.post("{{ route('com.contact.edit') }}",form_data,function(result){
  188. if(result.status == 1){
  189. disapperTooltip('success',result.msg);
  190. setTimeout(function(){
  191. window.location.reload();
  192. },2000);
  193. }else{
  194. disapperTooltip('remind',result.msg);
  195. }
  196. },'json');
  197. }
  198. }
  199. });
  200. $.getJSON("{{ route('com.contact.edit') }}",{id:id},function(result){
  201. if(result.status == 1){
  202. qsDialog.setContent(result.data);
  203. qsDialog.showFooter(true);
  204. }else{
  205. qsDialog.setContent('<div class="confirm">' + result.msg + '</div>');
  206. }
  207. });
  208. });
  209. //查看联系人
  210. $('.J_contact_check').click(function(){
  211. var f = $(this).closest('.contact'),
  212. id = f.attr('contact_id');
  213. var qsDialog = $(this).dialog({
  214. title: '企业联系人详情',
  215. loading: true,
  216. footer: false
  217. });
  218. $.getJSON("{{ route('com.contact.show') }}",{id:id},function(result){
  219. if(result.status == 1){
  220. qsDialog.setContent(result.data);
  221. qsDialog.showFooter(true);
  222. }else{
  223. qsDialog.setContent(result.msg);
  224. }
  225. });
  226. });
  227. //删除联系人
  228. $(".delete").click(function () {
  229. var url = $(this).attr('url'),
  230. f = $(this).closest('.contact'),
  231. id = f.attr('contact_id');
  232. var qsDialog = $(this).dialog({
  233. title: '删除企业联系人',
  234. loading: true,
  235. border: false,
  236. yes: function () {
  237. $.post(url,{id:id,_token: "{{csrf_token()}}"},function(result){
  238. if(result.status == 1){
  239. f.remove();
  240. disapperTooltip('success',result.msg);
  241. setTimeout(function () {
  242. location.href="{{route('com.contact')}}"
  243. },1000)
  244. }else{
  245. disapperTooltip('remind',result.msg);
  246. }
  247. },'json');
  248. }
  249. });
  250. qsDialog.setContent('被删除后将无法恢复,您确定要删除选中的企业联系信息吗?');
  251. });
  252. $('.J_delall').click(function(){
  253. var listCheckedArray = $('.J_allListBox .J_allList:checked');
  254. if (listCheckedArray.length) {
  255. var idarr = new Array();
  256. $.each($("input[name='id[]']:checked") ,function(){
  257. idarr.push($(this).val());
  258. });
  259. var qsDialog = $(this).dialog({
  260. title: '删除企业联系人',
  261. loading: true,
  262. border: false,
  263. yes: function () {
  264. $.post("{{ route('com.contact.del') }}",{id:idarr,_token: "{{csrf_token()}}"},function(result){
  265. if(result.status == 1){
  266. listCheckedArray.closest('.contact').remove();
  267. $(".J_allListBox input[type='checkbox']").prop("checked",false);
  268. disapperTooltip('success',result.msg);
  269. setTimeout(function () {
  270. location.href="{{route('com.contact')}}"
  271. },1000)
  272. }else{
  273. disapperTooltip('remind',result.msg);
  274. }
  275. },'json');
  276. }
  277. });
  278. qsDialog.setContent('被删除后将无法恢复,您确定要删除选中的企业联系信息吗?');
  279. } else {
  280. disapperTooltip("remind", "请选择要删除的联系信息");
  281. }
  282. });
  283. </script>
  284. @endsection