edit.php 69 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. ComponentHelper::loadComponentView('com-dialog-select');
  4. ComponentHelper::loadComponentView('com-select-cat');
  5. $diyPath = dirname(__DIR__) . '/components';
  6. ComponentHelper::loadComponentView('free-goods-choice', $diyPath);
  7. ComponentHelper::loadComponentView('com-dialog-select-store');
  8. ?>
  9. <div id="app" v-cloak>
  10. <el-card class="box-card" v-loading="cardLoading" shadow="never" style="border:0;min-width: 1200px;"
  11. body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  12. <div slot="header">
  13. <el-breadcrumb separator="/">
  14. <el-breadcrumb-item>
  15. <span style="color: #409EFF;cursor: pointer"
  16. @click="$navigate({r:'cloud-stock/level/index'})">
  17. 代理商等级
  18. </span>
  19. </el-breadcrumb-item>
  20. <el-breadcrumb-item>{{titleName}}</el-breadcrumb-item>
  21. </el-breadcrumb>
  22. </div>
  23. <div class="form-body">
  24. <el-form :model="ruleForm" :rules="rules" size="small" ref="ruleForm" label-width="150px" v-loading="btnLoading">
  25. <el-row>
  26. <el-col :span="24">
  27. <el-form-item label="代理商等级权重" prop="level">
  28. <el-select style="width: 100%" v-model="ruleForm.level" @change="levelChangeFun" placeholder="请选择">
  29. <el-option
  30. v-for="item in weights"
  31. :key="item.level"
  32. :label="item.name"
  33. :value="item.level"
  34. :disabled="item.is_can_choose == 0?true:false">
  35. </el-option>
  36. </el-select>
  37. </el-form-item>
  38. <el-form-item label="代理商等级名称" prop="name">
  39. <el-input v-model="ruleForm.name" placeholder="请输入代理商等级名称" maxlength="10"></el-input>
  40. </el-form-item>
  41. <el-form-item label="代理进货数量限制" prop="name">
  42. <el-switch
  43. v-model="ruleForm.is_open_fill_min"
  44. :active-value="1"
  45. :inactive-value="0">
  46. </el-switch>
  47. <el-input v-model="ruleForm.fill_min" placeholder="请输入限制数量" maxlength="10"></el-input>
  48. </el-form-item>
  49. <el-form-item label="一次性提货数量限制" prop="is_open_fill_min_once">
  50. <el-switch
  51. v-model="ruleForm.is_open_fill_min_once"
  52. :active-value="1"
  53. :inactive-value="0">
  54. </el-switch>
  55. </el-form-item>
  56. <template v-if="ruleForm.is_open_fill_min_once">
  57. <el-form-item label="最低" prop="fill_min_once">
  58. <el-input v-model="ruleForm.fill_min_once" placeholder="请输入限制数量" maxlength="10"></el-input>
  59. </el-form-item>
  60. <el-form-item label="最高" prop="fill_max_once">
  61. <el-input v-model="ruleForm.fill_max_once" placeholder="请输入限制数量" maxlength="10"></el-input>
  62. </el-form-item>
  63. </template>
  64. <el-form-item label="是否开启越级奖" prop="is_over" required>
  65. <el-switch
  66. v-model="ruleForm.is_over"
  67. :active-value="1"
  68. :inactive-value="0">
  69. </el-switch>
  70. </el-form-item>
  71. <el-form-item label="是否开启平级奖" prop="is_equal" required>
  72. <el-switch
  73. v-model="ruleForm.is_equal"
  74. :active-value="1"
  75. :inactive-value="0">
  76. </el-switch>
  77. </el-form-item>
  78. <el-form-item label="补货奖" prop="is_fill" required>
  79. <el-switch
  80. v-model="ruleForm.is_fill"
  81. :active-value="1"
  82. :inactive-value="0">
  83. </el-switch>
  84. </el-form-item>
  85. <template>
  86. <el-form-item label="购买商品升级">
  87. <el-form-item>
  88. <el-switch v-model="ruleForm.upgrade_type_goods" :active-value="1"
  89. :inactive-value="0" active-text="开启" inactive-text="关闭">
  90. </el-switch>
  91. </el-form-item>
  92. <el-form-item v-if="ruleForm.upgrade_type_goods==1">
  93. <el-radio-group v-model="ruleForm.upgrade_goods_list.buy_goods_type">
  94. <el-radio :label="0">订单完成
  95. </el-radio>
  96. <el-radio :label="1">支付完成
  97. </el-radio>
  98. </el-radio-group>
  99. </el-form-item>
  100. <el-form-item v-if="ruleForm.upgrade_type_goods==1">
  101. <el-radio-group v-model="ruleForm.upgrade_goods_list.goods_type">
  102. <el-radio :label="1">任意商品
  103. </el-radio>
  104. <el-radio :label="2">
  105. <div style="display: inline-block;">
  106. <div flex="cross:center">
  107. <div>指定商品</div>
  108. <div style="margin-left: 10px;" v-if="ruleForm.upgrade_goods_list.goods_type==2">
  109. <com-dialog-select :multiple="true" @selected="goodsUpgradeSelect"
  110. title="商品选择">
  111. <el-button type="primary" style="margin-left: 20px;">选择商品</el-button>
  112. </com-dialog-select>
  113. </div>
  114. </div>
  115. </div>
  116. </el-radio>
  117. </el-radio-group>
  118. </el-form-item>
  119. </el-form-item>
  120. <el-form-item prop="goods_ids" v-if="ruleForm.upgrade_type_goods==1">
  121. <template v-if="ruleForm.upgrade_goods_list.goods_type==2">
  122. <div style="color: #ff4544;">最多可添加20个商品</div>
  123. <div style="max-height: 300px;overflow-y: auto">
  124. <el-table :data="ruleForm.upgrade_goods_list.goods_list" border style="100%">
  125. <el-table-column type="index" align="center" label="序号" width="50"></el-table-column>
  126. <el-table-column prop="name,cover_pic" label="商品名称" >
  127. <template slot-scope="scope">
  128. <div flex="box:first">
  129. <div style="padding-right: 10px;">
  130. <com-image mode="aspectFill" :src="scope.row.cover_pic"></com-image>
  131. </div>
  132. <div style="display:flex;flex-direction:column;align-items:flex-start;">
  133. <div>{{scope.row.goods_name}}</div>
  134. </div>
  135. </div>
  136. </template>
  137. </el-table-column>
  138. <el-table-column align="center" label="商品件数" width="200">
  139. <template #header>
  140. <div style="display: flex; align-items: center; justify-content: center;">
  141. <span>商品件数</span>
  142. <el-tooltip class="item" effect="dark" content="开启之后计算以往所有商品购买件数" placement="top">
  143. <i class="el-icon-info" style="margin-right: 5px; margin-bottom: 5px;"></i>
  144. </el-tooltip>
  145. <el-switch v-model="ruleForm.upgrade_goods_list.is_custom_condition_num" :active-value="1" :inactive-value="0">
  146. </el-switch>
  147. </div>
  148. </template>
  149. <template slot-scope="scope">
  150. <el-input-number :disabled="!Number(ruleForm.upgrade_goods_list.is_custom_condition_num)" v-model="scope.row.condition_num" :precision="0" size="mini" :min="1"></el-input-number>
  151. </template>
  152. </el-table-column>
  153. <el-table-column label="操作" width="100">
  154. <template slot-scope="scope">
  155. <el-button @click="deleteUpgradeGoods(scope.$index)" type="primary" size="mini">删除</el-button>
  156. </template>
  157. </el-table-column>
  158. </el-table>
  159. </div>
  160. </template>
  161. </el-form-item>
  162. </template>
  163. <el-form-item label="购买门店商品升级">
  164. <el-form-item>
  165. <el-switch v-model="ruleForm.upgrade_type_store_goods" :active-value="1"
  166. :inactive-value="0" active-text="开启" inactive-text="关闭">
  167. </el-switch>
  168. </el-form-item>
  169. <el-form-item v-if="ruleForm.upgrade_type_store_goods==1">
  170. <el-radio-group v-model="ruleForm.upgrade_store_goods_list.buy_store_goods_type">
  171. <el-radio :label="0">订单完成
  172. </el-radio>
  173. <el-radio :label="1">支付完成
  174. </el-radio>
  175. </el-radio-group>
  176. </el-form-item>
  177. <el-form-item v-if="ruleForm.upgrade_type_store_goods==1">
  178. <el-radio-group v-model="ruleForm.upgrade_store_goods_list.store_goods_type">
  179. <el-radio :label="1">任意商品</el-radio>
  180. <el-radio :label="2">指定商品</el-radio>
  181. </el-radio-group>
  182. <div style="margin-top: 10px; display: flex;" v-if="ruleForm.upgrade_store_goods_list.store_goods_type==2">
  183. <com-dialog-select-store :multiple="true" @selected="storeGoodsSelect" title="商品选择" :is_show_store_name="true" url="store/store-goods/search-with-store">
  184. <el-button type="primary" plain>选择商品</el-button>
  185. </com-dialog-select-store>
  186. <com-dialog-select-store :multiple="true" @selected="storeGoodsSelectDelete" title="批量删除" :is_show_store_name="true" url="store/store-goods/search-with-store">
  187. <el-button type="primary" plain style="margin-left: 10px">批量删除</el-button>
  188. </com-dialog-select-store>
  189. <!-- <div style="color: #ff4544; margin-left: 10px;">最多可添加99个商品</div>-->
  190. </div>
  191. </el-form-item>
  192. </el-form-item>
  193. <el-form-item prop="store_goods_ids" v-if="ruleForm.upgrade_type_store_goods==1">
  194. <template v-if="ruleForm.upgrade_store_goods_list.store_goods_type==2">
  195. <div style="max-height: 300px;overflow-y: auto;width: 60%;">
  196. <el-table :data="ruleForm.upgrade_store_goods_list.store_goods_list" border style="width: 100%">
  197. <el-table-column type="index" align="center" label="序号" width="50"></el-table-column>
  198. <el-table-column prop="id" align="center" label="商品id" width="100"></el-table-column>
  199. <el-table-column prop="name,cover_pic" label="商品名称" >
  200. <template slot-scope="scope">
  201. <div flex="box:first">
  202. <div style="padding-right: 10px;">
  203. <com-image mode="aspectFill" :src="scope.row.cover_pic"></com-image>
  204. </div>
  205. <div style="display:flex;flex-direction:column;align-items:flex-start;">
  206. <div>{{scope.row.name}}</div>
  207. <div>
  208. <span style="color: #ff4544;" v-if="scope.row.price">¥{{ scope.row.price }}</span>
  209. <span style="margin-left: 20px;" v-if="scope.row.stock">库存:{{ scope.row.stock }}</span>
  210. </div>
  211. </div>
  212. </div>
  213. </template>
  214. </el-table-column>
  215. <el-table-column label="操作" width="100">
  216. <template slot-scope="scope">
  217. <el-button @click="deleteStoreGoods(scope.$index)" type="primary" size="mini">删除</el-button>
  218. </template>
  219. </el-table-column>
  220. </el-table>
  221. </div>
  222. </template>
  223. </el-form-item>
  224. <el-form-item label="条件升级">
  225. <el-form-item>
  226. <el-switch
  227. v-model="ruleForm.upgrade_type_condition"
  228. @change="upgradeTypeSwitch"
  229. :active-value="1"
  230. :inactive-value="0"
  231. active-text="开启"
  232. inactive-text="关闭"
  233. >
  234. </el-switch>
  235. </el-form-item>
  236. <el-form-item v-if="ruleForm.upgrade_type_condition==1">
  237. <el-radio-group v-model="ruleForm.condition_type">
  238. <el-radio :label="1">满足其一条件可升级</el-radio>
  239. <el-radio :label="2">满足所有条件可升级</el-radio>
  240. </el-radio-group>
  241. </el-form-item>
  242. <div v-if="ruleForm.upgrade_type_condition==1">
  243. <div style="margin-bottom: 20px;display: flex;">
  244. <el-checkbox v-model="checkbox1isCheck" label="条件1:购买指定商品"></el-checkbox>
  245. <com-dialog-select :multiple="true" @selected="goodsSelect"
  246. title="商品选择">
  247. <el-button v-if="checkbox1isCheck" type="primary" style="margin-left: 20px;">选择商品</el-button>
  248. </com-dialog-select>
  249. </div>
  250. <el-form-item v-if="checkbox1isCheck">
  251. <template>
  252. <div style="color: #ff4544;">最多可添加10个商品 &nbsp;&nbsp; 当前已经选择 <span style="font-size: 18px;">{{ruleForm.goods_list.length}}</span> 个商品</div>
  253. <div style="max-height: 300px;overflow-y: auto" >
  254. <el-table :data="ruleForm.goods_list" border style="width: 100%">
  255. <el-table-column type="index" align="center" label="序号" width="50"></el-table-column>
  256. <el-table-column prop="goods_id" align="center" label="商品id" width="100"></el-table-column>
  257. <el-table-column prop="name,cover_pic" label="商品名称" >
  258. <template slot-scope="scope">
  259. <div flex="box:first">
  260. <div style="padding-right: 10px;">
  261. <com-image mode="aspectFill" :src="scope.row.cover_pic"></com-image>
  262. </div>
  263. <div style="display:flex;flex-direction:column;align-items:flex-start;">
  264. <div>{{scope.row.goods_name}}</div>
  265. <div>
  266. <span style="color: #ff4544;" v-if="scope.row.price">¥{{ scope.row.price }}</span>
  267. <span style="margin-left: 20px;" v-if="scope.row.stock">库存:{{ scope.row.stock }}</span>
  268. </div>
  269. </div>
  270. </div>
  271. </template>
  272. </el-table-column>
  273. <el-table-column label="操作" width="100">
  274. <template slot-scope="scope">
  275. <el-button @click="deleteGoods(scope.$index)" type="primary" size="mini">删除</el-button>
  276. </template>
  277. </el-table-column>
  278. </el-table>
  279. </div>
  280. </template>
  281. </el-form-item>
  282. <el-col>
  283. <el-checkbox v-model="checkbox2isCheck" label="条件2:代理商渠道满足指定人数"></el-checkbox>
  284. <div v-if="checkbox2isCheck" style="margin-left: 23px;" style="background-color: red;">
  285. <div v-for="(item,index) in ruleForm.checked_condition_values[1].value" :key="index" style="margin-bottom: 10px;width: 400px" v-if="item.is_use == 1">
  286. <el-input v-model="item.num" onkeyup="value=value.replace(/[^\d]/g,'')" placeholder="请填入数量"><!-- conditionNum -->
  287. <div slot="prepend"><span style="color:#03C5FF">{{item.name}}</span> 的人数满</div>
  288. <template slot="append">个</template>
  289. </el-input>
  290. </div>
  291. </div>
  292. </el-col>
  293. <div style="display: inline-block;">
  294. <div style="display: flex;">
  295. <el-checkbox v-model="checkbox3isCheck" label="条件3:商品补货升级" @change="editCheckbox3isCheck"></el-checkbox>
  296. <com-dialog-select :multiple="true" @selected="addGoodsTree"
  297. title="商品选择">
  298. <el-button v-if="checkbox3isCheck" style="background: none;border: 0;color: #0373ff;" type="primary" style="margin-left: 20px;">选择商品</el-button>
  299. </com-dialog-select>
  300. </div>
  301. <div style="margin-left: 10px;font-size: 12px;color: #666;margin-left: 20px;">商品补货升级包含云库存代理商在商城购买的商品和云库存补货的商品</div>
  302. </div>
  303. <div v-if="checkbox3isCheck">
  304. <el-radio-group v-if="ruleForm.checked_condition_values[2]" v-model="ruleForm.checked_condition_values[2].radio_type">
  305. <el-radio :label="1">或</el-radio>
  306. <el-radio :label="2">与</el-radio>
  307. </el-radio-group>
  308. <template>
  309. <div style="max-height: 300px;overflow-y: auto;max-width: 514px;" v-if="ruleForm.checked_condition_values[2]">
  310. <el-table ref="goodsInfos" :data="ruleForm.checked_condition_values[2].value" style="width: 100%" @selection-change="selectionGoods">
  311. <el-table-column
  312. type="selection"
  313. width="55"
  314. >
  315. </el-table-column>
  316. <el-table-column
  317. label="商品"
  318. width="200">
  319. <template slot-scope="scope">
  320. <div style="display: flex;align-items: center;">
  321. <el-image style="height:40px;width:40px;min-height:40px;min-width:40px;margin-right:10px;" :src="scope.row.cover_pic"></el-image>
  322. <div>
  323. <div style="color: #000;">{{scope.row.name}}</div>
  324. <div style="font-size: 12px;">
  325. <label>{{scope.row.cost_price}}</label>
  326. -
  327. <label>{{scope.row.original_price}}</label>
  328. </div>
  329. </div>
  330. </div>
  331. </template>
  332. </el-table-column>
  333. <el-table-column
  334. label="数量"
  335. width="120">
  336. <template slot-scope="scope">
  337. <el-input v-model.number="scope.row.num" onkeyup="value=value.replace(/[^\d]/g,'')" style="width: 110px;">
  338. <template slot="append">件</template>
  339. </el-input>
  340. </template>
  341. </el-table-column>
  342. <el-table-column
  343. fixed="right"
  344. label="操作"
  345. width="120">
  346. <template slot-scope="scope">
  347. <el-button
  348. @click.native.prevent="deleteGoodsThree(scope.$index)"
  349. type="text"
  350. size="small">
  351. 删除
  352. </el-button>
  353. </template>
  354. </el-table-column>
  355. </el-table>
  356. </div>
  357. </template>
  358. </div>
  359. <el-col>
  360. <el-checkbox v-model="checkbox4isCheck" label="条件4:渠道补货商品数量达到N件">
  361. </el-checkbox>
  362. <div v-if="checkbox4isCheck" style="margin-left: 23px;" style="background-color: red;">
  363. <el-input v-model="ruleForm.checked_condition_values[3].nums" onkeyup="value=value.replace(/[^\d]/g,'')" placeholder="请填入数量"><!-- conditionNum -->
  364. <template slot="append">件</template>
  365. </el-input>
  366. </div>
  367. </el-col>
  368. <el-col>
  369. <el-checkbox v-model="checkbox5isCheck" label="条件5:直推XX等级N人,且N人中每人伞下产生xx等级N人">
  370. </el-checkbox>
  371. <div v-if="checkbox5isCheck" style="margin-left: 23px;margin-bottom: 10px;">
  372. <span style="margin-right:10px;">直推</span>
  373. <el-select style="width: 150px;" v-model="ruleForm.checked_condition_values[4].level" placeholder="请选择">
  374. <el-option v-for="item in levels" :key="item.level" :label="item.name" :value="item.level">
  375. </el-option>
  376. </el-select>
  377. <span style="margin:0 10px;">数量</span>
  378. <el-input style="width: 150px;" v-model="ruleForm.checked_condition_values[4].nums" type="number">
  379. <template slot="append">个</template>
  380. </el-input>
  381. </div>
  382. <div v-if="checkbox5isCheck" style="margin-left: 23px;" style="background-color: red;">
  383. <span style="margin-right:10px;">伞下</span>
  384. <el-select style="width: 150px;" v-model="ruleForm.checked_condition_values[4].c_level" placeholder="请选择">
  385. <el-option v-for="item in levels" :key="item.level" :label="item.name" :value="item.level">
  386. </el-option>
  387. </el-select>
  388. <span style="margin:0 10px;">数量</span>
  389. <el-input style="width: 150px;" v-model="ruleForm.checked_condition_values[4].c_nums" type="number">
  390. <template slot="append">个</template>
  391. </el-input>
  392. </div>
  393. </el-col>
  394. <el-col>
  395. <el-checkbox v-model="checkbox6isCheck" label="条件6:二二复制XX等级直推XX等级N人,渠道产生xx等级N人">
  396. </el-checkbox>
  397. <div v-if="checkbox6isCheck" style="margin-left: 23px;margin-bottom: 10px;">
  398. <span style="margin-right:10px;">自身等级</span>
  399. <el-select style="width: 150px;" v-model="ruleForm.checked_condition_values[5].self_level" placeholder="请选择">
  400. <el-option v-for="item in double_copy_levels" :key="item.level" :label="item.name" :value="item.level">
  401. </el-option>
  402. </el-select>
  403. </div>
  404. <div v-if="checkbox6isCheck" style="margin-left: 23px;margin-bottom: 10px;">
  405. <span style="margin-right:10px;">直推</span>
  406. <el-select style="width: 150px;" v-model="ruleForm.checked_condition_values[5].level" placeholder="请选择">
  407. <el-option v-for="item in double_copy_levels" :key="item.level" :label="item.name" :value="item.level">
  408. </el-option>
  409. </el-select>
  410. <span style="margin:0 10px;">数量</span>
  411. <el-input style="width: 150px;" v-model="ruleForm.checked_condition_values[5].nums" type="number">
  412. <template slot="append">个</template>
  413. </el-input>
  414. </div>
  415. <div v-if="checkbox6isCheck" style="margin-left: 23px;" style="background-color: red;">
  416. <span style="margin-right:10px;">渠道</span>
  417. <el-select style="width: 150px;" v-model="ruleForm.checked_condition_values[5].c_level" placeholder="请选择">
  418. <el-option v-for="item in double_copy_levels" :key="item.level" :label="item.name" :value="item.level">
  419. </el-option>
  420. </el-select>
  421. <span style="margin:0 10px;">数量</span>
  422. <el-input style="width: 150px;" v-model="ruleForm.checked_condition_values[5].c_nums" type="number">
  423. <template slot="append">个</template>
  424. </el-input>
  425. </div>
  426. </el-col>
  427. <el-col>
  428. <div style="display: flex;">
  429. <el-checkbox v-model="checkbox7isCheck" label="条件7:个人补货指定商品数量,直推指定等级代理N人" @change="editCheckbox3isCheck"></el-checkbox>
  430. <free-goods-choice :multiple="true" @selected="addGoodsTree7"
  431. title="商品选择">
  432. <el-button v-if="checkbox7isCheck" style="background: none;border: 0;color: #0373ff;" type="primary" style="margin-left: 20px;">选择商品</el-button>
  433. </free-goods-choice>
  434. </div>
  435. <div v-if="checkbox7isCheck">
  436. <template>
  437. <div style="max-height: 300px;overflow-y: auto;max-width: 514px;" v-if="ruleForm.checked_condition_values[6]">
  438. <el-table ref="goodsInfos7" :data="ruleForm.checked_condition_values[6].value" style="width: 100%" @selection-change="selectionGoods7">
  439. <el-table-column
  440. type="selection"
  441. width="55"
  442. >
  443. </el-table-column>
  444. <el-table-column
  445. label="商品"
  446. width="200">
  447. <template slot-scope="scope">
  448. <div style="display: flex;align-items: center;">
  449. <el-image style="height:40px;width:40px;min-height:40px;min-width:40px;" :src="scope.row.cover_pic"></el-image>
  450. <div>
  451. <div style="color: #000;">{{scope.row.name}}</div>
  452. </div>
  453. </div>
  454. </template>
  455. </el-table-column>
  456. <el-table-column
  457. fixed="right"
  458. label="操作"
  459. width="120">
  460. <template slot-scope="scope">
  461. <el-button
  462. @click.native.prevent="deleteGoodsThree7(scope.$index)"
  463. type="text"
  464. size="small">
  465. 删除
  466. </el-button>
  467. </template>
  468. </el-table-column>
  469. </el-table>
  470. </div>
  471. </template>
  472. </div>
  473. <div v-if="checkbox7isCheck" style="margin-top: 10px;" style="background-color: red;">
  474. <span style="margin-right:10px;">合计补货数量</span>
  475. <el-input style="width: 300px;" v-model="ruleForm.checked_condition_values[6].num" type="number">
  476. <template slot="append">个</template>
  477. </el-input>
  478. </div>
  479. <div v-if="checkbox7isCheck" style="margin-left: 23px;margin: 10px 0;">
  480. <span style="margin-right:10px;">直推</span>
  481. <el-select style="width: 150px;" v-model="ruleForm.checked_condition_values[6].level" placeholder="请选择">
  482. <el-option v-for="item in levels" :key="item.level" :label="item.name" :value="item.level">
  483. </el-option>
  484. </el-select>
  485. <span style="margin:0 10px;">数量</span>
  486. <el-input style="width: 150px;" v-model="ruleForm.checked_condition_values[6].nums" type="number">
  487. <template slot="append">个</template>
  488. </el-input>
  489. </div>
  490. </el-col>
  491. <el-col>
  492. <el-checkbox v-model="checkbox8isCheck" label="条件8:所有商品进货金额累计达到N元">
  493. </el-checkbox>
  494. <div v-if="checkbox8isCheck" style="margin-left: 23px;" style="background-color: red;">
  495. <el-input v-model="ruleForm.checked_condition_values[7].nums" onkeyup="value=value.replace(/[^\d]/g,'')" placeholder="请填入数量">
  496. <template slot="append">元</template>
  497. </el-input>
  498. </div>
  499. </el-col>
  500. </div>
  501. </el-form-item>
  502. <el-form-item label="赠送等级" v-if="ruleForm.give_quota.length && is_show_give">
  503. <div style="display: flex;flex-wrap: wrap;width: 400px;justify-content: space-between;">
  504. <el-input v-for="(item,index) in ruleForm.give_quota" v-if="item.is_use == 1" :key="index" v-model="item.num" style="margin-top: 10px;" placeholder="请填入数量" onkeyup="value=value.replace(/[^\d]/g,'')">
  505. <div slot="prepend"><span style="color:#03C5FF">{{item.name}}</span> 赠送</div><!-- 因为这里的等级名称长度不确定 不能固定input的长度 prepend文字不会换行 所以input竖着排列 -->
  506. <template slot="append">个</template>
  507. </el-input>
  508. </div>
  509. </el-form-item>
  510. <el-form-item label="是否启用" prop="status">
  511. <el-switch
  512. v-model="ruleForm.status"
  513. :active-value="1"
  514. :inactive-value="0">
  515. </el-switch>
  516. </el-form-item>
  517. <el-form-item label="等级说明" >
  518. <el-input
  519. type="textarea"
  520. :autosize="{ minRows: 4, maxRows: 4}"
  521. placeholder="请输入等级说明"
  522. v-model="ruleForm.detail">
  523. </el-input>
  524. </el-form-item>
  525. </el-col>
  526. </el-row>
  527. </el-form>
  528. </div>
  529. <el-button class="button-item" :loading="btnLoading" type="primary" @click="saveFun"
  530. size="small">保存
  531. </el-button>
  532. </el-card>
  533. </div>
  534. <script>
  535. const app = new Vue({
  536. el: '#app',
  537. data() {
  538. return {
  539. titleName:'添加代理商等级',
  540. msg: 1,
  541. options: [],//会员等级列表
  542. enable_level_list:[], //可用等级列表
  543. level: 0,
  544. form: {
  545. type: [],
  546. },
  547. checked_condition_keys: [],
  548. showConditionMsg: false,
  549. conditionMsg: '',
  550. weights: [],//等级权重列表
  551. ruleForm: {
  552. id:'',
  553. level: '',//权重 1 2 3等
  554. name: '',
  555. is_open_fill_min: 0,
  556. fill_min: 0,
  557. status: 1,
  558. is_equal: 1,
  559. is_over: 1,
  560. is_fill: 1,
  561. condition_type: 1,//1=满足其一可升级 2=满足所有条件可升级
  562. service_price: 0,
  563. is_auto_upgrade: 1,
  564. service_price_type: 0,
  565. upgrade_type_condition: 0,//条件升级
  566. sub_stock_rate: 100,
  567. rule: '',
  568. checked_condition_keys: [],//升级条件选中的key集合 ["0","1"]
  569. goodsNum:1,//指定购买商品的数量
  570. detail:'',//等级说明
  571. checked_condition_values:[//条件升级的数据upgradeData
  572. {"key":"0","value":[]},//{"goods_id":1},{"goods_id":2}条件1的数据 商品的数据id列表
  573. {"key":"1","value":[]},//{"level":1,"num":2},{"level":2,"num":3}条件2的数据 等级id和人数
  574. {"key":"2","value":[]},
  575. {"key":"3","value":[]},
  576. {"key":"4","value":[]},
  577. {"key":"5","value":[]},
  578. {"key":"6","value":[]},
  579. {"key":"7","value":[]},
  580. ],
  581. goods_list:[],
  582. give_quota:[],
  583. is_open_fill_min_once:0,
  584. fill_min_once:0,
  585. fill_max_once:0,
  586. upgrade_type_goods: 0, // 是否开启购买商品升级
  587. upgrade_goods_list: {
  588. buy_goods_type: 0, // 支付类型0订单完成1订单支付完成
  589. goods_type: 1, // 商品类型1任意商品 2 指定商品
  590. goods_list: [],
  591. goods_ids: [],
  592. },
  593. upgrade_type_store_goods:0,
  594. upgrade_store_goods_list: {
  595. buy_store_goods_type:0, // 支付类型0订单完成1订单支付完成
  596. store_goods_type: 1, // 门店商品类型1任意商品 2 指定商品
  597. store_goods_ids:[],
  598. store_goods_list:[],
  599. },
  600. },
  601. rules: {
  602. level: [
  603. {required: true, message: '请选择代理商等级', trigger: 'change'},
  604. ],
  605. name: [
  606. {required: true, message: '请输入代理商等级名称', trigger: 'change'},
  607. ],
  608. is_use: [
  609. {required: true, message: '请选择代理商等级状态', trigger: 'change'},
  610. ],
  611. detail: [
  612. {required: true, message: '等级说明不能为空', trigger: 'change'},
  613. ],
  614. },
  615. btnLoading: false,
  616. cardLoading: false,
  617. checkList:[],
  618. checkbox1isCheck:false,//条件1 购买指定商品 是否勾选
  619. checkbox2isCheck:false,//条件2 代理商渠道满足指定的人数 是否勾选
  620. checkbox3isCheck: false, //条件3 商品补货升级
  621. checkbox4isCheck: false, //条件4 商品补货升级
  622. checkbox5isCheck:false,//条件5 伞下渠道等级数量升级
  623. checkbox6isCheck:false,//条件6 伞下二二复制等级数量升级
  624. checkbox7isCheck:false,//条件7 个人补货指定商品
  625. checkbox8isCheck:false,//条件8 所有商品进货金额累计达到N元
  626. goods:null,
  627. conditionNum:'',//条件2 代理商权重指定满足的人数
  628. //lowerLevel:[],//比当前选中的等级低的等级列表
  629. is_show_give:true,
  630. getWeightsLevel:'', //编辑的时候传进来的level
  631. radio_type: 1,
  632. goodsInfos: [],//商品假数据
  633. levels:[],
  634. double_copy_levels:[],
  635. };
  636. },
  637. mounted() {
  638. if (getQuery('id')) {
  639. this.titleName="编辑代理商等级";
  640. this.getWeightsLevel = getQuery('level');
  641. this.loadData();//请求详情的数据
  642. }
  643. this.getWeights();//获取权重列表
  644. this.getLevelList();//获取等级列表
  645. this.getDoubleCopyLevelList();//获取等级列表
  646. },
  647. methods: {
  648. getWeights(){
  649. let that = this;
  650. request({
  651. params: {
  652. r: 'cloud-stock/level/get-can-choose-level-list',
  653. level:this.getWeightsLevel
  654. },
  655. method: 'get',
  656. }).then(e => {
  657. if(e.data.code == 0){
  658. that.weights = e.data.data;
  659. }else{
  660. that.$message.error(e.data.msg);
  661. }
  662. }).catch(e => {
  663. console.log(e);
  664. });
  665. },
  666. close(e) {
  667. this.visible = false;
  668. },
  669. levelChangeFun(e){
  670. this.getLowerLevel();//获取代理商等级下级等级列表
  671. },
  672. getLowerLevel(){//获取代理商等级下级等级列表
  673. request({
  674. params: {
  675. r: 'cloud-stock/level/get-less-level-list',
  676. level:this.ruleForm.level
  677. },
  678. method: 'get',
  679. }).then(e => {
  680. if(e.data.code == 0){
  681. let arr = e.data.data;
  682. arr.forEach((item,index)=>{
  683. item.num = '';
  684. })
  685. this.ruleForm.give_quota = arr;
  686. /* 判断是否显示 等级赠送 start */
  687. let arr2 = [];
  688. arr2 = this.ruleForm.give_quota.filter((item)=>{
  689. return item.is_use == 1;
  690. })
  691. if(arr2.length){
  692. this.is_show_give=true;
  693. }else{
  694. this.is_show_give=false;
  695. }
  696. console.log(arr2.length)
  697. console.log(this.is_show_give)
  698. /* 判断是否显示 等级赠送 end */
  699. this.ruleForm.checked_condition_values[1].value = JSON.parse(JSON.stringify(arr))
  700. }else{
  701. this.$message.error(e.data.msg);
  702. }
  703. }).catch(e => {
  704. console.log(e);
  705. });
  706. },
  707. saveFun(){
  708. //console.log('请求了保存的函数')
  709. this.ruleForm.checked_condition_keys = [];
  710. if(this.checkbox1isCheck){//条件1 购买指定商品 是否勾选
  711. this.ruleForm.checked_condition_keys.push("0");
  712. }
  713. if(this.checkbox2isCheck){//条件2 代理商渠道满足指定的人数 是否勾选
  714. this.ruleForm.checked_condition_keys.push("1");
  715. }
  716. if(this.checkbox3isCheck){
  717. this.ruleForm.checked_condition_keys.push("2");
  718. }
  719. if(this.checkbox4isCheck){
  720. this.ruleForm.checked_condition_keys.push("3");
  721. }
  722. if(this.checkbox5isCheck){
  723. this.ruleForm.checked_condition_keys.push("4");
  724. }
  725. if(this.checkbox6isCheck){
  726. this.ruleForm.checked_condition_keys.push("5");
  727. }
  728. if(this.checkbox7isCheck){
  729. this.ruleForm.checked_condition_keys.push("6");
  730. }
  731. if(this.checkbox8isCheck){
  732. this.ruleForm.checked_condition_keys.push("7");
  733. }
  734. if(this.ruleForm.level == ''){
  735. return this.$message.error('请选择代理商等级权重');
  736. }
  737. if(this.ruleForm.name == ''){
  738. return this.$message.error('请输入代理商等级名称');
  739. }
  740. if(this.ruleForm.upgrade_type_condition == 1){//勾选了条件升级
  741. if(!this.ruleForm.checked_condition_keys.length){//为空数组 没有勾选任何一个条件
  742. return this.$message.error('请勾选升级条件');
  743. }
  744. if(this.ruleForm.condition_type == 1 && this.ruleForm.checked_condition_keys.length == 0){//选择了满足其一条件
  745. return this.$message.error('请填写其中一个升级条件');
  746. }
  747. /* if(this.ruleForm.condition_type == 2 && this.ruleForm.checked_condition_keys.length == 1){//选择了满足所有条件
  748. return this.$message.error('请勾选升级条件1和条件2');
  749. } */
  750. if(this.checkbox1isCheck && !this.ruleForm.goods_list.length){//勾选条件1 没有选择商品
  751. return this.$message.error('请选择商品');
  752. }
  753. /* if(this.checkbox1isCheck && this.ruleForm.upgradeData[0].value.val1 <= 0){//勾选条件1 商品数量不对
  754. return this.$message.error('请填写正确的商品数量');
  755. } */
  756. if(this.checkbox2isCheck){//勾选条件2 但是没有可用下级代理商列表
  757. let is_use_arr = [];
  758. let judge_arr = [];
  759. is_use_arr = this.ruleForm.checked_condition_values[1].value.filter((item)=>{
  760. return item.is_use == 1
  761. })
  762. judge_arr = this.ruleForm.checked_condition_values[1].value.filter((item)=>{
  763. return item.num == '' || item.num == 0
  764. })
  765. //console.log('judge_arr='+JSON.stringify(judge_arr))
  766. if(is_use_arr.length == 0){
  767. return this.$message.error('升级条件2暂不可选');
  768. }
  769. if(judge_arr.length == this.ruleForm.checked_condition_values[1].value.length){
  770. return this.$message.error('升级条件2:代理商渠道指定满足的人数,至少填一个大于0的数字');
  771. }
  772. }
  773. }
  774. for(var i=0;i<this.ruleForm.checked_condition_values[1].value.length;i++){
  775. if(this.ruleForm.checked_condition_values[1].value[i].num < 0){
  776. return this.$message.error('请正确填写升级条件2的数据');
  777. break;
  778. }
  779. }
  780. for(var i=0;i<this.ruleForm.give_quota.length;i++){
  781. if(this.ruleForm.give_quota[i].num < 0){
  782. return this.$message.error('赠送等级:请填写正确的赠送数量');
  783. break;
  784. }
  785. }
  786. //let give_quota_arr=[];
  787. this.ruleForm.give_quota.forEach((item,index)=>{
  788. if(item.num == ''){
  789. item.num = 0
  790. }
  791. /* let obj ={
  792. level:item.level,
  793. num:item.num
  794. }
  795. give_quota_arr.push(obj) */
  796. })
  797. //console.log('赠送名额='+JSON.stringify(give_quota_arr))
  798. this.ruleForm.checked_condition_values[1].value.forEach((item,index)=>{
  799. if(item.num == ''){
  800. item.num = 0
  801. }
  802. })
  803. if (this.ruleForm.upgrade_store_goods_list.store_goods_type == 1) {
  804. this.ruleForm.upgrade_store_goods_list.store_goods_ids = [];
  805. this.ruleForm.upgrade_store_goods_list.store_goods_list = [];
  806. }
  807. let submitObj={};//提交给后台的对象
  808. submitObj.level = this.ruleForm.level;
  809. submitObj.name = this.ruleForm.name;
  810. submitObj.fill_min = this.ruleForm.fill_min;
  811. submitObj.is_open_fill_min = this.ruleForm.is_open_fill_min;
  812. submitObj.is_use = this.ruleForm.is_use;
  813. submitObj.checked_condition_keys = JSON.stringify(this.ruleForm.checked_condition_keys);
  814. submitObj.condition_type = this.ruleForm.condition_type;
  815. submitObj.checked_condition_values =JSON.stringify(this.ruleForm.checked_condition_values);
  816. submitObj.give_quota =JSON.stringify(this.ruleForm.give_quota);
  817. submitObj.is_over = this.ruleForm.is_over;
  818. submitObj.is_equal = this.ruleForm.is_equal;
  819. submitObj.is_fill = this.ruleForm.is_fill;
  820. submitObj.upgrade_type_condition = this.ruleForm.upgrade_type_condition;
  821. submitObj.detail = this.ruleForm.detail;
  822. submitObj.status = this.ruleForm.status;
  823. submitObj.is_open_fill_min_once = this.ruleForm.is_open_fill_min_once;
  824. submitObj.fill_min_once = this.ruleForm.fill_min_once;
  825. submitObj.fill_max_once = this.ruleForm.fill_max_once;
  826. submitObj.upgrade_type_goods = this.ruleForm.upgrade_type_goods;
  827. submitObj.upgrade_goods_list = JSON.stringify(this.ruleForm.upgrade_goods_list);
  828. submitObj.upgrade_type_store_goods = this.ruleForm.upgrade_type_store_goods;
  829. submitObj.upgrade_store_goods_list = JSON.stringify(this.ruleForm.upgrade_store_goods_list);
  830. if(getQuery('id')){
  831. submitObj.id = this.ruleForm.id
  832. }
  833. this.btnLoading = true;
  834. request({
  835. params: {
  836. r: 'cloud-stock/level/edit'
  837. },
  838. method: 'post',
  839. data:submitObj
  840. }).then(e => {
  841. this.btnLoading = false;
  842. if (e.data.code == 0) {
  843. this.$message.success('保存成功');
  844. navigateTo({
  845. r: 'cloud-stock/level/index'
  846. })
  847. } else {
  848. this.$message.error(e.data.msg);
  849. }
  850. }).catch(e => {
  851. this.$message.error(e.data.msg);
  852. this.btnLoading = false;
  853. });
  854. },
  855. submitForm(formName) {
  856. let self = this;
  857. self.showConditionMsg = false;
  858. if (this.ruleForm.upgrade_type_condition == 1) {
  859. if (this.ruleForm.checked_condition_keys.length == 0) {
  860. this.$message.error('请完善升级条件');
  861. return;
  862. }
  863. let checked_condition_values = this.ruleForm.checked_condition_values;
  864. this.ruleForm.checked_condition_keys.forEach(v => {
  865. self.conditionMsg = '请完善条件:' + (parseInt(v) + 1);
  866. if (v == 0) {
  867. if (!checked_condition_values[v].value.val || !checked_condition_values[v].value.val1) {
  868. self.showConditionMsg = true;
  869. return;
  870. }
  871. }
  872. if (v > 0) {
  873. if (!checked_condition_values[v].value.val) {
  874. self.showConditionMsg = true;
  875. return;
  876. }
  877. }
  878. })
  879. if (self.showConditionMsg) {
  880. return
  881. }
  882. if (this.ruleForm.checked_condition_keys.length > 0) {
  883. if (this.ruleForm.condition_type == 0) {
  884. this.$message.error('请选择条件升级的方式升级类型');
  885. return;
  886. }
  887. }
  888. }
  889. this.$refs[formName].validate((valid) => {
  890. if (valid) {
  891. self.btnLoading = true;
  892. request({
  893. params: {
  894. r: 'plugin/stock/mall/level/edit'
  895. },
  896. method: 'post',
  897. data: {
  898. form: self.ruleForm,
  899. }
  900. }).then(e => {
  901. self.btnLoading = false;
  902. if (e.data.code == 0) {
  903. self.$message.success(e.data.msg);
  904. navigateTo({
  905. r: 'plugin/stock/mall/level/index'
  906. })
  907. } else {
  908. self.$message.error(e.data.msg);
  909. }
  910. }).catch(e => {
  911. self.$message.error(e.data.msg);
  912. self.btnLoading = false;
  913. });
  914. } else {
  915. console.log('error submit!!');
  916. return false;
  917. }
  918. });
  919. },
  920. loadData() {//请求详情的数据
  921. this.cardLoading = true;
  922. //console.log('请求详情前的参数=='+getQuery('id'))
  923. request({
  924. params: {
  925. r: 'cloud-stock/level/edit',//'plugin/stock/mall/level/edit',
  926. id: getQuery('id'),
  927. },
  928. method: 'get'
  929. }).then(e => {
  930. this.cardLoading = false;
  931. //console.log('请求详情的结果='+JSON.stringify(e))
  932. if (e.data.code == 0) {
  933. let data = e.data.data;
  934. this.ruleForm.id = data.id;
  935. this.ruleForm.level = data.level;
  936. this.ruleForm.name = data.name;
  937. this.ruleForm.is_open_fill_min = data.is_open_fill_min;
  938. this.ruleForm.fill_min = data.fill_min;
  939. this.ruleForm.status = data.status;
  940. this.ruleForm.checked_condition_keys = data.checked_condition_keys;
  941. this.ruleForm.checked_condition_keys.forEach((item)=>{
  942. if(item == 0){
  943. this.checkbox1isCheck = true;
  944. }
  945. if(item == 1){
  946. this.checkbox2isCheck = true;
  947. }
  948. if(item == 2){
  949. this.checkbox3isCheck = true;
  950. localStorage.setItem("booType",1);
  951. this.editCheckbox3isCheck(true);
  952. }
  953. if(item == 3){
  954. this.checkbox4isCheck = true;
  955. }
  956. if(item == 4){
  957. this.checkbox5isCheck = true;
  958. }
  959. if(item == 5){
  960. this.checkbox6isCheck = true;
  961. }
  962. if(item == 6){
  963. this.checkbox7isCheck = true;
  964. localStorage.setItem("booType7",1);
  965. this.editCheckbox7isCheck(true);
  966. }
  967. if(item == 7){
  968. this.checkbox8isCheck = true;
  969. }
  970. })
  971. this.ruleForm.condition_type = data.condition_type;
  972. this.ruleForm.goods_list = data.checked_condition_values[0].value;//给商品进行赋值
  973. if(!data.checked_condition_values[2]){
  974. data.checked_condition_values.push({
  975. key: 2,
  976. radio_type: 1,
  977. value: []
  978. })
  979. }
  980. if(data.checked_condition_values[2] && data.checked_condition_values[2].value){
  981. data.checked_condition_values[2].value.forEach(v => {
  982. if(typeof(v.num) == "undefined"){
  983. this.$set(v,'num',1);
  984. }
  985. })
  986. }
  987. this.ruleForm.checked_condition_values = data.checked_condition_values;
  988. // 判断商品升级条件
  989. this.ruleForm.upgrade_type_goods = data.upgrade_type_goods ?? 0;
  990. let goods_list = data.upgrade_goods_list;
  991. if (goods_list.length > 0) {
  992. this.ruleForm.upgrade_goods_list = JSON.parse(goods_list);
  993. }
  994. // 判断门店商品升级条件
  995. this.ruleForm.upgrade_type_store_goods = data.upgrade_type_store_goods ?? 0;
  996. let store_goods_list = data.upgrade_store_goods_list;
  997. if (store_goods_list.length > 0) {
  998. this.ruleForm.upgrade_store_goods_list = JSON.parse(store_goods_list);
  999. }
  1000. let arr = [];
  1001. this.ruleForm.checked_condition_values[0].value.forEach((item)=>{
  1002. let obj={
  1003. goods_id:item.goods_id,
  1004. cover_pic:item.cover_pic,
  1005. goods_name:item.goods_name,
  1006. price:item.price,
  1007. stock:item.stock
  1008. }
  1009. arr.push(obj)
  1010. })
  1011. this.ruleForm.checked_condition_values[0].value = arr;
  1012. /* end */
  1013. this.ruleForm.give_quota = data.give_quota;
  1014. /* 判断是否显示 等级赠送 start */
  1015. let arr2 = [];
  1016. arr2 = this.ruleForm.give_quota.filter((item)=>{
  1017. return item.is_use == 1;
  1018. })
  1019. if(arr2.length){
  1020. this.is_show_give=true;
  1021. }else{
  1022. this.is_show_give=false;
  1023. }
  1024. this.ruleForm.is_over = data.is_over;
  1025. this.ruleForm.is_equal = data.is_equal;
  1026. this.ruleForm.is_fill = data.is_fill;
  1027. this.ruleForm.upgrade_type_condition = data.upgrade_type_condition;
  1028. this.ruleForm.detail = data.detail;
  1029. this.ruleForm.is_open_fill_min_once = data.is_open_fill_min_once;
  1030. this.ruleForm.fill_min_once = data.fill_min_once;
  1031. this.ruleForm.fill_max_once = data.fill_max_once;
  1032. } else {
  1033. this.$message.error(e.data.msg);
  1034. }
  1035. }).catch(e => {
  1036. console.log(e);
  1037. });
  1038. },
  1039. goodsSelect(param){
  1040. for (let j in param) {
  1041. let item = param[j];
  1042. if (this.ruleForm.goods_list.length >= 10) {
  1043. this.$message.error('指定商品不能大于10个');
  1044. return;
  1045. }
  1046. let flag = true;
  1047. for (let i in this.ruleForm.checked_condition_values[0].value) {
  1048. if (this.ruleForm.checked_condition_values[0].value[i].goods_id == item.id) {
  1049. flag = false;
  1050. break;
  1051. }
  1052. }
  1053. if (flag) {
  1054. let obj={};
  1055. obj.goods_id = item.id;
  1056. obj.goods_name = item.goods_name;
  1057. obj.cover_pic = item.cover_pic;
  1058. obj.price = item.price;
  1059. obj.stock = item.stock;
  1060. obj.stock = item.stock;
  1061. this.ruleForm.checked_condition_values[0].value.push(obj);
  1062. this.ruleForm.goods_list.push({
  1063. goods_id: item.id,
  1064. goods_name: item.goods_name,
  1065. cover_pic: item.cover_pic,
  1066. price: item.price,
  1067. stock: item.stock,
  1068. });
  1069. }
  1070. }
  1071. },
  1072. deleteGoods(index) {
  1073. //this.goods = null;
  1074. this.ruleForm.checked_condition_values[0].value.splice(index, 1);
  1075. this.ruleForm.goods_list.splice(index, 1);
  1076. },
  1077. goodsUpgradeSelect(param){
  1078. for (let j in param) {
  1079. let item = param[j];
  1080. if (this.ruleForm.upgrade_goods_list.goods_list.length >= 20) {
  1081. this.$message.error('指定商品不能大于20个');
  1082. return;
  1083. }
  1084. // 判断当前商品是否已经存在
  1085. if (this.ruleForm.upgrade_goods_list.goods_ids.includes(item.id)){
  1086. continue;
  1087. }
  1088. let obj={};
  1089. obj.goods_id = item.id;
  1090. obj.goods_name = item.goods_name;
  1091. obj.cover_pic = item.cover_pic;
  1092. obj.price = item.price;
  1093. obj.stock = item.stock;
  1094. obj.condition_num = 1;
  1095. this.ruleForm.upgrade_goods_list.goods_ids.push(item.id);
  1096. this.ruleForm.upgrade_goods_list.goods_list.push({
  1097. goods_id: item.id,
  1098. goods_name: item.goods_name,
  1099. cover_pic: item.cover_pic,
  1100. price: item.price,
  1101. stock: item.stock,
  1102. condition_num: 1,
  1103. });
  1104. console.log("ggggggvv",this.ruleForm.upgrade_goods_list)
  1105. }
  1106. },
  1107. deleteUpgradeGoods(index) {
  1108. //this.goods = null;
  1109. this.ruleForm.upgrade_goods_list.goods_ids.splice(index, 1);
  1110. this.ruleForm.upgrade_goods_list.goods_list.splice(index, 1);
  1111. },
  1112. deleteGoodsThree(index) {
  1113. this.ruleForm.checked_condition_values[2].value.splice(index, 1);
  1114. },
  1115. addGoodsTree(param){
  1116. for (let j in param) {
  1117. let item = param[j];
  1118. let obj = {
  1119. id: item.id,
  1120. name: item.goods_name,
  1121. cover_pic: item.cover_pic,
  1122. cost_price: item.cost_price,
  1123. original_price: item.original_price,
  1124. }
  1125. this.$set(obj,'num',1);
  1126. this.ruleForm.checked_condition_values[2].value.push(obj);
  1127. console.info(this.ruleForm.checked_condition_values[2]);
  1128. }
  1129. console.log(obj);
  1130. },
  1131. selectionGoods(val){
  1132. let boo = localStorage.getItem("booType");
  1133. if(boo) return;
  1134. let that = this;
  1135. this.ruleForm.checked_condition_values[2].value.forEach((v,i) => {
  1136. let index = val.findIndex(vv => vv.id == v.id);
  1137. if(index != -1){
  1138. v.isSelected = true;
  1139. }else{
  1140. v.isSelected = false;
  1141. }
  1142. })
  1143. },
  1144. editCheckbox3isCheck(v){
  1145. if(v){
  1146. // 等模板渲染完毕再加载
  1147. this.$nextTick( () => {
  1148. console.info(this.$refs,this.ruleForm.checked_condition_values[2].value);
  1149. if(!this.ruleForm.checked_condition_values[2]) return
  1150. this.ruleForm.checked_condition_values[2].value.forEach((v,i) => {
  1151. if (v.isSelected) {
  1152. this.$refs.goodsInfos.toggleRowSelection(v);
  1153. }else {
  1154. this.$refs.goodsInfos.clearSelection();
  1155. }
  1156. })
  1157. localStorage.removeItem("booType");
  1158. })
  1159. }
  1160. },
  1161. upgradeTypeSwitch(boo){
  1162. if(boo == 1 && this.checkbox3isCheck){
  1163. this.editCheckbox3isCheck(true)
  1164. }
  1165. },
  1166. deleteGoodsThree7(index) {
  1167. this.ruleForm.checked_condition_values[6].value.splice(index, 1);
  1168. },
  1169. addGoodsTree7(param){
  1170. for (let j in param) {
  1171. let item = param[j];
  1172. let obj = {
  1173. id: item.id,
  1174. goods_id:item.goods_id,
  1175. name: item.goods_name,
  1176. cover_pic: item.cover_pic,
  1177. cost_price: item.cost_price,
  1178. original_price: item.original_price,
  1179. }
  1180. this.$set(obj,'num',1);
  1181. if(!this.ruleForm.checked_condition_values[6].value){
  1182. this.ruleForm.checked_condition_values[6].value = [];
  1183. }
  1184. this.ruleForm.checked_condition_values[6].value.push(obj);
  1185. console.info(this.ruleForm.checked_condition_values[6]);
  1186. }
  1187. console.log(obj);
  1188. },
  1189. selectionGoods7(val){
  1190. let boo = localStorage.getItem("booType7");
  1191. if(boo) return;
  1192. let that = this;
  1193. this.ruleForm.checked_condition_values[6].value.forEach((v,i) => {
  1194. let index = val.findIndex(vv => vv.id == v.id);
  1195. if(index != -1){
  1196. v.isSelected = true;
  1197. }else{
  1198. v.isSelected = false;
  1199. }
  1200. })
  1201. },
  1202. editCheckbox7isCheck(v){
  1203. if(v){
  1204. // 等模板渲染完毕再加载
  1205. this.$nextTick( () => {
  1206. console.info(this.$refs,this.ruleForm.checked_condition_values[6].value);
  1207. if(!this.ruleForm.checked_condition_values[6]) return
  1208. this.ruleForm.checked_condition_values[6].value.forEach((v,i) => {
  1209. if (v.isSelected) {
  1210. this.$refs.goodsInfos7.toggleRowSelection(v);
  1211. }else {
  1212. this.$refs.goodsInfos7.clearSelection();
  1213. }
  1214. })
  1215. localStorage.removeItem("booType7");
  1216. })
  1217. }
  1218. },
  1219. upgradeTypeSwitch(boo){
  1220. if(boo == 1 && this.checkbox7isCheck){
  1221. this.editCheckbox7isCheck(true)
  1222. }
  1223. },
  1224. getLevelList(){//获取二二复制等级下级等级列表
  1225. request({
  1226. params: {
  1227. r: 'cloud-stock/level/get-level-list',
  1228. },
  1229. method: 'get',
  1230. }).then(e => {
  1231. if(e.data.code == 0){
  1232. this.levels = e.data.data;
  1233. }else{
  1234. this.$message.error(e.data.msg);
  1235. }
  1236. }).catch(e => {
  1237. console.log(e);
  1238. });
  1239. },
  1240. getDoubleCopyLevelList(){//获取代理商等级下级等级列表
  1241. request({
  1242. params: {
  1243. r: 'cloud-stock/level/get-double-copy-level-list',
  1244. },
  1245. method: 'get',
  1246. }).then(e => {
  1247. if(e.data.code == 0){
  1248. this.double_copy_levels = e.data.data;
  1249. }else{
  1250. this.$message.error(e.data.msg);
  1251. }
  1252. }).catch(e => {
  1253. console.log(e);
  1254. });
  1255. },
  1256. //选择商品
  1257. storeGoodsSelect(param) {
  1258. for (let j in param) {
  1259. let item = param[j];
  1260. // if (this.ruleForm.upgrade_store_goods_list.store_goods_ids.length >= 99) {
  1261. // this.$message.error('指定商品不能大于99个');
  1262. // return;
  1263. // }
  1264. let flag = true;
  1265. for (let i in this.ruleForm.upgrade_store_goods_list.store_goods_ids) {
  1266. if (this.ruleForm.upgrade_store_goods_list.store_goods_ids[i] == param[j].id) {
  1267. flag = false;
  1268. break;
  1269. }
  1270. }
  1271. if (flag) {
  1272. this.ruleForm.upgrade_store_goods_list.store_goods_ids.push(param[j].id);
  1273. this.ruleForm.upgrade_store_goods_list.store_goods_list.push({
  1274. id: param[j].id,
  1275. name: param[j].goods_name,
  1276. cover_pic: param[j].cover_pic,
  1277. price: param[j].price,
  1278. stock: param[j].stock,
  1279. });
  1280. }
  1281. }
  1282. console.log('选择商品 ======>' ,this.ruleForm.store_goods_list);
  1283. },
  1284. //批量删除商品
  1285. storeGoodsSelectDelete(param) {
  1286. if (param === undefined || param.length === 0) {
  1287. alert('未勾选商品');
  1288. } else {
  1289. let store_goods_ids = this.ruleForm.upgrade_store_goods_list.store_goods_ids;
  1290. for (let j = 0; j < param.length; j++) {
  1291. let item = param[j];
  1292. let itemId = item.id;
  1293. let index = store_goods_ids.indexOf(itemId);
  1294. if (index !== -1) {
  1295. this.deleteStoreGoods(index);
  1296. }
  1297. }
  1298. }
  1299. console.log('删除完选择商品 ======>' ,this.ruleForm.store_goods_list);
  1300. },
  1301. //删除商品
  1302. deleteStoreGoods(index) {
  1303. this.ruleForm.upgrade_store_goods_list.store_goods_list.splice(index, 1);
  1304. this.ruleForm.upgrade_store_goods_list.store_goods_ids.splice(index, 1);
  1305. },
  1306. clickSelectCheckConditionGoods() {
  1307. this.$refs.checkgoods.$el.click()
  1308. },
  1309. conditionGoodsSelectCheck(param) {
  1310. let ckey;
  1311. this.ruleForm.checked_condition_values.forEach(function(item, index) {
  1312. if (item.key == 2) {
  1313. ckey = index;
  1314. }
  1315. })
  1316. let gval = this.ruleForm.checked_condition_values[2].value.val0;
  1317. let garr = [];
  1318. if (gval.length > 0) {
  1319. garr = gval.split(",")
  1320. }
  1321. for (let j in param) {
  1322. let item = param[j];
  1323. let isHave = false;
  1324. garr.forEach(element => {
  1325. if (element == param[j].id) {
  1326. isHave = true;
  1327. }
  1328. });
  1329. if (!isHave) {
  1330. garr.push(param[j].id);
  1331. }
  1332. }
  1333. gval = garr.join(',');
  1334. this.ruleForm.checked_condition_values[2].value.val0 = gval;
  1335. console.log(gval);
  1336. },
  1337. conditionGoodsSelect(param) {
  1338. let ckey;
  1339. this.ruleForm.checked_condition_values.forEach(function(item, index) {
  1340. if (item.key == 2) {
  1341. ckey = index;
  1342. }
  1343. })
  1344. let gval = this.ruleForm.checked_condition_values[ckey].value.val0;
  1345. let garr = [];
  1346. if (gval.length > 0) {
  1347. garr = gval.split(",")
  1348. }
  1349. for (let j in param) {
  1350. let item = param[j];
  1351. let isHave = false;
  1352. garr.forEach(element => {
  1353. if (element == param[j].id) {
  1354. isHave = true;
  1355. }
  1356. });
  1357. if (!isHave) {
  1358. garr.push(param[j].id);
  1359. }
  1360. }
  1361. gval = garr.join(',');
  1362. console.log(gval);
  1363. this.ruleForm.checked_condition_values[ckey].value.val0 = gval;
  1364. },
  1365. }
  1366. });
  1367. </script>
  1368. <style>
  1369. .form-body {
  1370. padding: 20px;
  1371. background-color: #fff;
  1372. margin-bottom: 20px;
  1373. padding-right: 20%;
  1374. min-width: 900px;
  1375. }
  1376. .form-body .el-form-item {
  1377. padding-right: 25%;
  1378. min-width: 850px;
  1379. }
  1380. .form-button {
  1381. margin: 0;
  1382. }
  1383. .form-button .el-form-item__content {
  1384. margin-left: 0 !important;
  1385. }
  1386. .button-item {
  1387. padding: 9px 25px;
  1388. }
  1389. .check-group {
  1390. font-size: 14px !important;
  1391. }
  1392. .check-group .el-col {
  1393. display: flex;
  1394. }
  1395. .check-group .el-input {
  1396. margin: 0 5px;
  1397. }
  1398. .check-group .el-col .el-checkbox {
  1399. display: flex;
  1400. align-items: center;
  1401. }
  1402. .check-group .el-col .el-input {
  1403. width: 100px;
  1404. }
  1405. .check-group .el-col .el-input .el-input__inner {
  1406. height: 30px;
  1407. width: 100px;
  1408. }
  1409. .el-checkbox-group .el-col {
  1410. margin-bottom: 10px;
  1411. }
  1412. </style>