3842d4cff02ed8a8fdaa7dea044f6e6b.php 102 KB

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