index.php 79 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719
  1. <?php
  2. use common\enums\AddonsEnum;
  3. use common\helpers\AddonHelper;
  4. use common\helpers\ComponentHelper;
  5. use common\models\common\Addons;
  6. ComponentHelper::loadComponentView('component/com-add-cat',__DIR__);
  7. ComponentHelper::loadComponentView('com-export-dialog');
  8. if (!empty($pay_success_jump_component)) {
  9. ComponentHelper::loadComponentView('pay-success-select-jump-url',
  10. AddonHelper::getAddonRootPath('PaySuccessJump') . 'backend/views/components');
  11. }
  12. ?>
  13. <style>
  14. <?= ComponentHelper::loadComponentView('index', __DIR__ . '/css', [],true, 'css'); ?>
  15. </style>
  16. <div id="app" v-cloak>
  17. <el-card shadow="never" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  18. <div slot="header">
  19. <span>商品列表</span>
  20. <div style="float: right; margin: -5px 0">
  21. <el-button type="primary" size="small" @click="handle('edit')">添加商品</el-button>
  22. <el-button v-if="synchronize_goods_dialog > 0" type="primary" size="small" @click="syncGoods">同步商品</el-button>
  23. <!-- //todo v2-->
  24. <!-- <el-button type="primary" size="small">商品导出</el-button>-->
  25. <el-button class="all_button" type="primary" size="small" @click="importGoods" >批量导入</el-button>
  26. <com-export-dialog
  27. style="float: right;margin-left: 10px;"
  28. :field_list='export_list'
  29. :action_url="export_url"
  30. :params="search_data">
  31. </com-export-dialog>
  32. </div>
  33. </div>
  34. <div class="table-body">
  35. <el-tabs v-model="activeName" @tab-click="handleClick">
  36. <el-tab-pane v-for="item in tabs" :key="item.value" :label="item.name" :name="item.value">
  37. <el-form :inline="true" :model="search_data" size="small" class="demo-form-inline">
  38. <el-form-item>
  39. <el-button size="small" @click="$refs.cats.openDialog()">分类筛选</el-button>
  40. <el-button size="small" v-if="search_data.cats && search_data.cats.length > 0" type="danger" @click="clearCat">清除分类</el-button>
  41. </el-form-item>
  42. <el-form-item>
  43. <el-date-picker style="margin-top: 1px;" size="small" @change="changeTime" v-model="datetime" type="datetimerange" value-format="yyyy-MM-dd HH:mm:ss" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']"></el-date-picker>
  44. </el-form-item>
  45. <el-form-item label="">
  46. <el-input size="small" placeholder="请输入商品名称" @keyup.enter.native="search" v-model="search_data.goods_name"></el-input>
  47. </el-form-item>
  48. <el-form-item label="">
  49. <el-input size="small" placeholder="请输入商品ID精准搜索" @keyup.enter.native="search" v-model="search_data.goods_id"></el-input>
  50. </el-form-item>
  51. <el-form-item label="">
  52. <el-select size="small" v-model="search_data.goods_type" placeholder="请选择商品类型" style="width: 100%;" clearable>
  53. <el-option label="实体商品" :value="1"></el-option>
  54. <el-option label="虚拟商品" :value="2"></el-option>
  55. <el-option label="预约商品" :value="3"></el-option>
  56. </el-select>
  57. </el-form-item>
  58. <el-form-item>
  59. <el-button type="primary" @click="search">搜索</el-button>
  60. <el-button type="danger" @click="clearSearch" v-if="show_clear_search_btn">清除条件</el-button>
  61. </el-form-item>
  62. </el-form>
  63. <template >
  64. <el-button @click="upDownBatch(1)" size="mini">批量上架</el-button>
  65. <el-button @click="upDownBatch(0)" size="mini">批量下架</el-button>
  66. </template>
  67. <el-button @click="allDeleteBatch" size="mini">批量删除</el-button>
  68. <el-button v-if="alipay_mini_app_id" @click="batchSetTemplate" size="mini">批量设置广告模板</el-button>
  69. <template>
  70. <el-button @click="openScoreSetting(1)" size="mini">积分批量抵扣</el-button>
  71. <el-button @click="openScoreSetting(2)" size="mini">积分批量赠送</el-button>
  72. </template>
  73. <el-table v-loading="listLoading" :data="list" stripe style="width: 100%" @sort-change="sortChange" @selection-change="handleSelectionChange" :row-key="(row) => { return row.id }">
  74. <el-table-column type="selection" align="center" width="60" :reserve-selection="true"></el-table-column>
  75. <el-table-column label="ID" prop="id" align="center"></el-table-column>
  76. <el-table-column label="商品名称" min-width="200" prop="goods_name" align="center">
  77. <template slot-scope="scope">
  78. <div flex="cross:center">
  79. <div style="margin-right: 10px;">
  80. <el-image style="width: 50px; height: 50px;border-radius: 5px;" :src="scope.row.cover_pic"></el-image>
  81. </div>
  82. <div v-if="goods_name_id != scope.row.id" flex="cross:center">
  83. <el-tooltip class="item" effect="dark" :content="scope.row.goods_name+''" placement="top">
  84. <span class="over2">{{scope.row.goods_name}}</span>
  85. </el-tooltip>
  86. <el-button class="edit-sort" type="text" @click="edit(scope.row,'goods_name')">
  87. <img src="resources/img/mall/order/edit.png" alt="">
  88. </el-button>
  89. </div>
  90. <div style="display: flex;align-items: center" v-else>
  91. <el-input style="min-width: 70px" size="mini" class="change" v-model="goods_name" autocomplete="off"></el-input>
  92. <el-button class="change-quit" type="text" style="color: #F56C6C;padding: 0 5px" icon="el-icon-error" circle @click="cancelEdit('goods_name')"></el-button>
  93. <el-button class="change-success" type="text" style="margin-left: 0;color: #67C23A;padding: 0 5px" icon="el-icon-success" circle @click="handle('goods_name',scope.row)">
  94. </el-button>
  95. </div>
  96. </div>
  97. </template>
  98. </el-table-column>
  99. <el-table-column label="分类" align="center">
  100. <template slot-scope="scope">
  101. <div class="goods-cat">
  102. <el-tag v-if="scope.row.cats && scope.row.cats.length > 0" size="mini">
  103. {{scope.row.cats[0].name}}
  104. </el-tag>
  105. <el-tooltip v-if="scope.row.cats && scope.row.cats.length > 1" placement="top">
  106. <div slot="content">
  107. <span v-for="item in scope.row.cats" :key="item.id">{{item.name}}&nbsp;</span>
  108. </div>
  109. <span>...</span>
  110. </el-tooltip>
  111. </div>
  112. </template>
  113. </el-table-column>
  114. <el-table-column label="售价" prop="price" align="center" sortable="false">
  115. <template slot-scope="scope">
  116. <div size="small">{{scope.row.price}}</div>
  117. </template>
  118. </el-table-column>
  119. <el-table-column label="库存" prop="stock" align="center" sortable="false" min-width="150">
  120. <template slot-scope="scope">
  121. <div v-if="scope.row.attr.length < 2">
  122. <div v-if="goods_stock_id != scope.row.id">
  123. <el-tooltip class="item" effect="dark" content="库存" placement="top">
  124. <span style="color: red;" v-if="scope.row.stock<=scope.row.stock_warning">{{scope.row.stock}}</span>
  125. <span>{{scope.row.stock}}</span>
  126. </el-tooltip>
  127. <el-button class="edit-sort" type="text" @click="edit(scope.row,'goods_stock')"
  128. v-if="scope.row.goods_source == '' && scope.row.goods_type != 3">
  129. <img src="resources/img/mall/order/edit.png" alt="">
  130. </el-button>
  131. </div>
  132. <div style="display: flex;align-items: center" v-else>
  133. <el-input style="min-width: 70px" type="number" size="mini" class="change"
  134. v-model="goods_stock" autocomplete="off"></el-input>
  135. <el-button class="change-quit" type="text" style="color: #F56C6C;padding: 0 5px"
  136. icon="el-icon-error" circle
  137. @click="cancelEdit('goods_stock')"></el-button>
  138. <el-button class="change-success" type="text"
  139. style="margin-left: 0;color: #67C23A;padding: 0 5px"
  140. icon="el-icon-success" circle
  141. @click="handle('goods_stock',scope.row)">
  142. </el-button>
  143. </div>
  144. </div>
  145. <div v-else>
  146. <div>
  147. <el-tooltip class="item" effect="dark" content="库存" placement="top">
  148. <span style="color: red;" v-if="scope.row.stock<=scope.row.stock_warning">{{scope.row.stock}}</span>
  149. <span>{{scope.row.stock}}</span>
  150. </el-tooltip>
  151. <el-button class="edit-sort" type="text" @click="edit(scope.row,'attr_goods_stock')"
  152. v-if="scope.row.goods_source == '' && scope.row.goods_type != 3">
  153. <img src="resources/img/mall/order/edit.png" alt="">
  154. </el-button>
  155. </div>
  156. </div>
  157. </template>
  158. </el-table-column>
  159. <el-table-column label="虚拟销量" prop="virtual_sales" align="center" width="150">
  160. <!-- <template slot-scope="scope">
  161. <div size="small">{{scope.row.virtual_sales}}</div>
  162. </template> -->
  163. <template slot-scope="scope">
  164. <div v-if="virtual_sales_id != scope.row.id">
  165. <el-tooltip class="item" effect="dark" content="虚拟销量" placement="top">
  166. <span>{{scope.row.virtual_sales}}</span>
  167. </el-tooltip>
  168. <el-button class="edit-sort" type="text" @click="edit(scope.row,'virtual_sales')">
  169. <img src="resources/img/mall/order/edit.png" alt="">
  170. </el-button>
  171. </div>
  172. <div style="display: flex;align-items: center" v-else>
  173. <el-input style="min-width: 70px" type="number" size="mini" class="change" v-model="virtual_sales" autocomplete="off"></el-input>
  174. <el-button class="change-quit" type="text" style="color: #F56C6C;padding: 0 5px" icon="el-icon-error" circle @click="cancelEdit('virtual_sales')"></el-button>
  175. <el-button class="change-success" type="text" style="margin-left: 0;color: #67C23A;padding: 0 5px" icon="el-icon-success" circle @click="handle('virtual_sales',scope.row)">
  176. </el-button>
  177. </div>
  178. </template>
  179. </el-table-column>
  180. <el-table-column label="销量数量" prop="sales" align="center">
  181. <template slot-scope="scope">
  182. <div size="small">{{scope.row.sales_num}}</div>
  183. </template>
  184. </template>
  185. </el-table-column>
  186. <el-table-column label="状态" prop="is_on_sale" align="center">
  187. <template slot-scope="scope">
  188. <div size="small" v-if="scope.row.is_on_sale == 1">上架</div>
  189. <div size="small" v-if="scope.row.is_on_sale == 0">下架</div>
  190. </template>
  191. </el-table-column>
  192. <el-table-column prop="sort" label="排序" width="150">
  193. <template slot-scope="scope">
  194. <div v-if="sort_id != scope.row.id">
  195. <el-tooltip class="item" effect="dark" content="排序" placement="top">
  196. <span>{{scope.row.sort}}</span>
  197. </el-tooltip>
  198. <el-button class="edit-sort" type="text" @click="edit(scope.row,'sort')">
  199. <img src="resources/img/mall/order/edit.png" alt="">
  200. </el-button>
  201. </div>
  202. <div style="display: flex;align-items: center" v-else>
  203. <el-input style="min-width: 70px" type="number" size="mini" class="change" v-model="sort" autocomplete="off"></el-input>
  204. <el-button class="change-quit" type="text" style="color: #F56C6C;padding: 0 5px" icon="el-icon-error" circle @click="cancelEdit('sort')"></el-button>
  205. <el-button class="change-success" type="text" style="margin-left: 0;color: #67C23A;padding: 0 5px" icon="el-icon-success" circle @click="handle('sort',scope.row)">
  206. </el-button>
  207. </div>
  208. </template>
  209. </el-table-column>
  210. <el-table-column label="类型" prop="goods_type" align="center">
  211. <template slot-scope="scope">
  212. <div size="small" v-if="scope.row.goods_type == 1">实体商品</div>
  213. <div size="small" v-if="scope.row.goods_type == 2">虚拟商品</div>
  214. <div size="small" v-if="scope.row.goods_type == 3">预约商品</div>
  215. </template>
  216. </el-table-column>
  217. <el-table-column label="来源" prop="goods_source" align="center">
  218. <template slot-scope="scope">
  219. <el-tag size="mini" :type="scope.row.goods_source == '' ? 'success' : 'danger'">
  220. {{scope.row.goods_source == '' ? '自营' : '供应链'}}
  221. </el-tag>
  222. </template>
  223. </el-table-column>
  224. <el-table-column label="添加时间" width="160" prop="created_at" align="center">
  225. <template slot-scope="scope">
  226. <div size="small">{{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}</div>
  227. </template>
  228. </el-table-column>
  229. <el-table-column label="操作" min-width="300" align="center">
  230. <template slot-scope="scope">
  231. <template v-if="scope.row.addons_name!=''">
  232. <el-tooltip class="item" effect="dark" content="该商品正在参与营销活动,暂不可操作" placement="left-start">
  233. <el-tag size="small" type="warning">{{scope.row.addons_name}}</el-tag>
  234. </el-tooltip>
  235. </template>
  236. <template v-else="group_buy_active_arr[scope.row.id]">
  237. <el-button type="text" @click="handle('edit',scope.row)">编辑</el-button>
  238. <el-button type="text" @click="handle('destroy',scope.row)">删除</el-button>
  239. <el-button type="text" @click="handle('is_on_sale',scope.row)">
  240. <span size="small" v-if="scope.row.is_on_sale == 0">上架</span>
  241. <span size="small" v-if="scope.row.is_on_sale == 1">下架</span>
  242. </el-button>
  243. </template>
  244. <el-button v-if="is_compliance == 0" type="text" @click="handle('model',scope.row)">模式</el-button>
  245. <el-dropdown style="margin-left: 10px">
  246. <el-button type="text" class="el-dropdown-link">
  247. 更多<i class="el-icon-arrow-down el-icon--right"></i>
  248. </el-button>
  249. <el-dropdown-menu slot="dropdown">
  250. <el-dropdown-item>
  251. <div style="width: 100%; height: 100%;" @click="onCopyAlipayMiniQrCodeUrl(scope.row.id)">
  252. <el-button type="text" class="copy_btn">复制支付宝小程序短链接</el-button>
  253. </div>
  254. </el-dropdown-item>
  255. <el-dropdown-item v-if="show_sku_dialog == 1">
  256. <div style="width: 100%; height: 100%;" @click="handle('sku', scope.row)">
  257. <el-button type="text">规格</el-button>
  258. </div>
  259. </el-dropdown-item>
  260. <el-dropdown-item>
  261. <div style="width: 100%; height: 100%;" @click="handle('copy', scope.row)">
  262. <el-button type="text">复制商品</el-button>
  263. </div>
  264. </el-dropdown-item>
  265. <el-dropdown-item v-if="pay_success_jump > 0">
  266. <div style="width: 100%; height: 100%;" @click="onChangeJumpUrl(scope.row)">
  267. <el-button type="text">支付后跳转设置</el-button>
  268. </div>
  269. </el-dropdown-item>
  270. <el-dropdown-item>
  271. <div style="width: 100%; height: 100%;" @click="copyLink(scope.row.h5_url)">
  272. <el-button type="text">复制h5链接</el-button>
  273. </div>
  274. </el-dropdown-item>
  275. </el-dropdown-menu>
  276. </el-dropdown>
  277. </template>
  278. </el-table-column>
  279. </el-table>
  280. <div style="text-align: right;margin: 20px 0;">
  281. <el-pagination @size-change="handleSizeChange" @current-change="pagination" v-if="pageCount > 0" :current-page="page" background layout="prev, pager, next, sizes, jumper" :page-sizes="[10, 20, 50, 100]" :page-count="pageCount" :page-size="pageSize"></el-pagination>
  282. </div>
  283. </el-tab-pane>
  284. </el-tabs>
  285. </div>
  286. </el-card>
  287. <el-dialog :close-on-click-modal="false" title="批量选择广告模版" :visible.sync="goodsDialogVisible" width="50%">
  288. <el-table stripe v-loading="templateListLoading" :data="templateList" style="margin-top: 5px;"
  289. @selection-change="selectionChange">
  290. <el-table-column width="100px" label="ID" props="id" align="center">
  291. <template slot-scope="props">
  292. <el-radio-group v-model="tempory_template_id" @change="selectionChange(props.row)">
  293. <el-radio :label="props.row.id"></el-radio>
  294. </el-radio-group>
  295. </template>
  296. </el-table-column>
  297. <el-table-column label="模版编号" prop="id"></el-table-column>
  298. <el-table-column label="模版名称" prop="name"></el-table-column>
  299. <el-table-column label="是否为默认模版" prop="is_default">
  300. <template slot-scope="scope">
  301. <div size="small" v-if="scope.row.is_default == 1">是</div>
  302. <div size="small" v-else>否</div>
  303. </template>
  304. </el-table-column>
  305. <el-table-column label="创建时间" prop="created_at">
  306. <template slot-scope="scope">
  307. <div size="small">{{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}</div>
  308. </template>
  309. </el-table-column>
  310. <el-table-column label="状态" prop="status">
  311. <template slot-scope="scope">
  312. <div size="small" v-if="scope.row.status == 1">启用</div>
  313. <div size="small" v-if="scope.row.status == 0">禁用</div>
  314. </template>
  315. </el-table-column>
  316. <!-- <el-table-column label="已绑定推荐人" prop="parent_name"></el-table-column>-->
  317. </el-table>
  318. <div style="text-align: right;margin: 20px 0;">
  319. <el-pagination @current-change="templatePagination" background layout="prev, pager, next"
  320. :page-count="templatePageCount" :current-page="templatePage"></el-pagination>
  321. </div>
  322. <span slot="footer" class="dialog-footer">
  323. <el-button @click="goodsDialogVisible = false">取 消</el-button>
  324. <el-button :loading="btnLoading" type="primary" @click="confirmSelectTemplate">确认</el-button>
  325. </span>
  326. </el-dialog>
  327. <!--支付宝小程序url复制-->
  328. <el-dialog :close-on-click-modal="false" title="支付支付宝小程序链接" :visible.sync="copyAlipayMiniDialogVisible" width="50%">
  329. <el-form>
  330. <el-form-item label="商品页面路径及参数">
  331. <el-input v-model="alipay_goods_path" :disabled="true">
  332. <template #append>
  333. <el-button @click="onCopyAlipayUrl(alipay_goods_path, 'btn-copy-alipay-goods-path')" class="btn-copy-alipay-goods-path">复制</el-button>
  334. </template>
  335. </el-input>
  336. </el-form-item>
  337. <el-form-item label="支付宝小程序URL(参数已转)">
  338. <el-input v-model="alipay_mini_goods_path" :disabled="true">
  339. <template #append>
  340. <el-button @click="onCopyAlipayUrl(alipay_mini_goods_path, 'btn-copy-alipay-mini-goods-path')" class="btn-copy-alipay-mini-goods-path">复制</el-button>
  341. </template>
  342. </el-input>
  343. </el-form-item>
  344. </el-form>
  345. <span slot="footer" class="dialog-footer">
  346. <el-button @click="copyAlipayMiniDialogVisible = false">关 闭</el-button>
  347. </span>
  348. </el-dialog>
  349. <!-- 查看规格 -->
  350. <el-dialog :close-on-click-modal="false" title="查看规格" :visible.sync="skuDialogVisible" width="50%">
  351. <div>
  352. <div style="text-align: center; color: red; font-size: 18px; padding-bottom: 15px;">
  353. <p><strong>若未启用自定义商品编码,请将第三方对应的商品编码修改为规格ID</strong></p>
  354. <p><strong>若启用自定义商品编码,则以输入的商品编码为准</strong></p>
  355. </div>
  356. <el-form :rules='rules' ref='ruleForm' :model="ruleForm">
  357. <el-table border v-loading="skuLoading" :data="ruleForm.skus">
  358. <el-table-column prop="id" label="规格ID" width="180"> </el-table-column>
  359. <el-table-column width="180" prop="price" label="销售价格"> </el-table-column>
  360. <el-table-column prop="name" label="规格名称">
  361. <template slot-scope="scope">
  362. {{scope.row.name != '' ? scope.row.name : '默认规格'}}
  363. </template>
  364. </el-table-column>
  365. <el-table-column prop="name" label="是否启用商品编码">
  366. <template slot="header" slot-scope="scope">
  367. <span>是否启用商品编码</span>
  368. <el-switch v-model="ruleForm.is_show_code" :active-value="1" :inactive-value="0"></el-switch>
  369. </template>
  370. <template slot-scope="scope">
  371. <el-form-item class='form-item' :prop="'skus.'+ scope.$index + '.spec_no'" :rules="rules.spec_no" label='' v-if="ruleForm.is_show_code==1">
  372. <el-input v-model='scope.row.spec_no' size="small"></el-input>
  373. </el-form-item>
  374. </template>
  375. </el-table-column>
  376. </el-table>
  377. </el-form>
  378. <div style="margin-top:10px;font-weight:bold;">
  379. <p>注意:若商品的规格进行变动(包括但不限于新增,删除,移动规格位置),规格ID会变动,</p>
  380. <p>对应自定义商品编码会清空,需及时重新输入,否则订单会推送失败;</p>
  381. </div>
  382. </div>
  383. <span slot="footer" class="dialog-footer">
  384. <el-button @click="skuDialogVisible = false">取 消</el-button>
  385. <el-button type="primary" @click="setSkusData">确认</el-button>
  386. </span>
  387. </el-dialog>
  388. <!-- 同步商品至门店 -->
  389. <el-dialog :close-on-click-modal="false" title="同步商品" :visible.sync="syncGoods2Store" width="50%" center>
  390. <div class="el-row" style="margin-bottom: 16px;">
  391. <div class="el-col el-col-10">
  392. <el-radio-group v-model="syncType" @change="changeSyncType">
  393. <el-radio :label="0">指定门店</el-radio>
  394. <el-radio :label="1">全部门店</el-radio>
  395. </el-radio-group>
  396. </div>
  397. </div>
  398. <div class="el-row">
  399. <div class="el-col el-col-21">
  400. <el-input v-model="storeSearch.store_name" :disabled="syncType == 1" size="small" clearable @clear="searchStore" placeholder="请输入名称或者ID"></el-input>
  401. </div>
  402. <div class="el-col el-col-3" style="display:flex;justify-content:center">
  403. <el-button slot="append" icon="el-icon-search" :disabled="syncType == 1" @click="searchStore" type="primary" size="small" style="width:100px"></el-button>
  404. </div>
  405. </div>
  406. <el-table border v-loading="syncGoods2StoreLoading" :data="syscStoreList" style="margin-top: 5px;" ref="multipleTable" @select-all="handleSelectAll" @select="handleSyncSelect" :row-key="getRowKey">
  407. <el-table-column type="selection" :selectable='checkboxT' :reserve-selection="true" width="60" align='center'>
  408. </el-table-column>
  409. <el-table-column label="门店id" prop="id" align="center"></el-table-column>
  410. <el-table-column label="门店名称" prop="store_name" align="center">
  411. <template slot-scope="scope">
  412. <div style="display:flex;justify-content:center">
  413. <div style="padding-right:3px;">
  414. <el-image style="width: 50px; height: 50px; border-radius:3px;" :src="scope.row.logo_img" fit="fit">
  415. </el-image>
  416. </div>
  417. <div style="display:flex;align-items:center">
  418. {{scope.row.store_name}}
  419. </div>
  420. </div>
  421. </template>
  422. </el-table-column>
  423. <el-table-column label="会员" prop="store_name" align="center">
  424. <template slot-scope="scope">
  425. <div style="display:flex;justify-content:center">
  426. <div style="padding-right:3px;">
  427. <el-image style="width: 50px; height: 50px; border-radius:3px;" :src="scope.row.avatar_url" fit="fit">
  428. </el-image>
  429. </div>
  430. <div style="display:flex;align-items:center">
  431. {{scope.row.nickname}}
  432. </div>
  433. </div>
  434. </template>
  435. </el-table-column>
  436. <el-table-column label="店长姓名" prop="shop_owner" align="center"></el-table-column>
  437. </el-table>
  438. <div style="text-align: right;margin: 20px 0;">
  439. <el-pagination @current-change="storePagination" background layout="prev, pager, next" :page-count="storePageCount" :current-page="storePage"></el-pagination>
  440. </div>
  441. <span slot="footer" class="dialog-footer">
  442. <el-button @click="syncGoods2Store = false" size="small">取 消</el-button>
  443. <el-button :loading="btnLoading" type="primary" @click="confirmSyncGoods" size="small">确认</el-button>
  444. </span>
  445. </el-dialog>
  446. <!-- 分类筛选 -->
  447. <com-add-cat ref="cats" :new-cats="search_data.cats" @select="selectCat" :mch_id="mch_id"></com-add-cat>
  448. <textarea style="opacity: 0;width: 0;height: 0;" id="copy-container"></textarea>
  449. <!-- 绑定跳转链接 -->
  450. <pay-success-select-jump-url :goods="currentItem" :show="paySuccessSelectJumpUrlDialogVisible"
  451. @hide="hidePaySuccessSelectJumpUrlDialogVisible"></pay-success-select-jump-url>
  452. <template>
  453. <?= ComponentHelper::loadComponentView('batch-set-score', __DIR__.'/part') ?>
  454. </template>
  455. <el-dialog
  456. :close-on-click-modal="false"
  457. title="库存修改"
  458. :visible.sync="attrStockDialogVisible"
  459. width="70%"
  460. >
  461. <!-- 批量操作栏 -->
  462. <div class="batch-bar" style="display:flex;align-items:center;box-sizing: border-box; padding: 0 0 20px 11px">
  463. <el-checkbox
  464. v-model="selectAll"
  465. :indeterminate="isIndeterminate"
  466. @change="handleSelectAllAttr"
  467. >全选</el-checkbox>
  468. <div style="box-sizing: border-box;padding-left: 40px;">批量设置:</div>
  469. <el-input-number
  470. v-model="batchValue"
  471. precision="0"
  472. :min="0"
  473. :step="1"
  474. style="width: 200px; margin-left: 15px;"
  475. placeholder="批量设置库存"
  476. ></el-input-number>
  477. <el-button
  478. type="primary"
  479. style="margin-left: 10px;"
  480. @click="applyBatchStock"
  481. >确定</el-button>
  482. </div>
  483. <!-- 动态表格 -->
  484. <el-table
  485. ref="stockTable"
  486. :data="processedStockData"
  487. v-loading="attrStockListLoading"
  488. border
  489. stripe
  490. @selection-change="handleSelectionChangeAttr"
  491. >
  492. <!-- 选择列 -->
  493. <el-table-column type="selection" width="55"></el-table-column>
  494. <!-- 动态属性列 -->
  495. <el-table-column
  496. v-for="(group, index) in attr_goods_stock_group"
  497. :key="group.attr_group_id"
  498. :label="group.attr_group_name"
  499. align="center"
  500. >
  501. <template slot-scope="{ row }">
  502. {{ row[`colum${index + 1}`] }}
  503. </template>
  504. </el-table-column>
  505. <!-- 库存列 -->
  506. <el-table-column label="库存" align="center">
  507. <template slot-scope="{ row }">
  508. <el-input-number
  509. v-model.number="row.stock"
  510. :min="0"
  511. :step="1"
  512. controls-position="right"
  513. ></el-input-number>
  514. </template>
  515. </el-table-column>
  516. </el-table>
  517. <span slot="footer" class="dialog-footer">
  518. <el-button @click="attrStockDialogVisible = false">取消</el-button>
  519. <el-button
  520. type="primary"
  521. :loading="btnLoading"
  522. @click="handleConfirm"
  523. >确认修改</el-button>
  524. </span>
  525. </el-dialog>
  526. </div>
  527. <script src="/resources/unpkg/clipboard@1.5.12/dist/clipboard.min.js"></script>
  528. <script>
  529. const app = new Vue({
  530. el: '#app',
  531. props: {
  532. import_goods_url: {
  533. type: String,
  534. default: 'mall/goods/import-goods'
  535. },
  536. },
  537. data() {
  538. return {
  539. goods_name: '',
  540. goods_id: '',
  541. tabs: [{
  542. name: '全部',
  543. value: 'all'
  544. },
  545. {
  546. name: '销售中',
  547. value: 'onsale'
  548. },
  549. {
  550. name: '下架中',
  551. value: 'offline'
  552. },
  553. {
  554. name: '售罄',
  555. value: 'sell-out'
  556. },
  557. {
  558. name: '库存不足',
  559. value: 'stock-lack'
  560. },
  561. ],
  562. activeName: 'all',
  563. list: [],
  564. listLoading: false,
  565. page: 1,
  566. pageCount: 0,
  567. pageSize: 10,
  568. mch_id: 0, // 这个地方不知道要怎么获取
  569. searchCats: [],
  570. datetime: [],
  571. search_data: { // 筛选条件
  572. type: null,
  573. cats: [],
  574. start: null,
  575. end: null,
  576. goods_id: null,
  577. goods_name: null,
  578. choose_list: null,
  579. goods_type: null,
  580. },
  581. sort: 0,
  582. sort_id: 0,
  583. virtual_sales: 0,
  584. virtual_sales_id: 0,
  585. goods_name_id: 0,
  586. batchUpdateStatusUrl: '',
  587. choose_list: [],
  588. chooseList: [],
  589. is_bath: 1,
  590. btnLoading: false,
  591. batchExtraParams: [],
  592. export_url: 'mall/goods/export-excel',
  593. export_list: {},
  594. group_buy_active_arr: {},
  595. goodsDialogVisible: false,
  596. templateList: [],
  597. templateListLoading: false,
  598. tempory_template_id: 0,
  599. templatePage: 1,
  600. templatePageCount: 0,
  601. alipay_mini_app_id: null,
  602. synchronize_goods_dialog: null,
  603. mall_sign: '',
  604. copyAlipayMiniDialogVisible: false,
  605. alipay_goods_path: '',
  606. alipay_mini_goods_path: '',
  607. show_sku_dialog: 0,
  608. pay_success_jump: 0,
  609. skuDialogVisible: false,
  610. skuLoading: false,
  611. paySuccessSelectJumpUrlDialogVisible: false,
  612. currentItem: {},
  613. ruleForm: {
  614. is_show_code: 0,
  615. skus: [],
  616. },
  617. syncGoods2Store: false,
  618. syncGoods2StoreLoading: false,
  619. syscStoreList: [],
  620. selectedRowIds: [],
  621. syncType: 1,
  622. storePage: 1,
  623. storePageCount: 0,
  624. storeSearch: {
  625. store_name: ''
  626. },
  627. goodsScore: {
  628. goodsScoreDeductVisible: false,
  629. goodsScoreSetVisible: false,
  630. give:{give_num: 0,give_type: 1, settlement: 0},
  631. deduct:{deduct_num: 0, deduct_type: 1, type: 1},
  632. },
  633. goods_stock_id:0,
  634. goods_stock: 0,
  635. is_compliance : <?= $is_compliance; ?>,
  636. attrDialogVisible: true,
  637. attr_goods_stock_id: 0,
  638. attr_goods_stock: [],
  639. attr_goods_stock_group: [],
  640. attrStockDialogVisible: false,
  641. selectAll: false,
  642. isIndeterminate: false,
  643. attrStockListLoading: false,
  644. batchValue: null,
  645. selectedRows: [],
  646. processedStockData: [],
  647. rules: {
  648. spec_no: [
  649. {required: true, message: '请输入商家编码', trigger: 'blur'},
  650. ],
  651. },
  652. };
  653. },
  654. mounted: function() {
  655. this.page = Number(getQuery('page')) || 1;
  656. if(this.page > 1){
  657. this.pagination(this.page);
  658. }
  659. this.getList();
  660. },
  661. computed: {
  662. show_clear_search_btn: function() {
  663. return !isEmpty(this.search_data.cats) || !isEmpty(this.search_data.start) ||
  664. !isEmpty(this.search_data.end) || !isEmpty(this.search_data.goods_id) ||
  665. !isEmpty(this.search_data.goods_name);
  666. }
  667. },
  668. watch: {
  669. chooseList: {
  670. handler(newValue, oldValue) {
  671. this.search_data.choose_list = newValue
  672. },
  673. },
  674. deep: true,
  675. immediate: true
  676. },
  677. methods: {
  678. getRowKey(row) {
  679. return row.id;
  680. },
  681. handleSelectAll() {
  682. let _this = this
  683. if(_this.syncType == 1){
  684. return
  685. }
  686. _this.syscStoreList.map(function(item, index) {
  687. _this.selectedRowIds.push(item.id)
  688. })
  689. },
  690. handleSyncSelect(selection, row) {
  691. this.selectedRowIds.push(row.id)
  692. },
  693. importGoods() {
  694. navigateTo({
  695. r: this.import_goods_url,
  696. page: this.page
  697. });
  698. },
  699. selectCat(arr) {
  700. this.search_data.cats = [];
  701. arr.forEach(it => this.search_data.cats.push(it.id))
  702. this.getList()
  703. },
  704. clearCat() { // 清除分类
  705. this.search_data.cats = []
  706. this.getList()
  707. },
  708. changeTime(e) {
  709. // console.log(e)
  710. this.search_data.start = e[0]
  711. this.search_data.end = e[1]
  712. },
  713. handleClick(res) { //标签页切换
  714. if (this.search_data.status == this.activeName) return;
  715. this.search_data.type = this.activeName;
  716. this.getList();
  717. },
  718. sortChange(row) {
  719. if (row.prop) {
  720. this.search_data.sort_field = row.prop;
  721. this.search_data.sort_type = row.order == "descending" ? 'desc' : 'asc';
  722. } else {
  723. this.search_data.sort_prop = null;
  724. this.search_data.sort_type = null;
  725. }
  726. this.getList();
  727. },
  728. search() {
  729. this.page = 1;
  730. this.getList();
  731. },
  732. // 全选单前页
  733. handleSelectionChange(val) {
  734. let self = this;
  735. self.chooseList = [];
  736. val.forEach(function(item) {
  737. self.chooseList.push(item.id);
  738. })
  739. },
  740. checkChooseList() {
  741. if (this.isAllChecked) {
  742. this.dialogTitle = '已选所有商品';
  743. return true;
  744. }
  745. if (this.chooseList.length > 0) {
  746. this.dialogTitle = '已选商品' + this.chooseList.length + '种';
  747. return true;
  748. }
  749. this.$message.warning('请先勾选要设置的商品');
  750. return false;
  751. },
  752. upDown(command) {
  753. let self = this;
  754. if (!self.checkChooseList()) {
  755. return false;
  756. }
  757. if (command === 1) {
  758. this.statusChange(1)
  759. }
  760. let text = this.isAllChecked ? '警告:批量' + (command === 1 ? '上架' : '下架') + '所有商品?' : '批量' + (command === 1 ? '上架' : '下架') + ',是否继续';
  761. this.batchAction({
  762. url: self.batchUpdateStatusUrl,
  763. content: text,
  764. params: {
  765. batch_ids: this.chooseList,
  766. status: command,
  767. type: 'is_on_sale',
  768. }
  769. });
  770. },
  771. upDownBatch(command) {
  772. operate_type = command == 1 ? '上架' : '下架';
  773. this.$confirm('是否' + operate_type + '该商品?', '警告', {type: 'warning'}).then(() => {
  774. let self = this;
  775. let ids = this.getIds();
  776. request({
  777. params: {
  778. r: 'mall/goods/do-on-sale-batch',
  779. },
  780. method: 'post',
  781. data: {
  782. id:ids,
  783. is_on_sale:command
  784. }
  785. }).then(e => {
  786. if (e.data.code == 0) {
  787. self.$message.success(e.data.msg);
  788. self.getList();
  789. } else {
  790. self.$message.error(e.data.msg);
  791. }
  792. }).catch(e => {
  793. console.log(e);
  794. });
  795. });
  796. },
  797. getIds(){
  798. let self = this;
  799. if(this.chooseList.length==0){
  800. self.$message.error('请选择商品');
  801. return [];
  802. }
  803. let listMap = [];
  804. self.list.forEach(function (value, k) {
  805. listMap[value.id] = value;
  806. });
  807. let goods_name = '';
  808. let ids = [];
  809. this.chooseList.forEach(function (id, index){
  810. var value = listMap[id]
  811. if(value && value.addons_name){
  812. goods_name = goods_name + '【' + value.goods_name + '】';
  813. }else{
  814. ids.push(id);
  815. }
  816. });
  817. if(goods_name){
  818. self.$message.error('商品' + goods_name + '正在参与营销活动,不可以操作');
  819. return [];
  820. }
  821. return ids
  822. },
  823. allDeleteBatch() {
  824. this.$confirm('警告:是否确认删除所有商品?').then(() => {
  825. let self = this;
  826. let ids = this.getIds();
  827. if(ids.length==0){
  828. return false;
  829. }
  830. request({
  831. params: {
  832. r: 'mall/goods/del-batch',
  833. },
  834. method: 'post',
  835. data: {
  836. id:ids
  837. }
  838. }).then(e => {
  839. if (e.data.code == 0) {
  840. self.$message.success(e.data.msg);
  841. self.getList();
  842. } else {
  843. self.$message.error(e.data.msg);
  844. }
  845. }).catch(e => {
  846. console.log(e);
  847. });
  848. });
  849. },
  850. allDelete() {
  851. let self = this;
  852. if (!self.checkChooseList()) {
  853. return false;
  854. }
  855. let text = this.isAllChecked ? '警告:是否确认删除所有商品?' : '是否确认删除选中的商品?';
  856. this.batchAction({
  857. url: self.batchDestroyUrl,
  858. content: text,
  859. params: {
  860. batch_ids: this.chooseList,
  861. type: 'destroy',
  862. }
  863. });
  864. },
  865. // 上架状态开关,弹框文字提示
  866. statusChange(res) {
  867. let text = this.statusChangeText;
  868. if (res && text) {
  869. this.$alert(text, '提示', {
  870. confirmButtonText: '确定',
  871. callback: action => {}
  872. });
  873. }
  874. },
  875. batchAction(data) {
  876. let self = this;
  877. self.is_bath = 2;
  878. self.batchExtraParams.forEach(function (item) {
  879. data.params[item.key] = item.value;
  880. });
  881. self.$confirm(data.content, '提示', {
  882. confirmButtonText: '确定',
  883. cancelButtonText: '取消',
  884. type: 'warning'
  885. }).then(() => {
  886. self.btnLoading = true;
  887. let goods_name = '';
  888. let num = 0;
  889. data.params.batch_ids.forEach(function (item, key) {
  890. //判断营销产品不给操作
  891. let is_make = 1;
  892. self.list.forEach(function (value, k) {
  893. if (item == value.id && value.addons_name) {
  894. goods_name = goods_name + '【' + value.goods_name + '】';
  895. is_make = 2;
  896. }
  897. });
  898. if (is_make == 1) {
  899. num++;
  900. param = {
  901. id: item,
  902. is_on_sale: data.params.status,
  903. type: data.params.type,
  904. data_index: key,
  905. data_count_index: data.params.batch_ids.length,
  906. goods_name: goods_name,
  907. };
  908. self.send(param);
  909. } else {
  910. if (key == (data.params.batch_ids.length - 1)) {
  911. if (goods_name) {
  912. self.$message.success('商品' + goods_name + '正在参与营销活动,不可以操作,其他商品操作成功');
  913. } else {
  914. self.$message.success('操作成功');
  915. }
  916. self.getList();
  917. }
  918. }
  919. });
  920. }).catch((e) => {
  921. });
  922. },
  923. clearSearch() {
  924. this.search_data.cats = [];
  925. this.search_data.start = null;
  926. this.search_data.end = null;
  927. this.search_data.goods_id = null;
  928. this.search_data.goods_name = null;
  929. this.datetime = [];
  930. this.getList();
  931. },
  932. handle(type, data = null) {
  933. let id = data ? parseInt(data.id) : '';
  934. switch (type) {
  935. case 'edit':
  936. let params = {
  937. r: 'mall/goods/edit'
  938. };
  939. if (id) params = Object.assign(params, {
  940. id: id
  941. });
  942. navigateTo(params,true);
  943. break;
  944. case 'model': // 模式跳转
  945. param = {
  946. r: 'mall/goods/goods-model'
  947. };
  948. if (id) param = Object.assign(param, {
  949. id: id
  950. });
  951. navigateTo(param);
  952. break;
  953. case 'destroy':
  954. param = {
  955. id: data.id,
  956. type
  957. };
  958. this.$confirm('删除该条数据后不可以恢复, 是否继续?', '警告', {
  959. type: 'warning'
  960. }).then(() => {
  961. this.del(param)
  962. })
  963. break;
  964. case 'sort':
  965. param = {
  966. id: id,
  967. sort: this.sort,
  968. type
  969. };
  970. this.do_sort(param);
  971. break;
  972. case 'goods_name':
  973. param = {
  974. id: id,
  975. goods_name: this.goods_name,
  976. type
  977. };
  978. this.do_goods_name(param);
  979. break;
  980. case 'virtual_sales':
  981. param = {
  982. id: id,
  983. virtual_sales: this.virtual_sales,
  984. type
  985. };
  986. this.do_virtual_sales(param);
  987. break;
  988. case 'is_on_sale':
  989. param = {
  990. id: id,
  991. is_on_sale: data.is_on_sale == 0 ? 1 : 0,
  992. type
  993. };
  994. operate_type = data.is_on_sale == 0 ? '上架' : '下架';
  995. this.$confirm('是否' + operate_type + '该商品?', '警告', {
  996. type: 'warning'
  997. }).then(() => {
  998. this.do_on_sale(param)
  999. })
  1000. break;
  1001. case 'sku':
  1002. this.ruleForm.is_show_code = 0;
  1003. this.skuDialogVisible = true;
  1004. this.getSku(data)
  1005. break
  1006. case 'copy':
  1007. param = {
  1008. id: data.id
  1009. };
  1010. this.$confirm('是否复制该商品?', '警告', {
  1011. type: 'warning'
  1012. }).then(() => {
  1013. this.copy_goods(param)
  1014. })
  1015. break;
  1016. case 'goods_stock':
  1017. param = {
  1018. id: id,
  1019. stock: this.goods_stock,
  1020. type
  1021. };
  1022. this.do_goods_stock(param);
  1023. break;
  1024. }
  1025. this.cancelEdit(type);
  1026. },
  1027. send(params) {
  1028. let self = this;
  1029. request({
  1030. params: {
  1031. r: 'mall/goods/index',
  1032. },
  1033. method: 'post',
  1034. data: params
  1035. }).then(e => {
  1036. if (!params.data_count_index || (params.data_count_index - 1) == params.data_index) {
  1037. if (e.data.code == 0) {
  1038. if (params.goods_name) {
  1039. self.$message.success('商品' + params.goods_name + '正在参与营销活动,不可以操作,其他商品操作成功');
  1040. } else {
  1041. self.$message.success(e.data.msg);
  1042. }
  1043. self.getList();
  1044. } else {
  1045. self.$message.error(e.data.msg);
  1046. }
  1047. }
  1048. }).catch(e => {
  1049. console.log(e);
  1050. });
  1051. },
  1052. del(params) {
  1053. let self = this;
  1054. request({
  1055. params: {
  1056. r: 'mall/goods/del',
  1057. },
  1058. method: 'post',
  1059. data: params
  1060. }).then(e => {
  1061. if (e.data.code == 0) {
  1062. self.$message.success(e.data.msg);
  1063. self.getList();
  1064. } else {
  1065. self.$message.error(e.data.msg);
  1066. }
  1067. }).catch(e => {
  1068. console.log(e);
  1069. });
  1070. },
  1071. do_on_sale(params) {
  1072. let self = this;
  1073. request({
  1074. params: {
  1075. r: 'mall/goods/do-on-sale',
  1076. },
  1077. method: 'post',
  1078. data: params
  1079. }).then(e => {
  1080. if (e.data.code == 0) {
  1081. self.$message.success(e.data.msg);
  1082. self.getList();
  1083. } else {
  1084. self.$message.error(e.data.msg);
  1085. }
  1086. }).catch(e => {
  1087. console.log(e);
  1088. });
  1089. },
  1090. copy_goods(params) {
  1091. let self = this;
  1092. request({
  1093. params: {
  1094. r: 'mall/goods/copy-goods',
  1095. },
  1096. method: 'post',
  1097. data: params
  1098. }).then(e => {
  1099. if (e.data.code == 0) {
  1100. self.$message.success(e.data.msg);
  1101. self.getList();
  1102. } else {
  1103. self.$message.error(e.data.msg);
  1104. }
  1105. }).catch(e => {
  1106. console.log(e);
  1107. });
  1108. },
  1109. do_sort(params) {
  1110. let self = this;
  1111. request({
  1112. params: {
  1113. r: 'mall/goods/do-sort',
  1114. },
  1115. method: 'post',
  1116. data: params
  1117. }).then(e => {
  1118. if (e.data.code == 0) {
  1119. self.$message.success(e.data.msg);
  1120. self.getList();
  1121. } else {
  1122. self.$message.error(e.data.msg);
  1123. }
  1124. }).catch(e => {
  1125. console.log(e);
  1126. });
  1127. },
  1128. do_goods_name(params) {
  1129. let self = this;
  1130. request({
  1131. params: {
  1132. r: 'mall/goods/do-goods-name',
  1133. },
  1134. method: 'post',
  1135. data: params
  1136. }).then(e => {
  1137. if (e.data.code == 0) {
  1138. self.$message.success(e.data.msg);
  1139. self.getList();
  1140. } else {
  1141. self.$message.error(e.data.msg);
  1142. }
  1143. }).catch(e => {
  1144. console.log(e);
  1145. });
  1146. },
  1147. do_virtual_sales(params) {
  1148. let self = this;
  1149. request({
  1150. params: {
  1151. r: 'mall/goods/do-virtual-sales',
  1152. },
  1153. method: 'post',
  1154. data: params
  1155. }).then(e => {
  1156. if (e.data.code == 0) {
  1157. self.$message.success(e.data.msg);
  1158. self.getList();
  1159. } else {
  1160. self.$message.error(e.data.msg);
  1161. }
  1162. }).catch(e => {
  1163. console.log(e);
  1164. });
  1165. },
  1166. do_goods_stock(params) {
  1167. let self = this;
  1168. request({
  1169. params: {
  1170. r: 'mall/goods/do-goods-stock',
  1171. },
  1172. method: 'post',
  1173. data: params
  1174. }).then(e => {
  1175. if (e.data.code == 0) {
  1176. self.$message.success(e.data.msg);
  1177. self.getList();
  1178. } else {
  1179. self.$message.error(e.data.msg);
  1180. }
  1181. }).catch(e => {
  1182. console.log(e);
  1183. });
  1184. },
  1185. edit(row, type) {
  1186. switch (type) {
  1187. case 'sort':
  1188. this.sort = row.sort;
  1189. this.sort_id = row.id;
  1190. break;
  1191. case 'goods_name':
  1192. this.goods_name_id = row.id;
  1193. this.goods_name = row.goods_name;
  1194. break;
  1195. case 'virtual_sales':
  1196. this.virtual_sales_id = row.id;
  1197. this.virtual_sales = row.virtual_sales;
  1198. break;
  1199. case 'goods_stock':
  1200. this.goods_stock_id = row.id;
  1201. this.goods_stock = row.stock;
  1202. break;
  1203. case 'attr_goods_stock':
  1204. this.attr_goods_stock_id = row.id;
  1205. this.attr_goods_stock = row.attr;
  1206. this.attr_goods_stock_group = JSON.parse(row.attr_groups);
  1207. this.processedStockData = this.stockData();
  1208. this.batchValue = null;
  1209. this.attrStockDialogVisible = true;
  1210. break;
  1211. }
  1212. },
  1213. stockData() {
  1214. return this.attr_goods_stock.map(item => {
  1215. const signIdStr = String(item.sign_id);
  1216. const signIds = !signIdStr.includes(':') ? [item.sign_id] : signIdStr.split(':');
  1217. const processedItem = { id: item.id, stock: item.stock }
  1218. this.attr_goods_stock_group.forEach((group, index) => {
  1219. const attrId = signIds[index]
  1220. const attr = group.attr_list.find(a => a.attr_id == attrId)
  1221. processedItem[`colum${index + 1}`] = attr ? attr.attr_name : '未知属性'
  1222. })
  1223. return processedItem
  1224. })
  1225. },
  1226. handleSelectAllAttr(val) {
  1227. this.$refs.stockTable.clearSelection()
  1228. if (val) {
  1229. this.processedStockData.forEach(row => {
  1230. this.$refs.stockTable.toggleRowSelection(row)
  1231. })
  1232. }
  1233. },
  1234. // 选择变化
  1235. handleSelectionChangeAttr(selection) {
  1236. this.selectedRows = selection
  1237. const total = this.processedStockData.length
  1238. this.selectAll = selection.length === total
  1239. this.isIndeterminate = selection.length > 0 && selection.length < total
  1240. },
  1241. // 应用批量设置
  1242. applyBatchStock() {
  1243. if (this.batchValue === null) return
  1244. this.selectedRows.forEach(row => {
  1245. row.stock = this.batchValue
  1246. })
  1247. // this.batchValue = null
  1248. },
  1249. // 确认操作
  1250. async handleConfirm() {
  1251. try {
  1252. this.btnLoading = true
  1253. const attr_stock = this.processedStockData.map(item => ({
  1254. id: item.id,
  1255. stock: item.stock
  1256. }))
  1257. let self = this;
  1258. self.attrStockListLoading = true;
  1259. request({
  1260. params: {
  1261. r: 'mall/goods/do-goods-attr-stock',
  1262. },
  1263. method: 'post',
  1264. data: {
  1265. id: this.attr_goods_stock_id,
  1266. type: 'attr_stock',
  1267. attr_stock: attr_stock,
  1268. }
  1269. }).then(e => {
  1270. if (e.data.code == 0) {
  1271. self.$message.success(e.data.msg);
  1272. this.$message.success('库存更新成功')
  1273. this.attrStockDialogVisible = false
  1274. self.attrStockListLoading = false;
  1275. self.getList();
  1276. } else {
  1277. self.$message.error(e.data.msg);
  1278. self.attrStockListLoading = false;
  1279. }
  1280. }).catch(e => {
  1281. console.log(e);
  1282. });
  1283. return false;
  1284. // 这里调用保存接口
  1285. // await saveStock(payload)
  1286. } catch (error) {
  1287. console.error(error)
  1288. } finally {
  1289. this.btnLoading = false
  1290. }
  1291. },
  1292. cancelEdit(type) {
  1293. switch (type) {
  1294. case 'sort':
  1295. this.sort = 0;
  1296. this.sort_id = 0;
  1297. break;
  1298. case 'goods_name':
  1299. this.goods_name = '';
  1300. this.goods_name_id = 0;
  1301. break;
  1302. case 'virtual_sales':
  1303. this.virtual_sales = 0;
  1304. this.virtual_sales_id = 0;
  1305. break;
  1306. case 'goods_stock':
  1307. this.goods_stock_id = 0;
  1308. this.goods_stock = 0;
  1309. break;
  1310. }
  1311. },
  1312. searchClick() {
  1313. this.page = 1;
  1314. this.getList();
  1315. },
  1316. handleSizeChange(val) {
  1317. let self = this;
  1318. self.limit = val;
  1319. self.getList();
  1320. },
  1321. pagination(currentPage) {
  1322. let self = this;
  1323. self.page = currentPage;
  1324. sessionStorage.setItem('goodsPage', self.page)
  1325. self.getList();
  1326. },
  1327. // 获取商品列表
  1328. getList() {
  1329. let self = this;
  1330. let basic_params = {
  1331. r: 'mall/goods/index',
  1332. page: self.page,
  1333. limit:self.limit
  1334. };
  1335. params = Object.assign(basic_params, this.search_data);
  1336. if (self.listLoading == false) {
  1337. self.listLoading = true;
  1338. request({
  1339. params: params,
  1340. method: 'get',
  1341. }).then(e => {
  1342. self.listLoading = false;
  1343. if (e.data.code == 0) {
  1344. self.list = e.data.data.list;
  1345. self.group_buy_active_arr = e.data.data.group_buy_active_arr;
  1346. self.pageCount = e.data.data.page_count;
  1347. self.pageSize = e.data.data.page_size;
  1348. this.export_list = e.data.data.export_list;
  1349. this.alipay_mini_app_id = e.data.data.alipay_mini_app_id
  1350. this.synchronize_goods_dialog = e.data.data.synchronize_goods_dialog
  1351. this.mall_sign = e.data.data.mall_sign
  1352. this.show_sku_dialog = e.data.data.show_sku_dialog
  1353. this.pay_success_jump = e.data.data.pay_success_jump
  1354. } else {
  1355. self.$message.error(e.data.msg);
  1356. }
  1357. }).catch(e => {
  1358. self.$message.error(e.data.msg);
  1359. self.listLoading = false;
  1360. });
  1361. }
  1362. },
  1363. selectionChange(e) {
  1364. this.tempory_template_id = e.id;
  1365. },
  1366. templatePagination(currentPage) {
  1367. this.templatePage = currentPage;
  1368. this.getTemplateList();
  1369. },
  1370. storePagination(currentPage) {
  1371. this.storePage = currentPage;
  1372. this.getStoreList();
  1373. },
  1374. searchStore(){
  1375. this.storePage = 1
  1376. this.getStoreList()
  1377. },
  1378. getStoreList() {
  1379. let _this = this;
  1380. let basic_params = {
  1381. r: 'store/store/index',
  1382. page: this.storePage,
  1383. limit: 10,
  1384. status: 1,
  1385. ..._this.storeSearch
  1386. };
  1387. params = Object.assign(basic_params, {});
  1388. if (_this.syncGoods2StoreLoading == false) {
  1389. _this.syncGoods2StoreLoading = true;
  1390. request({
  1391. params: params,
  1392. method: 'get',
  1393. }).then(e => {
  1394. _this.syncGoods2StoreLoading = false;
  1395. if (e.data.code == 0) {
  1396. _this.syscStoreList = e.data.data.list;
  1397. _this.storePageCount = e.data.data.page_count;
  1398. if(_this.syncType == 1){
  1399. for (i = 0; i < _this.syscStoreList.length; i++) {
  1400. this.$refs.multipleTable.toggleRowSelection(_this.syscStoreList[i],true);
  1401. }
  1402. }
  1403. } else {
  1404. _this.$message.error(e.data.data.msg);
  1405. }
  1406. }).catch(e => {
  1407. _this.$message.error(e.data.data.msg);
  1408. _this.syncGoods2StoreLoading = false;
  1409. });
  1410. }
  1411. },
  1412. getTemplateList() {
  1413. let self = this;
  1414. let basic_params = {
  1415. r: 'mall/goods-template/index',
  1416. status: 1,
  1417. limit: 12
  1418. };
  1419. params = Object.assign(basic_params, {});
  1420. if (self.templateListLoading == false) {
  1421. self.templateListLoading = true;
  1422. request({
  1423. params: params,
  1424. method: 'get',
  1425. }).then(e => {
  1426. self.templateListLoading = false;
  1427. if (e.data.code == 0) {
  1428. self.templateList = e.data.data.list;
  1429. self.pageCount = e.data.data.page_count;
  1430. } else {
  1431. self.$message.error(e.data.msg);
  1432. }
  1433. }).catch(e => {
  1434. self.$message.error(e.data.msg);
  1435. self.templateListLoading = false;
  1436. });
  1437. }
  1438. },
  1439. batchSetTemplate() {
  1440. if (this.chooseList.length <= 0) {
  1441. this.$message.error('请选择要设置广告模板的商品');
  1442. return false;
  1443. }
  1444. this.goodsDialogVisible = true;
  1445. this.getTemplateList();
  1446. },
  1447. syncGoods() {
  1448. if (this.chooseList.length <= 0) {
  1449. this.$message.error('请选择要同步的商品');
  1450. return false;
  1451. }
  1452. this.syncGoods2Store = true;
  1453. this.getStoreList();
  1454. },
  1455. confirmSelectTemplate() {
  1456. if (this.tempory_template_id == 0) {
  1457. this.$message.error('请选择要设置的广告模板');
  1458. return false;
  1459. }
  1460. this.$confirm('确定设置广告模板?', '警告', {
  1461. type: 'warning'
  1462. }).then(() => {
  1463. this.btnLoading = true;
  1464. request({
  1465. params: {
  1466. r: 'mall/goods-template/batch-set'
  1467. },
  1468. method: 'post',
  1469. data: {
  1470. chooseList: this.chooseList,
  1471. template_id: this.tempory_template_id
  1472. }
  1473. }).then(res => {
  1474. if (res.data.code == 0) {
  1475. this.$message.success(res.data.msg);
  1476. } else {
  1477. this.$message.error(res.data.msg);
  1478. }
  1479. self.getList();
  1480. }).catch(err => {
  1481. console.info(err);
  1482. this.goodsDialogVisible = false;
  1483. this.btnLoading = false;
  1484. })
  1485. });
  1486. },
  1487. confirmSyncGoods() {
  1488. if (this.syncType == 0 && this.selectedRowIds.length <= 0) {
  1489. this.$message.error('请选择要同步的门店');
  1490. return false;
  1491. }
  1492. this.$confirm('确定要同步商品到这些门店?', '警告', {
  1493. type: 'warning'
  1494. }).then(() => {
  1495. this.btnLoading = true;
  1496. request({
  1497. params: {
  1498. r: 'mall/goods/sync-goods-store'
  1499. },
  1500. method: 'post',
  1501. data: {
  1502. selected_goods_ids: this.chooseList,
  1503. selected_store_ids: this.selectedRowIds,
  1504. sync_type: this.syncType,
  1505. }
  1506. }).then(res => {
  1507. if (res.data.code == 0) {
  1508. this.$message.success(res.data.msg);
  1509. this.syncGoods2Store = false;
  1510. this.btnLoading = false;
  1511. } else {
  1512. this.$message.error(res.data.msg);
  1513. }
  1514. }).catch(err => {
  1515. console.info(err);
  1516. this.syncGoods2Store = false;
  1517. this.btnLoading = false;
  1518. })
  1519. });
  1520. },
  1521. onCopyAlipayMiniQrCodeUrl(id) {
  1522. let query = encodeURIComponent(`proId=${id}`)
  1523. this.alipay_mini_goods_path = `alipays://platformapi/startapp?appId=${this.alipay_mini_app_id}&page=/plugins/pages/goods/detail&query=${query}`
  1524. this.alipay_goods_path = `&page=/plugins/pages/goods/detail?proId=${id}`
  1525. this.copyAlipayMiniDialogVisible = true;
  1526. },
  1527. onCopyAlipayUrl(str, btn) {
  1528. var clipboard = new Clipboard(`.${btn}`, {
  1529. text: function() {
  1530. return str;
  1531. }
  1532. });
  1533. var self = this;
  1534. clipboard.on('success', function(e) {
  1535. self.$message.success('复制成功');
  1536. e.clearSelection();
  1537. clipboard.destroy()
  1538. });
  1539. clipboard.on('error', function(e) {
  1540. self.$message.error('复制失败,请手动复制');
  1541. });
  1542. },
  1543. getSku(item) {
  1544. this.skuLoading = true;
  1545. request({
  1546. params: {
  1547. r: 'mall/goods/sku',
  1548. id: item.id
  1549. },
  1550. method: 'get',
  1551. }).then(e => {
  1552. this.skuLoading = false;
  1553. if (e.data.code == 0) {
  1554. this.ruleForm.skus = e.data.data
  1555. if (this.ruleForm.skus[0].is_show_code == 1) this.ruleForm.is_show_code = 1;
  1556. } else {
  1557. this.$message.error(e.data.msg);
  1558. }
  1559. }).catch(e => {
  1560. this.$message.error(e.data.msg);
  1561. this.skuLoading = false;
  1562. });
  1563. },
  1564. // 复制首页链接
  1565. copyLink(link) {
  1566. var input = document.getElementById("copy-container");
  1567. input.value = link; // 修改文本框的内容
  1568. input.select(); // 选中文本
  1569. document.execCommand("copy"); // 执行浏览器复制命令
  1570. this.$message.success('复制成功');
  1571. },
  1572. checkboxT(row, index) {
  1573. return !this.syncType
  1574. },
  1575. changeSyncType(val){
  1576. let _this = this
  1577. _this.syncType = val
  1578. if(_this.syncType == 0){
  1579. _this.$refs.multipleTable.clearSelection()
  1580. }
  1581. _this.getStoreList()
  1582. },
  1583. hidePaySuccessSelectJumpUrlDialogVisible() {
  1584. this.paySuccessSelectJumpUrlDialogVisible = false
  1585. },
  1586. onChangeJumpUrl(goods) {
  1587. this.currentItem = goods
  1588. this.paySuccessSelectJumpUrlDialogVisible = true
  1589. },
  1590. openScoreSetting(type){
  1591. if (this.chooseList.length <= 0) {
  1592. this.$message.error('请选择需要设置的商品');
  1593. return false;
  1594. }
  1595. if(type == 1){
  1596. this.goodsScore.goodsScoreDeductVisible = true
  1597. }else if(type == 2){
  1598. this.goodsScore.goodsScoreSetVisible = true
  1599. }
  1600. },
  1601. batchSetGiveScore(type) {
  1602. this.$confirm('确定要设置些商品?', '警告', {
  1603. type: 'warning'
  1604. }).then(() => {
  1605. this.btnLoading = true;
  1606. let data = {
  1607. selected_goods_ids: this.chooseList,
  1608. set_type: type
  1609. }
  1610. if(type == 2){
  1611. Object.assign(data, this.goodsScore.give)
  1612. }else{
  1613. Object.assign(data, this.goodsScore.deduct)
  1614. }
  1615. request({
  1616. params: {
  1617. r: 'mall/goods/batch-set-score'
  1618. },
  1619. method: 'post',
  1620. data
  1621. }).then(res => {
  1622. if (res.data.code == 0) {
  1623. this.$message.success(res.data.msg);
  1624. this.btnLoading = false;
  1625. if(type == 1){
  1626. this.goodsScore.goodsScoreDeductVisible = false
  1627. }else if(type == 2){
  1628. this.goodsScore.goodsScoreSetVisible = false
  1629. }
  1630. } else {
  1631. this.$message.error(res.data.msg);
  1632. }
  1633. }).catch(err => {
  1634. console.info(err);
  1635. this.btnLoading = false;
  1636. if(type == 1){
  1637. this.goodsScore.goodsScoreDeductVisible = false
  1638. }else if(type == 2){
  1639. this.goodsScore.goodsScoreSetVisible = false
  1640. }
  1641. })
  1642. });
  1643. },
  1644. setSkusData() {
  1645. this.$refs['ruleForm'].validate((valid) => {
  1646. if (valid) {
  1647. this.btnLoading = true;
  1648. request({
  1649. params: {
  1650. r: 'mall/goods/set-skus-code',
  1651. },
  1652. method: 'post',
  1653. data: this.ruleForm
  1654. }).then(e => {
  1655. this.btnLoading = false;
  1656. this.skuDialogVisible = false;
  1657. if (e.data.code == 0) {
  1658. this.$message.success(e.data.msg);
  1659. } else {
  1660. this.$message.error(e.data.msg);
  1661. }
  1662. }).catch(e => {
  1663. this.$message.error(e);
  1664. this.btnLoading = false;
  1665. })
  1666. } else {
  1667. this.btnLoading = false;
  1668. console.log('error submit!!');
  1669. return false;
  1670. }
  1671. });
  1672. },
  1673. }
  1674. });
  1675. </script>
  1676. <style>
  1677. @media screen and (max-width: 1500px) {
  1678. #app {
  1679. min-width: 1270px;
  1680. }
  1681. }
  1682. </style>