Açıklama Yok

editTheme.html 8.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>专题编辑</title>
  6. <script src="../Script/Common/huayi.load.js"></script>
  7. <script src="../Script/Common/huayi.config.js"></script>
  8. <link rel="stylesheet" href="../js/zTree/zTreeStyle.css" />
  9. <link rel="stylesheet" href="../css/init.css" />
  10. <script src="../js/laydate/laydate.js"></script>
  11. <style>
  12. th {
  13. padding: 5px 8px 5px 0;
  14. text-align: right;
  15. }
  16. input {
  17. background-color: #FFF;
  18. background-image: none;
  19. border: 1px solid #ccc;
  20. border-radius: 1px;
  21. color: inherit;
  22. padding: 6px 12px;
  23. width: 200px;
  24. }
  25. td {
  26. padding: 6px 0 5px 10px;
  27. }
  28. .addts {
  29. background: #1ab394;
  30. color: #fff;
  31. padding: 6px 10px;
  32. outline: none;
  33. font-size: 12px;
  34. margin-left: 15px;
  35. border: 0;
  36. border-radius: 3px;
  37. box-sizing: border-box;
  38. }
  39. .time-box {
  40. display: inline-block;
  41. position: relative;
  42. }
  43. .tub {
  44. position: absolute;
  45. right: 8px;
  46. top: 10px;
  47. font-size: 18px;
  48. color: #00a0ca;
  49. }
  50. #layui-laydate3 .layui-laydate-header {
  51. height: 31px;
  52. padding: 5px;
  53. }
  54. .laydate-theme-molv .layui-laydate-header i,
  55. .laydate-theme-molv .layui-laydate-header span {
  56. top: 2px;
  57. }
  58. .layui-laydate-header {
  59. padding: 0;
  60. }
  61. .laydate-theme-molv .layui-laydate-content {
  62. height: 195px;
  63. overflow: hidden;
  64. }
  65. .laydate-month-list>li {
  66. margin: 10px 0;
  67. }
  68. .laydate-footer-btns span:hover {
  69. color: #00a1cb;
  70. }
  71. .select {
  72. width: 200px;
  73. background-color: #FFF;
  74. background-image: none;
  75. border: 1px solid #ccc;
  76. border-radius: 1px;
  77. height: 36px;
  78. }
  79. </style>
  80. </head>
  81. <body>
  82. <div style="padding: 10px;">
  83. <div style="padding: 10px;" class="clearFix">
  84. <div>
  85. <span>【基础信息】</span>
  86. <div class="box_content">
  87. <table id="sqzx" style="width: 100%;" border="0" cellspacing="0" cellpadding="0">
  88. <tr class="theme">
  89. <th>类型:</th>
  90. <td>
  91. <select class="select" id="types">
  92. <!--<option value="1">周主题</option>-->
  93. <option value="2">月主题</option>
  94. </select>
  95. </td>
  96. </tr>
  97. <tr class="theme">
  98. <th>周期:</th>
  99. <td style="position: relative;">
  100. <input type="text" readonly class="layui-input" id="cycle" style="position: absolute;top: 0px;left: 10px;z-index: 2;">
  101. <input type="text" class="layui-input" id="week-picker" placeholder="yyyy-MM-dd" style="position: absolute;left: 10px;top: 0px;">
  102. </td>
  103. </tr>
  104. <tr class="theme">
  105. <th>统计时段:</th>
  106. <td>
  107. <input type="text" id="time" style="margin-top: 5px;" />
  108. </td>
  109. </tr>
  110. <tr>
  111. <th>名称:</th>
  112. <td>
  113. <input type="text" id="name" style="margin-top: 5px;" />
  114. </td>
  115. </tr>
  116. </table>
  117. </div>
  118. </div>
  119. <div class="bton" style="text-align: center;">
  120. <input class="addts" type="button" value="保存" />
  121. </div>
  122. </div>
  123. </div>
  124. <script>
  125. var id = helper.request.queryString("id");
  126. var type = helper.request.queryString("type");
  127. var themeid = helper.request.queryString("themeid");
  128. var info = null;
  129. function getWeekStr(str) {
  130. // 将字符串转为标准时间格式
  131. str2 = Date.parse(str);
  132. let date = new Date(str2);
  133. let month = date.getMonth() + 1;
  134. let week = getWeekFromDate(date);
  135. if(week === 0) { //第0周归于上月的最后一周
  136. month = date.getMonth();
  137. let dateLast = new Date();
  138. let dayLast = new Date(dateLast.getFullYear(), dateLast.getMonth(), 0).getDate();
  139. let timestamp = new Date(new Date().getFullYear(), new Date().getMonth() - 1, dayLast);
  140. week = getWeekFromDate(new Date(timestamp));
  141. }
  142. let time = date.getFullYear() + '年' + (month < 10 ? ('0' + month) : month) + "月第" + week + "周";
  143. return time;
  144. }
  145. function getWeekFromDate(date) {
  146. // 将字符串转为标准时间格式
  147. let w = date.getDay(); //周几
  148. if(w === 0) {
  149. w = 7;
  150. }
  151. let week = Math.ceil((date.getDate() + 6 - w) / 7) - 1;
  152. return week;
  153. }
  154. $(document).ready(function() {
  155. laydate.render({
  156. elem: '#time',
  157. type: 'datetime',
  158. range: true
  159. });
  160. if(type == 1) {
  161. $('.theme').show()
  162. } else {
  163. $('.theme').hide()
  164. }
  165. document.getElementById('cycle').addEventListener('focus', function() {
  166. $('#week-picker').val('');
  167. if($('#types').val() == 1) {
  168. // 初始化日期选择器
  169. laydate.render({
  170. elem: '#week-picker', // 指定元素
  171. type: 'date', // 设置选择器类型为周
  172. format: 'yyyy-MM-dd', // 自定义格式
  173. show: true,
  174. ready: function(date) {
  175. // 当选择器打开时,可以执行一些操作
  176. console.log('Selected week: ' + date);
  177. },
  178. done: function(value, date, endDate) {
  179. // 当选择器的日期发生变化时,可以执行一些操作
  180. console.log('Changed week: ', value);
  181. $('#cycle').val(getWeekStr(value));
  182. },
  183. closeStop: '#cycle'
  184. });
  185. } else {
  186. // 初始化日期选择器
  187. laydate.render({
  188. elem: '#week-picker', // 指定元素
  189. type: 'month', // 设置选择器类型为周
  190. format: 'yyyy年MM月', // 自定义格式
  191. show: true,
  192. ready: function(date) {
  193. // 当选择器打开时,可以执行一些操作
  194. console.log('Selected week: ' + date);
  195. },
  196. done: function(value, date, endDate) {
  197. // 当选择器的日期发生变化时,可以执行一些操作
  198. console.log('Changed week: ', value);
  199. $('#cycle').val(value);
  200. },
  201. closeStop: '#cycle'
  202. });
  203. }
  204. })
  205. if(id) {
  206. $.getJSON(huayi.config.callcenter_url + 'Theme/GetModel', {
  207. id: id,
  208. "token": $.cookie("token")
  209. }, function(result) {
  210. if(result.state.toLowerCase() == "success") {
  211. var content = result.data;
  212. info = content;
  213. $("#name").val(content.F_Name);
  214. $("#types").val(content.F_TypesOf);
  215. $("#cycle").val(content.F_Cycle);
  216. $("#time").val(content.F_StatisticsBeginTime + ' - ' + content.F_StatisticsEndTime );
  217. }
  218. })
  219. }
  220. $(".addts").click(function() {
  221. var name = $("#name").val();
  222. var types = $("#types").val();
  223. var cycle = $("#cycle").val();
  224. if(!name) {
  225. layer.confirm('请输入名称!', {
  226. btn: ['确定']
  227. });
  228. return;
  229. }
  230. if(type == 1 && (types == 1 && cycle.indexOf('周') < 0) || (types == 2 && cycle.indexOf('周') >= 0)) {
  231. layer.confirm('类型与周期不匹配请重新选择!', {
  232. btn: ['确定']
  233. });
  234. return;
  235. }
  236. var startTime = '';
  237. var endTime = '';
  238. if(type == 1) {
  239. var timeArr = $('#time').val().split(' - ');
  240. if(!timeArr || timeArr.length != 2) {
  241. layer.confirm('请选择统计时段!', {
  242. btn: ['确定']
  243. });
  244. return;
  245. }
  246. startTime = timeArr[0];
  247. endTime = timeArr[1];
  248. }
  249. console.log($('#time').val(), 'time')
  250. var parentid = themeid;
  251. if(type == 2 && !parentid) {
  252. parentid = info.F_ParentId;
  253. }
  254. $.post(huayi.config.callcenter_url + 'Theme/AddModel', {
  255. id,
  256. type,
  257. cycle,
  258. types,
  259. parentid,
  260. statisticsBeginTime: startTime,
  261. statisticsEndTime: endTime,
  262. name: name,
  263. "token": $.cookie("token")
  264. }, function(result) {
  265. result = $.parseJSON(result);
  266. if(result.state.toLowerCase() == "success") {
  267. layer.msg("操作成功");
  268. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  269. parent.layer.close(index); //再执行关闭
  270. // parent.initTable()();
  271. }
  272. })
  273. })
  274. });
  275. </script>
  276. </body>
  277. </html>