227078ad09ee4a9a2b2b4cdfd89eae45.php 37 KB

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