index.blade.php 77 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412
  1. @extends('layouts.base')
  2. @section('title', "商品列表")
  3. @section('content')
  4. <link rel="stylesheet" type="text/css" href="{{static_url('yunshop/goods/vue-goods.css')}}"/>
  5. <style>
  6. .a-btn {
  7. border-radius: 2px;
  8. padding: 8px 12px;
  9. box-sizing: border-box;
  10. color: #666;
  11. font-weight: 500;
  12. text-align: center;
  13. margin-left: 1%;
  14. background-color: #fff;
  15. }
  16. .a-btn:hover{
  17. background-color: #29BA9C;
  18. color: #FFF;
  19. border-radius: 5px;
  20. }
  21. .tabs-div {
  22. background: #fff;
  23. padding: 13px 0;
  24. margin-left: 10px;
  25. cursor: pointer;
  26. border-radius:10px;
  27. }
  28. .a-colour2 {
  29. background-color: #29BA9C;
  30. color: #FFF;
  31. border-radius: 5px;
  32. }
  33. .sort_active{
  34. color: #29BA9C;
  35. }
  36. </style>
  37. <div id="qrcode" ref="qrcode" style="display:none;"></div>
  38. <div class="rightlist">
  39. <div id="app" v-cloak v-loading="all_loading">
  40. <template>
  41. <div class="">
  42. <div class="third-list">
  43. <div class="tabs-div">
  44. <span :class="tab_state == 1? 'a-btn a-colour2':'a-btn'" size="small" type="text" @click="stateList(1)">
  45. 上架中([[statistics.put_shelf]])
  46. </span>
  47. <span :class="tab_state == 0? 'a-btn a-colour2':'a-btn'" size="small" type="text" @click="stateList(0)">
  48. 仓库中([[statistics.lower_shelf]])
  49. </span>
  50. <span :class="tab_state == 'all'? 'a-btn a-colour2':'a-btn'" size="small" type="text" @click="stateList('all')">
  51. 全部商品([[statistics.all_goods]])
  52. </span>
  53. </div>
  54. <div class="form-list">
  55. <el-form :inline="true" :model="search_form" ref="search_form" style="margin-left:10px;">
  56. <el-row>
  57. {{--<el-form-item label="" prop="">--}}
  58. {{--<el-select v-model="search_form.status" placeholder="请选择商品状态" clearable>--}}
  59. {{--<el-option v-for="item in status_list" :key="item.id" :label="item.name"--}}
  60. {{--:value="item.id"></el-option>--}}
  61. {{--</el-select>--}}
  62. {{--</el-form-item>--}}
  63. <el-form-item label="" prop="">
  64. <el-select v-model="search_form.sell_stock" placeholder="请选择售中库存" clearable>
  65. <el-option v-for="item in sell_stock_list" :key="item.id" :label="item.name"
  66. :value="item.id"></el-option>
  67. </el-select>
  68. </el-form-item>
  69. <el-form-item>
  70. <el-select v-model="search_form.id_v1" placeholder="请选择一级分类" clearable
  71. @change="changeV1()">
  72. <el-option v-for="item in category_list" :key="item.id" :label="item.name"
  73. :value="item.id"></el-option>
  74. </el-select>
  75. </el-form-item>
  76. <el-form-item>
  77. <el-select v-model="search_form.id_v2" placeholder="请选择二级分类" clearable
  78. @change="changeV2()">
  79. <el-option v-for="item in category_list_v2" :key="item.id"
  80. :label="item.name" :value="item.id"></el-option>
  81. </el-select>
  82. </el-form-item>
  83. <el-form-item>
  84. <el-select v-model="search_form.id_v3" placeholder="请选择三级分类" clearable
  85. v-if="catlevel==3">
  86. <el-option v-for="item in category_list_v3" :key="item.id"
  87. :label="item.name" :value="item.id"></el-option>
  88. </el-select>
  89. </el-form-item>
  90. <el-form-item label="" prop="">
  91. <el-select v-model="search_form.brand_id" placeholder="请选择品牌" clearable remote filterable :remote-method="getBrandData">
  92. <el-option v-for="item in brands_list" :key="item.id" :label="item.name"
  93. :value="item.id"></el-option>
  94. </el-select>
  95. </el-form-item>
  96. <el-form-item label="" prop="keyword">
  97. <el-input v-model="search_form.keyword" placeholder="请输入商品ID或关键字"></el-input>
  98. </el-form-item>
  99. <el-form-item label="" prop="keyword">
  100. <el-input v-model="search_form.filtering_name" placeholder="请输入商品标签"></el-input>
  101. </el-form-item>
  102. <el-form-item label="" prop="">
  103. <el-select v-model="search_form.is_spec" placeholder="请选择商品是否多规格" clearable>
  104. <el-option v-for="item in spec_list" :key="item.id" :label="item.name"
  105. :value="item.id"></el-option>
  106. </el-select>
  107. </el-form-item>
  108. <el-form-item>
  109. <el-select v-model="search_form.is_hide" placeholder="请选择商品是否显示" clearable>
  110. <el-option label="显示" value="1"></el-option>
  111. <el-option label="隐藏" value="2"></el-option>
  112. </el-select>
  113. </el-form-item>
  114. <el-form-item>
  115. <el-select v-model="search_form.source_id" placeholder="请选择商品来源" clearable v-if="is_source_open==1">
  116. <el-option v-for="item in source_list" :key="item.id" :label="item.source_name" :value="item.id"></el-option>
  117. </el-select>
  118. </el-form-item>
  119. <el-form-item label="价格区间" prop="">
  120. <el-input v-model="search_form.min_price" placeholder="最低价"
  121. style="width:150px;"></el-input>
  122. <el-input v-model="search_form.max_price" placeholder="最高价"
  123. style="width:150px;"></el-input>
  124. </el-form-item>
  125. <el-form-item label="商品类型" prop="leader_name">
  126. <el-checkbox v-model.number="search_form.is_new" :true-label="1"
  127. :false-label="0">新品
  128. </el-checkbox>
  129. <el-checkbox v-model.number="search_form.is_hot" :true-label="1"
  130. :false-label="0">热卖
  131. </el-checkbox>
  132. <el-checkbox v-model.number="search_form.is_recommand" :true-label="1"
  133. :false-label="0">推荐
  134. </el-checkbox>
  135. <el-checkbox v-model.number="search_form.is_discount" :true-label="1"
  136. :false-label="0">促销
  137. </el-checkbox>
  138. </el-form-item>
  139. {{--<el-form-item label="是否多规格" prop="is_spec">--}}
  140. {{--<el-radio v-model="search_form.is_spec" label="1">是</el-radio>--}}
  141. {{--<el-radio v-model="search_form.is_spec" label="0">否</el-radio>--}}
  142. {{--</el-form-item>--}}
  143. <a href="#">
  144. <el-button type="primary" icon="el-icon-search" @click="search(1)">搜索
  145. </el-button>
  146. </a>
  147. </el-col>
  148. </el-row>
  149. </el-form>
  150. </div>
  151. <div class="table-list">
  152. <div style="margin-left:10px;">
  153. <el-checkbox v-model.number="is_all_choose" :true-label="1" :false-label="0"
  154. @change="allChoose">[[is_all_choose==1?'全不选':'全选']]
  155. </el-checkbox>
  156. <el-button size="small" @click="batchPutAway(1)">批量上架</el-button>
  157. <el-button size="small" @click="batchPutAway(0)">批量下架</el-button>
  158. <el-button size="small" @click="batchDestroy">批量删除</el-button>
  159. <el-button size="small" @click="openCategory">批量修改分类</el-button>
  160. <el-button size="small" @click="openService">批量编辑服务提供</el-button>
  161. </div>
  162. <div>
  163. <template>
  164. <!-- 表格start -->
  165. <el-table :data="goods_list" style="width: 100%"
  166. :class="table_loading==true?'loading-height':''"
  167. v-loading="table_loading">
  168. <el-table-column prop="id" label="选择" width="60" align="center">
  169. <template slot-scope="scope">
  170. <el-checkbox v-model.number="scope.row.is_choose" :true-label="1"
  171. :false-label="0"
  172. @change="oneChange(scope.row)"></el-checkbox>
  173. </template>
  174. </el-table-column>
  175. <el-table-column prop="id" label="ID" width="70"
  176. align="center"></el-table-column>
  177. </el-table-column>
  178. <el-table-column prop="member_name" label="排序" max-width="80" align="center">
  179. <template slot-scope="scope">
  180. <el-popover class="item" placement="top" effect="light">
  181. <div style="text-align:center;">
  182. <el-input v-model="change_sort" size="small"
  183. style="width:100px;"></el-input>
  184. <el-button size="small"
  185. @click="confirmChangeSort(scope.row.id)">确定
  186. </el-button>
  187. </div>
  188. <a slot="reference">
  189. <i class="el-icon-edit edit-i" title="点击编辑排序"
  190. @click="editTitle(scope.$index,'sort')"></i>
  191. </a>
  192. </el-popover>
  193. [[scope.row.display_order]]
  194. </template>
  195. </el-table-column>
  196. <el-table-column prop="total" label="商品" width="60" align="center">
  197. <template slot-scope="scope">
  198. <img :src="scope.row.thumb" style="width:50px;height:50px;">
  199. </template>
  200. </el-table-column>
  201. <el-table-column prop="down_time" label="" min-width="180" align="left"
  202. class="edit-cell">
  203. <template slot-scope="scope">
  204. <el-popover class="item" placement="top" effect="light">
  205. <div style="text-align:center;">
  206. <div style="text-align:left;margin-bottom:10px;font-weight:900">
  207. 修改商品标题
  208. </div>
  209. <el-input v-model="change_title" style="width:400px"
  210. size="small"></el-input>
  211. <el-button size="small"
  212. @click="confirmChange(scope.row.id,'title')">确定
  213. </el-button>
  214. </div>
  215. <a slot="reference">
  216. <i class="el-icon-edit edit-i" title="点击编辑"
  217. @click="editTitle(scope.$index,'title')"></i>
  218. </a>
  219. </el-popover>
  220. [[scope.row.title]]
  221. </template>
  222. </el-table-column>
  223. <el-table-column prop="cost_price" label="成本价" max-width="80" align="center">
  224. <template slot="header" slot-scope="scope">
  225. <div style="display: flex;align-items: center;justify-content:center">
  226. <span>成本价</span>
  227. <div style="display: flex;flex-direction: column;margin-left: 5px;">
  228. <i class="el-icon-caret-top" :class="sort_cost_price == 'asc' ? 'sort_active' : '' " @click="btnPositiveSequence('cost_price')" ></i>
  229. <i class="el-icon-caret-bottom" :class="sort_cost_price == 'desc' ? 'sort_active' : '' " @click="btnReverseOrder('cost_price')"></i>
  230. </div>
  231. </div>
  232. </template>
  233. <template slot-scope="scope">
  234. <el-popover class="item" placement="top" effect="light"
  235. :disabled="scope.row.has_option==1">
  236. <div style="text-align:center;">
  237. <el-input v-model="change_cost_price" size="small"
  238. style="width:100px;"></el-input>
  239. <el-button size="small"
  240. @click="confirmChange(scope.row.id,'cost_price')">确定
  241. </el-button>
  242. </div>
  243. <a slot="reference">
  244. <i class="el-icon-edit edit-i"
  245. :title="scope.row.has_option==1?'多规格不支持快速修改':'点击编辑'"
  246. @click="editTitle(scope.$index,'cost_price')"></i>
  247. </a>
  248. </el-popover>
  249. ¥[[scope.row.cost_price]]
  250. </template>
  251. </el-table-column>
  252. <el-table-column prop="member_num" label="价格" max-width="80" align="center">
  253. <template slot="header" slot-scope="scope">
  254. <div style="display: flex;align-items: center;justify-content:center">
  255. <span>价格</span>
  256. <div style="display: flex;flex-direction: column;margin-left: 5px;">
  257. <i class="el-icon-caret-top" :class="sort_price == 'asc' ? 'sort_active' : '' " @click="btnPositiveSequence('price')" ></i>
  258. <i class="el-icon-caret-bottom" :class="sort_price == 'desc' ? 'sort_active' : '' " @click="btnReverseOrder('price')"></i>
  259. </div>
  260. </div>
  261. </template>
  262. <template slot-scope="scope">
  263. <el-popover class="item" placement="top" effect="light"
  264. :disabled="scope.row.has_option==1">
  265. <div style="text-align:center;">
  266. <el-input v-model="change_price" size="small"
  267. style="width:100px;"></el-input>
  268. <el-button size="small"
  269. @click="confirmChange(scope.row.id,'price')">确定
  270. </el-button>
  271. </div>
  272. <a slot="reference">
  273. <i class="el-icon-edit edit-i"
  274. :title="scope.row.has_option==1?'多规格不支持快速修改':'点击编辑'"
  275. @click="editTitle(scope.$index,'price')"></i>
  276. </a>
  277. </el-popover>
  278. ¥[[scope.row.price]]
  279. </template>
  280. </el-table-column>
  281. <el-table-column label="成本利润率" prop="cost_ratio" align="center">
  282. <template slot-scope="scope">
  283. [[scope.row.cost_ratio]]
  284. </template>
  285. </el-table-column>
  286. <el-table-column label="库存" align="center" max-width="80">
  287. <template slot="header" slot-scope="scope">
  288. <div style="display: flex;align-items: center;justify-content:center">
  289. <span>库存</span>
  290. <div style="display: flex;flex-direction: column;margin-left: 5px;">
  291. <i class="el-icon-caret-top" :class="sort_stock == 'asc' ? 'sort_active' : '' " @click="btnPositiveSequence('stock')" ></i>
  292. <i class="el-icon-caret-bottom" :class="sort_stock == 'desc' ? 'sort_active' : '' " @click="btnReverseOrder('stock')"></i>
  293. </div>
  294. </div>
  295. </template>
  296. <template slot-scope="scope">
  297. <el-popover class="item" placement="top" effect="light"
  298. :disabled="scope.row.has_option==1">
  299. <div style="text-align:center;">
  300. <el-input v-model="change_stock" size="small"
  301. style="width:100px;"></el-input>
  302. <el-button size="small"
  303. @click="confirmChange(scope.row.id,'stock')">确定
  304. </el-button>
  305. </div>
  306. <a slot="reference">
  307. <i class="el-icon-edit edit-i"
  308. :title="scope.row.has_option==1?'多规格不支持快速修改':'点击编辑'"
  309. @click="editTitle(scope.$index,'stock')"></i>
  310. </a>
  311. </el-popover>
  312. [[scope.row.stock]]
  313. </template>
  314. </el-table-column>
  315. <el-table-column prop="real_sales" label="销量" max-width="80" align="center">
  316. <template slot="header" slot-scope="scope">
  317. <div style="display: flex;align-items: center;justify-content:center">
  318. <span>销量</span>
  319. <div style="display: flex;flex-direction: column;margin-left: 5px;">
  320. <i class="el-icon-caret-top" :class="sort_sales == 'asc' ? 'sort_active' : '' " @click="btnPositiveSequence('sales')" ></i>
  321. <i class="el-icon-caret-bottom" :class="sort_sales == 'desc' ? 'sort_active' : '' " @click="btnReverseOrder('sales')"></i>
  322. </div>
  323. </div>
  324. </template>
  325. </el-table-column>
  326. <el-table-column label="状态" prop="status_message" align="center">
  327. <template slot-scope="scope">
  328. [[scope.row.status?'上架':'下架']]
  329. <el-switch v-model="scope.row.status" :active-value="1"
  330. :inactive-value="0"
  331. @change="putAway(scope.row.id,scope.$index)"></el-switch>
  332. </template>
  333. </el-table-column>
  334. <el-table-column label="操作" width="320" align="center">
  335. <template slot-scope="scope">
  336. <div class="table-option">
  337. <el-popover class="item" placement="left" effect="light"
  338. trigger="hover">
  339. <div style="text-align:center;">
  340. <img :src="smallImg" alt=""
  341. style="margin:10px;width:100px;height:100px;">
  342. </div>
  343. <a slot="reference" @mouseover="SmallCode(scope.$index)" :href="'{{ yzWebFullUrl('goods.goods.generate-small-code', array('id' => '')) }}'+[[scope.row.id]]">小程序</a>
  344. </el-popover>&nbsp;&nbsp;
  345. <el-popover class="item" placement="left" effect="light"
  346. trigger="hover">
  347. <div style="text-align:center;">
  348. <img :src="img" alt=""
  349. style="margin:10px;width:120px;height:120px;">
  350. </div>
  351. <a slot="reference" @mouseover="listCode(scope.$index)">推广链接</a>
  352. </el-popover>&nbsp;&nbsp;
  353. <a @click="copyGoods(scope.row.id)">
  354. 复制商品
  355. </a>
  356. &nbsp;&nbsp;
  357. <a @click="editGoods(scope.row.id)">
  358. 编辑
  359. </a>&nbsp;&nbsp;
  360. <a @click="delOne(scope.row.id)">
  361. 删除
  362. </a>&nbsp;&nbsp;
  363. <a @click="copyList(scope.row.id)">
  364. 复制链接
  365. </a>
  366. <div>
  367. <input v-model="scope.row.link" :ref="'list'+scope.row.id"
  368. style="position:absolute;opacity:0;height:1px;"/>
  369. </div>
  370. </div>
  371. <div>
  372. <el-checkbox border size="mini" v-model.number="scope.row.is_new"
  373. :true-label="1" :false-label="0"
  374. @change="setProperty(scope.row.id,scope.$index,'is_new')">
  375. 新品
  376. </el-checkbox>
  377. <el-checkbox border size="mini" v-model.number="scope.row.is_hot"
  378. :true-label="1" :false-label="0"
  379. @change="setProperty(scope.row.id,scope.$index,'is_hot')">
  380. 热卖
  381. </el-checkbox>
  382. <el-checkbox border size="mini"
  383. v-model.number="scope.row.is_recommand" :true-label="1"
  384. :false-label="0"
  385. @change="setProperty(scope.row.id,scope.$index,'is_recommand')">
  386. 推荐
  387. </el-checkbox>
  388. <el-checkbox border size="mini"
  389. v-model.number="scope.row.is_discount" :true-label="1"
  390. :false-label="0"
  391. @change="setProperty(scope.row.id,scope.$index,'is_discount')">
  392. 促销
  393. </el-checkbox>
  394. </div>
  395. </template>
  396. </el-table-column>
  397. </el-table>
  398. <!-- 表格end -->
  399. </template>
  400. </div>
  401. </div>
  402. </div>
  403. <el-dialog :visible.sync="category_show" width="60%" center title="选择分类">
  404. <div style="height:500px">
  405. <el-select v-model="batch_v1" placeholder="请选择一级分类" clearable @change="batchChangeV1($event)" :style="{width:catlevel==3?'33%':'48%'}">
  406. <el-option v-for="(item,index) in batch_category" :key="item.id" :label="item.name" :value="item.id"></el-option>
  407. </el-select>
  408. <el-select v-model="batch_v2" placeholder="请选择二级分类" clearable @change="batchChangeV2($event)" :style="{width:catlevel==3?'33%':'48%'}">
  409. <el-option v-for="item in batch_category_v2" :key="item.id" :label="item.name" :value="item.id"></el-option>
  410. </el-select>
  411. <el-select v-model="batch_v3" placeholder="请选择三级分类" clearable v-if="catlevel==3" style="width:33%">
  412. <el-option v-for="item in batch_category_v3" :key="item.id" :label="item.name" :value="item.id"></el-option>
  413. </el-select>
  414. </div>
  415. <span slot="footer" class="dialog-footer">
  416. <el-button @click="category_show = false">取 消</el-button>
  417. <el-button type="primary" @click="batchCategory">确 定 </el-button>
  418. </span>
  419. </el-dialog>
  420. <el-dialog title="服务提供" :visible.sync="service_show" center width="730px">
  421. <div style="overflow:auto">
  422. <el-form ref="service_form" style="width: 100%;height:auto;overflow:auto">
  423. <el-form-item label="是否自动上下架">
  424. <el-radio v-model="service_form.is_automatic" :label="1">是</el-radio>
  425. <el-radio v-model="service_form.is_automatic" :label="0">否</el-radio>
  426. </el-form-item>
  427. <el-form-item label="时间方式">
  428. <el-radio v-model="service_form.time_type" :label="0">固定</el-radio>
  429. <el-radio v-model="service_form.time_type" :label="1">循环</el-radio>
  430. <span style="display: flex">
  431. <span class="tip" style="margin-right: 20px">固定:在设置的时间商品自动上下架时间</span>
  432. <span class="tip">循环:在循环日期内商品每天在设置的时间点自动循环上下架</span>
  433. </span>
  434. </el-form-item>
  435. <el-form-item label="上下架时间" v-if="service_form.time_type==0">
  436. <el-date-picker
  437. v-model="service_form.shelves_time"
  438. type="datetimerange"
  439. value-format="timestamp"
  440. align="right"
  441. unlink-panels
  442. range-separator="至"
  443. start-placeholder="开始日期"
  444. end-placeholder="结束日期"
  445. :picker-options="pickerOptions">
  446. </el-date-picker>
  447. </el-form-item>
  448. <el-form-item label="循环日期" v-if="service_form.time_type==1">
  449. <el-date-picker
  450. v-model="service_form.loop_date"
  451. type="daterange"
  452. value-format="timestamp"
  453. align="right"
  454. unlink-panels
  455. range-separator="至"
  456. start-placeholder="开始日期"
  457. end-placeholder="结束日期"
  458. :picker-options="pickerOptions"
  459. >
  460. </el-date-picker>
  461. </el-form-item>
  462. <el-form-item label="上架时间" v-if="service_form.time_type==1">
  463. <el-time-select
  464. v-model="service_form.loop_time_up"
  465. value-format="timestamp"
  466. :picker-options="{
  467. start: '00:00',
  468. step: '00:05',
  469. end: '24:00'
  470. }"
  471. placeholder="选择时间">
  472. </el-time-select>
  473. <span style="margin-left: 15px;margin-right: 8px">下架时间</span>
  474. <el-time-select
  475. v-model="service_form.loop_time_down"
  476. value-format="timestamp"
  477. :picker-options="{
  478. start: '00:00',
  479. step: '00:05',
  480. end: '24:00',
  481. minTime: service_form.loop_time_up
  482. }"
  483. placeholder="选择时间">
  484. </el-time-select>
  485. </el-form-item>
  486. <el-form-item label="库存自动刷新" v-if="service_form.time_type==1">
  487. <el-switch v-model="service_form.auth_refresh_stock" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0"></el-switch>
  488. <div class="tip">开启后,循环日期期间,每日重新上架时,库存商品数自动刷新为原始库存数</div>
  489. </el-form-item>
  490. <el-form-item label="原始库存" v-if="service_form.time_type==1">
  491. <el-input v-model="service_form.original_stock" style="width:30%;"></el-input>
  492. </el-form-item>
  493. <span style="">
  494. <el-button type="primary" @click="serviceSubmit">确 认</el-button>
  495. <el-button @click="closeService">取 消</el-button>
  496. </span>
  497. </el-form>
  498. </div>
  499. </el-dialog>
  500. <!-- 分页 -->
  501. <div class="vue-page" v-show="total>1">
  502. <el-row>
  503. <el-col align="right">
  504. <el-pagination
  505. background
  506. v-loading="loading"
  507. @size-change="setPageSize"
  508. @current-change="search"
  509. layout="total, sizes, prev, pager, next, jumper"
  510. :current-page="current_page"
  511. :page-sizes="[20, 50, 100, 200]"
  512. :page-size="per_size"
  513. :total="total">
  514. </el-pagination>
  515. {{--<el-pagination layout="prev, pager, next,jumper" @current-change="search" :total="total"--}}
  516. {{--:page-size="per_size" :current-page="current_page" background--}}
  517. {{--v-loading="loading"></el-pagination>--}}
  518. </el-col>
  519. </el-row>
  520. </div>
  521. </div>
  522. </template>
  523. </div>
  524. </div>
  525. <script src="{{resource_get('static/js/qrcode.min.js')}}"></script>
  526. <script>
  527. var app = new Vue({
  528. el: "#app",
  529. delimiters: ['[[', ']]'],
  530. data() {
  531. return {
  532. edit_url: '{!! yzWebFullUrl('goods.goods.edit') !!}',//商品编辑链接
  533. delete_url: '{!! yzWebFullUrl('goods.goods.destroy') !!}',//商品删除链接
  534. copy_url: '{!! yzWebFullUrl('goods.goods.copy') !!}', //商品复制链接
  535. sort_url: '{!! yzWebFullUrl('goods.goods.displayorder') !!}', //商品排序链接
  536. id: "",
  537. img: "",//二维码
  538. smallImg:"",//小程序二维码
  539. catlevel: 0,//是否显示三级分类
  540. is_all_choose: 0,//是否全选
  541. goods_list: [],//商品列表
  542. change_title: "",//修改标题弹框赋值
  543. change_price: "",//修改价格弹框赋值
  544. change_cost_price: "",//修改成本价弹框赋值
  545. change_stock: "",//修改库存弹框赋值
  546. change_sort: "",//修改排序弹框赋值
  547. all_loading: false,
  548. status_list: [
  549. {id: '', name: '全部状态'},
  550. {id: 0, name: '下架'},
  551. {id: 1, name: '上架'},
  552. ],
  553. sell_stock_list: [
  554. {id: '', name: '全部'},
  555. {id: 0, name: '售罄'},
  556. {id: 1, name: '出售中'},
  557. ],
  558. spec_list: [
  559. {id: '', name: '全部'},
  560. {id: 0, name: '否'},
  561. {id: 1, name: '是'},
  562. ],
  563. brands_list: [],//品牌名称
  564. category_list: [],
  565. category_list_v2: [],
  566. category_list_v3: [],
  567. search_form: {
  568. id_v1: '',
  569. id_v2: '',
  570. id_v3: '',
  571. sort:'',
  572. filtering_name:'',
  573. },
  574. form: {},
  575. level_list: [],
  576. //批量修改分类
  577. batch_category:[],
  578. batch_category_v2:[],
  579. batch_category_v3:[],
  580. batch_v1:'',
  581. batch_v2:'',
  582. batch_v3:'',
  583. category_show:false,
  584. service_show:false,
  585. loading: false,
  586. table_loading: false,
  587. //服务提供
  588. service_form:{
  589. is_automatic: 0,
  590. time_type: 1,
  591. auth_refresh_stock: 1,
  592. shelves_time:[],
  593. loop_date:[],
  594. },
  595. //商品来源
  596. source_list: [],
  597. is_source_open: 0,
  598. pickerOptions: {
  599. shortcuts: [{
  600. text: "最近一周",
  601. onClick(picker) {
  602. const end = new Date();
  603. const start = new Date();
  604. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  605. picker.$emit("pick", [start, end]);
  606. }
  607. }, {
  608. text: "最近一个月",
  609. onClick(picker) {
  610. const end = new Date();
  611. const start = new Date();
  612. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  613. picker.$emit("pick", [start, end]);
  614. }
  615. }, {
  616. text: "最近三个月",
  617. onClick(picker) {
  618. const end = new Date();
  619. const start = new Date();
  620. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  621. picker.$emit("pick", [start, end]);
  622. }
  623. }]
  624. },
  625. //
  626. producer_id: 0, //什么厂家搜索的
  627. //分页
  628. total: 0,
  629. per_size: 0,
  630. current_page: 0,
  631. this_page:0,
  632. rules: {},
  633. tab_state:1,//选项卡
  634. statistics: {
  635. 'lower_shelf':0,
  636. 'put_shelf': 0,
  637. 'all_goods': 0,
  638. },
  639. sort_price:"",
  640. sort_stock:"",
  641. sort_sales:"",
  642. sort_cost_price:""
  643. }
  644. },
  645. created() {
  646. //this.getData();
  647. let that = this;
  648. document.onkeydown = function(){
  649. if(window.event.keyCode == 13)
  650. that.search(1);
  651. }
  652. },
  653. mounted() {
  654. let data = {!! $data !!};
  655. let producer_id = JSON.parse('{!! $producerId !!}');
  656. if (producer_id) {
  657. this.producer_id = producer_id;
  658. }
  659. this.setData(data);
  660. console.log(data)
  661. },
  662. methods: {
  663. btnPositiveSequence(val){
  664. switch (val) {
  665. case 'price'://价格
  666. this.sort_price = this.sort_price == 'asc'? '' : 'asc';
  667. break;
  668. case 'stock': //库存
  669. this.sort_stock = this.sort_stock == 'asc'? '' : 'asc';
  670. break;
  671. case 'sales': //销量
  672. this.sort_sales = this.sort_sales == 'asc'? '' : 'asc';
  673. break;
  674. case 'cost_price'://成本价
  675. this.sort_cost_price = this.sort_cost_price == 'asc'? '' : 'asc';
  676. break;
  677. default:
  678. break;
  679. }
  680. this.search(1);
  681. },
  682. btnReverseOrder(val){
  683. switch (val) {
  684. case 'price'://价格
  685. this.sort_price = this.sort_price == 'desc'? '' : 'desc';
  686. break;
  687. case 'stock': //库存
  688. this.sort_stock = this.sort_stock == 'desc'? '' : 'desc';
  689. break;
  690. case 'sales': //销量
  691. this.sort_sales = this.sort_sales == 'desc'? '' : 'desc';
  692. break;
  693. case 'cost_price': //成本价
  694. this.sort_cost_price = this.sort_cost_price == 'desc'? '' : 'desc';
  695. break;
  696. default:
  697. break;
  698. }
  699. this.search(1);
  700. },
  701. stateList(value) {
  702. this.tab_state = value;
  703. this.search(1);
  704. },
  705. //设置每页条数
  706. setPageSize(val) {
  707. let refresh = val !== this.per_size;
  708. this.per_size = val;
  709. if (refresh) {
  710. this.search(1);
  711. }
  712. },
  713. setData(data) {
  714. this.goods_list = data.list.data;
  715. let arr = [];
  716. this.goods_list.forEach((item, index) => {
  717. item.title = this.escapeHTML(item.title)
  718. arr.push(Object.assign({}, item, {is_choose: 0}))//是否选中
  719. });
  720. this.goods_list = arr;
  721. this.total = data.list.total;
  722. this.current_page = data.list.current_page;
  723. this.per_size = data.list.per_page;
  724. this.category_list = data.category;
  725. this.catlevel = data.cat_level;
  726. this.source_list = data.source_list;
  727. this.is_source_open = data.is_source_open;
  728. if (data.edit_url) {
  729. this.edit_url = data.edit_url;
  730. }
  731. if (data.delete_url) {
  732. this.delete_url = data.delete_url;
  733. }
  734. if (data.sort_url) {
  735. this.sort_url = data.sort_url;
  736. }
  737. if (data.copy_url) {
  738. this.copy_url = data.copy_url;
  739. }
  740. if (data.lower_shelf) {
  741. this.statistics.lower_shelf = data.lower_shelf;
  742. }
  743. if (data.put_shelf) {
  744. this.statistics.put_shelf = data.put_shelf;
  745. }
  746. if (data.all_goods) {
  747. this.statistics.all_goods = data.all_goods;
  748. }
  749. },
  750. getData() {
  751. var that = this;
  752. that.table_loading = true;
  753. that.$http.post("{!! yzWebFullUrl('goods.goods.goods-list') !!}").then(response => {
  754. //console.log(response);
  755. if (response.data.result == 1) {
  756. this.setData(response.data.data);
  757. } else {
  758. that.$message.error(response.data.msg);
  759. }
  760. that.table_loading = false;
  761. }), function (res) {
  762. //console.log(res);
  763. that.table_loading = false;
  764. };
  765. },
  766. // 一级分类改变
  767. changeV1() {
  768. let that = this;
  769. this.search_form.id_v2 = "";
  770. this.search_form.id_v3 = "";
  771. this.category_list_v2 = [];
  772. this.category_list_v3 = [];
  773. that.$http.post("{!! yzWebFullUrl('goods.category.get-categorys-json') !!}",{level:2,parent_id:this.search_form.id_v1}).then(response => {
  774. if (response.data.result == 1) {
  775. this.category_list_v2 = response.data.data;
  776. } else {
  777. that.$message.error(response.data.msg);
  778. }
  779. }), function (res) {
  780. //console.log(res);
  781. };
  782. this.category_list.find(item => {
  783. if (item.id == this.search_form.id_v1) {
  784. this.category_list_v2 = item.childrens;
  785. }
  786. });
  787. },
  788. // 二级分类改变
  789. changeV2() {
  790. let that = this;
  791. this.search_form.id_v3 = "";
  792. this.category_list_v3 = [];
  793. if (this.catlevel == 3) {
  794. that.$http.post("{!! yzWebFullUrl('goods.category.get-categorys-json') !!}",{level:3,parent_id:this.search_form.id_v2}).then(response => {
  795. if (response.data.result == 1) {
  796. this.category_list_v3 = response.data.data;
  797. } else {
  798. that.$message.error(response.data.msg);
  799. }
  800. }), function (res) {
  801. //console.log(res);
  802. };
  803. }
  804. },
  805. getBrandData(keyword) {
  806. if(keyword=="") {
  807. return;
  808. }
  809. let that = this;
  810. that.$http.post("{!! yzWebFullUrl('goods.brand.search-brand') !!}",{keyword:keyword}).then(response => {
  811. if (response.data.result == 1) {
  812. this.brands_list = response.data.data;
  813. } else {
  814. that.$message.error(response.data.msg);
  815. }
  816. }), function (res) {
  817. //console.log(res);
  818. };
  819. },
  820. // 搜索、分页
  821. search(page) {
  822. this.this_page = page;
  823. var that = this;
  824. console.log(that.search_form)
  825. // 商品类型
  826. let product_attr = [];
  827. if (that.search_form.is_new == 1) {
  828. product_attr.push('is_new')
  829. }
  830. if (that.search_form.is_hot == 1) {
  831. product_attr.push('is_hot')
  832. }
  833. if (that.search_form.is_recommand == 1) {
  834. product_attr.push('is_recommand')
  835. }
  836. if (that.search_form.is_discount == 1) {
  837. product_attr.push('is_discount')
  838. }
  839. let order_by = {};
  840. if (this.sort_price) {
  841. order_by.price = this.sort_price;
  842. }
  843. if (this.sort_stock) {
  844. order_by.stock = this.sort_stock;
  845. }
  846. if (this.sort_sales) {
  847. order_by.real_sales = this.sort_sales;
  848. }
  849. if (this.sort_cost_price) {
  850. order_by.cost_price = this.sort_cost_price;
  851. }
  852. let json = {
  853. page: page,
  854. tab_state:that.tab_state != 'all'?that.tab_state:'',
  855. order_by:order_by,
  856. per_size:that.per_size,
  857. producer_id:that.producer_id,
  858. search: {
  859. keyword: that.search_form.keyword,
  860. status: that.search_form.status,
  861. sell_stock: that.search_form.sell_stock,
  862. brand_id: that.search_form.brand_id,
  863. min_price: that.search_form.min_price,
  864. max_price: that.search_form.max_price,
  865. product_attr: product_attr,//商品类型
  866. is_spec: that.search_form.is_spec,
  867. is_hide: that.search_form.is_hide,
  868. filtering_name:that.search_form.filtering_name,
  869. source_id:that.search_form.source_id,
  870. },
  871. category: {
  872. parentid: that.search_form.id_v1,
  873. childid: that.search_form.id_v2,
  874. thirdid: that.search_form.id_v3,
  875. }
  876. };
  877. that.table_loading = true;
  878. that.$http.post("{!! yzWebFullUrl('goods.goods.goods-search') !!}", json).then(response => {
  879. console.log(response);
  880. if (response.data.result == 1) {
  881. let arr = [];
  882. that.goods_list = response.data.data.data;
  883. that.goods_list.forEach((item, index) => {
  884. item.title = that.escapeHTML(item.title)
  885. arr.push(Object.assign({}, item, {is_choose: 0}))//是否选中
  886. });
  887. that.goods_list = arr;
  888. that.total = response.data.data.total;
  889. that.current_page = response.data.data.current_page;
  890. that.per_size = response.data.data.per_page;
  891. } else {
  892. that.$message.error(response.data.msg);
  893. }
  894. that.table_loading = false;
  895. }), function (res) {
  896. console.log(res);
  897. that.table_loading = false;
  898. };
  899. },
  900. qrcodeScan(url) {//生成二维码
  901. let qrcode = new QRCode('qrcode', {
  902. width: 100, // 二维码宽度
  903. height: 100, // 二维码高度
  904. render: 'image',
  905. text: url
  906. });
  907. var data = $("canvas")[$("canvas").length - 1].toDataURL().replace("image/png", "image/octet-stream;");
  908. console.log(data)
  909. this.img = data;
  910. },
  911. // 活动二维码
  912. listCode(index) {
  913. this.qrcodeScan(this.goods_list[index].link);
  914. },
  915. // 小程序二维码
  916. SmallCode(index) {
  917. this.smallImg = this.goods_list[index].small_link;
  918. },
  919. // 复制活动链接
  920. copyList(index) {
  921. that = this;
  922. let Url = that.$refs['list' + index];
  923. console.log(Url)
  924. Url.select(); // 选择对象
  925. document.execCommand("Copy", false);
  926. that.$message({message: "复制成功!", type: "success"});
  927. },
  928. editGoods(id) {
  929. let link = this.edit_url +`&id=`+id;
  930. window.open(link)
  931. },
  932. copyGoods(id) {
  933. let link = this.copy_url +`&id=`+id;
  934. window.location.href = link;
  935. },
  936. // 单个选择
  937. oneChange(item) {
  938. let that = this;
  939. let is_all = 0;
  940. that.goods_list.some((item, index) => {
  941. if (item.is_choose == 1) {
  942. is_all = 1;
  943. } else {
  944. is_all = 0;
  945. return true;
  946. }
  947. })
  948. that.is_all_choose = is_all;
  949. },
  950. // 全选
  951. allChoose() {
  952. let that = this;
  953. let status = 0;
  954. if (that.is_all_choose == 1) {
  955. status = 1;
  956. } else {
  957. status = 0;
  958. }
  959. that.goods_list.forEach((item, index) => {
  960. item.is_choose = status;
  961. })
  962. },
  963. // 上架、下架
  964. putAway(id, index) {
  965. var that = this;
  966. that.table_loading = true;
  967. let data = that.goods_list[index].status;
  968. let json = {id: id, type: 'status', data: data};
  969. that.$http.post("{!! yzWebFullUrl('goods.goods.setPutaway') !!}", json).then(response => {
  970. console.log(response);
  971. if (response.data.result == 1) {
  972. that.$message.success('操作成功!');
  973. } else {
  974. that.$message.error(response.data.msg);
  975. that.goods_list[index].is_choose == 1 ? 0 : 1;
  976. }
  977. that.table_loading = false;
  978. }), function (res) {
  979. console.log(res);
  980. that.table_loading = false;
  981. };
  982. },
  983. // 批量上架、下架
  984. batchPutAway(data) {
  985. var that = this;
  986. that.table_loading = true;
  987. let ids = [];
  988. that.goods_list.forEach((item, index) => {
  989. if (item.is_choose == 1) {
  990. ids.push(item.id);
  991. }
  992. })
  993. let json = {data: data, ids: ids}
  994. that.$http.post("{!! yzWebFullUrl('goods.goods.batchSetProperty') !!}", json).then(response => {
  995. console.log(response);
  996. if (response.data.result == 1) {
  997. that.$message.success('操作成功!');
  998. that.is_all_choose = 0;
  999. that.search(1);
  1000. } else {
  1001. that.$message.error(response.data.msg);
  1002. }
  1003. that.table_loading = false;
  1004. }), function (res) {
  1005. console.log(res);
  1006. that.table_loading = false;
  1007. };
  1008. },
  1009. // 单个删除
  1010. delOne(id) {
  1011. var that = this;
  1012. that.$confirm('确定删除吗', '提示', {
  1013. confirmButtonText: '确定',
  1014. cancelButtonText: '取消',
  1015. type: 'warning'
  1016. }).then(() => {
  1017. that.table_loading = true;
  1018. that.$http.post(this.delete_url, {id: id}).then(response => {
  1019. console.log(response);
  1020. if (response.data.result == 1) {
  1021. that.$message.success("删除成功!");
  1022. that.search(1);
  1023. } else {
  1024. that.$message.error(response.data);
  1025. }
  1026. that.table_loading = false;
  1027. }), function (res) {
  1028. console.log(res);
  1029. that.table_loading = false;
  1030. };
  1031. }).catch(() => {
  1032. this.$message({type: 'info', message: '已取消修改'});
  1033. });
  1034. },
  1035. // 批量删除
  1036. batchDestroy() {
  1037. var that = this;
  1038. that.$confirm('确定删除吗', '提示', {
  1039. confirmButtonText: '确定',
  1040. cancelButtonText: '取消',
  1041. type: 'warning'
  1042. }).then(() => {
  1043. that.table_loading = true;
  1044. let ids = [];
  1045. that.goods_list.forEach((item, index) => {
  1046. if (item.is_choose == 1) {
  1047. ids.push(item.id);
  1048. }
  1049. })
  1050. let json = {ids: ids}
  1051. that.$http.post("{!! yzWebFullUrl('goods.goods.batchDestroy') !!}", json).then(response => {
  1052. console.log(response);
  1053. if (response.data.result == 1) {
  1054. that.$message.success('操作成功!');
  1055. that.is_all_choose = 0;
  1056. that.search(1);
  1057. } else {
  1058. that.$message.error(response.data.msg);
  1059. }
  1060. that.table_loading = false;
  1061. }), function (res) {
  1062. console.log(res);
  1063. that.table_loading = false;
  1064. };
  1065. }).catch(() => {
  1066. this.$message({type: 'info', message: '已取消修改'});
  1067. });
  1068. },
  1069. // 批量修改分类-打开分类选择框
  1070. openCategory() {
  1071. this.category_show = true;
  1072. if(this.batch_category.length==0) {
  1073. this.getBatchCategory();
  1074. }
  1075. },
  1076. openService() {
  1077. this.service_show = true;
  1078. },
  1079. closeService() {
  1080. this.service_show = false;
  1081. },
  1082. serviceSubmit() {
  1083. var that = this;
  1084. that.table_loading = true;
  1085. let ids = [];
  1086. that.goods_list.forEach((item, index) => {
  1087. if (item.is_choose == 1) {
  1088. ids.push(item.id);
  1089. }
  1090. });
  1091. if (this.service_form.time_type==0) {
  1092. console.log(this.service_form)
  1093. if (!this.service_form.shelves_time[0] || !this.service_form.shelves_time[1]) {
  1094. this.$message({message: '上下架时间不能为空', type: 'error'});return;
  1095. }
  1096. this.service_form.on_shelf_time = this.service_form.shelves_time[0] / 1000;
  1097. this.service_form.lower_shelf_time = this.service_form.shelves_time[1] / 1000;
  1098. }
  1099. if (this.service_form.time_type==1) {
  1100. if (!this.service_form.loop_date[0] || !this.service_form.loop_date[1]) {
  1101. this.$message({message: '循环时间不能为空', type: 'error'});return;
  1102. }
  1103. this.service_form.loop_date_start = this.service_form.loop_date[0] / 1000;
  1104. this.service_form.loop_date_end = this.service_form.loop_date[1] / 1000;
  1105. }
  1106. if (this.service_form.time_type==1) {
  1107. if (!this.service_form.loop_time_up || !this.service_form.loop_time_down) {
  1108. this.$message({message: '循环上下架时间不能为空', type: 'error'});return;
  1109. }
  1110. }
  1111. let json = {
  1112. ids:ids,
  1113. service_form:this.service_form,
  1114. };
  1115. that.$http.post("{!! yzWebFullUrl('goods.goods.batchService') !!}", json).then(response => {
  1116. console.log(response);
  1117. if (response.data.result == 1) {
  1118. that.$message.success('操作成功!');
  1119. that.is_all_choose = 0;
  1120. that.search(1);
  1121. that.service_show = false;
  1122. } else {
  1123. that.$message.error(response.data.msg);
  1124. }
  1125. that.table_loading = false;
  1126. }), function (res) {
  1127. console.log(res);
  1128. that.table_loading = false;
  1129. };
  1130. },
  1131. getBatchCategory() {
  1132. var that = this;
  1133. that.$http.post("{!! yzWebFullUrl('goods.category.get-all-shop-category') !!}", {}).then(response => {
  1134. console.log(response);
  1135. if (response.data.result == 1) {
  1136. this.batch_category = response.data.data.list;
  1137. } else {
  1138. that.$message.error(response.data.msg);
  1139. }
  1140. }), function (res) {
  1141. console.log(res);
  1142. };
  1143. },
  1144. batchCategory() {
  1145. let that = this;
  1146. let json = {
  1147. level_1:this.batch_v1,
  1148. level_2:this.batch_v2,
  1149. goods_id_arr:[],
  1150. };
  1151. if(!json.level_1) {
  1152. this.$message.error('请选择一级分类')
  1153. return;
  1154. }
  1155. if(!json.level_2) {
  1156. this.$message.error('请选择二级分类')
  1157. return;
  1158. }
  1159. that.goods_list.forEach((item, index) => {
  1160. if (item.is_choose == 1) {
  1161. json.goods_id_arr.push(item.id);
  1162. }
  1163. })
  1164. if(this.catlevel == 3) {
  1165. json.level_3 = this.batch_v3
  1166. if(!json.level_3) {
  1167. this.$message.error('请选择三级分类')
  1168. return;
  1169. }
  1170. }
  1171. that.$http.post("{!! yzWebFullUrl('goods.category.change-many-goods-category') !!}", json).then(response => {
  1172. console.log(response);
  1173. if (response.data.result == 1) {
  1174. that.$message.success('操作成功!');
  1175. that.is_all_choose = 0;
  1176. that.search(1);
  1177. } else {
  1178. that.$message.error(response.data.msg);
  1179. }
  1180. }), function (res) {
  1181. console.log(res);
  1182. };
  1183. },
  1184. batchChangeV1(val) {
  1185. console.log(val)
  1186. this.batch_category_v2 = [];
  1187. this.batch_category_v3 = [];
  1188. this.batch_v2 = '';
  1189. this.batch_v3 = '';
  1190. let obj = this.batch_category.find((item,index) => {
  1191. return item.id == val
  1192. })
  1193. this.batch_category_v2 = obj?obj.has_many_children:[]
  1194. },
  1195. batchChangeV2(val) {
  1196. if(this.catlevel!=3) {
  1197. return
  1198. }
  1199. this.batch_category_v3 = [];
  1200. this.batch_v3 = '';
  1201. let obj = this.batch_category_v2.find((item,index) => {
  1202. return item.id == val
  1203. })
  1204. this.batch_category_v3 = obj?obj.has_many_children:[]
  1205. },
  1206. // 新品、热卖、推荐、促销、
  1207. setProperty(id, index, type) {
  1208. var that = this;
  1209. that.table_loading = true;
  1210. console.log(that.goods_list[index][type])
  1211. let data = that.goods_list[index][type];
  1212. let json = {id: id, type: type, data: data};
  1213. that.$http.post("{!! yzWebFullUrl('goods.goods.setProperty') !!}", json).then(response => {
  1214. console.log(response);
  1215. if (response.data.result == 1) {
  1216. that.$message.success('操作成功!');
  1217. } else {
  1218. that.$message.error(response.data.msg);
  1219. that.goods_list[index][type] == 1 ? 0 : 1;
  1220. }
  1221. that.table_loading = false;
  1222. }), function (res) {
  1223. console.log(res);
  1224. that.table_loading = false;
  1225. };
  1226. },
  1227. // 编辑商品标题
  1228. editTitle(index, type) {
  1229. let that = this;
  1230. if (type == 'title') {
  1231. that.change_title = "";
  1232. that.change_title = that.goods_list[index].title;
  1233. }
  1234. if (type == 'price') {
  1235. if (that.goods_list[index].has_option == 1) {
  1236. that.$message.error('多规格不支持快速修改');
  1237. return false;
  1238. }
  1239. that.change_price = "";
  1240. that.change_price = that.goods_list[index].price;
  1241. }
  1242. if (type == 'cost_price') {
  1243. if (that.goods_list[index].has_option == 1) {
  1244. that.$message.error('多规格不支持快速修改');
  1245. return false;
  1246. }
  1247. that.change_cost_price = "";
  1248. that.change_cost_price = that.goods_list[index].cost_price;
  1249. }
  1250. if (type == 'stock') {
  1251. if (that.goods_list[index].has_option == 1) {
  1252. that.$message.error('多规格不支持快速修改');
  1253. return false;
  1254. }
  1255. that.change_stock = "";
  1256. that.change_stock = that.goods_list[index].stock;
  1257. }
  1258. if (type == 'sort') {
  1259. that.change_sort = "";
  1260. that.change_sort = that.goods_list[index].display_order;
  1261. }
  1262. },
  1263. // 确认修改标题、价格、库存
  1264. confirmChange(id, type) {
  1265. let that = this;
  1266. let value = '';
  1267. if (type == 'title') {
  1268. value = that.change_title;
  1269. if (that.change_title == '') {
  1270. that.$message.error('标题不能为空');
  1271. return false;
  1272. }
  1273. }
  1274. if (type == 'price') {
  1275. value = that.change_price;
  1276. if (!(/^\d+(\.\d+)?$/.test(that.change_price))) {
  1277. that.$message.error('请输入正确价格');
  1278. return false;
  1279. }
  1280. }
  1281. if (type == 'cost_price') {
  1282. value = that.change_cost_price;
  1283. if (!(/^\d+(\.\d+)?$/.test(that.change_cost_price))) {
  1284. that.$message.error('请输入正确成本价');
  1285. return false;
  1286. }
  1287. }
  1288. if (type == 'stock') {
  1289. value = that.change_stock;
  1290. if (!(/^\d+$/.test(that.change_stock))) {
  1291. that.$message.error('请输入正确数字');
  1292. return false;
  1293. }
  1294. }
  1295. let json = {
  1296. id: id,
  1297. type: type,
  1298. value: value,
  1299. };
  1300. that.table_loading = true;
  1301. that.$http.post("{!! yzWebFullUrl('goods.goods.change') !!}", json).then(response => {
  1302. console.log(response);
  1303. if (response.data.result == 1) {
  1304. that.$message.success('操作成功!');
  1305. if (document.all) {
  1306. document.getElementById('app').click();
  1307. } else {// 其它浏览器
  1308. var e = document.createEvent('MouseEvents')
  1309. e.initEvent('click', true, true)
  1310. document.getElementById('app').dispatchEvent(e)
  1311. }
  1312. that.search(this.this_page);
  1313. } else {
  1314. that.$message.error(response.data.msg);
  1315. }
  1316. that.table_loading = false;
  1317. }), function (res) {
  1318. console.log(res);
  1319. that.table_loading = false;
  1320. };
  1321. },
  1322. // 确认修改排序
  1323. confirmChangeSort(id) {
  1324. let that = this;
  1325. if (!(/^\d+$/.test(that.change_sort))) {
  1326. that.$message.error('请输入正确数字');
  1327. return false;
  1328. }
  1329. that.table_loading = true;
  1330. let json = {id: id, value: that.change_sort};
  1331. that.$http.post("{!! yzWebFullUrl('goods.goods.displayorder') !!}", json).then(response => {
  1332. console.log(response);
  1333. if (response.data.result == 1) {
  1334. that.$message.success('操作成功!');
  1335. // that.$refs.search_form.click();
  1336. if (document.all) {
  1337. document.getElementById('app').click();
  1338. } else {// 其它浏览器
  1339. var e = document.createEvent('MouseEvents')
  1340. e.initEvent('click', true, true)
  1341. document.getElementById('app').dispatchEvent(e)
  1342. }
  1343. that.search(1);
  1344. } else {
  1345. that.$message.error(response.data.msg);
  1346. }
  1347. that.table_loading = false;
  1348. }), function (res) {
  1349. console.log(res);
  1350. that.table_loading = false;
  1351. };
  1352. },
  1353. // 字符转义
  1354. escapeHTML(a) {
  1355. a = "" + a;
  1356. return a.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, "\"").replace(/&apos;/g, "'");
  1357. ;
  1358. },
  1359. },
  1360. })
  1361. </script>
  1362. @endsection