edit.php 33 KB

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