add.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. {extend name="common/common2" /}
  2. {block name="main"}
  3. <style>
  4. .select-box{
  5. position: fixed;
  6. z-index: 100;
  7. width: 350px;
  8. top: 0;
  9. right: 0;
  10. background-color: #ffffff;
  11. bottom: 0;
  12. overflow: auto;
  13. }
  14. .select-img{
  15. cursor: pointer;
  16. width: 25px;
  17. height: 25px;
  18. }
  19. .select-title{
  20. padding: 15px;
  21. }
  22. </style>
  23. <div class="row">
  24. <div class="col-sm-12">
  25. <div class="ibox float-e-margins">
  26. <div class="ibox-title">
  27. <h5>{$meta_title}</h5>
  28. <div class="ibox-tools">
  29. <a class="toback" href="{:url('index')}">
  30. 返回上一页
  31. </a>
  32. </div>
  33. </div>
  34. <div class="ibox-content">
  35. <div class="row">
  36. <div class="col-xs-8">
  37. <form method="post" action="{:url('add')}" class="form-horizontal">
  38. <input type="hidden" name="id" value="{$info['id']|default='0'}">
  39. <div class="form-group">
  40. <label class="col-xs-3 control-label">名称<span class="text-danger">*</span></label>
  41. <div class="col-xs-9">
  42. <input type="text" class="form-control" name="title" value="{$info.title|default=''}">
  43. </div>
  44. </div>
  45. <div class="form-group">
  46. <label class="col-xs-3 control-label">图片</label>
  47. <div class="col-xs-9">
  48. {:widget_view('common/upimg',['name'=>'img','multi'=>0,'val'=>isset($info)?$info['img']:''])}
  49. </div>
  50. </div>
  51. <div class="form-group">
  52. <label class="col-xs-3 control-label">备注</label>
  53. <div class="col-xs-9">
  54. <input type="text" class="form-control" name="remark" value="{$info.remark|default=''}">
  55. </div>
  56. </div>
  57. <div class="form-group">
  58. <label class="col-xs-3 control-label">大屏类型<span class="text-danger">*</span></label>
  59. <div class="col-xs-9">
  60. <select name="type" id="screentype" class="form-control" onchange="changeType()">
  61. <option value="1">项目大屏</option>
  62. <option value="2">自定义大屏</option>
  63. <option value="3">3D大屏</option>
  64. </select>
  65. </div>
  66. </div>
  67. <div class="form-group" id="screen-url">
  68. <label class="col-xs-3 control-label">大屏链接</label>
  69. <div class="col-xs-9">
  70. <input type="text" class="form-control" name="url" value="{$info.url|default=''}">
  71. </div>
  72. </div>
  73. <div id="vueapp-module">
  74. <div class="form-group">
  75. <label class="col-xs-3 control-label">模板<span class="text-danger">*</span></label>
  76. <div class="col-xs-9">
  77. <input type="hidden" name="tid" id="tid" value="{$info.tid|default='0'}">
  78. <button type="button" class="btn btn-sm btn-primary" @click="selectTemp">选择模板</button>
  79. <div v-if="ttitle">
  80. {{ttitle}}
  81. </div>
  82. </div>
  83. </div>
  84. <div class="form-group">
  85. <label class="col-xs-3 control-label">模块绑定</label>
  86. <div class="col-xs-9">
  87. <input type="hidden" id="ele-module" name="content" value="{$info.content|default=''}">
  88. <table class="table table-bordered">
  89. <thead>
  90. <tr>
  91. <th>序号</th>
  92. <th>绑定模块</th>
  93. <th>预览模块</th>
  94. </tr>
  95. </thead>
  96. <tbody>
  97. <tr v-for="(item,index) in contents" :key="index">
  98. <th>{{item.id}}</th>
  99. <th>
  100. <button type="button" class="btn btn-sm btn-primary" @click="selectModule(item)">选择模块</button>
  101. {{item.title}}
  102. </th>
  103. <th>
  104. <img v-if="item.img" :src="item.img" style="width: 40px;height: 40px;" onclick="open_img(this)" alt="">
  105. </th>
  106. </tr>
  107. </tbody>
  108. </table>
  109. </div>
  110. </div>
  111. <div class="select-box" v-if="showTemp || showModule">
  112. <div v-if="showTemp">
  113. <div class="select-title">
  114. 选择模板
  115. <button type="button" class="btn btn-xs pull-right btn-danger" @click="closeSelect">关闭</button>
  116. </div>
  117. <table class="table table-bordered">
  118. <tr v-for="(item,index) in temps" :key="index">
  119. <td>
  120. <img v-if="tid == item.id" class="select-img" src="/img/dui.png" alt="" @click="sTemp(item)">
  121. <img v-if="tid != item.id" class="select-img" src="/img/undui.png" alt="" @click="sdTemp(item)">
  122. <img onclick="open_img(this)" :src="item.img" style="width: 50px;height: 50px" alt="">
  123. {{item.title}}
  124. </td>
  125. </tr>
  126. </table>
  127. </div>
  128. <div v-if="showModule">
  129. <div class="select-title">
  130. 选择模块
  131. <button type="button" class="btn btn-xs pull-right btn-danger" @click="closeSelect">关闭</button>
  132. </div>
  133. <table class="table table-bordered">
  134. <tr v-for="(item,index) in options" :key="index">
  135. <td>
  136. <img v-if="curItem.mid == item.id" class="select-img" src="/img/dui.png" alt="" @click="sModule(item)">
  137. <img v-if="curItem.mid != item.id" class="select-img" src="/img/undui.png" alt="" @click="sdModule(item)">
  138. <img onclick="open_img(this)" :src="item.img" style="width: 50px;height: 50px" alt="">
  139. {{item.title}}
  140. </td>
  141. </tr>
  142. </table>
  143. </div>
  144. </div>
  145. </div>
  146. <div class="hr-line-dashed"></div>
  147. <div class="form-group">
  148. <div class="col-xs-9 col-xs-offset-3">
  149. <button class="btn btn-primary ajax-post" target-form="form-horizontal" type="submit">确 定</button>
  150. <a href="{:url('index')}" class="btn btn-default">取 消</a>
  151. </div>
  152. </div>
  153. </form>
  154. </div>
  155. </div>
  156. </div>
  157. </div>
  158. </div>
  159. </div>
  160. {/block}
  161. {block name="script"}
  162. <script>
  163. $(document).ready(function(){
  164. formSetValue("tid", {$info.tid|default=0});
  165. formSetValue("type", {$info.type|default=1});
  166. changeType();
  167. });
  168. function changeType() {
  169. var v = $('#screentype').val();
  170. if(v == 1){
  171. $('#vueapp-module').show();
  172. $('#screen-url').hide();
  173. }else{
  174. $('#screen-url').show();
  175. $('#vueapp-module').hide();
  176. }
  177. }
  178. var options = {:json_encode($moduleList)};
  179. var temps = {:json_encode($tempList)};
  180. var tid = {$info.tid|default=0};
  181. var nums = {$nums|default=0};
  182. new Vue({
  183. el: '#vueapp-module',
  184. data: function() {
  185. return {
  186. options: options,
  187. temps: temps,
  188. showTemp: false,
  189. showModule: false,
  190. contents: [],
  191. value: '',
  192. tid: tid,
  193. nums: nums,
  194. ttitle: '',
  195. curItem: null
  196. }
  197. },
  198. computed: {
  199. scontent() {
  200. const vals = JSON.parse(JSON.stringify(this.contents));
  201. return vals;
  202. },
  203. },
  204. watch: {
  205. scontent: function (newVal, oldVal) {
  206. this.formatContent();
  207. const vv = [];
  208. this.contents.forEach((item) => {
  209. vv.push({
  210. id: item.id,
  211. mid: item.mid,
  212. })
  213. });
  214. this.value = vv.length > 0 ? JSON.stringify(vv):'';
  215. $('#ele-module').val(this.value);
  216. },
  217. tid: function (newVal, oldVal) {
  218. $('#tid').val(this.tid);
  219. }
  220. },
  221. created(){
  222. {if condition="!empty($info)"}
  223. const vals = '{:json_encode($info["content2"])}';
  224. {else /}
  225. const vals = '';
  226. {/if}
  227. console.log(vals);
  228. this.value = vals;
  229. const valss = vals?JSON.parse(vals):[];
  230. console.log(valss);
  231. const cc = [];
  232. valss.forEach((item) => {
  233. let img = '';
  234. let tti = '';
  235. this.options.forEach((item2) => {
  236. if(item.mid == item2.id){
  237. img = item2.img;
  238. tti = item2.title;
  239. }
  240. });
  241. cc.push({
  242. id: item.id,
  243. mid: item.mid,
  244. img: img,
  245. title: tti,
  246. })
  247. });
  248. if(this.tid > 0){
  249. this.temps.forEach((item) => {
  250. if(item.id == this.tid){
  251. this.nums = item.nums;
  252. this.ttitle = item.title;
  253. }
  254. });
  255. }
  256. if(cc.length == 0 && this.nums > 0){
  257. let i = 1;
  258. this.contents = [];
  259. while (this.nums > i){
  260. this.contents.push({
  261. id: i,
  262. mid: 0,
  263. img: '',
  264. title: '',
  265. });
  266. i++;
  267. }
  268. }
  269. if(cc.length > 0){
  270. this.contents = cc;
  271. }
  272. console.log('11111',this.value,this.options, this.contents);
  273. },
  274. methods:{
  275. changeTemp(){
  276. this.contents = [];
  277. if(this.tid > 0){
  278. this.temps.forEach((item) => {
  279. if(item.id == this.tid){
  280. this.nums = item.nums;
  281. }
  282. });
  283. if(this.nums > 0){
  284. let i = 1;
  285. while (this.nums >= i){
  286. this.contents.push({
  287. id: i,
  288. mid: 0,
  289. img: '',
  290. title: '',
  291. });
  292. i++;
  293. }
  294. }
  295. }
  296. console.log('contents',this.contents);
  297. },
  298. selectTemp(){
  299. this.showTemp = true;
  300. this.showModule = false;
  301. },
  302. selectModule(obj){
  303. this.showTemp = false;
  304. this.showModule = true;
  305. this.curItem = obj;
  306. },
  307. closeSelect(){
  308. this.showTemp = false;
  309. this.showModule = false;
  310. },
  311. sdTemp(obj) {
  312. this.tid = obj.id;
  313. this.ttitle = obj.title;
  314. this.changeTemp();
  315. this.closeSelect();
  316. },
  317. sTemp(obj) {
  318. this.tid = 0;
  319. this.ttitle = '';
  320. this.changeTemp();
  321. this.closeSelect();
  322. },
  323. sdModule(obj) {
  324. this.curItem.mid = obj.id;
  325. this.curItem.title = obj.title;
  326. this.curItem.img = obj.img;
  327. this.changeModule();
  328. this.closeSelect();
  329. },
  330. sModule(obj) {
  331. this.curItem.mid = 0;
  332. this.curItem.title = '';
  333. this.curItem.img = '';
  334. this.changeModule();
  335. this.closeSelect();
  336. },
  337. changeModule(){
  338. this.contents.forEach((item) => {
  339. const info = item;
  340. if(item.id == this.curItem.id){
  341. info.title = this.curItem.title;
  342. info.img = this.curItem.img;
  343. info.mid = this.curItem.mid;
  344. }
  345. })
  346. },
  347. formatContent(){
  348. this.contents.forEach((item) => {
  349. const info = item;
  350. this.options.forEach((item2) => {
  351. if(item2.id == item.mid){
  352. info.img = item2.img;
  353. info.title = item2.title;
  354. }
  355. });
  356. })
  357. },
  358. }
  359. })
  360. </script>
  361. {/block}