edit.php 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  6. <link href="{__FRAME_PATH}css/font-awesome.min.css" rel="stylesheet">
  7. <link href="{__ADMIN_PATH}plug/umeditor/themes/default/css/umeditor.css" type="text/css" rel="stylesheet">
  8. <script type="text/javascript" src="{__ADMIN_PATH}plug/umeditor/third-party/jquery.min.js"></script>
  9. <script type="text/javascript" src="{__ADMIN_PATH}plug/umeditor/third-party/template.min.js"></script>
  10. <script type="text/javascript" charset="utf-8" src="{__ADMIN_PATH}plug/umeditor/umeditor.config.js"></script>
  11. <script type="text/javascript" charset="utf-8" src="{__ADMIN_PATH}plug/umeditor/umeditor.min.js"></script>
  12. <script type="text/javascript" src="{__ADMIN_PATH}plug/umeditor/lang/zh-cn/zh-cn.js"></script>
  13. <link rel="stylesheet" href="/static/plug/layui/css/layui.css">
  14. <script src="/static/plug/layui/layui.js"></script>
  15. <script src="{__PLUG_PATH}vue/dist/vue.min.js"></script>
  16. <script src="/static/plug/axios.min.js"></script>
  17. <script src="{__MODULE_PATH}widget/aliyun-oss-sdk-4.4.4.min.js"></script>
  18. <script src="{__MODULE_PATH}widget/cos-js-sdk-v5.min.js"></script>
  19. <script src="{__MODULE_PATH}widget/qiniu-js-sdk-2.5.5.js"></script>
  20. <script src="{__MODULE_PATH}widget/plupload.full.min.js"></script>
  21. <script src="{__MODULE_PATH}widget/videoUpload.js"></script>
  22. <style>
  23. .layui-form-item {
  24. margin-bottom: 0px;
  25. }
  26. .pictrueBox {
  27. display: inline-block !important;
  28. }
  29. .pictrue {
  30. width: 60px;
  31. height: 60px;
  32. border: 1px dotted rgba(0, 0, 0, 0.1);
  33. margin-right: 15px;
  34. display: inline-block;
  35. position: relative;
  36. cursor: pointer;
  37. }
  38. .pictrue img {
  39. width: 100%;
  40. height: 100%;
  41. }
  42. .upLoad {
  43. width: 58px;
  44. height: 58px;
  45. line-height: 58px;
  46. border: 1px dotted rgba(0, 0, 0, 0.1);
  47. border-radius: 4px;
  48. background: rgba(0, 0, 0, 0.02);
  49. cursor: pointer;
  50. display: flex;
  51. justify-content: center;
  52. align-items: center;
  53. }
  54. .rulesBox {
  55. display: flex;
  56. flex-wrap: wrap;
  57. margin-left: 10px;
  58. }
  59. .layui-tab-content {
  60. margin-top: 15px;
  61. }
  62. .ml110 {
  63. margin: 18px 0 4px 110px;
  64. }
  65. .rules {
  66. display: flex;
  67. }
  68. .rules-btn-sm {
  69. height: 30px;
  70. line-height: 30px;
  71. font-size: 12px;
  72. width: 109px;
  73. }
  74. .rules-btn-sm input {
  75. width: 79% !important;
  76. height: 84% !important;
  77. padding: 0 10px;
  78. }
  79. .ml10 {
  80. margin-left: 10px !important;
  81. }
  82. .ml40 {
  83. margin-left: 40px !important;
  84. }
  85. .closes {
  86. position: absolute;
  87. left: 86%;
  88. top: -18%;
  89. }
  90. .red {
  91. color: red;
  92. }
  93. .layui-input-block .layui-video-box{
  94. width: 22%;
  95. height: 180px;
  96. border-radius: 10px;
  97. background-color: #707070;
  98. margin-top: 10px;
  99. position: relative;
  100. overflow: hidden;
  101. }
  102. .layui-input-block .layui-video-box i{
  103. color: #fff;
  104. line-height: 180px;
  105. margin: 0 auto;
  106. width: 50px;
  107. height: 50px;
  108. display: inherit;
  109. font-size: 50px;
  110. }
  111. .layui-input-block .layui-video-box .mark{
  112. position: absolute;
  113. width: 100%;
  114. height: 30px;
  115. top: 0;
  116. background-color: rgba(0,0,0,.5);
  117. text-align: center;
  118. }
  119. .store_box{
  120. display: flex;
  121. }
  122. .info{
  123. color: #c9c9c9;
  124. padding-left: 10px;
  125. line-height: 30px;
  126. }
  127. </style>
  128. </head>
  129. <body>
  130. <div class="layui-fluid">
  131. <div class="layui-row layui-col-space15" id="app" v-cloak="">
  132. <div class="layui-card">
  133. <div class="layui-card-header">
  134. <span class="">竞拍添加</span>
  135. <button style="margin-left: 20px" type="button" class="layui-btn layui-btn-primary layui-btn-xs" @click="goBack">返回列表</button>
  136. </div>
  137. <div class="layui-card-body">
  138. <form class="layui-form" action="" v-cloak="">
  139. <div class="layui-tab layui-tab-brief" lay-filter="docTabBrief">
  140. <div class="layui-tab-content">
  141. <div class="layui-tab-item layui-show">
  142. <div class="layui-row layui-col-space15">
  143. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  144. <div class="grid-demo grid-demo-bg1">
  145. <div class="layui-form-item">
  146. <label class="layui-form-label">商品名称<i class="red">*</i></label>
  147. <div class="layui-input-block">
  148. <input type="text" name="name" lay-verify="title" autocomplete="off"
  149. placeholder="场馆名称" class="layui-input" v-model="formData.name" maxlength="100">
  150. </div>
  151. </div>
  152. </div>
  153. </div>
  154. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  155. <div class="grid-demo grid-demo-bg1">
  156. <div class="layui-form-item">
  157. <label class="layui-form-label">商品图片<i class="red">*</i></label>
  158. <div class="pictrueBox">
  159. <div class="pictrue" v-if="formData.image" @click="uploadImage('image')">
  160. <img :src="formData.image"></div>
  161. <div class="upLoad" @click="uploadImage('image')" v-else>
  162. <i class="layui-icon layui-icon-camera" class="iconfont"
  163. style="font-size: 26px;"></i>
  164. </div>
  165. </div>
  166. </div>
  167. </div>
  168. </div>
  169. <div class="layui-form-item">
  170. <label class="layui-form-label">场馆</label>
  171. <div class="layui-input-inline">
  172. <select id="auction_id" name="auction_id" lay-verify="title" v-model="formData.auction_id">
  173. <option value="">请选择场馆</option>
  174. {foreach $list as $key=>$vo }
  175. <option value="{$vo.id}">{$vo.nickname}<option>
  176. {/foreach}
  177. </select>
  178. </div>
  179. </div>
  180. <div class="layui-row layui-col-space15">
  181. <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
  182. <div class="grid-demo grid-demo-bg1">
  183. <div class="layui-form-item">
  184. <label class="layui-form-label">场馆状态</label>
  185. <div class="layui-input-block">
  186. <input type="radio" name="is_show" lay-filter="status" value="1" title="上架"
  187. :checked="formData.is_show == 1 ? true : false">
  188. <input type="radio" name="is_show" lay-filter="status" value="0" title="下架"
  189. :checked="formData.is_show == 0 ? true : false">
  190. </div>
  191. </div>
  192. </div>
  193. </div>
  194. </div>
  195. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  196. <div class="grid-demo grid-demo-bg1">
  197. <div class="layui-form-item">
  198. <label class="layui-form-label">价格<i class="red">*</i></label>
  199. <div class="layui-input-inline">
  200. <input type="number" name="price" lay-verify="title" autocomplete="off" class="layui-input" v-model="formData.price" maxlength="100" value="0">
  201. </div>
  202. </div>
  203. </div>
  204. </div>
  205. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  206. <div class="grid-demo grid-demo-bg1">
  207. <div class="layui-form-item">
  208. <label class="layui-form-label">涨幅<i class="red">*</i></label>
  209. <div class="layui-input-inline">
  210. <input type="number" name="rise" lay-verify="title" autocomplete="off" class="layui-input" v-model="formData.rise" maxlength="100" value="0">
  211. </div>
  212. </div>
  213. </div>
  214. </div>
  215. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  216. <div class="grid-demo grid-demo-bg1">
  217. <div class="layui-form-item">
  218. <label class="layui-form-label">扣除<i class="red">*</i></label>
  219. <div class="layui-input-inline">
  220. <input type="number" name="deduct" lay-verify="title" autocomplete="off" class="layui-input" v-model="formData.deduct" maxlength="100" value="0">
  221. </div>
  222. </div>
  223. </div>
  224. </div>
  225. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  226. <div class="grid-demo grid-demo-bg1">
  227. <div class="layui-form-item layui-form-text">
  228. <label class="layui-form-label">商品介绍</label>
  229. <div class="layui-input-block">
  230. <textarea name="info" v-model="formData.info"
  231. placeholder="请输入商品简介" class="layui-textarea"></textarea>
  232. </div>
  233. </div>
  234. </div>
  235. </div>
  236. <div class="layui-tab-item">
  237. <div class="layui-row layui-col-space15">
  238. <textarea type="text/plain" name="description" id="myEditor" style="width:100%;">{{formData.description}}</textarea>
  239. </div>
  240. </div>
  241. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  242. <div class="grid-demo grid-demo-bg1">
  243. <div class="layui-form-item">
  244. <label class="layui-form-label">排序</label>
  245. <div class="layui-input-inline">
  246. <input type="number" name="sort" lay-verify="title" autocomplete="off" class="layui-input" v-model="formData.sort" maxlength="100" value="0">
  247. </div>
  248. </div>
  249. </div>
  250. </div>
  251. </div>
  252. </div>
  253. <div class="layui-tab-content">
  254. <div class="layui-row layui-col-space15">
  255. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  256. <button class="layui-btn layui-btn-normal layui-btn-sm" id="submit" type="button" @click="handleSubmit()">提交</button>
  257. </div>
  258. </div>
  259. </div>
  260. </div>
  261. </form>
  262. </div>
  263. </div>
  264. </div>
  265. </div>
  266. <script>
  267. var id = {$id};
  268. layui.use('laydate', function(){
  269. var laydate = layui.laydate;
  270. })
  271. //Demo
  272. layui.use('form', function(){
  273. var form = layui.form;
  274. //监听提交
  275. form.on('submit(formDemo)', function(data){
  276. layer.msg(JSON.stringify(data.field));
  277. return false;
  278. });
  279. });
  280. new Vue({
  281. el: '#app',
  282. data: {
  283. id:id,
  284. //分类列表
  285. cateList: [],
  286. //运费模板
  287. tempList: [],
  288. upload:{
  289. videoIng:false
  290. },
  291. formData: {
  292. description: '',
  293. name: '',
  294. is_show: 1,
  295. image:'',
  296. price:'',
  297. deduct: '',
  298. rise: '',
  299. info: '',
  300. sort: '',
  301. auction_id: ''
  302. },
  303. rule: { //多图选择规则
  304. slider_image: {
  305. maxLength: 1
  306. }
  307. },
  308. attr: [],//临时属性
  309. newRule: false,//是否添加新规则
  310. radioRule: ['status'],//radio 当选规则
  311. ruleList:[],
  312. ruleIndex:-1,
  313. progress: 0,
  314. um: null,//编译器实例化
  315. form: null,//layui.form
  316. layTabId: 1,
  317. ruleBool: id ? true : false,
  318. },
  319. watch:{
  320. 'formData.is_sub':function (n) {
  321. if (n == 1) {
  322. this.formHeader.push({title:'一级返佣(元)'});
  323. this.formHeader.push({title:'二级级返佣(元)'});
  324. } else {
  325. this.formHeader.pop();
  326. this.formHeader.pop();
  327. }
  328. },
  329. 'formData.spec_type':function (n) {
  330. if (n) {
  331. this.render();
  332. }
  333. },
  334. // 'formData.image':function (n) {
  335. // if(!this.batchAttr.pic){
  336. // this.batchAttr.pic = n;
  337. // }
  338. // if(!this.formData.attr.pic){
  339. // this.formData.attr.pic = n;
  340. // }
  341. // }
  342. },
  343. methods: {
  344. back:function(){
  345. var that = this;
  346. layui.use(['element'], function () {
  347. layui.element.tabChange('docTabBrief', that.layTabId == 1 ? 1 : parseInt(that.layTabId) - 1);
  348. });
  349. },
  350. next:function(){
  351. var that = this;
  352. layui.use(['element'], function () {
  353. layui.element.tabChange('docTabBrief', that.layTabId == 3 ? 3 : parseInt(that.layTabId) + 1);
  354. });
  355. },
  356. goBack:function(){
  357. location.href = this.U({c:'auction.auction_product',a:'index'});
  358. },
  359. U: function (opt) {
  360. var m = opt.m || 'admin', c = opt.c || window.controlle || '', a = opt.a || 'index', q = opt.q || '',
  361. p = opt.p || {};
  362. var params = Object. keys(p).map(function (key) {
  363. return key + '/' + p[key];
  364. }).join('/');
  365. var gets = Object.keys(q).map(function (key) {
  366. return key+'='+ q[key];
  367. }).join('&');
  368. return '/' + m + '/' + c + '/' + a + (params == '' ? '' : '/' + params) + (gets == '' ? '' : '?' + gets);
  369. },
  370. /**
  371. * 提示
  372. * */
  373. showMsg: function (msg, success) {
  374. $('#submit').removeAttr('disabled').text('提交');
  375. layui.use(['layer'], function () {
  376. layui.layer.msg(msg, success);
  377. });
  378. },
  379. addBrokerage:function(){
  380. if (this.brokerage.brokerage >= 0 && this.brokerage.brokerage_two >= 0){
  381. var that = this;
  382. this.$set(this.formData,'attrs',this.formData.attrs.map(function (item) {
  383. item.brokerage = that.brokerage.brokerage;
  384. item.brokerage_two = that.brokerage.brokerage_two;
  385. return item;
  386. }));
  387. } else {
  388. return this.showMsg('请填写返佣金额在进行批量添加');
  389. }
  390. },
  391. batchClear:function(){
  392. this.$set(this,'batchAttr',{
  393. pic: '',
  394. price: 0,
  395. cost: 0,
  396. ot_price: 0,
  397. stock: 0,
  398. bar_code: '',
  399. weight: 0,
  400. volume: 0,
  401. });
  402. },
  403. /**
  404. * 批量添加
  405. * */
  406. batchAdd:function(){
  407. var that = this;
  408. this.$set(this.formData,'attrs',this.formData.attrs.map(function (item) {
  409. if (that.batchAttr.pic) {
  410. item.pic = that.batchAttr.pic;
  411. }
  412. if (that.batchAttr.price > 0){
  413. item.price = that.batchAttr.price;
  414. }
  415. if (that.batchAttr.cost > 0){
  416. item.cost = that.batchAttr.cost;
  417. }
  418. if (that.batchAttr.ot_price > 0){
  419. item.ot_price = that.batchAttr.ot_price;
  420. }
  421. if (that.batchAttr.stock > 0){
  422. item.stock = that.batchAttr.stock;
  423. }
  424. if (that.batchAttr.bar_code != ''){
  425. item.bar_code = that.batchAttr.bar_code;
  426. }
  427. if (that.batchAttr.weight > 0){
  428. item.weight = that.batchAttr.weight;
  429. }
  430. if (that.batchAttr.volume > 0){
  431. item.volume = that.batchAttr.volume;
  432. }
  433. return item;
  434. }));
  435. },
  436. /**
  437. * 获取商品信息
  438. * */
  439. getProductInfo: function () {
  440. var that = this;
  441. that.requestGet(that.U({c:"auction.auction_product",a:'get_list',q:{id:that.id}})).then(function (res) {
  442. var productInfo = res.data || {};
  443. if(productInfo.id && that.id){
  444. that.$set(that,'formData',productInfo);
  445. that.generate();
  446. }
  447. that.getRuleList();
  448. that.init();
  449. }).catch(function (res) {
  450. that.showMsg(res.msg);
  451. })
  452. },
  453. /**
  454. * 给某个属性添加属性值
  455. * @param item
  456. * */
  457. addDetail: function (item) {
  458. if (!item.detailValue) return false;
  459. if (item.detail.find(function (val) {
  460. if(item.detailValue == val){
  461. return true;
  462. }
  463. })) {
  464. return this.showMsg('添加的属性值重复');
  465. }
  466. item.detail.push(item.detailValue);
  467. item.detailValue = '';
  468. },
  469. /**
  470. * 删除某个属性值
  471. * @param item 父级循环集合
  472. * @param inx 子集index
  473. * */
  474. deleteValue: function (item, inx) {
  475. if (item.detail.length > 1) {
  476. item.detail.splice(inx, 1);
  477. } else {
  478. return this.showMsg('请设置至少一个属性');
  479. }
  480. },
  481. /**
  482. * 删除某条属性
  483. * @param index
  484. * */
  485. deleteItem: function (index) {
  486. this.formData.items.splice(index, 1);
  487. },
  488. /**
  489. * 删除某条属性
  490. * @param index
  491. * */
  492. deleteAttrs: function (index) {
  493. var that = this;
  494. if(that.id > 0){
  495. that.requestGet(that.U({c:"store.StoreProduct",a:'check_activity',q:{id:that.id}})).then(function (res) {
  496. that.showMsg(res.msg);
  497. }).catch(function (res) {
  498. if (that.formData.attrs.length > 1) {
  499. that.formData.attrs.splice(index, 1);
  500. } else {
  501. return that.showMsg('请设置至少一个规则');
  502. }
  503. })
  504. }else{
  505. if (that.formData.attrs.length > 1) {
  506. that.formData.attrs.splice(index, 1);
  507. } else {
  508. return that.showMsg('请设置至少一个规则');
  509. }
  510. }
  511. },
  512. /**
  513. * 创建属性
  514. * */
  515. createAttrName: function () {
  516. if (this.formDynamic.attrsName && this.formDynamic.attrsVal) {
  517. if (this.formData.items.find(function (val) {
  518. if (val.value == this.formDynamic.attrsName) {
  519. return true;
  520. }
  521. }.bind(this))) {
  522. return this.showMsg('添加的属性重复');
  523. }
  524. this.formData.items.push({
  525. value: this.formDynamic.attrsName,
  526. detailValue: '',
  527. attrHidden: false,
  528. detail: [this.formDynamic.attrsVal]
  529. });
  530. this.formDynamic.attrsName = '';
  531. this.formDynamic.attrsVal = '';
  532. this.newRule = false;
  533. } else {
  534. return this.showMsg('请添加完整的规格!');
  535. }
  536. },
  537. /**
  538. * 删除图片
  539. * */
  540. deleteImage: function (key, index) {
  541. var that = this;
  542. if (index != undefined) {
  543. that.formData[key].splice(index, 1);
  544. that.$set(that.formData, key, that.formData[key]);
  545. } else {
  546. that.$set(that.formData, key, '');
  547. }
  548. },
  549. createFrame: function (title, src, opt) {
  550. opt === undefined && (opt = {});
  551. var h = 0;
  552. if (window.innerHeight < 800 && window.innerHeight >= 700) {
  553. h = window.innerHeight - 50;
  554. } else if (window.innerHeight < 900 && window.innerHeight >= 800) {
  555. h = window.innerHeight - 100;
  556. } else if (window.innerHeight < 1000 && window.innerHeight >= 900) {
  557. h = window.innerHeight - 150;
  558. } else if (window.innerHeight >= 1000) {
  559. h = window.innerHeight - 200;
  560. } else {
  561. h = window.innerHeight;
  562. }
  563. var area = [(opt.w || window.innerWidth / 2) + 'px', (!opt.h || opt.h > h ? h : opt.h) + 'px'];
  564. layui.use('layer',function () {
  565. return layer.open({
  566. type: 2,
  567. title: title,
  568. area: area,
  569. fixed: false, //不固定
  570. maxmin: true,
  571. moveOut: false,//true 可以拖出窗外 false 只能在窗内拖
  572. anim: 5,//出场动画 isOutAnim bool 关闭动画
  573. offset: 'auto',//['100px','100px'],//'auto',//初始位置 ['100px','100px'] t[ 上 左]
  574. shade: 0,//遮罩
  575. resize: true,//是否允许拉伸
  576. content: src,//内容
  577. move: '.layui-layer-title'
  578. });
  579. });
  580. },
  581. changeIMG: function (name, value) {
  582. if (this.getRule(name).maxLength !== undefined) {
  583. var that = this;
  584. value.map(function (v) {
  585. that.formData[name].push(v);
  586. });
  587. this.$set(this.formData, name, this.formData[name]);
  588. } else {
  589. if(name == 'batchAttr.pic'){
  590. this.batchAttr.pic = value;
  591. } else {
  592. if (name.indexOf('.') !== -1) {
  593. var key = name.split('.');
  594. if (key.length == 2){
  595. this.formData[key[0]][key[1]] = value;
  596. } else if(key.length == 3){
  597. this.formData[key[0]][key[1]][key[2]] = value;
  598. } else if(key.length == 4){
  599. this.$set(this.formData[key[0]][key[1]][key[2]],key[3],value)
  600. }
  601. } else {
  602. this.formData[name] = value;
  603. }
  604. }
  605. }
  606. },
  607. getRule: function (name) {
  608. return this.rule[name] || {};
  609. },
  610. uploadImage: function (name) {
  611. return this.createFrame('选择图片',this.U({c:"widget.images",a:'index',p:{fodder:name}}),{h:545,w:900});
  612. },
  613. uploadVideo: function () {
  614. if (this.videoLink) {
  615. this.formData.video_link = this.videoLink;
  616. } else {
  617. $(this.$refs.filElem).click();
  618. }
  619. },
  620. delVideo: function () {
  621. var that = this;
  622. that.$set(that.formData, 'video_link', '');
  623. },
  624. insertEditor: function (list) {
  625. this.um.execCommand('insertimage', list);
  626. },
  627. insertEditorVideo: function (src) {
  628. this.um.setContent('<div><video style="width: 99%" src="'+src+'" class="video-ue" controls="controls" width="100"><source src="'+src+'"></source></video></div><br>',true);
  629. },
  630. getContent: function () {
  631. return this.um.getContent();
  632. },
  633. /**
  634. * 监听radio字段
  635. */
  636. eeventRadio: function () {
  637. var that = this;
  638. that.radioRule.map(function (val) {
  639. that.form.on('radio(' + val + ')', function (res) {
  640. that.formData[val] = res.value;
  641. });
  642. })
  643. },
  644. init: function () {
  645. var that = this;
  646. window.UMEDITOR_CONFIG.toolbar = [
  647. // 加入一个 test
  648. 'source | undo redo | bold italic underline strikethrough | superscript subscript | forecolor backcolor | removeformat |',
  649. 'insertorderedlist insertunorderedlist | selectall cleardoc paragraph | fontfamily fontsize',
  650. '| justifyleft justifycenter justifyright justifyjustify |',
  651. 'link unlink | emotion selectimgs video | map',
  652. '| horizontal print preview fullscreen', 'drafts', 'formula'
  653. ];
  654. UM.registerUI('selectimgs', function (name) {
  655. var me = this;
  656. var $btn = $.eduibutton({
  657. icon: 'image',
  658. click: function () {
  659. that.createFrame('选择图片', "{:Url('widget.images/index',['fodder'=>'editor'])}");
  660. },
  661. title: '选择图片'
  662. });
  663. this.addListener('selectionchange', function () {
  664. //切换为不可编辑时,把自己变灰
  665. var state = this.queryCommandState(name);
  666. $btn.edui().disabled(state == -1).active(state == 1)
  667. });
  668. return $btn;
  669. });
  670. UM.registerUI('video', function (name) {
  671. var me = this;
  672. var $btn = $.eduibutton({
  673. icon: 'video',
  674. click: function () {
  675. that.createFrame('选择视频', "{:Url('widget.video/index',['fodder'=>'video'])}");
  676. },
  677. title: '选择视频'
  678. });
  679. this.addListener('selectionchange', function () {
  680. //切换为不可编辑时,把自己变灰
  681. var state = this.queryCommandState(name);
  682. $btn.edui().disabled(state == -1).active(state == 1)
  683. });
  684. return $btn;
  685. });
  686. //实例化编辑器
  687. this.um = UM.getEditor('myEditor', {initialFrameWidth: '99%', initialFrameHeight: 400});
  688. this.um.setContent(that.formData.description);
  689. that.$nextTick(function () {
  690. layui.use(['form','element'], function () {
  691. that.form = layui.form;
  692. that.form.render();
  693. that.form.on('select(temp_id)', function (data) {
  694. that.$set(that.formData, 'temp_id', data.value);
  695. });
  696. that.form.on('select(rule_index)', function (data) {
  697. that.ruleIndex = data.value;
  698. });
  699. layui.element.on('tab(docTabBrief)', function(){
  700. that.layTabId = this.getAttribute('lay-id');
  701. });
  702. that.eeventRadio();
  703. });
  704. })
  705. },
  706. requestPost: function (url, data) {
  707. return new Promise(function (resolve, reject) {
  708. axios.post(url, data).then(function (res) {
  709. if (res.status == 200 && res.data.code == 200) {
  710. resolve(res.data)
  711. } else {
  712. reject(res.data);
  713. }
  714. }).catch(function (err) {
  715. reject({msg:err})
  716. });
  717. })
  718. },
  719. requestGet: function (url) {
  720. return new Promise(function (resolve, reject) {
  721. axios.get(url).then(function (res) {
  722. if (res.status == 200 && res.data.code == 200) {
  723. resolve(res.data)
  724. } else {
  725. reject(res.data);
  726. }
  727. }).catch(function (err) {
  728. reject({msg:err})
  729. });
  730. })
  731. },
  732. generates: function () {
  733. var that = this;
  734. that.generate(1);
  735. },
  736. handleSubmit:function () {
  737. var that = this;
  738. var auction_id = $('#auction_id').val();
  739. if (that.formData.name === ''){
  740. return that.showMsg('请输入商品名称');
  741. }
  742. if (auction_id <= 0){
  743. return that.showMsg('请选择场馆');
  744. }
  745. if (that.formData.image === ''){
  746. return that.showMsg('请输入上传图片');
  747. }
  748. if (that.formData.price <= 0){
  749. return that.showMsg('请输入价格');
  750. }
  751. if (that.formData.rise <= 0){
  752. return that.showMsg('涨幅不能为空');
  753. }
  754. if (that.formData.deduct <= 0){
  755. return that.showMsg('扣除不能为空');
  756. }
  757. that.formData.auction_id = auction_id;
  758. $('#submit').attr('disabled', 'disabled').text('保存中...');
  759. that.requestPost(that.U({c:'auction.auction_product',a:'update',p:{id:that.id}}),that.formData).then(function (res) {
  760. that.confirm();
  761. }).catch(function (res) {
  762. that.showMsg(res.msg);
  763. });
  764. },
  765. confirm: function(){
  766. var that = this;
  767. layui.use(['layer'], function () {
  768. var layer = layui.layer;
  769. layer.confirm(that.id ? '修改成功是否返回产品列表' : '添加成功是否返回产品列表', {
  770. btn: ['返回列表',that.id ? '继续修改' : '继续添加'] //按钮
  771. }, function(){
  772. location.href = that.U({c:'auction.auction_product',a:'index'});
  773. }, function(){
  774. location.reload();
  775. });
  776. });
  777. },
  778. render:function(){
  779. this.$nextTick(function(){
  780. layui.use(['form'], function () {
  781. layui.form.render('select');
  782. });
  783. })
  784. },
  785. // 移动
  786. handleDragStart (e, item) {
  787. this.dragging = item;
  788. },
  789. handleDragEnd (e, item) {
  790. this.dragging = null
  791. },
  792. handleDragOver (e) {
  793. e.dataTransfer.dropEffect = 'move'
  794. },
  795. handleDragEnter (e, item) {
  796. e.dataTransfer.effectAllowed = 'move'
  797. if (item === this.dragging) {
  798. return
  799. }
  800. var newItems = [...this.formData.activity];
  801. var src = newItems.indexOf(this.dragging);
  802. var dst = newItems.indexOf(item);
  803. newItems.splice(dst, 0, ...newItems.splice(src, 1))
  804. this.formData.activity = newItems;
  805. },
  806. addRule:function(){
  807. return this.createFrame('添加商品规则',this.U({c:'store.StoreProductRule',a:'create'}));
  808. },
  809. allRule:function () {
  810. if (this.ruleIndex != -1) {
  811. var rule = this.ruleList[this.ruleIndex];
  812. if (rule) {
  813. this.ruleBool = true;
  814. var rule_value = rule.rule_value.map(function (item) {
  815. return item;
  816. });
  817. this.$set(this.formData,'items',rule_value);
  818. this.$set(this.formData,'attrs',[]);
  819. this.$set(this,'formHeader',[]);
  820. return true;
  821. }
  822. }
  823. this.showMsg('选择的属性无效');
  824. }
  825. },
  826. mounted: function () {
  827. var that = this;
  828. that.getProductInfo();
  829. window.changeIMG = that.changeIMG;
  830. window.$vm = that;
  831. }
  832. });
  833. </script>
  834. </body>
  835. </html>
  836. <script>
  837. </script>