edit.php 37 KB

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