cde64222a9838f4589012167faf74b59.php 95 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632
  1. <?php /*a:1:{s:59:"D:\wwwroot\gp\app\admin\view\store\store_product\create.php";i:1595820902;}*/ ?>
  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="">{{id ? '商品修改': '商品添加' }}</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. <ul class="layui-tab-title">
  142. <li class="layui-this" lay-id='1'>基础信息</li>
  143. <li lay-id='2'>商品详情</li>
  144. <li lay-id='3'>其他设置</li>
  145. </ul>
  146. <div class="layui-tab-content">
  147. <div class="layui-tab-item layui-show">
  148. <div class="layui-row layui-col-space15">
  149. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  150. <div class="grid-demo grid-demo-bg1">
  151. <div class="layui-form-item">
  152. <label class="layui-form-label">商品分类<i class="red">*</i></label>
  153. <div class="layui-input-block" id="cate_id">
  154. </div>
  155. </div>
  156. </div>
  157. </div>
  158. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  159. <div class="grid-demo grid-demo-bg1">
  160. <div class="layui-form-item">
  161. <label class="layui-form-label">商品名称<i class="red">*</i></label>
  162. <div class="layui-input-block">
  163. <input type="text" name="store_name" lay-verify="title" autocomplete="off"
  164. placeholder="请输入商品名称" class="layui-input" v-model="formData.store_name" maxlength="100">
  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-block">
  174. <input style="width: 40%" type="text" name="keyword" lay-verify="title" autocomplete="off"
  175. placeholder="请输入商品关键字" class="layui-input" v-model="formData.keyword">
  176. </div>
  177. </div>
  178. </div>
  179. </div>
  180. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  181. <div class="grid-demo grid-demo-bg1">
  182. <div class="layui-form-item">
  183. <label class="layui-form-label">单位</label>
  184. <div class="layui-input-block">
  185. <input style="width: 40%" type="text" name="unit_name" lay-verify="title" autocomplete="off"
  186. placeholder="请输入单位" class="layui-input" v-model="formData.unit_name">
  187. </div>
  188. </div>
  189. </div>
  190. </div>
  191. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  192. <div class="grid-demo grid-demo-bg1">
  193. <div class="layui-form-item layui-form-text">
  194. <label class="layui-form-label">商品简介</label>
  195. <div class="layui-input-block">
  196. <textarea name="store_info" v-model="formData.store_info"
  197. placeholder="请输入商品简介" class="layui-textarea"></textarea>
  198. </div>
  199. </div>
  200. </div>
  201. </div>
  202. <div class="layui-form-item submit">
  203. <label class="layui-form-label">主图视频</label>
  204. <div class="layui-input-block">
  205. <input type="text" name="link_key" v-model="videoLink" style="width:50%;display:inline-block;margin-right: 10px;" autocomplete="off" placeholder="请输入视频链接" class="layui-input">
  206. <button type="button" @click="uploadVideo" class="layui-btn layui-btn-sm layui-btn-normal">{{videoLink ? '确认添加' : '上传视频'}}</button>
  207. <input ref="filElem" type="file" style="display: none">
  208. </div>
  209. <div class="layui-input-block video_show" style="width: 30%;margin-top: 20px;" v-if="upload.videoIng">
  210. <div class="layui-progress" style="margin-bottom: 10px">
  211. <div class="layui-progress-bar layui-bg-blue" :style="'width:'+progress+'%'"></div>
  212. </div>
  213. <button type="button" class="layui-btn layui-btn-sm layui-btn-danger percent">{{progress}}%</button>
  214. </div>
  215. <div class="layui-input-block" v-if="formData.video_link">
  216. <div class="layui-video-box" v-if="formData.video_link">
  217. <video style="width:100%;height: 100%!important;border-radius: 10px;" :src="formData.video_link" controls="controls">
  218. 您的浏览器不支持 video 标签。
  219. </video>
  220. <div class="mark" @click="delVideo">
  221. <span class="layui-icon layui-icon-delete" style="font-size: 30px; color: #1E9FFF;"></span>
  222. </div>
  223. </div>
  224. <div class="layui-video-box" v-else>
  225. <i class="layui-icon layui-icon-play"></i>
  226. </div>
  227. </div>
  228. </div>
  229. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  230. <div class="grid-demo grid-demo-bg1">
  231. <div class="layui-form-item">
  232. <label class="layui-form-label">商品封面图<i class="red">*</i></label>
  233. <div class="pictrueBox">
  234. <div class="pictrue" v-if="formData.image" @click="uploadImage('image')">
  235. <img :src="formData.image"></div>
  236. <div class="upLoad" @click="uploadImage('image')" v-else>
  237. <i class="layui-icon layui-icon-camera" class="iconfont"
  238. style="font-size: 26px;"></i>
  239. </div>
  240. </div>
  241. </div>
  242. </div>
  243. </div>
  244. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  245. <div class="grid-demo grid-demo-bg1">
  246. <div class="layui-form-item">
  247. <label class="layui-form-label">商品轮播图<i class="red">*</i></label>
  248. <div class="pictrueBox pictrue" v-for="(item,index) in formData.slider_image">
  249. <img :src="item">
  250. <i class="layui-icon closes" @click="deleteImage('slider_image',index)">&#x1007</i>
  251. </div>
  252. <div class="pictrueBox">
  253. <div class="upLoad" @click="uploadImage('slider_image')"
  254. v-if="formData.slider_image.length <= rule.slider_image.maxLength">
  255. <i class="layui-icon layui-icon-camera" class="iconfont"
  256. style="font-size: 26px;"></i>
  257. </div>
  258. </div>
  259. </div>
  260. </div>
  261. </div>
  262. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  263. <div class="grid-demo grid-demo-bg1">
  264. <div class="layui-form-item">
  265. <label class="layui-form-label">商品规格<i class="red">*</i></label>
  266. <div class="layui-input-block">
  267. <input type="radio" name="spec_type" value="0" title="单规格"
  268. lay-filter="spec_type"
  269. :checked="formData.spec_type == 0 ? true : false">
  270. <input type="radio" name="spec_type" value="1" title="多规格"
  271. lay-filter="spec_type"
  272. :checked="formData.spec_type == 1 ? true : false">
  273. </div>
  274. </div>
  275. </div>
  276. </div>
  277. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12" v-if="formData.spec_type == 0">
  278. <div class="grid-demo grid-demo-bg1">
  279. <div class="layui-form-item">
  280. <label class="layui-form-label"></label>
  281. <div class="layui-input-block">
  282. <table class="layui-table">
  283. <thead>
  284. <tr>
  285. <th>图片<i class="red">*</i></th>
  286. <th>售价<i class="red">*</i></th>
  287. <th>成本价</th>
  288. <th>原价<i class="red">*</i></th>
  289. <th>库存<i class="red">*</i></th>
  290. <th>产品编号</th>
  291. <th>重量(KG)</th>
  292. <th>体积(m³)</th>
  293. </tr>
  294. </thead>
  295. <tr>
  296. <td>
  297. <div class="pictrueBox">
  298. <div class="pictrue" v-if="formData.attr.pic"
  299. @click="uploadImage('attr.pic')"><img
  300. :src="formData.attr.pic"></div>
  301. <div class="upLoad" @click="uploadImage('attr.pic')"
  302. v-else>
  303. <i class="layui-icon layui-icon-camera" class="iconfont"
  304. style="font-size: 26px;"></i>
  305. </div>
  306. </div>
  307. </td>
  308. <td><input type="text" v-model="formData.attr.price"
  309. class="layui-input"></td>
  310. <td><input type="text" v-model="formData.attr.cost"
  311. class="layui-input"></td>
  312. <td><input type="text" v-model="formData.attr.ot_price"
  313. class="layui-input"></td>
  314. <td><input type="text" v-model="formData.attr.stock"
  315. class="layui-input"></td>
  316. <td><input type="text" v-model="formData.attr.bar_code"
  317. class="layui-input"></td>
  318. <td><input type="text" v-model="formData.attr.weight"
  319. class="layui-input"></td>
  320. <td><input type="text" v-model="formData.attr.volume"
  321. class="layui-input"></td>
  322. </tr>
  323. </table>
  324. </div>
  325. </div>
  326. </div>
  327. </div>
  328. <!-- 多规格-->
  329. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12" v-if="formData.spec_type == 1">
  330. <div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
  331. <div class="grid-demo grid-demo-bg1" style="margin-bottom: 10px;">
  332. <div class="layui-form-item">
  333. <label class="layui-form-label">选择规格<i class="red">*</i></label>
  334. <div class="layui-input-block selected store_box">
  335. <select name="ruleIndex" lay-filter="rule_index">
  336. <option value="-1">请选择</option>
  337. <option :value="index" v-for="(item,index) in ruleList" >{{item.rule_name}}</option>
  338. </select>
  339. <button type="button" style="height: 38px;border-left: 0;" class="layui-btn layui-btn-sm" @click="allRule">确认</button>
  340. <button type="button" style="height: 38px;" class="layui-btn layui-btn-sm layui-btn-primary" @click="addRule">添加规则</button>
  341. </div>
  342. </div>
  343. </div>
  344. </div>
  345. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  346. <div class="grid-demo grid-demo-bg1" v-for="(item,index) in formData.items">
  347. <div class="ml110"><span>{{item.value}}</span><i class="layui-icon"
  348. @click="deleteItem(index)">&#x1007;</i>
  349. </div>
  350. <div class="layui-form-item rules">
  351. <!-- <label class="layui-form-label"></label>-->
  352. <div class="layui-input-block">
  353. <div style="overflow: visible;text-overflow: inherit;white-space: normal;border-left: 0;">
  354. <button type="button" class="layui-btn layui-btn-primary layui-btn-sm"
  355. v-for="(val,inx) in item.detail" >
  356. {{val}}
  357. <i class="layui-icon layui-icon-close"
  358. @click="deleteValue(item,inx)"></i>
  359. </button>
  360. </div>
  361. <div class="rules rulesBox">
  362. <div class="rules-btn-sm">
  363. <input type="text" v-model="item.detailValue" name="title"
  364. autocomplete="off" placeholder="请输入">
  365. </div>
  366. <button class="layui-btn layui-btn-sm" type="button"
  367. @click="addDetail(item)">添加
  368. </button>
  369. </div>
  370. </div>
  371. </div>
  372. </div>
  373. <div class="grid-demo grid-demo-bg1 rules" style="margin-top: 24px;" v-if="newRule">
  374. <div class="layui-form-item layui-form-text rules">
  375. <label class="layui-form-label">规格:</label>
  376. <div class="rules-btn-sm">
  377. <input type="text" name="title" v-model="formDynamic.attrsName"
  378. autocomplete="off" placeholder="请输入规格">
  379. </div>
  380. </div>
  381. <div class="layui-form-item layui-form-text rules">
  382. <label class="layui-form-label">规格值:</label>
  383. <div class="rules-btn-sm">
  384. <input type="text" name="title" v-model="formDynamic.attrsVal"
  385. autocomplete="off" placeholder="请输入规格值">
  386. </div>
  387. </div>
  388. <button class="layui-btn layui-btn-sm ml40" type="button"
  389. @click="createAttrName">添加
  390. </button>
  391. <button class="layui-btn layui-btn-sm ml10" type="button"
  392. @click="newRule = false">取消
  393. </button>
  394. </div>
  395. <div class="grid-demo grid-demo-bg1" style="margin-top: 20px;margin-bottom: 10px;" v-if="newRule == false && ruleBool">
  396. <div class="layui-form-item">
  397. <label class="layui-form-label"></label>
  398. <button class="layui-btn layui-btn-sm" type="button" @click="newRule = true">
  399. 添加新规格
  400. </button>
  401. <button class="layui-btn layui-btn-sm" type="button" @click="generates">立即生成
  402. </button>
  403. </div>
  404. </div>
  405. </div>
  406. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12"
  407. v-if="formData.attrs.length && formHeader.length">
  408. <div class="grid-demo grid-demo-bg1" style="margin-top: 20px">
  409. <div class="layui-form-item">
  410. <label class="layui-form-label">批量设置:</label>
  411. <div class="layui-input-block">
  412. <table class="layui-table">
  413. <thead>
  414. <tr>
  415. <th>图片<i class="red">*</i></th>
  416. <th>售价<i class="red">*</i></th>
  417. <th>成本价</th>
  418. <th>原价<i class="red">*</i></th>
  419. <th>库存<i class="red">*</i></th>
  420. <th>产品编号</th>
  421. <th>重量(KG)</th>
  422. <th>体积(m³)</th>
  423. <th width="15%" style="text-align: center;">操作</th>
  424. </tr>
  425. </thead>
  426. <tr>
  427. <td>
  428. <div class="pictrueBox">
  429. <div class="pictrue" v-if="batchAttr.pic"
  430. @click="uploadImage('batchAttr.pic')"><img
  431. :src="batchAttr.pic"></div>
  432. <div class="upLoad" @click="uploadImage('batchAttr.pic')"
  433. v-else>
  434. <i class="layui-icon layui-icon-camera" class="iconfont"
  435. style="font-size: 26px;"></i>
  436. </div>
  437. </div>
  438. </td>
  439. <td><input type="text" v-model="batchAttr.price"
  440. class="layui-input"></td>
  441. <td><input type="text" v-model="batchAttr.cost"
  442. class="layui-input"></td>
  443. <td><input type="text" v-model="batchAttr.ot_price"
  444. class="layui-input"></td>
  445. <td>
  446. <input type="text" v-model="batchAttr.stock"
  447. class="layui-input">
  448. </td>
  449. <td>
  450. <input type="text" v-model="batchAttr.bar_code"
  451. class="layui-input">
  452. </td>
  453. <td>
  454. <input type="text" v-model="batchAttr.weight"
  455. class="layui-input">
  456. </td>
  457. <td>
  458. <input type="text" v-model="batchAttr.volume"
  459. class="layui-input">
  460. </td>
  461. <td style="text-align: center;">
  462. <button class="layui-btn layui-btn-sm" type="button"
  463. @click="batchAdd">批量修改
  464. </button>
  465. <button class="layui-btn layui-btn-sm layui-btn-danger" type="button"
  466. @click="batchClear">清空
  467. </button>
  468. </td>
  469. </tr>
  470. </table>
  471. </div>
  472. </div>
  473. </div>
  474. <div class="grid-demo grid-demo-bg1" style="margin-top: 20px">
  475. <div class="layui-form-item">
  476. <label class="layui-form-label">商品属性:</label>
  477. <div class="layui-input-block">
  478. <table class="layui-table">
  479. <thead>
  480. <tr>
  481. <th v-for="(item,index) in formHeader" v-if="item.align">
  482. {{item.title}}
  483. </th>
  484. </tr>
  485. </thead>
  486. <tr v-for="(item,index) in formData.attrs">
  487. <td v-for="(n,v) in item.detail">{{n}}</td>
  488. <td>
  489. <div class="pictrueBox">
  490. <div class="pictrue" v-if="item.pic"
  491. @click="uploadImage('attrs.'+index+'.pic')"><img
  492. :src="item.pic"></div>
  493. <div class="upLoad" @click="uploadImage('attrs.'+index+'.pic')"
  494. v-else>
  495. <i class="layui-icon layui-icon-camera"
  496. class="iconfont" style="font-size: 26px;"></i>
  497. </div>
  498. </div>
  499. </td>
  500. <td><input type="number" v-model="item.price"
  501. class="layui-input"></td>
  502. <td><input type="number" v-model="item.cost"
  503. class="layui-input"></td>
  504. <td><input type="number" v-model="item.ot_price"
  505. class="layui-input"></td>
  506. <td><input type="number" v-model="item.stock"
  507. class="layui-input"></td>
  508. <td>
  509. <input type="text" v-model="item.bar_code"
  510. class="layui-input">
  511. </td>
  512. <td>
  513. <input type="number" v-model="item.weight"
  514. class="layui-input">
  515. </td>
  516. <td>
  517. <input type="number" v-model="item.volume"
  518. class="layui-input">
  519. </td>
  520. <td>
  521. <button class="layui-btn layui-btn-sm" type="button"
  522. @click="deleteAttrs(index)">删除
  523. </button>
  524. </td>
  525. </tr>
  526. </table>
  527. </div>
  528. </div>
  529. </div>
  530. </div>
  531. </div>
  532. </div>
  533. <div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
  534. <div class="grid-demo grid-demo-bg1">
  535. <div class="layui-form-item">
  536. <label class="layui-form-label">运费模板<i class="red">*</i></label>
  537. <div class="layui-input-block">
  538. <select name="temp_id" lay-filter="temp_id">
  539. <option value="0">请选择</option>
  540. <option :value="item.id" v-for="item in tempList" :selected=" item.id == formData.temp_id ? true : false ">{{item.name}}</option>
  541. </select>
  542. </div>
  543. </div>
  544. </div>
  545. </div>
  546. <div class="layui-row layui-col-space15">
  547. <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
  548. <div class="grid-demo grid-demo-bg1">
  549. <div class="layui-form-item">
  550. <label class="layui-form-label">商品状态</label>
  551. <div class="layui-input-block">
  552. <input type="radio" name="is_show" lay-filter="is_show" value="1" title="上架"
  553. :checked="formData.is_show == 1 ? true : false">
  554. <input type="radio" name="is_show" lay-filter="is_show" value="0" title="下架"
  555. :checked="formData.is_show == 0 ? true : false">
  556. </div>
  557. </div>
  558. </div>
  559. </div>
  560. </div>
  561. </div>
  562. <div class="layui-tab-item">
  563. <div class="layui-row layui-col-space15">
  564. <textarea type="text/plain" name="description" id="myEditor" style="width:100%;">{{formData.description}}</textarea>
  565. </div>
  566. </div>
  567. <div class="layui-tab-item">
  568. <div class="layui-row layui-col-space15">
  569. <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
  570. <div class="grid-demo grid-demo-bg1">
  571. <div class="layui-form-item">
  572. <label class="layui-form-label">虚拟销量</label>
  573. <div class="layui-input-block">
  574. <input type="number" name="ficti" lay-verify="title" autocomplete="off"
  575. placeholder="请输入虚拟销量" class="layui-input" v-model="formData.ficti">
  576. </div>
  577. </div>
  578. </div>
  579. </div>
  580. <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
  581. <div class="grid-demo grid-demo-bg1">
  582. <div class="layui-form-item">
  583. <label class="layui-form-label">积分</label>
  584. <div class="layui-input-block">
  585. <input type="number" name="give_integral" lay-verify="title"
  586. autocomplete="off" placeholder="请输入积分" class="layui-input" v-model="formData.give_integral">
  587. </div>
  588. </div>
  589. </div>
  590. </div>
  591. <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
  592. <div class="grid-demo grid-demo-bg1">
  593. <div class="layui-form-item">
  594. <label class="layui-form-label">排序</label>
  595. <div class="layui-input-block">
  596. <input type="number" name="sort" lay-verify="title" autocomplete="off"
  597. placeholder="请输入排序" class="layui-input" v-model="formData.sort">
  598. </div>
  599. </div>
  600. </div>
  601. </div>
  602. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  603. <div class="grid-demo grid-demo-bg1">
  604. <div class="layui-form-item">
  605. <label class="layui-form-label">佣金设置</label>
  606. <div class="layui-input-block">
  607. <input type="radio" name="is_sub" lay-filter="is_sub" value="1" title="单独设置"
  608. :checked="formData.is_sub == 1 ? true : false">
  609. <input type="radio" name="is_sub" lay-filter="is_sub" value="0" title="默认设置"
  610. :checked="formData.is_sub == 0 ? true : false">
  611. </div>
  612. </div>
  613. </div>
  614. </div>
  615. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12" v-if="formData.is_sub == 1 && formData.spec_type == 1">
  616. <div class="grid-demo grid-demo-bg1">
  617. <div class="layui-form-item">
  618. <label class="layui-form-label">批量设置</label>
  619. <div class="layui-input-block">
  620. <input style="width: 20%;display: inline-block;" type="number" name="brokerage" lay-verify="title" autocomplete="off"
  621. placeholder="请输入一级返佣" class="layui-input" v-model="brokerage.brokerage">
  622. <input style="width: 20%;display: inline-block;" type="number" name="brokerage_two" lay-verify="title" autocomplete="off"
  623. placeholder="请输入二级返佣" class="layui-input" v-model="brokerage.brokerage_two">
  624. <button class="layui-btn layui-btn-sm" style="height: 38px;" type="button"
  625. @click="addBrokerage">批量设置
  626. </button>
  627. </div>
  628. </div>
  629. </div>
  630. </div>
  631. <!-- 单属性-->
  632. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12" v-if="formData.spec_type == 0 && formData.is_sub == 1">
  633. <div class="grid-demo grid-demo-bg1">
  634. <div class="layui-form-item">
  635. <label class="layui-form-label">商品属性:</label>
  636. <div class="layui-input-block">
  637. <table class="layui-table">
  638. <thead>
  639. <tr>
  640. <th>图片</th>
  641. <th>售价</th>
  642. <th>成本价</th>
  643. <th>原价</th>
  644. <th>库存</th>
  645. <th>产品编号</th>
  646. <th>重量</th>
  647. <th>体积</th>
  648. <th>一级返佣</th>
  649. <th>二级返佣</th>
  650. </tr>
  651. </thead>
  652. <tr>
  653. <td>
  654. <div class="pictrueBox">
  655. <div class="pictrue" v-if="formData.attr.pic">
  656. <img :src="formData.attr.pic">
  657. </div>
  658. </div>
  659. </td>
  660. <td>{{formData.attr.price}}</td>
  661. <td>{{formData.attr.cost}}</td>
  662. <td>{{formData.attr.ot_price}}</td>
  663. <td>{{formData.attr.stock}}</td>
  664. <td>{{formData.attr.bar_code}}</td>
  665. <td>{{formData.attr.weight}}</td>
  666. <td>{{formData.attr.volume}}</td>
  667. <td><input type="text" v-model="formData.attr.brokerage"
  668. class="layui-input"></td>
  669. <td><input type="text" v-model="formData.attr.brokerage_two"
  670. class="layui-input"></td>
  671. </tr>
  672. </table>
  673. </div>
  674. </div>
  675. </div>
  676. </div>
  677. <!-- 单属性结束-->
  678. <!-- 多属性-->
  679. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12"
  680. v-if="formData.attrs.length && formHeader.length && formData.is_sub == 1 && formData.spec_type == 1">
  681. <div class="grid-demo grid-demo-bg1" style="margin-top: 20px">
  682. <div class="layui-form-item">
  683. <label class="layui-form-label">商品属性:</label>
  684. <div class="layui-input-block">
  685. <table class="layui-table">
  686. <thead>
  687. <tr>
  688. <th v-for="(item,index) in formHeader" v-if="item.slot != 'action'">
  689. {{item.title}}
  690. </th>
  691. </tr>
  692. </thead>
  693. <tr v-for="(item,index) in formData.attrs">
  694. <td v-for="(n,v) in item.detail">{{n}}</td>
  695. <td>
  696. <div class="pictrueBox">
  697. <div class="pictrue" v-if="item.pic"><img :src="item.pic"></div>
  698. </div>
  699. </td>
  700. <td>{{item.price}}</td>
  701. <td>{{item.cost}}</td>
  702. <td>{{item.ot_price}}</td>
  703. <td>{{item.stock}}</td>
  704. <td>{{item.bar_code}}</td>
  705. <td>{{item.weight}}</td>
  706. <td>{{item.volume}}</td>
  707. <td>
  708. <input type="number" v-model="item.brokerage"
  709. class="layui-input">
  710. </td>
  711. <td>
  712. <input type="number" v-model="item.brokerage_two"
  713. class="layui-input">
  714. </td>
  715. </tr>
  716. </table>
  717. </div>
  718. </div>
  719. </div>
  720. </div>
  721. <!--多属性结束-->
  722. <!-- <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">-->
  723. <!-- <div class="grid-demo grid-demo-bg1">-->
  724. <!-- <div class="layui-form-item">-->
  725. <!-- <label class="layui-form-label">商品状态</label>-->
  726. <!-- <div class="layui-input-block">-->
  727. <!-- <input type="radio" name="is_show" lay-filter="is_show" value="1" title="上架"-->
  728. <!-- :checked="formData.is_show == 1 ? true : false">-->
  729. <!-- <input type="radio" name="is_show" lay-filter="is_show" value="0" title="下架"-->
  730. <!-- :checked="formData.is_show == 0 ? true : false">-->
  731. <!-- </div>-->
  732. <!-- </div>-->
  733. <!-- </div>-->
  734. <!-- </div>-->
  735. <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
  736. <div class="grid-demo grid-demo-bg1">
  737. <div class="layui-form-item">
  738. <label class="layui-form-label">热卖单品</label>
  739. <div class="layui-input-block">
  740. <input type="radio" name="is_hot" lay-filter="is_hot" value="1" title="开启"
  741. :checked="formData.is_hot == 1 ? true : false">
  742. <input type="radio" name="is_hot" lay-filter="is_hot" value="0" title="关闭"
  743. :checked="formData.is_hot == 0 ? true : false">
  744. </div>
  745. </div>
  746. </div>
  747. </div>
  748. <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
  749. <div class="grid-demo grid-demo-bg1">
  750. <div class="layui-form-item">
  751. <label class="layui-form-label">促销单品</label>
  752. <div class="layui-input-block">
  753. <input type="radio" name="is_benefit" lay-filter="is_benefit" value="1" title="开启"
  754. :checked="formData.is_benefit == 1 ? true : false">
  755. <input type="radio" name="is_benefit" lay-filter="is_benefit" value="0" title="关闭"
  756. :checked="formData.is_benefit == 0 ? true : false">
  757. </div>
  758. </div>
  759. </div>
  760. </div>
  761. <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
  762. <div class="grid-demo grid-demo-bg1">
  763. <div class="layui-form-item">
  764. <label class="layui-form-label">精品推荐</label>
  765. <div class="layui-input-block">
  766. <input type="radio" name="is_best" lay-filter="is_best" value="1" title="开启"
  767. :checked="formData.is_best == 1 ? true : false">
  768. <input type="radio" name="is_best" lay-filter="is_best" value="0" title="关闭"
  769. :checked="formData.is_best == 0 ? true : false">
  770. </div>
  771. </div>
  772. </div>
  773. </div>
  774. <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
  775. <div class="grid-demo grid-demo-bg1">
  776. <div class="layui-form-item">
  777. <label class="layui-form-label">首发新品</label>
  778. <div class="layui-input-block">
  779. <input type="radio" name="is_new" lay-filter="is_new" value="1" title="开启"
  780. :checked="formData.is_new == 1 ? true : false">
  781. <input type="radio" name="is_new" lay-filter="is_new" value="0" title="关闭"
  782. :checked="formData.is_new == 0 ? true : false">
  783. </div>
  784. </div>
  785. </div>
  786. </div>
  787. <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
  788. <div class="grid-demo grid-demo-bg1">
  789. <div class="layui-form-item">
  790. <label class="layui-form-label">优品推荐</label>
  791. <div class="layui-input-block">
  792. <input type="radio" name="is_good" lay-filter="is_good" value="1" title="开启"
  793. :checked="formData.is_good == 1 ? true : false">
  794. <input type="radio" name="is_good" lay-filter="is_good" value="0" title="关闭"
  795. :checked="formData.is_good == 0 ? true : false">
  796. </div>
  797. </div>
  798. </div>
  799. </div>
  800. <div class="layui-row layui-col-space15">
  801. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  802. <div class="grid-demo grid-demo-bg1">
  803. <div class="layui-form-item">
  804. <label class="layui-form-label">活动优先级</label>
  805. <div class="layui-input-block">
  806. <span class="layui-btn layui-btn-sm layui-btn-normal" :style="'background-color:'+activity[item]" v-for="(item,index) in formData.activity" :key="index"
  807. draggable="true"
  808. @dragstart="handleDragStart($event, item)"
  809. @dragover.prevent="handleDragOver($event, item)"
  810. @dragenter="handleDragEnter($event, item)"
  811. @dragend="handleDragEnd($event, item)">
  812. {{item}}
  813. </span>
  814. <span class="info">可拖动按钮调整活动的优先展示顺序</span>
  815. </div>
  816. </div>
  817. </div>
  818. </div>
  819. </div>
  820. </div>
  821. </div>
  822. </div>
  823. <div class="layui-tab-content">
  824. <div class="layui-row layui-col-space15">
  825. <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
  826. <div class="grid-demo grid-demo-bg1">
  827. <div class="layui-form-item" v-if="id">
  828. <button class="layui-btn layui-btn-primary layui-btn-sm" id="submit" type="button" @click="handleSubmit()">保存</button>
  829. <button class="layui-btn layui-btn-primary layui-btn-sm" type="button" @click="back" v-if="layTabId != 1">上一步</button>
  830. <button class="layui-btn layui-btn-normal layui-btn-sm" type="button" v-if="layTabId != 3" @click="next">下一步</button>
  831. </div>
  832. <div class="layui-form-item" v-else>
  833. <button class="layui-btn layui-btn-primary layui-btn-sm" type="button" @click="back" v-if="layTabId != 1">上一步</button>
  834. <button class="layui-btn layui-btn-normal layui-btn-sm" type="button" @click="next" v-if="layTabId != 3">下一步</button>
  835. <button class="layui-btn layui-btn-normal layui-btn-sm" id="submit" type="button" v-if="layTabId == 3" @click="handleSubmit()">提交</button>
  836. </div>
  837. </div>
  838. </div>
  839. </div>
  840. </div>
  841. </div>
  842. </form>
  843. </div>
  844. </div>
  845. </div>
  846. </div>
  847. <script>
  848. var id = <?php echo htmlentities($id); ?>;
  849. new Vue({
  850. el: '#app',
  851. data: {
  852. id:id,
  853. //分类列表
  854. cateList: [],
  855. //运费模板
  856. tempList: [],
  857. upload:{
  858. videoIng:false
  859. },
  860. formData: {
  861. cate_id: [],
  862. temp_id: 0,
  863. commission:0,
  864. store_name: '',
  865. keyword: '',
  866. unit_name: '',
  867. postage: '',
  868. store_info: '',
  869. image: '',
  870. video_link: '',
  871. slider_image: [],
  872. price: '',
  873. spec_type: 0,
  874. attr: {
  875. pic: '',
  876. price: 0,
  877. cost: 0,
  878. ot_price: 0,
  879. stock: 0,
  880. bar_code: '',
  881. weight: 0,
  882. volume: 0,
  883. brokerage: 0,
  884. brokerage_two: 0,
  885. },
  886. attrs: [],
  887. description: '',
  888. ficti: 0,
  889. give_integral: 0,
  890. sort: 0,
  891. is_show: 1,
  892. is_hot: 0,
  893. is_benefit: 0,
  894. is_best: 0,
  895. is_new: 0,
  896. is_good: 0,
  897. is_sub:0,
  898. items: [
  899. // {
  900. // value: '',
  901. // detailValue:'',
  902. // attrHidden:false,
  903. // detail:[]
  904. // }
  905. ],
  906. activity:['秒杀','砍价','拼团'],
  907. },
  908. videoLink:'',
  909. //批量添加属性
  910. batchAttr:{
  911. pic: '',
  912. price: 0,
  913. cost: 0,
  914. ot_price: 0,
  915. stock: 0,
  916. bar_code: '',
  917. weight: 0,
  918. volume: 0,
  919. },
  920. //多属性header头
  921. formHeader:[],
  922. // 规格数据
  923. formDynamic: {
  924. attrsName: '',
  925. attrsVal: ''
  926. },
  927. brokerage:{
  928. brokerage: '',
  929. brokerage_two: '',
  930. },
  931. activity:{'秒杀':'#1E9FFF','砍价':'#189688','拼团':'#FEB900'},
  932. attr: [],//临时属性
  933. newRule: false,//是否添加新规则
  934. radioRule: ['is_sub','is_show', 'is_hot', 'is_benefit', 'is_new','is_good' ,'is_best', 'spec_type'],//radio 当选规则
  935. rule: { //多图选择规则
  936. slider_image: {
  937. maxLength: 5
  938. }
  939. },
  940. ruleList:[],
  941. ruleIndex:-1,
  942. progress: 0,
  943. um: null,//编译器实例化
  944. form: null,//layui.form
  945. layTabId: 1,
  946. ruleBool: id ? true : false,
  947. },
  948. watch:{
  949. 'formData.is_sub':function (n) {
  950. if (n == 1) {
  951. this.formHeader.push({title:'一级返佣(元)'});
  952. this.formHeader.push({title:'二级级返佣(元)'});
  953. } else {
  954. this.formHeader.pop();
  955. this.formHeader.pop();
  956. }
  957. },
  958. 'formData.spec_type':function (n) {
  959. if (n) {
  960. this.render();
  961. }
  962. },
  963. // 'formData.image':function (n) {
  964. // if(!this.batchAttr.pic){
  965. // this.batchAttr.pic = n;
  966. // }
  967. // if(!this.formData.attr.pic){
  968. // this.formData.attr.pic = n;
  969. // }
  970. // }
  971. },
  972. methods: {
  973. back:function(){
  974. var that = this;
  975. layui.use(['element'], function () {
  976. layui.element.tabChange('docTabBrief', that.layTabId == 1 ? 1 : parseInt(that.layTabId) - 1);
  977. });
  978. },
  979. next:function(){
  980. var that = this;
  981. layui.use(['element'], function () {
  982. layui.element.tabChange('docTabBrief', that.layTabId == 3 ? 3 : parseInt(that.layTabId) + 1);
  983. });
  984. },
  985. goBack:function(){
  986. location.href = this.U({c:'store.StoreProduct',a:'index'});
  987. },
  988. U: function (opt) {
  989. var m = opt.m || 'admin', c = opt.c || window.controlle || '', a = opt.a || 'index', q = opt.q || '',
  990. p = opt.p || {};
  991. var params = Object.keys(p).map(function (key) {
  992. return key + '/' + p[key];
  993. }).join('/');
  994. var gets = Object.keys(q).map(function (key) {
  995. return key+'='+ q[key];
  996. }).join('&');
  997. return '/' + m + '/' + c + '/' + a + (params == '' ? '' : '/' + params) + (gets == '' ? '' : '?' + gets);
  998. },
  999. /**
  1000. * 提示
  1001. * */
  1002. showMsg: function (msg, success) {
  1003. $('#submit').removeAttr('disabled').text('提交');
  1004. layui.use(['layer'], function () {
  1005. layui.layer.msg(msg, success);
  1006. });
  1007. },
  1008. addBrokerage:function(){
  1009. if (this.brokerage.brokerage >= 0 && this.brokerage.brokerage_two >= 0){
  1010. var that = this;
  1011. this.$set(this.formData,'attrs',this.formData.attrs.map(function (item) {
  1012. item.brokerage = that.brokerage.brokerage;
  1013. item.brokerage_two = that.brokerage.brokerage_two;
  1014. return item;
  1015. }));
  1016. } else {
  1017. return this.showMsg('请填写返佣金额在进行批量添加');
  1018. }
  1019. },
  1020. batchClear:function(){
  1021. this.$set(this,'batchAttr',{
  1022. pic: '',
  1023. price: 0,
  1024. cost: 0,
  1025. ot_price: 0,
  1026. stock: 0,
  1027. bar_code: '',
  1028. weight: 0,
  1029. volume: 0,
  1030. });
  1031. },
  1032. /**
  1033. * 批量添加
  1034. * */
  1035. batchAdd:function(){
  1036. var that = this;
  1037. this.$set(this.formData,'attrs',this.formData.attrs.map(function (item) {
  1038. if (that.batchAttr.pic) {
  1039. item.pic = that.batchAttr.pic;
  1040. }
  1041. if (that.batchAttr.price > 0){
  1042. item.price = that.batchAttr.price;
  1043. }
  1044. if (that.batchAttr.cost > 0){
  1045. item.cost = that.batchAttr.cost;
  1046. }
  1047. if (that.batchAttr.ot_price > 0){
  1048. item.ot_price = that.batchAttr.ot_price;
  1049. }
  1050. if (that.batchAttr.stock > 0){
  1051. item.stock = that.batchAttr.stock;
  1052. }
  1053. if (that.batchAttr.bar_code != ''){
  1054. item.bar_code = that.batchAttr.bar_code;
  1055. }
  1056. if (that.batchAttr.weight > 0){
  1057. item.weight = that.batchAttr.weight;
  1058. }
  1059. if (that.batchAttr.volume > 0){
  1060. item.volume = that.batchAttr.volume;
  1061. }
  1062. return item;
  1063. }));
  1064. },
  1065. /**
  1066. * 获取商品信息
  1067. * */
  1068. getProductInfo: function () {
  1069. var that = this;
  1070. that.requestGet(that.U({c:"store.StoreProduct",a:'get_product_info',q:{id:that.id}})).then(function (res) {
  1071. that.$set(that,'cateList',res.data.cateList);
  1072. that.$set(that,'tempList',res.data.tempList);
  1073. var productInfo = res.data.productInfo || {};
  1074. if(productInfo.id && that.id){
  1075. that.$set(that,'formData',productInfo);
  1076. that.generate();
  1077. }
  1078. that.getRuleList();
  1079. that.init();
  1080. }).catch(function (res) {
  1081. that.showMsg(res.msg);
  1082. })
  1083. },
  1084. /**
  1085. * 给某个属性添加属性值
  1086. * @param item
  1087. * */
  1088. addDetail: function (item) {
  1089. if (!item.detailValue) return false;
  1090. if (item.detail.find(function (val) {
  1091. if(item.detailValue == val){
  1092. return true;
  1093. }
  1094. })) {
  1095. return this.showMsg('添加的属性值重复');
  1096. }
  1097. item.detail.push(item.detailValue);
  1098. item.detailValue = '';
  1099. },
  1100. /**
  1101. * 删除某个属性值
  1102. * @param item 父级循环集合
  1103. * @param inx 子集index
  1104. * */
  1105. deleteValue: function (item, inx) {
  1106. if (item.detail.length > 1) {
  1107. item.detail.splice(inx, 1);
  1108. } else {
  1109. return this.showMsg('请设置至少一个属性');
  1110. }
  1111. },
  1112. /**
  1113. * 删除某条属性
  1114. * @param index
  1115. * */
  1116. deleteItem: function (index) {
  1117. this.formData.items.splice(index, 1);
  1118. },
  1119. /**
  1120. * 删除某条属性
  1121. * @param index
  1122. * */
  1123. deleteAttrs: function (index) {
  1124. var that = this;
  1125. if(that.id > 0){
  1126. that.requestGet(that.U({c:"store.StoreProduct",a:'check_activity',q:{id:that.id}})).then(function (res) {
  1127. that.showMsg(res.msg);
  1128. }).catch(function (res) {
  1129. if (that.formData.attrs.length > 1) {
  1130. that.formData.attrs.splice(index, 1);
  1131. } else {
  1132. return that.showMsg('请设置至少一个规则');
  1133. }
  1134. })
  1135. }else{
  1136. if (that.formData.attrs.length > 1) {
  1137. that.formData.attrs.splice(index, 1);
  1138. } else {
  1139. return that.showMsg('请设置至少一个规则');
  1140. }
  1141. }
  1142. },
  1143. /**
  1144. * 创建属性
  1145. * */
  1146. createAttrName: function () {
  1147. if (this.formDynamic.attrsName && this.formDynamic.attrsVal) {
  1148. if (this.formData.items.find(function (val) {
  1149. if (val.value == this.formDynamic.attrsName) {
  1150. return true;
  1151. }
  1152. }.bind(this))) {
  1153. return this.showMsg('添加的属性重复');
  1154. }
  1155. this.formData.items.push({
  1156. value: this.formDynamic.attrsName,
  1157. detailValue: '',
  1158. attrHidden: false,
  1159. detail: [this.formDynamic.attrsVal]
  1160. });
  1161. this.formDynamic.attrsName = '';
  1162. this.formDynamic.attrsVal = '';
  1163. this.newRule = false;
  1164. } else {
  1165. return this.showMsg('请添加完整的规格!');
  1166. }
  1167. },
  1168. /**
  1169. * 删除图片
  1170. * */
  1171. deleteImage: function (key, index) {
  1172. var that = this;
  1173. if (index != undefined) {
  1174. that.formData[key].splice(index, 1);
  1175. that.$set(that.formData, key, that.formData[key]);
  1176. } else {
  1177. that.$set(that.formData, key, '');
  1178. }
  1179. },
  1180. createFrame: function (title, src, opt) {
  1181. opt === undefined && (opt = {});
  1182. var h = 0;
  1183. if (window.innerHeight < 800 && window.innerHeight >= 700) {
  1184. h = window.innerHeight - 50;
  1185. } else if (window.innerHeight < 900 && window.innerHeight >= 800) {
  1186. h = window.innerHeight - 100;
  1187. } else if (window.innerHeight < 1000 && window.innerHeight >= 900) {
  1188. h = window.innerHeight - 150;
  1189. } else if (window.innerHeight >= 1000) {
  1190. h = window.innerHeight - 200;
  1191. } else {
  1192. h = window.innerHeight;
  1193. }
  1194. var area = [(opt.w || window.innerWidth / 2) + 'px', (!opt.h || opt.h > h ? h : opt.h) + 'px'];
  1195. layui.use('layer',function () {
  1196. return layer.open({
  1197. type: 2,
  1198. title: title,
  1199. area: area,
  1200. fixed: false, //不固定
  1201. maxmin: true,
  1202. moveOut: false,//true 可以拖出窗外 false 只能在窗内拖
  1203. anim: 5,//出场动画 isOutAnim bool 关闭动画
  1204. offset: 'auto',//['100px','100px'],//'auto',//初始位置 ['100px','100px'] t[ 上 左]
  1205. shade: 0,//遮罩
  1206. resize: true,//是否允许拉伸
  1207. content: src,//内容
  1208. move: '.layui-layer-title'
  1209. });
  1210. });
  1211. },
  1212. changeIMG: function (name, value) {
  1213. if (this.getRule(name).maxLength !== undefined) {
  1214. var that = this;
  1215. value.map(function (v) {
  1216. that.formData[name].push(v);
  1217. });
  1218. this.$set(this.formData, name, this.formData[name]);
  1219. } else {
  1220. if(name == 'batchAttr.pic'){
  1221. this.batchAttr.pic = value;
  1222. } else {
  1223. if (name.indexOf('.') !== -1) {
  1224. var key = name.split('.');
  1225. if (key.length == 2){
  1226. this.formData[key[0]][key[1]] = value;
  1227. } else if(key.length == 3){
  1228. this.formData[key[0]][key[1]][key[2]] = value;
  1229. } else if(key.length == 4){
  1230. this.$set(this.formData[key[0]][key[1]][key[2]],key[3],value)
  1231. }
  1232. } else {
  1233. this.formData[name] = value;
  1234. }
  1235. }
  1236. }
  1237. },
  1238. getRule: function (name) {
  1239. return this.rule[name] || {};
  1240. },
  1241. uploadImage: function (name) {
  1242. return this.createFrame('选择图片',this.U({c:"widget.images",a:'index',p:{fodder:name}}),{h:545,w:900});
  1243. },
  1244. uploadVideo: function () {
  1245. if (this.videoLink) {
  1246. this.formData.video_link = this.videoLink;
  1247. } else {
  1248. $(this.$refs.filElem).click();
  1249. }
  1250. },
  1251. delVideo: function () {
  1252. var that = this;
  1253. that.$set(that.formData, 'video_link', '');
  1254. },
  1255. insertEditor: function (list) {
  1256. this.um.execCommand('insertimage', list);
  1257. },
  1258. insertEditorVideo: function (src) {
  1259. 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);
  1260. },
  1261. getContent: function () {
  1262. return this.um.getContent();
  1263. },
  1264. /**
  1265. * 监听radio字段
  1266. */
  1267. eeventRadio: function () {
  1268. var that = this;
  1269. that.radioRule.map(function (val) {
  1270. that.form.on('radio(' + val + ')', function (res) {
  1271. that.formData[val] = res.value;
  1272. });
  1273. })
  1274. },
  1275. init: function () {
  1276. var that = this;
  1277. window.UMEDITOR_CONFIG.toolbar = [
  1278. // 加入一个 test
  1279. 'source | undo redo | bold italic underline strikethrough | superscript subscript | forecolor backcolor | removeformat |',
  1280. 'insertorderedlist insertunorderedlist | selectall cleardoc paragraph | fontfamily fontsize',
  1281. '| justifyleft justifycenter justifyright justifyjustify |',
  1282. 'link unlink | emotion selectimgs video | map',
  1283. '| horizontal print preview fullscreen', 'drafts', 'formula'
  1284. ];
  1285. UM.registerUI('selectimgs', function (name) {
  1286. var me = this;
  1287. var $btn = $.eduibutton({
  1288. icon: 'image',
  1289. click: function () {
  1290. that.createFrame('选择图片', "<?php echo Url('widget.images/index',['fodder'=>'editor']); ?>");
  1291. },
  1292. title: '选择图片'
  1293. });
  1294. this.addListener('selectionchange', function () {
  1295. //切换为不可编辑时,把自己变灰
  1296. var state = this.queryCommandState(name);
  1297. $btn.edui().disabled(state == -1).active(state == 1)
  1298. });
  1299. return $btn;
  1300. });
  1301. UM.registerUI('video', function (name) {
  1302. var me = this;
  1303. var $btn = $.eduibutton({
  1304. icon: 'video',
  1305. click: function () {
  1306. that.createFrame('选择视频', "<?php echo Url('widget.video/index',['fodder'=>'video']); ?>");
  1307. },
  1308. title: '选择视频'
  1309. });
  1310. this.addListener('selectionchange', function () {
  1311. //切换为不可编辑时,把自己变灰
  1312. var state = this.queryCommandState(name);
  1313. $btn.edui().disabled(state == -1).active(state == 1)
  1314. });
  1315. return $btn;
  1316. });
  1317. //实例化编辑器
  1318. this.um = UM.getEditor('myEditor', {initialFrameWidth: '99%', initialFrameHeight: 400});
  1319. this.um.setContent(that.formData.description);
  1320. that.$nextTick(function () {
  1321. layui.use(['form','element'], function () {
  1322. that.form = layui.form;
  1323. that.form.render();
  1324. that.form.on('select(temp_id)', function (data) {
  1325. that.$set(that.formData, 'temp_id', data.value);
  1326. });
  1327. that.form.on('select(rule_index)', function (data) {
  1328. that.ruleIndex = data.value;
  1329. });
  1330. layui.element.on('tab(docTabBrief)', function(){
  1331. that.layTabId = this.getAttribute('lay-id');
  1332. });
  1333. that.eeventRadio();
  1334. });
  1335. layui.config({
  1336. base : '/static/plug/layui/'
  1337. }).extend({
  1338. selectN: './selectN',
  1339. }).use('selectM',function () {
  1340. var selectM = layui.selectM;
  1341. selectM({
  1342. //元素容器【必填】
  1343. elem: '#cate_id'
  1344. //候选数据【必填】
  1345. ,data: that.cateList
  1346. //默认值
  1347. ,selected: that.formData.cate_id || []
  1348. //最多选中个数,默认5
  1349. ,max : 10
  1350. ,name: 'cate_id'
  1351. ,model: 'formData.cate_id'
  1352. //值的分隔符
  1353. ,delimiter: ','
  1354. //候选项数据的键名
  1355. ,field: {idName:'value',titleName:'label',statusName:'disabled'}
  1356. });
  1357. });
  1358. })
  1359. },
  1360. requestPost: function (url, data) {
  1361. return new Promise(function (resolve, reject) {
  1362. axios.post(url, data).then(function (res) {
  1363. if (res.status == 200 && res.data.code == 200) {
  1364. resolve(res.data)
  1365. } else {
  1366. reject(res.data);
  1367. }
  1368. }).catch(function (err) {
  1369. reject({msg:err})
  1370. });
  1371. })
  1372. },
  1373. requestGet: function (url) {
  1374. return new Promise(function (resolve, reject) {
  1375. axios.get(url).then(function (res) {
  1376. if (res.status == 200 && res.data.code == 200) {
  1377. resolve(res.data)
  1378. } else {
  1379. reject(res.data);
  1380. }
  1381. }).catch(function (err) {
  1382. reject({msg:err})
  1383. });
  1384. })
  1385. },
  1386. generates: function () {
  1387. var that = this;
  1388. that.generate(1);
  1389. },
  1390. generate: function (type = 0) {
  1391. var that = this;
  1392. this.requestPost(that.U({c:"store.StoreProduct",a:'is_format_attr',p:{id:that.id,type:type}}), {attrs:this.formData.items}).then(function (res) {
  1393. that.$set(that.formData, 'attrs', res.data.value);
  1394. that.$set(that, 'formHeader', res.data.header);
  1395. if (that.id && that.formData.is_sub == 1 && that.formData.spec_type == 1) {
  1396. that.formHeader.push({title:'一级返佣(元)'});
  1397. that.formHeader.push({title:'二级级返佣(元)'});
  1398. }
  1399. }).catch(function (res) {
  1400. return that.showMsg(res.msg);
  1401. });
  1402. },
  1403. handleSubmit:function () {
  1404. var that = this, cate_id = $('input[name="cate_id"]').val();
  1405. if (cate_id != '') {
  1406. this.formData.cate_id = cate_id.split(',');
  1407. }
  1408. if (!that.formData.cate_id.length) {
  1409. return that.showMsg('请选择商品分类');
  1410. }
  1411. if (!that.formData.temp_id) {
  1412. return that.showMsg('请选择运费模板');
  1413. }
  1414. if (!that.formData.store_name) {
  1415. return that.showMsg('请填写商品名称');
  1416. }
  1417. if (!that.formData.image) {
  1418. return that.showMsg('请填选择商品图');
  1419. }
  1420. if (!that.formData.slider_image.length) {
  1421. return that.showMsg('请填选择商品轮播图');
  1422. }
  1423. if (that.formData.spec_type == 0) {
  1424. if (!that.formData.attr.pic) {
  1425. return that.showMsg('请选择单规则图片');
  1426. }
  1427. if (that.formData.attr.price == '') {
  1428. return that.showMsg('请输入单规格价格');
  1429. }
  1430. if (that.formData.attr.ot_price == '') {
  1431. return that.showMsg('请输入单规格原价');
  1432. }
  1433. if (!that.formData.attr.stock) {
  1434. return that.showMsg('请输入单规格库存');
  1435. }
  1436. var brokerage_totle = Number(that.formData.attr.brokerage) + Number(that.formData.attr.brokerage_two);
  1437. if (brokerage_totle > that.formData.attr.price) {
  1438. return that.showMsg('一二级返佣相加不能大于商品售价');
  1439. }
  1440. var attr = {
  1441. pic:that.formData.attr.pic,
  1442. price:that.formData.attr.price,
  1443. cost:that.formData.attr.cost,
  1444. ot_price:that.formData.attr.ot_price,
  1445. stock:that.formData.attr.stock,
  1446. bar_code:that.formData.attr.bar_code,
  1447. volume:that.formData.attr.volume,
  1448. weight:that.formData.attr.weight,
  1449. brokerage:that.formData.attr.brokerage,
  1450. brokerage_two:that.formData.attr.brokerage_two,
  1451. };
  1452. that.formData.attrs = [attr];
  1453. } else {
  1454. if (!that.formData.attrs.length) {
  1455. return that.showMsg('请添加多规格属性');
  1456. }
  1457. for(var index in that.formData.attrs){
  1458. if(!that.formData.attrs[index].pic){
  1459. return that.showMsg('请选择多规格属性第'+(parseInt(index) +1)+'条的图片');
  1460. }
  1461. if(that.formData.attrs[index].price === ''){
  1462. return that.showMsg('请填写多规格属性第'+(parseInt(index) +1)+'条的价格');
  1463. }
  1464. if(that.formData.attrs[index].ot_price === ''){
  1465. return that.showMsg('请填写多规格属性第'+(parseInt(index) +1)+'条的原价');
  1466. }
  1467. if(that.formData.attrs[index].stock === ''){
  1468. return that.showMsg('请填写多规格属性第'+(parseInt(index) +1)+'条的库存');
  1469. }
  1470. var brokerage_totle = Number(that.formData.attrs[index].brokerage) + Number(that.formData.attrs[index].brokerage_two);
  1471. if (brokerage_totle > that.formData.attrs[index].price) {
  1472. return that.showMsg('第'+(parseInt(index) +1)+'条的一二级返佣相加不能大于商品售价');
  1473. }
  1474. }
  1475. }
  1476. that.formData.description = that.getContent();
  1477. $('#submit').attr('disabled', 'disabled').text('保存中...');
  1478. that.requestPost(that.U({c:'store.StoreProduct',a:'save',p:{id:that.id}}),that.formData).then(function (res) {
  1479. that.confirm();
  1480. }).catch(function (res) {
  1481. that.showMsg(res.msg);
  1482. });
  1483. },
  1484. confirm: function(){
  1485. var that = this;
  1486. layui.use(['layer'], function () {
  1487. var layer = layui.layer;
  1488. layer.confirm(that.id ? '修改成功是否返回产品列表' : '添加成功是否返回产品列表', {
  1489. btn: ['返回列表',that.id ? '继续修改' : '继续添加'] //按钮
  1490. }, function(){
  1491. location.href = that.U({c:'store.StoreProduct',a:'index'});
  1492. }, function(){
  1493. location.reload();
  1494. });
  1495. });
  1496. },
  1497. render:function(){
  1498. this.$nextTick(function(){
  1499. layui.use(['form'], function () {
  1500. layui.form.render('select');
  1501. });
  1502. })
  1503. },
  1504. // 移动
  1505. handleDragStart (e, item) {
  1506. this.dragging = item;
  1507. },
  1508. handleDragEnd (e, item) {
  1509. this.dragging = null
  1510. },
  1511. handleDragOver (e) {
  1512. e.dataTransfer.dropEffect = 'move'
  1513. },
  1514. handleDragEnter (e, item) {
  1515. e.dataTransfer.effectAllowed = 'move'
  1516. if (item === this.dragging) {
  1517. return
  1518. }
  1519. var newItems = [...this.formData.activity];
  1520. var src = newItems.indexOf(this.dragging);
  1521. var dst = newItems.indexOf(item);
  1522. newItems.splice(dst, 0, ...newItems.splice(src, 1))
  1523. this.formData.activity = newItems;
  1524. },
  1525. getRuleList:function (type) {
  1526. var that = this;
  1527. that.requestGet(that.U({c:'store.StoreProduct',a:'get_rule'})).then(function (res) {
  1528. that.$set(that,'ruleList',res.data);
  1529. if(type !== undefined){
  1530. that.render();
  1531. }
  1532. });
  1533. },
  1534. addRule:function(){
  1535. return this.createFrame('添加商品规则',this.U({c:'store.StoreProductRule',a:'create'}));
  1536. },
  1537. allRule:function () {
  1538. if (this.ruleIndex != -1) {
  1539. var rule = this.ruleList[this.ruleIndex];
  1540. if (rule) {
  1541. this.ruleBool = true;
  1542. var rule_value = rule.rule_value.map(function (item) {
  1543. return item;
  1544. });
  1545. this.$set(this.formData,'items',rule_value);
  1546. this.$set(this.formData,'attrs',[]);
  1547. this.$set(this,'formHeader',[]);
  1548. return true;
  1549. }
  1550. }
  1551. this.showMsg('选择的属性无效');
  1552. }
  1553. },
  1554. mounted: function () {
  1555. var that = this;
  1556. axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  1557. that.getProductInfo();
  1558. window.$vm = that;
  1559. window.changeIMG = that.changeIMG;
  1560. window.insertEditor = that.insertEditor;
  1561. window.insertEditorVideo = that.insertEditorVideo;
  1562. window.successFun = function(){
  1563. that.getRuleList(1);
  1564. }
  1565. $(that.$refs.filElem).change(function () {
  1566. var inputFile = this.files[0];
  1567. that.requestPost(that.U({c:"widget.video",a:'get_signature'})).then(function (res) {
  1568. AdminUpload.upload(res.data.uploadType,{
  1569. token: res.data.uploadToken || '',
  1570. file: inputFile,
  1571. accessKeyId: res.data.accessKey || '',
  1572. accessKeySecret: res.data.secretKey || '',
  1573. bucketName: res.data.storageName || '',
  1574. region: res.data.storageRegion || '',
  1575. domain: res.data.domain || '',
  1576. uploadIng:function (progress) {
  1577. that.upload.videoIng = true;
  1578. that.progress = progress;
  1579. }
  1580. }).then(function (res) {
  1581. //成功
  1582. that.$set(that.formData, 'video_link', res.url);
  1583. that.progress = 0;
  1584. that.upload.videoIng = false;
  1585. return that.showMsg('上传成功');
  1586. }).catch(function (err) {
  1587. //失败
  1588. console.info(err);
  1589. return that.showMsg('上传错误请检查您的配置');
  1590. });
  1591. }).catch(function (res) {
  1592. return that.showMsg(res.msg || '获取密钥失败,请检查您的配置');
  1593. });
  1594. })
  1595. }
  1596. });
  1597. </script>
  1598. </body>
  1599. </html>
  1600. <script>
  1601. import Layout from "../../../../../public/static/plug/iview/dist/iview";
  1602. export default {
  1603. components: {Layout}
  1604. }
  1605. </script>