rabin hai 1 ano
pai
achega
1238b752d1
Modificáronse 5 ficheiros con 114 adicións e 6 borrados
  1. 67 1
      assets/manage/html/model.html
  2. 11 0
      database/model.php
  3. 2 2
      database/template.php
  4. 32 3
      lib/Manage.php
  5. 2 0
      template/manage/model.php

+ 67 - 1
assets/manage/html/model.html

@@ -5,10 +5,55 @@
 }
 
 #bg {
-  background-image:url('http://192.168.33.10/dreamland/data/upload/1/2020/11/09/d06b800db5022f9ae73dfa4de559eec7.jpg');
+  background-image:url('http://192.168.33.10/sellking/data/upload/1/2022/10/12/4d5893ad6c7f3ca0680c615e360a6041.png');
   background-repeat: no-repeat;
   background-size: contain;
   overflow: hidden;
+  border: 1px solid;
+}
+#item {
+    width: 600px;
+    height: 300px;
+    border: 1px solid #ddd;
+}
+
+.custom-context-menu {
+    position: fixed;
+    border: 1px solid #ccc;
+    font-size: 15px;
+    background: white;
+}
+
+.custom-context-menu {
+    position: fixed;
+    border: 1px solid #ccc;
+    list-style: none;
+    border-radius: 4px;
+    box-shadow: 0px 2px 6px 2px #ddd;
+}
+
+.custom-context-menu li {
+    padding: 8px 12px;
+    border-bottom: 1px solid #f0f2f5;
+    user-select: none;
+    transition: all 0.1s;
+}
+.custom-context-menu li:last-child {
+    border-bottom: none;
+}
+
+.custom-context-menu li:hover {
+    cursor: pointer;
+    background-color: #009688;
+    color: #fff;
+}
+
+.custom-context-menu li:active {
+    background-color: #009688;
+}
+
+.hidden {
+    display: none;
 }
 </style>
 <div class="layui-fluid" style="padding: 0px;">
@@ -41,6 +86,27 @@ $( function() {
       }
   });
 
+  $(".draggable").each(function() {
+      let item = $(this).get(0);
+
+      item.addEventListener('contextmenu', (e) => {
+          e.preventDefault();
+          let menu = item.getElementsByTagName('ul')[0]
+          menu.style.top = `${e.clientY}px`;
+          menu.style.left = `${e.clientX}px`;
+          menu.classList.remove('hidden');
+
+          let menuList = menu.getElementsByTagName('li')
+          for (let menuItem of menuList) {
+             
+          }
+      });
+      item.addEventListener('click', () => {
+          let menu = item.getElementsByTagName('ul')[0]
+          menu.classList.add('hidden')
+      })
+  })
+
   $('#bg').each(function() {
     var img=$(this);
     var url=$(this).css('backgroundImage');

+ 11 - 0
database/model.php

@@ -261,6 +261,17 @@ return array
 
 	'manage' => array
     (
+    	'delete' => false,
+    	'edit' => false,
+    	'insert' => false,
         'page_list_table' => 'model',
+        'button' => array
+        (
+            '新增' => array('fast'),
+        ),
+		'list_button' => array
+        (
+        	'edit' => array('编辑'),
+        )
     ),
 );

+ 2 - 2
database/template.php

@@ -129,7 +129,7 @@ return array
 			'name' 		=> '模板背景图',
 			'default' 	=> '',
 			'desc' 		=> '模板背景图',
-			'match' 	=> 'option',
+			'match' 	=> 'is_string',
 			'update'	=> 'image',
 			'key' 		=> '1',
 			'show'		=> 'create=2',
@@ -174,7 +174,7 @@ return array
 		# 列表
 		'list_button' => array
 		(
-			'list' => array('模块', '"model&project=poster&search_option_template_id={id}&oper_parent=template&oper_project=poster&page_type=1"'),
+			'list' => array('设计', '"model&project=poster&search_option_template_id={id}&oper_parent=template&oper_project=poster&page_type=1"'),
 		),
 	),
 

+ 32 - 3
lib/Manage.php

@@ -3,6 +3,7 @@
 namespace Poster\Lib;
 
 use Dever;
+use Dever\Support\Img as Handle;
 
 class Manage
 {
@@ -27,6 +28,28 @@ class Manage
         return $id;
     }
 
+    public function template()
+    {
+        $id = Dever::input('search_option_template_id');
+
+        $info = Dever::db('poster/template')->find($id);
+
+        if ($info['create'] == 1) {
+            # 生成空白背景图
+            $filename = 'background_' . $info['id'];
+            $file =  Dever::pathDay('upload/poster', false) . $filename . '.jpg';
+            $img = new Handle();
+            $img->create($file, $info['width'], $info['height'], 1);
+            $info['background'] = Dever::pic($file);
+        }
+
+        //$info['background'] = Dever::local($info['background']);
+
+        $info['background'] = "background-image:url('".$info['background']."');";
+
+        return $info;
+    }
+
     public function model()
     {
     	$where['template_id'] = Dever::input('search_option_template_id');
@@ -37,8 +60,9 @@ class Manage
     		foreach ($data as $k => $v) {
     			$data[$k]['content'] = '';
     			$data[$k]['style'] = 'display:none;position:absolute;';
-
+                
     			if ($v['type'] == 1) {
+                    
     				$data[$k]['content'] = '<img src="'.$v['value_pic'].'" style="width: '.$v['width'].'px;height:'.$v['height'].'px;">';
     				$data[$k]['style'] .= 'width: '.$v['width'].'px;height:'.$v['height'].'px;';
     			} else {
@@ -46,7 +70,7 @@ class Manage
     					$v['value'] = $v['name'];
     				}
     				$data[$k]['content'] = $v['value'];
-    				//$data[$k]['style'] .= 'width: '.$v['text_width'].'px;';
+    				$data[$k]['style'] .= 'width: '.$v['text_width'].'px;';
 
     				if ($v['color']) {
     					$data[$k]['style'] .= 'color:' . $v['color'] . ';';
@@ -61,8 +85,13 @@ class Manage
     				}
     			}
 
+                $edit_link = Dever::url('project/database/update&project=poster&table=model&where_id=' . $v['id'], 'manage');
+                $del_link = Dever::url('database.delete_action&project=poster&table=model&where_id=' . $v['id'], 'manage');
+                
+                $data[$k]['content'] .= '<ul class="custom-context-menu hidden"><li class="edit" onclick="fastEdit($(this), \''.$edit_link.'\', \'编辑\', \'\')">编辑</li><li class="del" onclick="del_act(\''.$del_link.'\')">删除</li></ul>';
+
     			$p = explode(',', $v['position']);
-    			$data[$k]['style'] .= 'left:'.$p[0].'px;top:'.$p[1].'px;'; 
+    			$data[$k]['style'] .= 'left:'.$p[0].'px;top:'.$p[1].'px;';
     		}
     	}
 

+ 2 - 0
template/manage/model.php

@@ -11,6 +11,8 @@ $view
 
 ->fetch('#url', 'var url="<{Dever::url("poster/lib/manage.update")}>"')
 
+->fetch('#bg@style', 'poster/lib/manage.template#background')
+
 ->loop
 (
     '.draggable',