promotion.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714
  1. define({
  2. name: "promotion",
  3. template: `
  4. <div class="promotion">
  5. <el-form ref="promotion" :model="json" :rules="rules">
  6. <div class="vue-main-title">
  7. <div class="vue-main-title-left"></div>
  8. <div class="vue-main-title-content">单品优惠</div>
  9. </div>
  10. <div style="margin:0 auto;width:80%;">
  11. <el-form-item label="单品满件包邮" label-width="155px" prop="ed_num">
  12. <el-input v-model.trim="json.ed_num" maxlength="300">
  13. <template slot="prepend">满</template>
  14. <template slot="append">件</template>
  15. </el-input>
  16. <div class="form-item_tips">设置为空或0,则不支持单品满件包邮</div>
  17. </el-form-item>
  18. <el-form-item label="单品满额包邮" label-width="155px" prop="ed_money">
  19. <el-input v-model.trim="json.ed_money" maxlength="300">
  20. <template slot="prepend">满</template>
  21. <template slot="append">元</template>
  22. </el-input>
  23. <div class="form-item_tips">设置为空或0,则不支持单品满额包邮</div>
  24. </el-form-item>
  25. <el-form-item label="单品满额立减" label-width="155px">
  26. <div style="display: flex;">
  27. <el-form-item prop="ed_full">
  28. <el-input v-model.trim="json.ed_full" maxlength="300">
  29. <template slot="prepend">满</template>
  30. <template slot="append">元</template>
  31. </el-input>
  32. </el-form-item>
  33. <el-form-item prop="ed_reduction">
  34. <el-input v-model.trim="json.ed_reduction" maxlength="300">
  35. <template slot="prepend">减</template>
  36. <template slot="append">元</template>
  37. </el-input>
  38. </el-form-item>
  39. </div>
  40. </el-form-item>
  41. <el-form-item label="不参与单品包邮地区" label-width="155px">
  42. <div>{{json.ed_areas}}</div>
  43. <el-button @click="openAreaDialog">添加不参加包邮的地区</el-button>
  44. </el-form-item>
  45. </div>
  46. <div class="vue-main-title">
  47. <div class="vue-main-title-left"></div>
  48. <div class="vue-main-title-content">余额设置</div>
  49. </div>
  50. <div style="margin:0 auto;width:80%;">
  51. <el-form-item label="赠送余额" label-width="155px" prop="award_balance">
  52. <el-input v-model.trim="json.award_balance" maxlength="300">
  53. <template slot="append">余额</template>
  54. </el-input>
  55. <div class="form-item_tips">如果设置为0,则不赠送</div>
  56. <div class="form-item_tips">如:购买两件,设置10余额,不管成交价格是多少,则购买后获得20余额</div>
  57. <div class="form-item_tips">如:购买两件,设置10%余额,成交价格2*200=400,则购买后获得40余额(400*10%)</div>
  58. </el-form-item>
  59. <el-form-item label="赠送门店余额" label-width="155px" prop="pay_reward_balance" v-if="json.is_store == 1">
  60. <el-input v-model.trim="json.pay_reward_balance" maxlength="300">
  61. <template slot="append">余额</template>
  62. </el-input>
  63. <div class="form-item_tips">如果设置为0,则不赠送</div>
  64. <div class="form-item_tips">如:购买两件,设置10余额,不管成交价格是多少,则购买后获得20余额</div>
  65. <div class="form-item_tips">如:购买两件,设置10%余额,成交价格2*200=400,则购买后获得40余额(400*10%)</div>
  66. </el-form-item>
  67. <el-form-item label="余额抵扣" label-width="155px">
  68. <el-switch
  69. v-model="json.balance_deduct"
  70. :active-value="1"
  71. :inactive-value="0">
  72. </el-switch>
  73. <div class="form-item_tips">开启余额抵扣,订单使用余额抵扣则不能使用余额支付。关闭则不支持余额抵扣</div>
  74. </el-form-item>
  75. <el-form-item v-if="json.balance_deduct" prop="" label-width="155px">
  76. <div style="display: flex;">
  77. <el-form-item prop="max_balance_deduct">
  78. <el-input v-model.trim="json.max_balance_deduct" maxlength="300">
  79. <template slot="prepend">最多抵扣</template>
  80. <template slot="append">元</template>
  81. </el-input>
  82. </el-form-item>
  83. <el-form-item prop="min_balance_deduct">
  84. <el-input v-model.trim="json.min_balance_deduct" maxlength="300">
  85. <template slot="prepend">最少抵扣</template>
  86. <template slot="append">元</template>
  87. </el-input>
  88. </el-form-item>
  89. </div>
  90. <div class="form-item_tips">抵扣金额不能大于商品现价</div>
  91. <div class="form-item_tips">如果设置为空为0,则采用余额统一设置</div>
  92. </el-form-item>
  93. </div>
  94. <div class="vue-main-title">
  95. <div class="vue-main-title-left"></div>
  96. <div class="vue-main-title-content">积分设置</div>
  97. </div>
  98. <div style="margin:0 auto;width:80%;">
  99. <el-form-item label="赠送积分" label-width="155px" prop="point">
  100. <el-input v-model.trim="json.point" maxlength="300">
  101. <template slot="append">积分</template>
  102. </el-input>
  103. <div class="form-item_tips">如果设置为空,则走积分统一设置</div>
  104. <div class="form-item_tips">如果设置为0,则不赠送</div>
  105. <div class="form-item_tips">如:购买2件,设置10积分,不管成交价格是多少,则购买后获得20积分</div>
  106. <div class="form-item_tips">如:购买2件,设置10%积分,成交价格2*200=400,则购买后获得40积分(400*10%)</div>
  107. </el-form-item>
  108. <el-form-item label="上级赠送积分" label-width="155px" prop="point">
  109. <el-input v-model.trim="json.first_parent_point" maxlength="300">
  110. <template slot="prepend">一级上级</template>
  111. <template slot="append">积分</template>
  112. </el-input>
  113. <br>
  114. <el-input v-model.trim="json.second_parent_point" maxlength="300">
  115. <template slot="prepend">二级上级</template>
  116. <template slot="append">积分</template>
  117. </el-input>
  118. <div class="form-item_tips">如果设置为空,则走积分统一设置</div>
  119. <div class="form-item_tips">如果设置为0,则不赠送</div>
  120. <div class="form-item_tips">如:购买2件,一级/二级设置10积分,不管成交价格是多少,则购买后一级/二级各获得20积分</div>
  121. <div class="form-item_tips">如:购买2件,一级/二级设置10%积分,成交价格2*200=400,则购买后一级/二级各获得40积分(400*10%)</div>
  122. </el-form-item>
  123. <div style="margin:0 0 10px 155px">
  124. <el-radio v-model="json.point_type" :label="0">订单完成立即赠送</el-radio>
  125. <el-radio v-model="json.point_type" :label="1">每月一号赠送</el-radio>
  126. <el-radio v-model="json.point_type" :label="2">订单支付后赠送</el-radio>
  127. <el-form-item v-if="json.point_type == 1" prop="max_once_point">
  128. <div>
  129. <el-input v-model.trim="json.max_once_point" maxlength="300" >
  130. <template slot="prepend">每月赠送</template>
  131. <template slot="append">积分</template>
  132. </el-input>
  133. </div>
  134. </el-form-item>
  135. </div>
  136. <el-form-item label="积分抵扣" label-width="155px">
  137. <el-radio v-model="json.point_deduct_type" :label="0">固定金额</el-radio>
  138. <el-radio v-model="json.point_deduct_type" :label="1">支付金额比例抵扣</el-radio>
  139. <div style="display: flex;">
  140. <el-form-item prop="max_point_deduct">
  141. <el-input v-model.trim="json.max_point_deduct" maxlength="300">
  142. <template slot="prepend">最多抵扣</template>
  143. <template slot="append">{{json.point_deduct_type==1?'%':'元'}}</template>
  144. </el-input>
  145. </el-form-item>
  146. <el-form-item prop="min_point_deduct">
  147. <el-input v-model.trim="json.min_point_deduct" maxlength="300">
  148. <template slot="prepend">最少抵扣</template>
  149. <template slot="append">{{json.point_deduct_type==1?'%':'元'}}</template>
  150. </el-input>
  151. </el-form-item>
  152. </div>
  153. <div class="form-item_tips">按固定金额:抵扣金额不能大于商品现价</div>
  154. <div class="form-item_tips">按比例抵扣:比例值为0-100的整数,设置最少抵扣不能大于最多抵扣</div>
  155. <div class="form-item_tips">比例抵扣说明:例如商品原价100元填写5,即为抵扣5%的商品价格,积分可以抵扣5元</div>
  156. <div class="form-item_tips">如果设置为空,则采用积分统一设置</div>
  157. <div class="form-item_tips">如果设置为0,则不支持积分抵扣</div>
  158. </el-form-item>
  159. <el-form-item label="积分全额抵扣" label-width="155px">
  160. <el-switch
  161. v-model="json.has_all_point_deduct"
  162. :active-value="1"
  163. :inactive-value="0">
  164. </el-switch>
  165. <el-form-item v-if="json.has_all_point_deduct" prop="all_point_deduct">
  166. <el-input v-model.trim="json.all_point_deduct" maxlength="300">
  167. <template slot="append">积分</template>
  168. </el-input>
  169. </el-form-item>
  170. </el-form-item>
  171. </div>
  172. <div class="vue-main-title">
  173. <div class="vue-main-title-left"></div>
  174. <div class="vue-main-title-content">其他设置</div>
  175. </div>
  176. <div style="margin:0 auto;width:80%;">
  177. <el-form-item label="推广相关商品显示设置" label-width="155px">
  178. <el-switch
  179. v-model="json.is_push"
  180. :active-value="1"
  181. :inactive-value="0">
  182. </el-switch>
  183. </el-form-item>
  184. <el-form-item v-if="json.is_push">
  185. <div class="choose" style="margin: 0 0 10px 155px;display:flex;">
  186. <div class="choose-item" v-for="(item,index) in json.push_goods_ids" :key="index">
  187. <div class="close-item" @click="deleteGoods(item.id)"><i class="el-icon-close"></i></div>
  188. <img :src="item.thumb_url" alt="">
  189. <div class="goods-title" style="color:#999">{{item.title}}</div>
  190. <div style="color:#999">[ID:{{item.id}}]</div>
  191. </div>
  192. <div class="add-goods" @click="openGoodsDialog">
  193. <i class="el-icon-plus"></i>
  194. <div>选择商品</div>
  195. </div>
  196. </div>
  197. </el-form-item>
  198. </div>
  199. </el-form>
  200. <el-dialog
  201. center
  202. title="请选择地区"
  203. :visible.sync="areaDialog"
  204. @close="handleAreaClose"
  205. custom-class="area-dialog"
  206. :close-on-click-modal="false"
  207. >
  208. <el-tree
  209. :props="treeProps"
  210. node-key="id"
  211. lazy
  212. show-checkbox
  213. :data="areaData"
  214. ref="addressTree"
  215. :load="loadNode"
  216. @check-change="checkAreas"
  217. :default-checked-keys="area_ids"
  218. :default-expanded-keys="province_ids"
  219. >
  220. </el-tree>
  221. <span slot="footer" class="dialog-footer">
  222. <el-button type="primary" @click="saveAreas">确 定</el-button>
  223. <el-button @click="handleAreaClose">取 消</el-button>
  224. </span>
  225. </el-dialog>
  226. <el-dialog
  227. v-loading="loading"
  228. :visible.sync="goodsDialog"
  229. width="60%"
  230. @close="handleGoodsClose">
  231. <div slot="title">
  232. 选择商品
  233. </div>
  234. <div style="height:600px;">
  235. <div style="display:flex">
  236. <el-input
  237. class="inline-input"
  238. v-model="goodsKey"
  239. placeholder="请输入搜索内容"
  240. ></el-input>
  241. <el-button style="margin-left: -4px;" @click="searchGoods">搜索</el-button>
  242. </div>
  243. <div>
  244. <el-table
  245. :data="goodsList"
  246. height="500"
  247. style="width: 100%">
  248. <el-table-column label="ID" prop="id" ></el-table-column>
  249. <el-table-column
  250. label="商品图片"
  251. width="100">
  252. <template slot-scope="scope">
  253. <img style="width:30px;height:30px;" :src="scope.row.thumb_url" alt="">
  254. </template>
  255. </el-table-column>
  256. <el-table-column
  257. prop="title"
  258. label="商品名称"
  259. align="center"
  260. width="450">
  261. <template slot-scope="scope">
  262. <span class="overflow-2">{{scope.row.title}}</span>
  263. </template>
  264. </el-table-column>
  265. <el-table-column
  266. label="操作"
  267. width="90">
  268. <template slot-scope="scope">
  269. <el-button
  270. size="mini"
  271. @click="selectGoods(scope.$index)">选择</el-button>
  272. </template>
  273. </el-table-column>
  274. </el-table>
  275. </div>
  276. <el-pagination style="text-align: right;"
  277. background
  278. layout="prev, pager, next"
  279. :total="paginationOpt.total"
  280. :page-size="paginationOpt.pageSize"
  281. :current-page="paginationOpt.page"
  282. @current-change="searchGoods"
  283. >
  284. </el-pagination>
  285. </div>
  286. </el-dialog>
  287. </div>
  288. `,
  289. style: `
  290. .promotion .two-input {
  291. display:flex;
  292. }
  293. .promotion .overflow-2 {
  294. display:-webkit-box;
  295. -webkit-box-orient:vertical;
  296. -webkit-line-clamp:2;
  297. overflow:hidden;
  298. }
  299. .promotion p {
  300. height:10px;
  301. }
  302. .promotion .el-radio {
  303. margin: 0px 30px 10px 0;
  304. }
  305. .promotion .el-input-group {
  306. width:300px;
  307. }
  308. .promotion .el-autocomplete{
  309. width:90%;
  310. }
  311. .promotion .goods-item {
  312. display: flex;
  313. margin: 10px 0 0 10px;
  314. }
  315. .promotion .goods-item-left {
  316. display: flex;
  317. justify-content: center;
  318. }
  319. .promotion .goods-name {
  320. display: flex;
  321. align-items: center;
  322. }
  323. .promotion .goods-item-left span {
  324. display:block;
  325. margin-left:5px;
  326. }
  327. .promotion .goods-item-left img {
  328. width:30px;
  329. height:30px;
  330. }
  331. .promotion .goods-item-right {
  332. margin: 5px 0 0 200px;
  333. cursor: pointer;
  334. }
  335. .promotion .choose {
  336. width:600px;
  337. display:flex;
  338. flex-wrap: wrap;
  339. }
  340. .promotion .choose-item {
  341. position: relative;
  342. width:120px;
  343. margin: 10px;
  344. cursor: pointer;
  345. }
  346. .promotion .choose-item .close-item{
  347. position: absolute;
  348. top:-7px;
  349. right:-7px;
  350. width:20px;
  351. height:20px;
  352. background-color: #ccc;
  353. border-radius:50%;
  354. text-align: center;
  355. }
  356. .promotion .choose-item .close-item .el-icon-close{
  357. position: absolute;
  358. top: 3px;
  359. right: 3px;
  360. }
  361. .promotion .choose-item img {
  362. width:120px;
  363. height:120px;
  364. }
  365. .promotion .choose-item .goods-title {
  366. width: 100%;
  367. overflow: hidden;
  368. white-space: nowrap;
  369. text-overflow: ellipsis;
  370. }
  371. .promotion .add-goods {
  372. width:120px;
  373. height:120px;
  374. text-align: center;
  375. margin: 10px;
  376. cursor: pointer;
  377. border:1px dashed #a59f9f;
  378. }
  379. .promotion .add-goods i{
  380. font-size:30px;
  381. margin-top:25px;
  382. }
  383. .promotion .area-dialog {
  384. width: 60%;
  385. height: 80%;
  386. overflow-y: scroll;
  387. }
  388. `,
  389. props: {
  390. form: {
  391. default() {
  392. return {};
  393. },
  394. },
  395. http_url:{
  396. type:String,
  397. default() {
  398. return "";
  399. },
  400. }
  401. },
  402. data() {
  403. let intReg = /^[0-9]*$/;
  404. let floatReg = /^\d+(\.\d+)?$/;
  405. let rateReg = /^([0-9.]+)[ ]*%$/;
  406. // 整数校验
  407. let intNum = (rule,value,callback)=>{
  408. let regular = intReg.test(value);
  409. if(!value){
  410. callback();
  411. }else{
  412. if (regular) {
  413. callback();
  414. }else{
  415. callback(new Error("请输入正整数"));
  416. }
  417. }
  418. };
  419. // 浮点数校验
  420. let floatNum = (rule,value,callback)=>{
  421. let regular = floatReg.test(value);
  422. if(!value){
  423. callback();
  424. }else{
  425. if (regular) {
  426. callback();
  427. }else{
  428. callback(new Error("请输入大于零或等于零的数字"));
  429. }
  430. }
  431. };
  432. // 百分比校验
  433. let rateNum = (rule, value, callback) => {
  434. let regular = floatReg.test(value);
  435. let regular2 = rateReg.test(value);
  436. if(!value){
  437. callback();
  438. }else{
  439. if (regular || regular2) {
  440. callback();
  441. }else{
  442. callback(new Error("请输入大于零等于零的数字,或百分比"));
  443. }
  444. }
  445. };
  446. return {
  447. rules: {
  448. ed_num: { validator: intNum },
  449. ed_money: { validator: floatNum },
  450. ed_full: { validator: floatNum },
  451. ed_reduction: { validator: floatNum },
  452. award_balance: { validator: rateNum },
  453. pay_reward_balance: { validator: rateNum },
  454. point: { validator: rateNum },
  455. first_parent_point: { validator: rateNum },
  456. second_parent_point: { validator: rateNum },
  457. max_once_point: { validator: rateNum },
  458. max_point_deduct: { validator: floatNum },
  459. min_point_deduct: { validator: floatNum },
  460. all_point_deduct: { validator: floatNum },
  461. max_balance_deduct: { validator: floatNum },
  462. min_balance_deduct: { validator: floatNum },
  463. },
  464. goodsDialog: false,
  465. areaDialog: false,
  466. areas: [],
  467. area_ids: [],
  468. province_ids: [],
  469. areaData: [],
  470. treeProps: {
  471. label: 'areaname',
  472. children: 'children',
  473. isLeaf: 'isLeaf'
  474. },
  475. loading: false,
  476. goodsKey: "",
  477. goodsList: [],
  478. paginationOpt: {
  479. total: 0,
  480. pageSize: 1,
  481. page: 1,
  482. },
  483. json: {
  484. ed_num: '',
  485. ed_money: '',
  486. ed_full: '',
  487. ed_areas: '',
  488. ed_areaids: '',
  489. ed_reduction: '',
  490. award_balance: '',
  491. pay_reward_balance: '',
  492. point: '',
  493. first_parent_point: '',
  494. second_parent_point: '',
  495. point_type: 0,
  496. max_once_point: '',
  497. point_deduct_type: 0,
  498. max_point_deduct: '',
  499. min_point_deduct: '',
  500. has_all_point_deduct: 0,
  501. all_point_deduct: '',
  502. balance_deduct: 0,
  503. max_balance_deduct:'',
  504. min_balance_deduct:'',
  505. is_push: 0,
  506. push_goods_ids: [],
  507. is_store:0
  508. },
  509. };
  510. },
  511. mounted() {
  512. if (this.form && this.form.sale) {
  513. let sale = this.form.sale;
  514. this.json.ed_num = sale.ed_num;
  515. this.json.ed_money = sale.ed_money;
  516. this.json.ed_full = sale.ed_full;
  517. this.json.ed_areas = sale.ed_areas;
  518. this.json.ed_areaids = sale.ed_areaids;
  519. this.json.ed_reduction = sale.ed_reduction;
  520. this.json.award_balance = sale.award_balance;
  521. this.json.is_store = sale.is_store;
  522. this.json.pay_reward_balance = sale.pay_reward_balance;
  523. this.json.point = sale.point;
  524. this.json.first_parent_point = sale.first_parent_point;
  525. this.json.second_parent_point = sale.second_parent_point;
  526. this.json.point_type = sale.point_type ? sale.point_type : 0;
  527. this.json.max_once_point = sale.max_once_point;
  528. this.json.point_deduct_type = sale.point_deduct_type;
  529. this.json.max_point_deduct = sale.max_point_deduct;
  530. this.json.min_point_deduct = sale.min_point_deduct;
  531. this.json.has_all_point_deduct = sale.has_all_point_deduct ? sale.has_all_point_deduct : 0;
  532. this.json.all_point_deduct = sale.all_point_deduct;
  533. this.json.balance_deduct = sale.balance_deduct ? sale.balance_deduct : 0;
  534. this.json.max_balance_deduct = sale.max_balance_deduct ? sale.max_balance_deduct : '';
  535. this.json.min_balance_deduct = sale.min_balance_deduct ? sale.min_balance_deduct : '';
  536. this.json.is_push = sale.is_push ? sale.is_push : 0;
  537. this.json.push_goods_ids = sale.push_goods_ids ? sale.push_goods_ids : [];
  538. }
  539. },
  540. methods: {
  541. extraDate(){
  542. },
  543. async validate() {
  544. try {
  545. this.validateResult = await this.$refs['promotion'].validate();
  546. } catch (err) {
  547. this.validateResult = false;
  548. }
  549. return this.validateResult ? this.json : false;
  550. },
  551. openGoodsDialog() {
  552. this.goodsDialog = true;
  553. },
  554. handleGoodsClose() {
  555. this.goodsDialog = false;
  556. },
  557. // 地区
  558. openAreaDialog() {
  559. this.areaDialog = true;
  560. if(this.area_ids){
  561. this.area_ids.forEach((item, index) => {
  562. this.area_ids[index] = Number(item)
  563. });
  564. }
  565. },
  566. handleAreaClose() {
  567. this.areaDialog = false;
  568. },
  569. loadNode(node, resolve) {
  570. this.loading = true;
  571. if (!node.data.id) {
  572. //省份
  573. node.data.id = 0;
  574. this.$http.get(this.http_url + "area.list&parent_id=0").then(response => {
  575. response.data.data.forEach(function (province) {
  576. province.isLeaf = false;
  577. });
  578. resolve(response.data.data);
  579. this.loading = false;
  580. }, response => {
  581. console.log(response);
  582. });
  583. } else {
  584. //城市
  585. this.$http.get(this.http_url + "area.list&parent_id=" + node.data.id).then(response => {
  586. //城市没有子节点
  587. response.data.data.forEach(function (city) {
  588. city.isLeaf = true;
  589. })
  590. resolve(response.data.data);
  591. // 载入数据后,刷新已选中
  592. this.loading = false;
  593. }, response => {
  594. console.log(response);
  595. });
  596. }
  597. },
  598. checkAreas(node, checked, children) {
  599. if (node.isLeaf) {
  600. return;
  601. }
  602. if (checked) {
  603. if (!this.province_ids) {
  604. this.province_ids = [];
  605. }
  606. this.province_ids.push(node.id)
  607. }
  608. },
  609. saveAreas() {
  610. let areas = [];
  611. let area_ids = [];
  612. let province_ids = [];
  613. this.$refs.addressTree.getCheckedNodes().forEach(function (node) {
  614. if (node.level == 1) {
  615. province_ids.push(node.id);
  616. } else if (node.level == 2) {
  617. area_ids.push(node.id);
  618. areas.push(node.areaname)
  619. }
  620. });
  621. this.$refs.addressTree.getHalfCheckedNodes().forEach(function (node) {
  622. if (node.level == 1) {
  623. province_ids.push(node.id);
  624. }
  625. });
  626. this.province_ids = province_ids;
  627. this.area_ids = area_ids;
  628. this.json.ed_areas = areas.join(";");
  629. this.json.ed_areaids = area_ids.join(",");
  630. this.areaDialog = false
  631. },
  632. // 商品
  633. searchGoods (page=this.paginationOpt.page) {
  634. if (this.goodsKey === "") {
  635. return;
  636. }
  637. let params = "goods.goods.get-search-goods-json&keyword=" + this.goodsKey;
  638. if (typeof page === "number") {
  639. params = params + "&page=" + page;
  640. }
  641. this.$http.get(this.http_url + params).then(response => {
  642. if (response.data.result != 1) {
  643. return this.$message.error(response.data.msg);
  644. }
  645. let resultData = response.data.data.goods;
  646. this.goodsList = resultData ? resultData.data : [];
  647. this.paginationOpt.page = resultData.current_page;
  648. this.paginationOpt.total = resultData.total;
  649. this.paginationOpt.pageSize = resultData.per_page;
  650. })
  651. .catch((err) => {
  652. this.$message.error(err);
  653. })
  654. },
  655. selectGoods(index) {
  656. let list = this.goodsList.slice(index, index + 1);
  657. let check = this.json.push_goods_ids.some(item=>item.id === list[0].id);
  658. if (check) {
  659. this.$message.error("已选择改商品,请勿重复选择");
  660. } else {
  661. this.json.push_goods_ids.push(...list);
  662. this.goodsDialog = false;
  663. }
  664. },
  665. deleteGoods(id) {
  666. this.json.push_goods_ids.some((item, i) => {
  667. if (item.id == id) {
  668. this.json.push_goods_ids.splice(i, 1);
  669. return true;
  670. }
  671. });
  672. },
  673. },
  674. });