8fc817836ac8aa087779a6a8af3d62b1.php 38 KB

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