27b77a7cbce072e3986c2320b6a30bb7.php 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815
  1. <?php /*a:1:{s:68:"D:\phpstudy_pro\WWW\CRMEB\app\admin\view\auction\auction_gu\edit.php";i:1648541874;}*/ ?>
  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-col-xs12 layui-col-sm12 layui-col-md12">
  171. <div class="grid-demo grid-demo-bg1">
  172. <div class="layui-form-item">
  173. <label class="layui-form-label">绑定用户</label>
  174. <div class="layui-input-inline">
  175. <select id="uid" name="uid" lay-verify="title" v-model="formData.uid">
  176. <?php foreach($user as $key=>$vo): ?>
  177. <option value="<?php echo htmlentities($vo['uid']); ?>"><?php echo htmlentities($vo['nickname']); ?><option>
  178. <?php endforeach; ?>
  179. </select>
  180. </div>
  181. </div>
  182. </div>
  183. </div>
  184. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  185. <div class="grid-demo grid-demo-bg1">
  186. <div class="layui-form-item layui-form-text">
  187. <label class="layui-form-label">会馆简介</label>
  188. <div class="layui-input-block">
  189. <textarea name="info" v-model="formData.info"
  190. placeholder="请输入商品简介" class="layui-textarea"></textarea>
  191. </div>
  192. </div>
  193. </div>
  194. </div>
  195. <div class="layui-tab-item">
  196. <div class="layui-row layui-col-space15">
  197. <textarea type="text/plain" name="description" id="myEditor" style="width:100%;">{{formData.description}}</textarea>
  198. </div>
  199. </div>
  200. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  201. <div class="grid-demo grid-demo-bg1">
  202. <div class="layui-form-item">
  203. <label class="layui-form-label">排序<i class="red">*</i></label>
  204. <div class="layui-input-inline">
  205. <input type="number" name="sort" lay-verify="title" autocomplete="off" class="layui-input" v-model="formData.sort" maxlength="100" value="0">
  206. </div>
  207. </div>
  208. </div>
  209. </div>
  210. </div>
  211. </div>
  212. <div class="layui-tab-content">
  213. <div class="layui-row layui-col-space15">
  214. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  215. <button class="layui-btn layui-btn-normal layui-btn-sm" id="submit" type="button" @click="handleSubmit()">提交</button>
  216. </div>
  217. </div>
  218. </div>
  219. </div>
  220. </form>
  221. </div>
  222. </div>
  223. </div>
  224. </div>
  225. <script>
  226. var id = <?php echo htmlentities($id); ?>;
  227. //Demo
  228. layui.use('form', function(){
  229. var form = layui.form;
  230. //监听提交
  231. form.on('submit(formDemo)', function(data){
  232. layer.msg(JSON.stringify(data.field));
  233. return false;
  234. });
  235. });
  236. new Vue({
  237. el: '#app',
  238. data: {
  239. id:id,
  240. //分类列表
  241. cateList: [],
  242. //运费模板
  243. tempList: [],
  244. upload:{
  245. videoIng:false
  246. },
  247. formData: {
  248. name: '',
  249. image:'',
  250. sort:'',
  251. description: '',
  252. info: '',
  253. uid:''
  254. },
  255. rule: { //多图选择规则
  256. slider_image: {
  257. maxLength: 1
  258. }
  259. },
  260. attr: [],//临时属性
  261. newRule: false,//是否添加新规则
  262. radioRule: ['status'],//radio 当选规则
  263. ruleList:[],
  264. ruleIndex:-1,
  265. progress: 0,
  266. um: null,//编译器实例化
  267. form: null,//layui.form
  268. layTabId: 1,
  269. ruleBool: id ? true : false,
  270. },
  271. watch:{
  272. 'formData.is_sub':function (n) {
  273. if (n == 1) {
  274. this.formHeader.push({title:'一级返佣(元)'});
  275. this.formHeader.push({title:'二级级返佣(元)'});
  276. } else {
  277. this.formHeader.pop();
  278. this.formHeader.pop();
  279. }
  280. },
  281. 'formData.spec_type':function (n) {
  282. if (n) {
  283. this.render();
  284. }
  285. },
  286. // 'formData.image':function (n) {
  287. // if(!this.batchAttr.pic){
  288. // this.batchAttr.pic = n;
  289. // }
  290. // if(!this.formData.attr.pic){
  291. // this.formData.attr.pic = n;
  292. // }
  293. // }
  294. },
  295. methods: {
  296. back:function(){
  297. var that = this;
  298. layui.use(['element'], function () {
  299. layui.element.tabChange('docTabBrief', that.layTabId == 1 ? 1 : parseInt(that.layTabId) - 1);
  300. });
  301. },
  302. next:function(){
  303. var that = this;
  304. layui.use(['element'], function () {
  305. layui.element.tabChange('docTabBrief', that.layTabId == 3 ? 3 : parseInt(that.layTabId) + 1);
  306. });
  307. },
  308. goBack:function(){
  309. location.href = this.U({c:'auction.auction_gu',a:'index'});
  310. },
  311. U: function (opt) {
  312. var m = opt.m || 'admin', c = opt.c || window.controlle || '', a = opt.a || 'index', q = opt.q || '',
  313. p = opt.p || {};
  314. var params = Object. keys(p).map(function (key) {
  315. return key + '/' + p[key];
  316. }).join('/');
  317. var gets = Object.keys(q).map(function (key) {
  318. return key+'='+ q[key];
  319. }).join('&');
  320. return '/' + m + '/' + c + '/' + a + (params == '' ? '' : '/' + params) + (gets == '' ? '' : '?' + gets);
  321. },
  322. /**
  323. * 提示
  324. * */
  325. showMsg: function (msg, success) {
  326. $('#submit').removeAttr('disabled').text('提交');
  327. layui.use(['layer'], function () {
  328. layui.layer.msg(msg, success);
  329. });
  330. },
  331. addBrokerage:function(){
  332. if (this.brokerage.brokerage >= 0 && this.brokerage.brokerage_two >= 0){
  333. var that = this;
  334. this.$set(this.formData,'attrs',this.formData.attrs.map(function (item) {
  335. item.brokerage = that.brokerage.brokerage;
  336. item.brokerage_two = that.brokerage.brokerage_two;
  337. return item;
  338. }));
  339. } else {
  340. return this.showMsg('请填写返佣金额在进行批量添加');
  341. }
  342. },
  343. batchClear:function(){
  344. this.$set(this,'batchAttr',{
  345. pic: '',
  346. price: 0,
  347. cost: 0,
  348. ot_price: 0,
  349. stock: 0,
  350. bar_code: '',
  351. weight: 0,
  352. volume: 0,
  353. });
  354. },
  355. /**
  356. * 批量添加
  357. * */
  358. batchAdd:function(){
  359. var that = this;
  360. this.$set(this.formData,'attrs',this.formData.attrs.map(function (item) {
  361. if (that.batchAttr.pic) {
  362. item.pic = that.batchAttr.pic;
  363. }
  364. if (that.batchAttr.price > 0){
  365. item.price = that.batchAttr.price;
  366. }
  367. if (that.batchAttr.cost > 0){
  368. item.cost = that.batchAttr.cost;
  369. }
  370. if (that.batchAttr.ot_price > 0){
  371. item.ot_price = that.batchAttr.ot_price;
  372. }
  373. if (that.batchAttr.stock > 0){
  374. item.stock = that.batchAttr.stock;
  375. }
  376. if (that.batchAttr.bar_code != ''){
  377. item.bar_code = that.batchAttr.bar_code;
  378. }
  379. if (that.batchAttr.weight > 0){
  380. item.weight = that.batchAttr.weight;
  381. }
  382. if (that.batchAttr.volume > 0){
  383. item.volume = that.batchAttr.volume;
  384. }
  385. return item;
  386. }));
  387. },
  388. /**
  389. * 获取商品信息
  390. * */
  391. getProductInfo: function () {
  392. var that = this;
  393. that.requestGet(that.U({c:"auction.auction_gu",a:'get_auction',q:{id:that.id}})).then(function (res) {
  394. var productInfo = res.data.productInfo || {};
  395. if(productInfo.id && that.id){
  396. that.$set(that,'formData',productInfo);
  397. that.generate();
  398. }
  399. that.getRuleList();
  400. that.init();
  401. }).catch(function (res) {
  402. that.showMsg(res.msg);
  403. })
  404. },
  405. /**
  406. * 给某个属性添加属性值
  407. * @param item
  408. * */
  409. addDetail: function (item) {
  410. if (!item.detailValue) return false;
  411. if (item.detail.find(function (val) {
  412. if(item.detailValue == val){
  413. return true;
  414. }
  415. })) {
  416. return this.showMsg('添加的属性值重复');
  417. }
  418. item.detail.push(item.detailValue);
  419. item.detailValue = '';
  420. },
  421. /**
  422. * 删除某个属性值
  423. * @param item 父级循环集合
  424. * @param inx 子集index
  425. * */
  426. deleteValue: function (item, inx) {
  427. if (item.detail.length > 1) {
  428. item.detail.splice(inx, 1);
  429. } else {
  430. return this.showMsg('请设置至少一个属性');
  431. }
  432. },
  433. /**
  434. * 删除某条属性
  435. * @param index
  436. * */
  437. deleteItem: function (index) {
  438. this.formData.items.splice(index, 1);
  439. },
  440. /**
  441. * 删除某条属性
  442. * @param index
  443. * */
  444. deleteAttrs: function (index) {
  445. var that = this;
  446. if(that.id > 0){
  447. that.requestGet(that.U({c:"store.StoreProduct",a:'check_activity',q:{id:that.id}})).then(function (res) {
  448. that.showMsg(res.msg);
  449. }).catch(function (res) {
  450. if (that.formData.attrs.length > 1) {
  451. that.formData.attrs.splice(index, 1);
  452. } else {
  453. return that.showMsg('请设置至少一个规则');
  454. }
  455. })
  456. }else{
  457. if (that.formData.attrs.length > 1) {
  458. that.formData.attrs.splice(index, 1);
  459. } else {
  460. return that.showMsg('请设置至少一个规则');
  461. }
  462. }
  463. },
  464. /**
  465. * 创建属性
  466. * */
  467. createAttrName: function () {
  468. if (this.formDynamic.attrsName && this.formDynamic.attrsVal) {
  469. if (this.formData.items.find(function (val) {
  470. if (val.value == this.formDynamic.attrsName) {
  471. return true;
  472. }
  473. }.bind(this))) {
  474. return this.showMsg('添加的属性重复');
  475. }
  476. this.formData.items.push({
  477. value: this.formDynamic.attrsName,
  478. detailValue: '',
  479. attrHidden: false,
  480. detail: [this.formDynamic.attrsVal]
  481. });
  482. this.formDynamic.attrsName = '';
  483. this.formDynamic.attrsVal = '';
  484. this.newRule = false;
  485. } else {
  486. return this.showMsg('请添加完整的规格!');
  487. }
  488. },
  489. /**
  490. * 删除图片
  491. * */
  492. deleteImage: function (key, index) {
  493. var that = this;
  494. if (index != undefined) {
  495. that.formData[key].splice(index, 1);
  496. that.$set(that.formData, key, that.formData[key]);
  497. } else {
  498. that.$set(that.formData, key, '');
  499. }
  500. },
  501. createFrame: function (title, src, opt) {
  502. opt === undefined && (opt = {});
  503. var h = 0;
  504. if (window.innerHeight < 800 && window.innerHeight >= 700) {
  505. h = window.innerHeight - 50;
  506. } else if (window.innerHeight < 900 && window.innerHeight >= 800) {
  507. h = window.innerHeight - 100;
  508. } else if (window.innerHeight < 1000 && window.innerHeight >= 900) {
  509. h = window.innerHeight - 150;
  510. } else if (window.innerHeight >= 1000) {
  511. h = window.innerHeight - 200;
  512. } else {
  513. h = window.innerHeight;
  514. }
  515. var area = [(opt.w || window.innerWidth / 2) + 'px', (!opt.h || opt.h > h ? h : opt.h) + 'px'];
  516. layui.use('layer',function () {
  517. return layer.open({
  518. type: 2,
  519. title: title,
  520. area: area,
  521. fixed: false, //不固定
  522. maxmin: true,
  523. moveOut: false,//true 可以拖出窗外 false 只能在窗内拖
  524. anim: 5,//出场动画 isOutAnim bool 关闭动画
  525. offset: 'auto',//['100px','100px'],//'auto',//初始位置 ['100px','100px'] t[ 上 左]
  526. shade: 0,//遮罩
  527. resize: true,//是否允许拉伸
  528. content: src,//内容
  529. move: '.layui-layer-title'
  530. });
  531. });
  532. },
  533. changeIMG: function (name, value) {
  534. if (this.getRule(name).maxLength !== undefined) {
  535. var that = this;
  536. value.map(function (v) {
  537. that.formData[name].push(v);
  538. });
  539. this.$set(this.formData, name, this.formData[name]);
  540. } else {
  541. if(name == 'batchAttr.pic'){
  542. this.batchAttr.pic = value;
  543. } else {
  544. if (name.indexOf('.') !== -1) {
  545. var key = name.split('.');
  546. if (key.length == 2){
  547. this.formData[key[0]][key[1]] = value;
  548. } else if(key.length == 3){
  549. this.formData[key[0]][key[1]][key[2]] = value;
  550. } else if(key.length == 4){
  551. this.$set(this.formData[key[0]][key[1]][key[2]],key[3],value)
  552. }
  553. } else {
  554. this.formData[name] = value;
  555. }
  556. }
  557. }
  558. },
  559. getRule: function (name) {
  560. return this.rule[name] || {};
  561. },
  562. uploadImage: function (name) {
  563. return this.createFrame('选择图片',this.U({c:"widget.images",a:'index',p:{fodder:name}}),{h:545,w:900});
  564. },
  565. uploadVideo: function () {
  566. if (this.videoLink) {
  567. this.formData.video_link = this.videoLink;
  568. } else {
  569. $(this.$refs.filElem).click();
  570. }
  571. },
  572. delVideo: function () {
  573. var that = this;
  574. that.$set(that.formData, 'video_link', '');
  575. },
  576. insertEditor: function (list) {
  577. this.um.execCommand('insertimage', list);
  578. },
  579. insertEditorVideo: function (src) {
  580. 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);
  581. },
  582. getContent: function () {
  583. return this.um.getContent();
  584. },
  585. /**
  586. * 监听radio字段
  587. */
  588. eeventRadio: function () {
  589. var that = this;
  590. that.radioRule.map(function (val) {
  591. that.form.on('radio(' + val + ')', function (res) {
  592. that.formData[val] = res.value;
  593. });
  594. })
  595. },
  596. init: function () {
  597. var that = this;
  598. window.UMEDITOR_CONFIG.toolbar = [
  599. // 加入一个 test
  600. 'source | undo redo | bold italic underline strikethrough | superscript subscript | forecolor backcolor | removeformat |',
  601. 'insertorderedlist insertunorderedlist | selectall cleardoc paragraph | fontfamily fontsize',
  602. '| justifyleft justifycenter justifyright justifyjustify |',
  603. 'link unlink | emotion selectimgs video | map',
  604. '| horizontal print preview fullscreen', 'drafts', 'formula'
  605. ];
  606. UM.registerUI('selectimgs', function (name) {
  607. var me = this;
  608. var $btn = $.eduibutton({
  609. icon: 'image',
  610. click: function () {
  611. that.createFrame('选择图片', "<?php echo Url('widget.images/index',['fodder'=>'editor']); ?>");
  612. },
  613. title: '选择图片'
  614. });
  615. this.addListener('selectionchange', function () {
  616. //切换为不可编辑时,把自己变灰
  617. var state = this.queryCommandState(name);
  618. $btn.edui().disabled(state == -1).active(state == 1)
  619. });
  620. return $btn;
  621. });
  622. UM.registerUI('video', function (name) {
  623. var me = this;
  624. var $btn = $.eduibutton({
  625. icon: 'video',
  626. click: function () {
  627. that.createFrame('选择视频', "<?php echo Url('widget.video/index',['fodder'=>'video']); ?>");
  628. },
  629. title: '选择视频'
  630. });
  631. this.addListener('selectionchange', function () {
  632. //切换为不可编辑时,把自己变灰
  633. var state = this.queryCommandState(name);
  634. $btn.edui().disabled(state == -1).active(state == 1)
  635. });
  636. return $btn;
  637. });
  638. //实例化编辑器
  639. this.um = UM.getEditor('myEditor', {initialFrameWidth: '99%', initialFrameHeight: 400});
  640. this.um.setContent(that.formData.description);
  641. that.$nextTick(function () {
  642. layui.use(['form','element'], function () {
  643. that.form = layui.form;
  644. that.form.render();
  645. that.form.on('select(temp_id)', function (data) {
  646. that.$set(that.formData, 'temp_id', data.value);
  647. });
  648. that.form.on('select(rule_index)', function (data) {
  649. that.ruleIndex = data.value;
  650. });
  651. layui.element.on('tab(docTabBrief)', function(){
  652. that.layTabId = this.getAttribute('lay-id');
  653. });
  654. that.eeventRadio();
  655. });
  656. })
  657. },
  658. requestPost: function (url, data) {
  659. return new Promise(function (resolve, reject) {
  660. axios.post(url, data).then(function (res) {
  661. if (res.status == 200 && res.data.code == 200) {
  662. resolve(res.data)
  663. } else {
  664. reject(res.data);
  665. }
  666. }).catch(function (err) {
  667. reject({msg:err})
  668. });
  669. })
  670. },
  671. requestGet: function (url) {
  672. return new Promise(function (resolve, reject) {
  673. axios.get(url).then(function (res) {
  674. if (res.status == 200 && res.data.code == 200) {
  675. resolve(res.data)
  676. } else {
  677. reject(res.data);
  678. }
  679. }).catch(function (err) {
  680. reject({msg:err})
  681. });
  682. })
  683. },
  684. generates: function () {
  685. var that = this;
  686. that.generate(1);
  687. },
  688. handleSubmit:function () {
  689. var that = this;
  690. var that = this;
  691. var uid = $('#uid').val();
  692. console.log(uid);
  693. that.formData.uid = uid;
  694. if (!that.formData['uid']){
  695. return that.showMsg('请绑定用户');
  696. }
  697. if (!that.formData['name']){
  698. return that.showMsg('请填写名称');
  699. }
  700. if (!that.formData['image']){
  701. return that.showMsg('请上传图片');
  702. }
  703. that.formData.description = that.getContent();
  704. $('#submit').attr('disabled', 'disabled').text('修改中...');
  705. that.requestPost(that.U({c:'auction.auction_gu',a:'update',p:{id:that.id}}),that.formData).then(function (res) {
  706. that.confirm();
  707. }).catch(function (res) {
  708. that.showMsg(res.msg);
  709. });
  710. },
  711. confirm: function(){
  712. var that = this;
  713. layui.use(['layer'], function () {
  714. var layer = layui.layer;
  715. layer.confirm(that.id ? '修改成功是否返回产品列表' : '修改成功是否返回产品列表', {
  716. btn: ['返回列表',that.id ? '继续修改' : '继续修改'] //按钮
  717. }, function(){
  718. location.href = that.U({c:'auction.auction_gu',a:'index'});
  719. }, function(){
  720. location.reload();
  721. });
  722. });
  723. },
  724. render:function(){
  725. this.$nextTick(function(){
  726. layui.use(['form'], function () {
  727. layui.form.render('select');
  728. });
  729. })
  730. },
  731. // 移动
  732. handleDragStart (e, item) {
  733. this.dragging = item;
  734. },
  735. handleDragEnd (e, item) {
  736. this.dragging = null
  737. },
  738. handleDragOver (e) {
  739. e.dataTransfer.dropEffect = 'move'
  740. },
  741. handleDragEnter (e, item) {
  742. e.dataTransfer.effectAllowed = 'move'
  743. if (item === this.dragging) {
  744. return
  745. }
  746. var newItems = [...this.formData.activity];
  747. var src = newItems.indexOf(this.dragging);
  748. var dst = newItems.indexOf(item);
  749. newItems.splice(dst, 0, ...newItems.splice(src, 1))
  750. this.formData.activity = newItems;
  751. },
  752. addRule:function(){
  753. return this.createFrame('添加商品规则',this.U({c:'store.StoreProductRule',a:'create'}));
  754. },
  755. allRule:function () {
  756. if (this.ruleIndex != -1) {
  757. var rule = this.ruleList[this.ruleIndex];
  758. if (rule) {
  759. this.ruleBool = true;
  760. var rule_value = rule.rule_value.map(function (item) {
  761. return item;
  762. });
  763. this.$set(this.formData,'items',rule_value);
  764. this.$set(this.formData,'attrs',[]);
  765. this.$set(this,'formHeader',[]);
  766. return true;
  767. }
  768. }
  769. this.showMsg('选择的属性无效');
  770. }
  771. },
  772. mounted: function () {
  773. var that = this;
  774. that.getProductInfo();
  775. window.changeIMG = that.changeIMG;
  776. window.$vm = that;
  777. }
  778. });
  779. </script>
  780. </body>
  781. </html>
  782. <script>
  783. </script>