create.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. {extend name="public/container"}
  2. {block name='head_top'}
  3. <style>
  4. .layui-form-item .special-label i{display: inline-block;width: 18px;height: 18px;font-size: 18px;color: #fff;}
  5. .layui-form-item .label-box p{line-height: inherit;}
  6. .m-t-5{margin-top:5px;}
  7. #app .layui-barrage-box{margin-bottom: 10px;margin-top: 10px;margin-left: 10px;border: 1px solid #0092DC;border-radius: 5px;cursor: pointer;position: relative;}
  8. #app .layui-barrage-box.border-color{border-color: #0bb20c;}
  9. #app .layui-barrage-box .del-text{position: absolute;top: 0;left: 0;background-color: rgba(0,0,0,0.5);color: #ffffff;width: 92%;text-align: center;}
  10. #app .layui-barrage-box p{padding:5px 5px; }
  11. #app .layui-empty-text{text-align: center;font-size: 18px;}
  12. #app .layui-empty-text p{padding: 10px 10px;}
  13. .edui-default .edui-for-image .edui-icon {background-position: -380px 0px;}
  14. .layui-form-item .special-label {width: 50px;float: left;height: 30px;line-height: 38px;margin-left: 10px;margin-top: 5px;border-radius: 5px;background-color: #0092DC;text-align: center;}
  15. .layui-form-item .special-label i {display: inline-block;width: 18px;height: 18px;font-size: 18px;color: #fff;}
  16. .layui-form-item .label-box {border: 1px solid;border-radius: 10px;position: relative;padding: 10px;height: 30px;color: #fff;background-color: #393D49;text-align: center;cursor: pointer;display: inline-block;line-height: 10px;}
  17. .layui-form-item .label-box p {line-height: inherit;}
  18. .layui-form-mid {margin-left: 18px;}
  19. .upload-image-box .mask p{width: 50px;}
  20. [v-cloak]{
  21. display: none;
  22. }
  23. </style>
  24. <script type="text/javascript" charset="utf-8" src="{__ADMIN_PATH}plug/ueditor/third-party/zeroclipboard/ZeroClipboard.js"></script>
  25. <script type="text/javascript" charset="utf-8" src="{__ADMIN_PATH}plug/ueditor/ueditor.config.js"></script>
  26. <script type="text/javascript" charset="utf-8" src="{__ADMIN_PATH}plug/ueditor/ueditor.all.min.js"></script>
  27. {/block}
  28. {block name="content"}
  29. <div class="layui-fluid" style="background: #fff">
  30. <div class="layui-row layui-col-space15" id="app" v-cloak="">
  31. <div class="layui-col-md12">
  32. <div class="layui-card" v-cloak="">
  33. <div class="layui-card-header">{{id ? '编辑讲师':'添加讲师'}}</div>
  34. <div class="layui-card-body" style="padding: 10px 10px;">
  35. <form action="" class="layui-form">
  36. <div class="layui-form-item m-t-5" v-cloak="">
  37. <div class="layui-form-item submit">
  38. <label class="layui-form-label">讲师名称:</label>
  39. <div class="layui-input-block">
  40. <input type="text" name="lecturer_name" style="width: 300px" v-model="formData.lecturer_name" autocomplete="off" placeholder="请输入讲师名称" class="layui-input">
  41. </div>
  42. </div>
  43. <div class="layui-form-item submit">
  44. <div class="layui-inline">
  45. <label class="layui-form-label">标签:</label>
  46. <div class="layui-input-block">
  47. <input type="text" v-model="label" name="price_min" placeholder="最多6个字" autocomplete="off" class="layui-input" style="float: left;width: 300px">
  48. <button type="button" class="layui-btn layui-btn-normal" @click="addLabrl" >
  49. <i class="layui-icon">&#xe654;</i>
  50. </button>
  51. <div class="layui-form-mid layui-word-aux" style="float:none;display:inline-block;">输入标签名称后点击”+“号按钮添加;最多写入6个字;点击标签即可删除</div>
  52. </div>
  53. </div>
  54. <div v-if="formData.label.length" class="layui-input-block">
  55. <div class="label-box" v-for="(item,index) in formData.label" @click="delLabel(index)">
  56. <p>{{item}}</p>
  57. </div>
  58. </div>
  59. </div>
  60. <div class="layui-form-item submit">
  61. <label class="layui-form-label">
  62. <div>头像:</div>
  63. <div>(200*200px)</div>
  64. </label>
  65. <div class="layui-input-block">
  66. <div class="upload-image-box" v-if="formData.lecturer_head" >
  67. <img :src="formData.lecturer_head" alt="">
  68. <div class="mask" style="display: block">
  69. <p>
  70. <i class="fa fa-eye" @click="look(formData.lecturer_head)"></i>
  71. <i class="fa fa-trash-o" @click="delect('lecturer_head')"></i>
  72. </p>
  73. </div>
  74. </div>
  75. <div class="upload-image" v-show="!formData.lecturer_head" @click="upload('lecturer_head')">
  76. <div class="fiexd"><i class="fa fa-plus"></i></div>
  77. <p>选择图片</p>
  78. </div>
  79. </div>
  80. </div>
  81. <div class="layui-form-item" style="margin-top: 10px;">
  82. <label class="layui-form-label">说明:</label>
  83. <div class="layui-input-block">
  84. <input type="text" name="explain" style="width: 100%" v-model="formData.explain" autocomplete="off" maxlength="20" placeholder="请输入讲师说明(20字以内)" class="layui-input">
  85. </div>
  86. </div>
  87. <div class="layui-form-item" style="margin-top: 10px;">
  88. <label class="layui-form-label">简介:</label>
  89. <div class="layui-input-block">
  90. <textarea id="myEditor" style="width:100%;height: 300px">{{formData.introduction}}</textarea>
  91. </div>
  92. </div>
  93. <div class="layui-form-item submit">
  94. <label class="layui-form-label">排序:</label>
  95. <div class="layui-input-block">
  96. <input type="number" name="sort" style="width: 300px" v-model="formData.sort" autocomplete="off" class="layui-input">
  97. </div>
  98. </div>
  99. <div class="layui-form-item">
  100. <label class="layui-form-label">状态:</label>
  101. <div class="layui-input-block">
  102. <input type="radio" name="is_show" value="1" title="显示" v-model="formData.is_show" lay-filter="is_show" >
  103. <input type="radio" name="is_show" value="0" title="隐藏" v-model="formData.is_show" lay-filter="is_show">
  104. </div>
  105. </div>
  106. <div class="layui-form-item submit">
  107. <div class="layui-input-block">
  108. <button class="layui-btn layui-btn-normal" type="button" @click="save">{{id ? '立即修改':'立即提交'}}</button>
  109. <button class="layui-btn layui-btn-primary clone" type="button" @click="clone_form">清空</button>
  110. </div>
  111. </div>
  112. </form>
  113. </div>
  114. </div>
  115. </div>
  116. </div>
  117. </div>
  118. <script type="text/javascript" src="{__ADMIN_PATH}js/layuiList.js"></script>
  119. {/block}
  120. {block name='script'}
  121. <script>
  122. var id={$id},lecturer=<?=isset($lecturer) ? $lecturer : []?>;
  123. require(['vue','helper','zh-cn','request','plupload','aliyun-oss','OssUpload'],function(Vue,$h) {
  124. new Vue({
  125. el: "#app",
  126. data: {
  127. formData:{
  128. lecturer_name:lecturer.lecturer_name || '',
  129. lecturer_head: lecturer.lecturer_head || '',
  130. label: lecturer.label || [],
  131. explain: lecturer.explain || '',
  132. introduction: lecturer.introduction || '',
  133. sort:Number(lecturer.sort) || 0,
  134. is_show:lecturer.is_show || 1
  135. },
  136. label: '',
  137. },
  138. methods:{
  139. //查看图片
  140. look: function (pic) {
  141. $eb.openImage(pic);
  142. },
  143. //上传图片
  144. upload: function (key, count) {
  145. ossUpload.createFrame('请选择图片', {fodder: key, max_count: count === undefined ? 0 : count},{w:800,h:550});
  146. },
  147. delLabel: function (index) {
  148. this.formData.label.splice(index, 1);
  149. this.$set(this.formData, 'label', this.formData.label);
  150. },
  151. addLabrl: function () {
  152. if (this.label) {
  153. if (this.label.length > 6) return layList.msg('您输入的标签字数太长');
  154. var length = this.formData.label.length;
  155. if (length >= 3) return layList.msg('标签最多添加3个');
  156. for (var i = 0; i < length; i++) {
  157. if (this.formData.label[i] == this.label) return layList.msg('请勿重复添加');
  158. }
  159. this.formData.label.push(this.label);
  160. this.$set(this.formData, 'label', this.formData.label);
  161. this.label = '';
  162. }
  163. },
  164. clone_form: function () {
  165. var that = this;
  166. if (parseInt(id) == 0) {
  167. parent.layer.closeAll();
  168. }
  169. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  170. parent.layer.close(index); //再执行关闭
  171. },
  172. save:function () {
  173. var that=this;
  174. that.formData.introduction = that.ueD.getContent();
  175. that.$nextTick(function () {
  176. if (!that.formData.lecturer_name) return layList.msg('请输入讲师名称');
  177. if (!that.formData.lecturer_head) return layList.msg('请输入讲师头像');
  178. if (!that.formData.label.length) return layList.msg('请输入标签');
  179. if (!that.formData.explain) return layList.msg('请编辑讲师说明');
  180. if (!that.formData.introduction) return layList.msg('请编辑讲师介绍');
  181. layList.loadFFF();
  182. layList.basePost(layList.U({a: 'save_lecturer', q: {id: id}}), that.formData, function (res) {
  183. layList.loadClear();
  184. if (parseInt(id) == 0) {
  185. layList.layer.confirm('添加成功,您要继续添加讲师吗?', {
  186. btn: ['继续添加', '立即提交'] //按钮
  187. }, function () {
  188. window.location.reload();
  189. }, function () {
  190. parent.layer.closeAll();
  191. });
  192. } else {
  193. layList.msg('修改成功', function () {
  194. parent.layer.closeAll();
  195. })
  196. }
  197. }, function (res) {
  198. layList.msg(res.msg);
  199. layList.loadClear();
  200. });
  201. })
  202. },
  203. delect:function(key){
  204. var that=this;
  205. that.formData[key]='';
  206. },
  207. changeIMG: function (key, value, multiple) {
  208. if (multiple) {
  209. var that = this;
  210. value.map(function (v) {
  211. that.formData[key].push({pic: v, is_show: false});
  212. });
  213. this.$set(this.formData, key, this.formData[key]);
  214. } else {
  215. this.$set(this.formData, key, value);
  216. }
  217. },
  218. },
  219. mounted:function () {
  220. var that=this;
  221. window.changeIMG = that.changeIMG;
  222. //选择图片插入到编辑器中
  223. window.insertEditor = function(list,fodder){
  224. that.ueD.execCommand('insertimage', list);
  225. };
  226. this.$nextTick(function () {
  227. layList.form.render();
  228. //实例化编辑器
  229. UE.registerUI('imagenone',function(editor,name){
  230. var $btn = new UE.ui.Button({
  231. name : 'image',
  232. onclick : function(){
  233. ossUpload.createFrame('选择图片',{fodder:'editors'},{w:800,h:550});
  234. },
  235. title: '选择图片'
  236. });
  237. return $btn;
  238. });
  239. that.ueD = UE.getEditor('myEditor');
  240. });
  241. layList.form.on('radio(is_show)',function (data) {
  242. that.formData.is_show=data.value;
  243. });
  244. }
  245. })
  246. })
  247. </script>
  248. {/block}