cashCloth.vue 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004
  1. <template>
  2. <div v-loading="dialogLoading" :element-loading-text="loadingText">
  3. <el-form :model="orderForm" :inline="true" ref="confirmPayForm">
  4. <el-card>
  5. <el-descriptions title="核对信息" border :column="3" :label-style="{ width: '120px' }">
  6. <el-descriptions-item label="总件数">{{ orderClothItemDTOS.length }}</el-descriptions-item>
  7. <el-descriptions-item label="总价格(元)">{{ calculateTotalPrice() + calculateDeliveryPrice() }}</el-descriptions-item>
  8. <el-descriptions-item label="卡余额(元)" v-if="appUserInfo">{{ appUserInfo.rechargeBalance + appUserInfo.giveBalance }}</el-descriptions-item>
  9. <el-descriptions-item label="卡余额(元)" v-else>0</el-descriptions-item>
  10. <el-descriptions-item label="衣服价格(元)">{{ calculateTotalPrice() }}</el-descriptions-item>
  11. <el-descriptions-item label="优惠金额(元)">{{ calculateTotalDiscountAmount() }}</el-descriptions-item>
  12. <el-descriptions-item label="现金余额(元)">{{ appUserInfo ? appUserInfo.rechargeBalance : '0' }}</el-descriptions-item>
  13. <el-descriptions-item label="配送费(元)">
  14. {{ calculateDeliveryPrice() }}
  15. </el-descriptions-item>
  16. <el-descriptions-item label="还需支付(元)">{{ Math.round((calculateTotalPrice() + calculateDeliveryPrice() - calculateTotalDiscountAmount()) * 100) / 100 }}</el-descriptions-item>
  17. <el-descriptions-item label="赠送余额">{{ appUserInfo ? appUserInfo.giveBalance : '0' }}</el-descriptions-item>
  18. </el-descriptions>
  19. </el-card>
  20. <el-card style="margin-top: 10px">
  21. <div slot="header" class="clearfix">
  22. <span>优惠信息</span>
  23. </div>
  24. <el-tabs v-model="confirmCouponTabIndex" type="card" @tab-click="onCouponTabChange">
  25. <el-tab-pane label="优惠券" name="0">
  26. <el-form-item label="优惠券" prop="fullCoupon">
  27. <el-input ref="couponRef" v-model="orderForm.fullCoupon" placeholder="请输入优惠券兑换码" clearable />
  28. </el-form-item>
  29. <el-form-item>
  30. <el-button type="primary">核销</el-button>
  31. <el-button type="primary" @click="onSelectCoupon">列表选券</el-button>
  32. </el-form-item>
  33. <el-tabs v-model="confirmDeductTabIndex" type="card" @tab-click="onCouponTabChange">
  34. <el-tab-pane label="优惠券使用明细" name="0">
  35. <el-table :data="selectCoupons">
  36. <el-table-column label="优惠券" align="center" prop="couponTypeTitle" />
  37. <el-table-column label="优惠券类型" align="center" prop="discountWay">
  38. <template slot-scope="scope">
  39. <span v-if="scope.row.discountWay == '0'">抵扣券</span>
  40. <span v-if="scope.row.discountWay == '1'">满减券</span>
  41. <span v-if="scope.row.discountWay == '2'">折扣券</span>
  42. </template>
  43. </el-table-column>
  44. <el-table-column label="优惠内容" align="center">
  45. <template slot-scope="scope">
  46. <span v-if="scope.row.discountWay == '0'">抵扣{{ scope.row.deductAmount }}元</span>
  47. <span v-if="scope.row.discountWay == '1'">满{{ parseInt(scope.row.minAmount) }}件减{{ scope.row.deductAmount }}件</span>
  48. <span v-if="scope.row.discountWay == '2'">优惠{{ scope.row.discountRate }}%,最多折扣{{ scope.row.deductAmount }}元</span>
  49. </template>
  50. </el-table-column>
  51. <el-table-column label="是否单件" align="center" prop="isUnique">
  52. <template slot-scope="scope">
  53. <span v-if="scope.row.discountWay == '2'">
  54. <span v-if="scope.row.isUnique == 'Y'">单件</span>
  55. <span v-if="scope.row.isUnique == 'N'">非单件</span>
  56. </span>
  57. <span v-else>--</span>
  58. </template>
  59. </el-table-column>
  60. <el-table-column label="优惠衣服" align="center" prop="selectClothInfo" :width="350">
  61. <template slot-scope="scope">
  62. <template v-for="(item, index) in scope.row.orderCouponClothDTOS">
  63. <br v-if="index != 0" />
  64. <span>{{ '#' + (item.clothIndex + 1) + ' ' + item.clothName + ' 优惠' + item.deductAmount + '元' }}</span>
  65. </template>
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="200">
  69. <template slot-scope="scope">
  70. <el-button type="text" @click="changeCouponDiscountCloth(scope.$index)" v-if="scope.$index == selectCoupons.length - 1 && scope.row.discountWay == '2' && scope.row.isUnique == 'Y'">修改优惠衣服</el-button>
  71. <el-button type="text" style="color: #ff4949" @click="removeSelectCoupon(scope.$index)" v-if="scope.$index == selectCoupons.length - 1">删除</el-button>
  72. </template>
  73. </el-table-column>
  74. </el-table>
  75. </el-tab-pane>
  76. <el-tab-pane label="衣服抵扣明细" name="1">
  77. <el-table :data="orderClothItemDTOS">
  78. <el-table-column label="序号" type="index" align="center" fixed="left" width="80"> </el-table-column>
  79. <el-table-column label="衣物名称" align="center" prop="name" width="250">
  80. <template slot-scope="scope">
  81. <span>{{ calculateClothName(scope.$index) }}</span>
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="颜色" align="center" width="120">
  85. <template slot-scope="scope">
  86. <span>
  87. <template v-for="(color, index) in scope.row.orderClothColorDTOS">
  88. {{ index == 0 ? color.clothColorName : ',' + color.clothColorName }}
  89. </template>
  90. </span>
  91. </template>
  92. </el-table-column>
  93. <el-table-column label="衣服品牌" align="center" prop="name" width="120">
  94. <template slot-scope="scope">
  95. <span>{{ scope.row.clothBrandName }}</span>
  96. </template>
  97. </el-table-column>
  98. <el-table-column label="瑕疵" align="center">
  99. <template slot-scope="scope">
  100. <span>
  101. <template v-for="(color, index) in scope.row.orderClothFlawDTOS">
  102. {{ index == 0 ? color.clothFlawName : ',' + color.clothFlawName }}
  103. </template>
  104. </span>
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="洗涤方式" align="center" width="80">
  108. <template slot-scope="scope">
  109. <span>{{ scope.row.clothWashModeName }}</span>
  110. </template>
  111. </el-table-column>
  112. <el-table-column label="价格(元)" align="center" prop="totalPrice" width="100" />
  113. <el-table-column label="优惠金额(元)" align="center" prop="deductAmount" width="130" />
  114. <el-table-column label="还需支付(元)" align="center" width="130">
  115. <template slot-scope="scope">
  116. <span>{{ handelPrice(scope.row.totalPrice - scope.row.deductAmount) }}</span>
  117. </template>
  118. </el-table-column>
  119. </el-table>
  120. </el-tab-pane>
  121. </el-tabs>
  122. </el-tab-pane>
  123. <el-tab-pane label="平台折扣活动" name="1">
  124. <!-- <el-form-item label="折扣" prop="discountCouponId">
  125. <el-select v-model="orderForm.discountCouponId" placeholder="请选择" clearable @change="onDiscountCouponSelect">
  126. <template v-for="(item, i) in discountCouponVOS">
  127. <el-option :key="i" :label="item.couponTypeTitle + '(' + item.deductAmount * 10 + '折)'" :value="item.id"> </el-option>
  128. </template>
  129. </el-select>
  130. </el-form-item> -->
  131. <el-table :data="discountCouponVOS" style="width: 100%">
  132. <el-table-column label="序号" type="index" align="center" fixed="left" width="80"> </el-table-column>
  133. <el-table-column label="活动名称" align="center" prop="title"> </el-table-column>
  134. <el-table-column label="适用衣服" align="center">
  135. <template slot-scope="scope">
  136. <span v-if="scope.row.clothScope == 0">全部衣服 折扣{{ scope.row.discount * 100 }}%</span>
  137. <span v-if="scope.row.clothScope == 1">指定衣服</span>
  138. </template>
  139. </el-table-column>
  140. <el-table-column label="适用支付方式" align="center">
  141. <template slot-scope="scope">
  142. <span v-if="scope.row.payScope == 0">全部</span>
  143. <span v-if="scope.row.payScope == 1">现金</span>
  144. <span v-if="scope.row.payScope == 2">余额</span>
  145. </template>
  146. </el-table-column>
  147. <el-table-column label="可优惠金额(元)" align="center">
  148. <template slot-scope="scope">
  149. <span>{{ calculateTotalDiscountByActivity(scope.row) }}</span>
  150. </template>
  151. </el-table-column>
  152. <!-- <el-table-column label="衣服品牌" align="center" prop="name" width="120"> -->
  153. <!-- <template slot-scope="scope"> -->
  154. <!-- <span>{{ scope.row.clothBrandName }}</span> -->
  155. <!-- </template> -->
  156. <!-- </el-table-column> -->
  157. <!-- <el-table-column label="瑕疵" align="center"> -->
  158. <!-- <template slot-scope="scope"> -->
  159. <!-- <span> -->
  160. <!-- <template v-for="(color, index) in scope.row.orderClothFlawDTOS"> -->
  161. <!-- {{ index == 0 ? color.clothFlawName : ',' + color.clothFlawName }} -->
  162. <!-- </template> -->
  163. <!-- </span> -->
  164. <!-- </template> -->
  165. <!-- </el-table-column> -->
  166. <!-- <el-table-column label="洗涤方式" align="center" width="80"> -->
  167. <!-- <template slot-scope="scope"> -->
  168. <!-- <span>{{ scope.row.clothWashModeName }}</span> -->
  169. <!-- </template> -->
  170. <!-- </el-table-column> -->
  171. <!-- <el-table-column label="原价(元)" align="center" prop="totalPrice" width="100" /> -->
  172. <!-- <el-table-column label="抵扣金额(元)" align="center" prop="deductAmount" width="130" /> -->
  173. <!-- <el-table-column label="折扣金额(元)" align="center" width="130">
  174. <template slot-scope="scope">
  175. <span>{{ parseInt((scope.row.totalPrice - scope.row.deductAmount) * 100 * parseInt(100 - orderForm.discountCoupon.deductAmount * 100)) / 10000 }}</span>
  176. </template>
  177. </el-table-column> -->
  178. <el-table-column label="操作" align="center">
  179. <template slot-scope="scope">
  180. <el-button type="text" style="color: #67c23a" @click="onSelectActivityItem({})" v-if="activity.id === scope.row.id">不使用</el-button>
  181. <el-button type="text" @click="onSelectActivityItem(scope.row)" v-else>使用</el-button>
  182. </template>
  183. </el-table-column>
  184. </el-table>
  185. </el-tab-pane>
  186. <el-tab-pane label="现金券" name="2">
  187. <el-form-item label="现金券" prop="cashDeductAmount">
  188. <el-input-number
  189. style="text-align: left"
  190. v-model="orderForm.cashDeductAmount"
  191. placeholder="请输入现金券金额"
  192. :precision="2"
  193. clearable
  194. :controls="false"
  195. :max="(parseInt(calculateTotalPrice() * 100) + parseInt(calculateDeliveryPrice() * 100) - parseInt(calculateTotalDiscountAmountWithoutCashAmount() * 100)) / 100"
  196. />
  197. </el-form-item>
  198. <el-form-item label="是否特殊" prop="isSpecial">
  199. <el-checkbox v-model="orderForm.isSpecial"></el-checkbox>
  200. </el-form-item>
  201. </el-tab-pane>
  202. </el-tabs>
  203. </el-card>
  204. <el-card style="margin-top: 10px">
  205. <div slot="header" class="clearfix">
  206. <span>收款方式</span>
  207. <template v-if="calculateTotalDiscountAmountByCoupon()">
  208. <span style="margin-left: 10px">优惠券优惠</span>
  209. <span style="color: #ff4949">{{ calculateTotalDiscountAmountByCoupon() }}</span>
  210. <span>元</span>
  211. </template>
  212. <template v-if="calculateTotalDiscountByActivity(activity)">
  213. <span style="margin-left: 10px">平台折扣活动优惠</span>
  214. <span style="color: #ff4949">{{ calculateTotalDiscountByActivity(activity) }}</span>
  215. <span>元</span>
  216. </template>
  217. <template v-if="orderForm.cashDeductAmount">
  218. <span style="margin-left: 10px">现金券优惠</span>
  219. <span style="color: #ff4949">{{ orderForm.cashDeductAmount }}</span>
  220. <span>元</span>
  221. </template>
  222. <span style="margin-left: 10px">还需支付</span>
  223. <span style="color: #ff4949">{{ (parseInt(calculateTotalPrice() * 100) + parseInt(calculateDeliveryPrice() * 100) - parseInt(calculateTotalDiscountAmount() * 100)) / 100 }}</span>
  224. <span>元</span>
  225. </div>
  226. <el-form-item label="支付方式" prop="payType">
  227. <el-radio-group v-model="orderForm.payType" @change="changePayType">
  228. <el-radio-button label="3" name="3">余额</el-radio-button>
  229. <el-radio-button label="2" name="2">现金</el-radio-button>
  230. <el-radio-button label="0" name="0">微信/支付宝</el-radio-button>
  231. <!-- <el-radio-button label="1" name="1">支付宝</el-radio-button>-->
  232. </el-radio-group>
  233. </el-form-item>
  234. <br />
  235. <el-form-item label="付款码" prop="authCode" v-if="orderForm.payType == '0' || orderForm.payType == '1'">
  236. <el-input ref="autoFocus" v-model="orderForm.authCode" clearable placeholder="请选择付款码" />
  237. </el-form-item>
  238. <el-descriptions border :column="3" :labelStyle="{ width: '140px' }" v-if="orderForm.payType == '3'">
  239. <el-descriptions-item label="用户" v-if="appUserInfo">{{ appUserInfo.realName }}</el-descriptions-item>
  240. <el-descriptions-item label="当前余额(元)" v-if="appUserInfo">{{ appUserInfo.rechargeBalance + appUserInfo.giveBalance }}</el-descriptions-item>
  241. <el-descriptions-item label="支付后余额(元)" v-if="appUserInfo">{{ appUserInfo.rechargeBalance + appUserInfo.giveBalance - calculateTotalPrice() }}</el-descriptions-item>
  242. </el-descriptions>
  243. <div style="margin-top: 20px">
  244. <el-button type="primary" @click="submitForm(0)" style="margin-right: 10px">立即支付</el-button>
  245. <el-button type="primary" @click="submitForm(1)" style="margin-right: 5%">取衣支付</el-button>
  246. </div>
  247. </el-card>
  248. </el-form>
  249. <el-dialog title="选择优惠券" :visible.sync="setCouponOpen" append-to-body width="55%">
  250. <!-- :before-close="handleClose"-->
  251. <el-table :data="deductCouponVOS" style="width: 100%">
  252. <el-table-column label="优惠券" align="center" prop="couponTypeTitle" />
  253. <el-table-column label="优惠券类型" align="center" prop="discountType">
  254. <template slot-scope="scope">
  255. <span v-if="scope.row.discountWay == '0'">抵扣券</span>
  256. <span v-if="scope.row.discountWay == '1'">满减券</span>
  257. <span v-if="scope.row.discountWay == '2'">折扣券</span>
  258. </template>
  259. </el-table-column>
  260. <el-table-column label="优惠内容" align="center">
  261. <template slot-scope="scope">
  262. <span v-if="scope.row.discountWay == '0'">抵扣{{ scope.row.deductAmount }}元</span>
  263. <span v-if="scope.row.discountWay == '1'">满{{ parseInt(scope.row.minAmount) }}件减{{ scope.row.deductAmount }}件</span>
  264. <span v-if="scope.row.discountWay == '2'">优惠{{ scope.row.discountRate }}%,最多折扣{{ scope.row.deductAmount }}元</span>
  265. </template>
  266. </el-table-column>
  267. <el-table-column label="是否单件" align="center" prop="isUnique">
  268. <template slot-scope="scope">
  269. <span v-if="scope.row.discountWay == '2'">
  270. <span v-if="scope.row.isUnique == 'Y'">单件</span>
  271. <span v-if="scope.row.isUnique == 'N'">非单件</span>
  272. </span>
  273. <span v-else>--</span>
  274. </template>
  275. </el-table-column>
  276. <el-table-column label="适用衣服" align="center">
  277. <template slot-scope="scope">
  278. <template v-for="(item, index) in scope.row.appCouponTypeApplyClothVOS" v-key="index">
  279. <span>{{ index > 0 ? '、' : '' }}{{ item.clothItemName }}</span>
  280. </template>
  281. <span v-if="!scope.row.appCouponTypeApplyClothVOS">全部衣服</span>
  282. </template>
  283. </el-table-column>
  284. <el-table-column label="操作" align="center">
  285. <template slot-scope="scope">
  286. <el-button type="text" @click="onSelectCouponItem(scope.$index)">选择</el-button>
  287. </template>
  288. </el-table-column>
  289. </el-table>
  290. </el-dialog>
  291. <el-dialog :title="changeDiscountCouponTitle" :visible.sync="changeDiscountCouponOpen" width="70%" append-to-body>
  292. <!-- <span v-if="changeDiscountCouponOpen"> 共可抵扣{{ selectCoupons[changeDiscountCouponIndex].deductAmount }}元,已抵扣{{ calculateCouponDiscountInfo() }}元,剩余可抵扣{{ selectCoupons[changeDiscountCouponIndex].deductAmount - calculateCouponDiscountInfo() }}元 </span>
  293. <br /> -->
  294. <span>可选择衣物</span>
  295. <br />
  296. <el-table :data="changeDiscountCouponCanSelectCloths">
  297. <el-table-column label="序号" align="center" fixed="left" width="80">
  298. <template slot-scope="scope">
  299. <span>#{{ scope.row.index + 1 }}</span>
  300. </template>
  301. </el-table-column>
  302. <el-table-column label="衣物名称" align="center" prop="name" width="250">
  303. <template slot-scope="scope">
  304. <span>{{ calculateClothNameByInfo(scope.row) }}</span>
  305. </template>
  306. </el-table-column>
  307. <el-table-column label="颜色" align="center" width="120">
  308. <template slot-scope="scope">
  309. <span>
  310. <template v-for="(color, index) in scope.row.orderClothColorDTOS">
  311. {{ index == 0 ? color.clothColorName : ',' + color.clothColorName }}
  312. </template>
  313. </span>
  314. </template>
  315. </el-table-column>
  316. <el-table-column label="衣服品牌" align="center" prop="name" width="120">
  317. <template slot-scope="scope">
  318. <span>{{ scope.row.clothBrandName }}</span>
  319. </template>
  320. </el-table-column>
  321. <el-table-column label="瑕疵" align="center">
  322. <template slot-scope="scope">
  323. <span>
  324. <template v-for="(color, index) in scope.row.orderClothFlawDTOS">
  325. {{ index == 0 ? color.clothFlawName : ',' + color.clothFlawName }}
  326. </template>
  327. </span>
  328. </template>
  329. </el-table-column>
  330. <el-table-column label="洗涤方式" align="center" width="80">
  331. <template slot-scope="scope">
  332. <span>{{ scope.row.clothWashModeName }}</span>
  333. </template>
  334. </el-table-column>
  335. <el-table-column label="价格(元)" align="center" prop="totalPrice" width="100" />
  336. <el-table-column label="待优惠金额(元)" align="center" prop="deductAmount" width="130" />
  337. <el-table-column label="还需支付(元)" align="center" width="130">
  338. <template slot-scope="scope">
  339. <span>{{ scope.row.totalPrice - scope.row.deductAmount }}</span>
  340. </template>
  341. </el-table-column>
  342. <el-table-column label="操作" align="center">
  343. <template slot-scope="scope">
  344. <el-button type="text" style="color: #67c23a" v-if="scope.row.isSelected">已选择</el-button>
  345. <el-button type="text" style="color: #ff4949" @click="addCouponRelateCloth(scope.$index)" v-else>选择</el-button>
  346. </template>
  347. </el-table-column>
  348. </el-table>
  349. <br />
  350. <!-- <span>已选择衣物</span> -->
  351. <!-- <br /> -->
  352. <!-- <el-table :data="changeDiscountCouponSelectCloths" style="width: 100%">
  353. <el-table-column label="序号" align="center" width="80">
  354. <template slot-scope="scope">
  355. <span>#{{ scope.row.clothIndex + 1 }}</span>
  356. </template>
  357. </el-table-column>
  358. <el-table-column label="衣服名称" align="center" prop="clothName" width="250" />
  359. <el-table-column label="颜色" align="center" width="120">
  360. <template slot-scope="scope">
  361. <span>
  362. <template v-for="(color, index) in scope.row.cloth.orderClothColorDTOS">
  363. {{ index == 0 ? color.clothColorName : ',' + color.clothColorName }}
  364. </template>
  365. </span>
  366. </template>
  367. </el-table-column>
  368. <el-table-column label="衣服品牌" align="center" prop="name" width="120">
  369. <template slot-scope="scope">
  370. <span>{{ scope.row.cloth.clothBrandName }}</span>
  371. </template>
  372. </el-table-column>
  373. <el-table-column label="瑕疵" align="center">
  374. <template slot-scope="scope">
  375. <span>
  376. <template v-for="(color, index) in scope.row.cloth.orderClothFlawDTOS">
  377. {{ index == 0 ? color.clothFlawName : ',' + color.clothFlawName }}
  378. </template>
  379. </span>
  380. </template>
  381. </el-table-column>
  382. <el-table-column label="洗涤方式" align="center" width="80">
  383. <template slot-scope="scope">
  384. <span>{{ scope.row.cloth.clothWashModeName }}</span>
  385. </template>
  386. </el-table-column>
  387. <el-table-column label="原价(元)" align="center" prop="totalPrice" width="100">
  388. <template slot-scope="scope">
  389. <span>{{ scope.row.cloth.totalPrice }}</span>
  390. </template>
  391. </el-table-column>
  392. <el-table-column label="已优惠金额(元)" align="center" prop="deductAmount" width="130">
  393. <template slot-scope="scope">
  394. <span>{{ scope.row.cloth.deductAmount }}</span>
  395. </template>
  396. </el-table-column>
  397. <el-table-column label="还需支付(元)" align="center" width="130">
  398. <template slot-scope="scope">
  399. <span>{{ scope.row.cloth.totalPrice - scope.row.cloth.deductAmount }}</span>
  400. </template>
  401. </el-table-column>
  402. <el-table-column label="本次优惠金额(元)" align="center" prop="deductAmount" width="180"> </el-table-column>
  403. <el-table-column label="操作" align="center" fixed="right">
  404. <template slot-scope="scope">
  405. <el-button type="text" style="color: #ff4949" @click="removeCouponRelateCloth(scope.$index)">删除</el-button>
  406. </template>
  407. </el-table-column>
  408. </el-table> -->
  409. <span slot="footer" class="dialog-footer">
  410. <el-button @click="changeDiscountCouponOpen = false">取 消</el-button>
  411. <el-button type="primary" @click="submitChangeCouponRelateCloth">确 定</el-button>
  412. </span>
  413. </el-dialog>
  414. </div>
  415. </template>
  416. <script>
  417. import { collectCloth } from '../../../../api/order/cloth'
  418. export default {
  419. name: 'cashCloth',
  420. props: {
  421. appUserInfo: {
  422. type: Object
  423. },
  424. orderForm: {
  425. type: Object
  426. },
  427. orderClothItemDTOS: {
  428. type: Array,
  429. default: []
  430. },
  431. clothSpeeds: {
  432. type: Array,
  433. default: []
  434. },
  435. deductCouponVOS: {
  436. type: Array,
  437. default: []
  438. },
  439. discountCouponVOS: {
  440. //可选择的折扣券
  441. type: Array,
  442. default: []
  443. }
  444. },
  445. data() {
  446. return {
  447. dialogLoading: false,
  448. setCouponOpen: false, //是否选择优惠券
  449. loadingText: '',
  450. confirmCouponTabIndex: '0',
  451. confirmDeductTabIndex: '0',
  452. selectCoupons: [],
  453. changeDiscountCouponIndex: -1,
  454. changeDiscountCouponOpen: false,
  455. changeDiscountCouponTitle: '',
  456. changeDiscountCouponSelectCloths: [],
  457. changeDiscountCouponCanSelectCloths: [],
  458. activity: {}
  459. }
  460. },
  461. mounted() {
  462. if (process.env.ENV != 'production') {
  463. window.cashClothDialog = this
  464. }
  465. console.log('a12')
  466. },
  467. methods: {
  468. changePayType() {
  469. if (this.orderForm.payType == 0) {
  470. this.orderForm.authCode = ''
  471. this.$nextTick((_) => {
  472. this.$refs.autoFocus.focus()
  473. })
  474. }
  475. },
  476. // 处理现金金额
  477. handelPrice(e) {
  478. return Math.round(e * 100) / 100
  479. },
  480. calculateTotalPrice() {
  481. var price = 0
  482. for (let i = 0; i < this.orderClothItemDTOS.length; i++) {
  483. price += this.calculateClothSpecialPrice(i) + this.orderClothItemDTOS[i].defaultPrice
  484. }
  485. return price
  486. },
  487. calculateClothSpecialPrice(index) {
  488. var specialPrice = 0
  489. if (this.orderClothItemDTOS[index].orderClothCraftDTOS && this.orderClothItemDTOS[index].orderClothCraftDTOS.length > 0) {
  490. for (let i = 0; i < this.orderClothItemDTOS[index].orderClothCraftDTOS.length; i++) {
  491. specialPrice += this.orderClothItemDTOS[index].orderClothCraftDTOS[i].price
  492. }
  493. }
  494. if (this.orderClothItemDTOS[index].isHedging == 'Y') {
  495. specialPrice += this.orderClothItemDTOS[index].hedgingPrice * 0.01
  496. }
  497. for (let i = 0; i < this.clothSpeeds.length; i++) {
  498. if (this.orderClothItemDTOS[index].clothSpeedId == this.clothSpeeds[i].id) {
  499. specialPrice += this.orderClothItemDTOS[index].defaultPrice * (this.clothSpeeds[i].multiple - 1)
  500. break
  501. }
  502. }
  503. return specialPrice
  504. },
  505. calculateDeliveryPrice() {
  506. if (this.calculateTotalPrice() >= 100) {
  507. return 0
  508. }
  509. var delivery = 0
  510. if (this.orderForm.takeClothWay && this.orderForm.takeClothWay == '1') {
  511. delivery += 10
  512. }
  513. if (this.orderForm.sendClothWay && this.orderForm.sendClothWay == '1') {
  514. delivery += 10
  515. }
  516. return delivery
  517. },
  518. //计算当前所有优惠金额
  519. calculateTotalDiscountAmount() {
  520. var totalDiscountAmount = this.orderForm.cashDeductAmount ? this.orderForm.cashDeductAmount : 0
  521. this.orderClothItemDTOS.forEach((cloth) => {
  522. totalDiscountAmount = totalDiscountAmount + cloth.deductAmount
  523. })
  524. if (this.activity.id) {
  525. totalDiscountAmount = totalDiscountAmount + this.calculateTotalDiscountByActivity(this.activity)
  526. }
  527. return Math.round(totalDiscountAmount * 100) / 100
  528. },
  529. // 计算优惠券优惠金额
  530. calculateTotalDiscountAmountByCoupon() {
  531. var totalDiscountAmount = 0
  532. this.orderClothItemDTOS.forEach((cloth) => {
  533. totalDiscountAmount = Math.round((totalDiscountAmount + cloth.deductAmount) * 100) / 100
  534. })
  535. return totalDiscountAmount
  536. },
  537. // 计算平台活动优惠金额
  538. calculateTotalDiscountByActivity(e) {
  539. if (e.payScope == 2 && this.orderForm.payType && this.orderForm.payType != 3) {
  540. return 0
  541. }
  542. if (e.payScope == 1 && this.orderForm.payType && this.orderForm.payType == 3) {
  543. return 0
  544. }
  545. let activityAmount = 0
  546. if (e.clothScope == 0) {
  547. let total = this.calculateTotalPrice() + this.calculateDeliveryPrice() - this.calculateTotalDiscountAmountByCoupon()
  548. activityAmount = total * e.discount
  549. }
  550. if (e.clothScope == 1) {
  551. let total = this.calculateTotalPrice() + this.calculateDeliveryPrice() - this.calculateTotalDiscountAmountByCoupon()
  552. activityAmount = total * e.discount
  553. }
  554. return Math.round(activityAmount * 100) / 100
  555. },
  556. //计算出去现金券其余的优惠金额
  557. calculateTotalDiscountAmountWithoutCashAmount() {
  558. var totalDiscountAmount = 0
  559. this.orderClothItemDTOS.forEach((cloth) => {
  560. totalDiscountAmount = totalDiscountAmount + cloth.deductAmount
  561. })
  562. if (this.activity.id) {
  563. totalDiscountAmount = totalDiscountAmount + this.calculateTotalDiscountByActivity(this.activity)
  564. }
  565. return Math.round(totalDiscountAmount * 100) / 100
  566. },
  567. /**
  568. * 计算当前优惠券抵扣明细
  569. */
  570. calculateCouponDiscountInfo() {
  571. var deductAmount = 0
  572. this.changeDiscountCouponSelectCloths.forEach((item) => {
  573. deductAmount += item.deductAmount
  574. })
  575. return deductAmount
  576. },
  577. onCouponTabChange(tab, event) {
  578. console.log('tab.index:' + tab.index)
  579. // if(tab.index == '1'){
  580. // this.$refs['couponRef'].focus()
  581. // }
  582. },
  583. onSelectCoupon() {
  584. if (this.deductCouponVOS.length == 0) {
  585. this.$message.error('没有可选择的优惠券')
  586. return
  587. }
  588. this.setCouponOpen = true
  589. },
  590. // 选择可优惠金额
  591. changeCouponDiscountCloth(index) {
  592. // this.changeDiscountCouponSelectCloths = this.selectCoupons[index].orderCouponClothDTOS.concat()
  593. // for (let i = 0; i < this.changeDiscountCouponSelectCloths.length; i++) {
  594. // var item = this.changeDiscountCouponSelectCloths[i]
  595. // item.cloth = JSON.parse(JSON.stringify(this.orderClothItemDTOS[item.clothIndex]))
  596. // }
  597. // this.changeDiscountCouponIndex = index
  598. this.changeDiscountCouponCanSelectCloths = this.selectCoupons[index].applyCloths.concat()
  599. this.changeDiscountCouponCanSelectCloths.forEach((item) => {
  600. let deductAmount1 = this.handelPrice(item.totalPrice * ( this.selectCoupons[index].discountRate / 100))
  601. let deductAmount = deductAmount1 > this.selectCoupons[index].deductAmount ? this.selectCoupons[index].deductAmount : deductAmount1
  602. item.deductAmount = deductAmount
  603. item.isSelected = item.id == this.selectCoupons[index].orderCouponClothDTOS[0].id
  604. })
  605. // this.orderClothItemDTOS.forEach((item) => {
  606. // //如果这件衣服已经被被抵扣完成,则不需要选择
  607. // if (item.totalPrice - item.deductAmount <= 0) {
  608. // return
  609. // }
  610. // //添加优惠券支持的衣服
  611. // console.log('A4')
  612. // if (this.selectCoupons[index].appCouponTypeApplyClothVOS) {
  613. // if (!this.selectCoupons[index].appCouponTypeApplyClothVOS.find((i) => i.clothItemId == item.id)) {
  614. // return
  615. // }
  616. // }
  617. // //如果这个优惠券已经被选择过,则跳过
  618. // console.log('A5')
  619. // if (this.selectCoupons[index].orderCouponClothDTOS) {
  620. // if (this.selectCoupons[index].orderCouponClothDTOS.find((i) => i.clothIndex == item.index)) {
  621. // return
  622. // }
  623. // }
  624. // this.changeDiscountCouponCanSelectCloths.push(item)
  625. // })
  626. this.changeDiscountCouponTitle = '修改『' + this.selectCoupons[index].couponTypeTitle + '』可抵扣衣物'
  627. this.changeDiscountCouponOpen = true
  628. },
  629. onDiscountCouponSelect(e) {
  630. this.orderForm.discountCoupon = this.discountCouponVOS.find((item) => item.id == e)
  631. },
  632. getDiscountClothList() {
  633. var cloths = []
  634. if (!this.orderForm.discountCoupon) {
  635. return cloths
  636. }
  637. this.orderClothItemDTOS.forEach((cloth) => {
  638. if (this.orderForm.discountCoupon.appCouponTypeApplyClothVOS) {
  639. if (this.orderForm.discountCoupon.appCouponTypeApplyClothVOS.find((item) => item.clothItemId == cloth.id)) {
  640. cloths.push(cloth)
  641. }
  642. }
  643. })
  644. return cloths
  645. },
  646. calculateClothName(index) {
  647. var clothName = this.orderClothItemDTOS[index].name
  648. this.orderClothItemDTOS[index].orderClothTypeDTOS.forEach((item) => {
  649. if (item.clothTypeCode == '0') {
  650. clothName += ' - 加厚'
  651. }
  652. if (item.clothTypeCode == '0') {
  653. clothName += ' - 羊绒'
  654. }
  655. if (item.clothTypeCode == '0') {
  656. clothName += ' - 真丝'
  657. }
  658. if (item.clothTypeCode == '0') {
  659. clothName += ' - 儿童'
  660. }
  661. })
  662. return clothName
  663. },
  664. calculateClothNameByInfo(cloth) {
  665. var clothName = cloth.name
  666. cloth.orderClothTypeDTOS.forEach((item) => {
  667. if (item.clothTypeCode == '0') {
  668. clothName += ' - 加厚'
  669. }
  670. if (item.clothTypeCode == '0') {
  671. clothName += ' - 羊绒'
  672. }
  673. if (item.clothTypeCode == '0') {
  674. clothName += ' - 真丝'
  675. }
  676. if (item.clothTypeCode == '0') {
  677. clothName += ' - 儿童'
  678. }
  679. })
  680. return clothName
  681. },
  682. onSelectActivityItem(e) {
  683. if (e.id) {
  684. let activityAmount = 0
  685. if (e.clothScope == 0) {
  686. let total = this.calculateTotalPrice() + this.calculateDeliveryPrice() - this.calculateTotalDiscountAmountByCoupon()
  687. activityAmount = total * e.discount
  688. }
  689. if (e.clothScope == 1) {
  690. let total = this.calculateTotalPrice() + this.calculateDeliveryPrice() - this.calculateTotalDiscountAmountByCoupon()
  691. activityAmount = total * e.discount
  692. }
  693. e.activityAmount = Math.round(activityAmount * 100) / 100
  694. }
  695. this.activity = e
  696. },
  697. onSelectCouponItem(index) {
  698. var coupon = this.deductCouponVOS[index]
  699. // 折扣券
  700. coupon.orderCouponClothDTOS = []
  701. //找出优惠券适配优惠的衣服
  702. var applyCloths = []
  703. if (coupon.appCouponTypeApplyClothVOS) {
  704. coupon.appCouponTypeApplyClothVOS.forEach((item) => {
  705. for (let i = 0; i < this.orderClothItemDTOS.length; i++) {
  706. var cloth = this.orderClothItemDTOS[i]
  707. if (cloth.id != item.clothItemId || cloth.totalPrice <= 0) {
  708. continue
  709. }
  710. applyCloths.push(cloth)
  711. }
  712. })
  713. }
  714. //排序,按照订单剩余需要支付的金额降序
  715. applyCloths.sort((a, b) => {
  716. return b.totalPrice - a.totalPrice
  717. })
  718. this.orderClothItemDTOS.sort((a, b) => {
  719. return b.totalPrice - a.totalPrice
  720. })
  721. coupon.applyCloths = coupon.useScope == 2 ? applyCloths : this.orderClothItemDTOS
  722. if (coupon.useScope == 2 && !applyCloths.length) {
  723. this.$message.error('没有指定衣物,无法使用该优惠券')
  724. return
  725. }
  726. if (coupon.discountWay == 2) {
  727. if (coupon.isUnique == 'Y') {
  728. // 单件
  729. let cloth = coupon.applyCloths[coupon.applyCloths.length - 1]
  730. // 获取可用衣物里的最小价格
  731. let deductAmount1 = cloth.totalPrice * (coupon.discountRate / 100)
  732. let deductAmount = deductAmount1 > coupon.deductAmount ? coupon.deductAmount : deductAmount1
  733. coupon.orderCouponClothDTOS.push({ clothIndex: cloth.index, id: cloth.id, deductAmount: deductAmount, clothName: this.calculateClothNameByInfo(cloth) })
  734. cloth.deductAmount = deductAmount
  735. } else {
  736. // 全部
  737. let list = coupon.applyCloths
  738. for (let i = 0; i < list.length; i++) {
  739. let cloth = list[i]
  740. let deductAmount1 = this.handelPrice(cloth.totalPrice * (coupon.discountRate / 100))
  741. let deductAmount = deductAmount1 > coupon.deductAmount ? coupon.deductAmount : deductAmount1
  742. coupon.orderCouponClothDTOS.push({ clothIndex: cloth.index, id: cloth.id, deductAmount: deductAmount, clothName: this.calculateClothNameByInfo(cloth) })
  743. cloth.deductAmount = deductAmount
  744. }
  745. }
  746. }
  747. if (coupon.discountWay == '0') {
  748. // //抵扣
  749. // if (coupon.isUnique == 'Y') {
  750. // //单件,只减一件
  751. // var cloth = applyCloths[0]
  752. // //抵扣所有衣服里金额最大的
  753. // if (cloth.totalPrice - cloth.deductAmount >= coupon.deductAmount) {
  754. // coupon.orderCouponClothDTOS.push({ clothIndex: cloth.index, id: cloth.id, deductAmount: coupon.deductAmount, clothName: this.calculateClothNameByInfo(cloth) })
  755. // cloth.deductAmount += coupon.deductAmount
  756. // } else {
  757. // coupon.orderCouponClothDTOS.push({ clothIndex: cloth.index, id: cloth.id, deductAmount: cloth.totalPrice - cloth.deductAmount, clothName: this.calculateClothNameByInfo(cloth) })
  758. // cloth.deductAmount = cloth.totalPrice
  759. // }
  760. // } else {
  761. // //非单件,可减多件
  762. var deductAmount = coupon.deductAmount
  763. for (let i = 0; i < coupon.applyCloths.length; i++) {
  764. //如果优惠券可抵扣金额用完
  765. if (deductAmount <= 0) {
  766. break
  767. }
  768. var cloth = coupon.applyCloths[i]
  769. if (cloth.totalPrice - cloth.deductAmount >= deductAmount) {
  770. coupon.orderCouponClothDTOS.push({ clothIndex: cloth.index, id: cloth.id, deductAmount: deductAmount, clothName: this.calculateClothNameByInfo(cloth) })
  771. cloth.deductAmount += deductAmount
  772. deductAmount = 0
  773. } else {
  774. coupon.orderCouponClothDTOS.push({ clothIndex: cloth.index, id: cloth.id, deductAmount: cloth.totalPrice - cloth.deductAmount, clothName: this.calculateClothNameByInfo(cloth) })
  775. cloth.deductAmount = cloth.totalPrice
  776. deductAmount -= cloth.totalPrice - cloth.deductAmount
  777. }
  778. }
  779. }
  780. // }
  781. // else
  782. if (coupon.discountWay == '1') {
  783. //满减
  784. // console.log(applyCloths, coupon.minAmount)
  785. // if (coupon.useScope === 2 && applyCloths.length < parseInt(coupon.minAmount)) {
  786. // //未满足满减条件
  787. // this.$message.error('未满足满减条件')
  788. // return
  789. // }
  790. if (coupon.applyCloths.length < parseInt(coupon.minAmount)) {
  791. this.$message.error('未满足满减条件')
  792. return
  793. }
  794. if (coupon.isUnique !== 'Y') {
  795. //单件,只减一件
  796. var cloth = coupon.applyCloths[coupon.applyCloths.length - 1]
  797. coupon.orderCouponClothDTOS.push({ clothIndex: cloth.index, id: cloth.id, deductAmount: cloth.totalPrice, clothName: this.calculateClothNameByInfo(cloth) })
  798. cloth.deductAmount = cloth.totalPrice
  799. } else {
  800. //非单件,可减多件
  801. var count = parseInt(coupon.applyCloths.length / parseInt(coupon.minAmount)) * parseInt(coupon.deductAmount)
  802. for (let i = 0; i < count; i++) {
  803. var cloth = coupon.applyCloths[coupon.applyCloths.length - 1 - i]
  804. coupon.orderCouponClothDTOS.push({ clothIndex: cloth.index, id: cloth.id, deductAmount: cloth.totalPrice, clothName: this.calculateClothNameByInfo(cloth) })
  805. cloth.deductAmount = cloth.totalPrice
  806. }
  807. }
  808. }
  809. // this.deductCouponVOS.splice(index, 1)
  810. this.selectCoupons = [coupon]
  811. this.setCouponOpen = false
  812. this.$emit('initOrderList', this.orderClothItemDTOS)
  813. },
  814. //去除已选择的优惠券
  815. removeSelectCoupon(index) {
  816. var coupon = this.selectCoupons[index]
  817. //将优惠券放回未选择的数组中
  818. // if (coupon.discountWay == '2') {
  819. // this.discountCouponVOS.push(coupon)
  820. // } else {
  821. // this.deductCouponVOS.push(coupon)
  822. // }
  823. this.selectCoupons.splice(index, 1)
  824. //重置这条优惠券给衣服的优惠信息
  825. var orderCouponClothDTOS = coupon.orderCouponClothDTOS
  826. coupon.orderCouponClothDTOS = []
  827. orderCouponClothDTOS.forEach((selectItem) => {
  828. this.calculateClothDiscountAmount(selectItem.clothIndex)
  829. })
  830. },
  831. /** 提交按钮 */
  832. async submitForm(payTimeType) {
  833. this.$refs['confirmPayForm'].validate((valid) => {
  834. if (valid) {
  835. var params = { ...this.orderForm }
  836. params.appUserId = this.appUserInfo.id
  837. params.orderClothItemDTOS = this.orderClothItemDTOS.concat()
  838. params.orderClothItemDTOS.forEach((item) => {
  839. item.clothItemName = item.name
  840. })
  841. var orderCouponDTOS = this.selectCoupons.concat()
  842. if (this.orderForm.discountCouponId) {
  843. var coupon = this.discountCouponVOS.find((item) => (item.id = this.orderForm.discountCouponId))
  844. var orderCouponClothDTOS = []
  845. this.getDiscountClothList().forEach((item) => {
  846. var orderCouponClothDTO = { id: item.id, clothIndex: item.index, deductAmount: parseInt((item.totalPrice - item.deductAmount) * 100 * parseInt(100 - coupon.deductAmount * 100)) / 10000 }
  847. orderCouponClothDTOS.push(orderCouponClothDTO)
  848. })
  849. orderCouponDTOS.push({ id: coupon.id, ...{ orderCouponClothDTOS: orderCouponClothDTOS } })
  850. }
  851. params.orderCouponDTOS = orderCouponDTOS
  852. params.isSpecial = params.isSpecial ? 'Y' : 'N'
  853. params.payTimeType = payTimeType
  854. if (payTimeType == 1) {
  855. params.payType = 0
  856. }
  857. if (this.calculateTotalDiscountByActivity(this.activity)) {
  858. params.activityId = this.activity.id
  859. params.activityDiscountAmount = this.calculateTotalDiscountByActivity(this.activity)
  860. }
  861. console.log(params)
  862. const loading = this.$loading({
  863. lock: true,
  864. text: 'Loading',
  865. spinner: 'el-icon-loading',
  866. background: 'rgba(0, 0, 0, 0.7)'
  867. })
  868. collectCloth(params)
  869. .then((res) => {
  870. this.$message('提交成功')
  871. loading.close()
  872. this.$emit('onPaySuccess', { ...res.data, authCode: this.orderForm.authCode })
  873. })
  874. .catch((e) => {
  875. loading.close()
  876. this.$message.error(e.data.msg)
  877. })
  878. }
  879. })
  880. },
  881. removeCouponRelateCloth(index) {
  882. var cloth = this.changeDiscountCouponSelectCloths[index].cloth
  883. cloth.deductAmount = cloth.deductAmount - this.changeDiscountCouponSelectCloths[index].deductAmount
  884. this.changeDiscountCouponCanSelectCloths.push(cloth)
  885. this.changeDiscountCouponSelectCloths.splice(index, 1)
  886. },
  887. //选择优惠券关联的衣服
  888. addCouponRelateCloth(index) {
  889. this.changeDiscountCouponCanSelectCloths.forEach((item, i) => {
  890. item.clothIndex = item.index
  891. ;(item.clothName = this.calculateClothNameByInfo(item)), (item.isSelected = i === index)
  892. })
  893. this.changeDiscountCouponCanSelectCloths = JSON.parse(JSON.stringify(this.changeDiscountCouponCanSelectCloths))
  894. // var hasDeductAmount = this.calculateCouponDiscountInfo()
  895. // if (this.selectCoupons[this.changeDiscountCouponIndex].deductAmount - hasDeductAmount <= 0) {
  896. // this.$message.error('抵扣金额已用完,无法抵扣其他衣物')
  897. // return
  898. // }
  899. // if (this.selectCoupons[this.changeDiscountCouponIndex].isUnique == 'Y' && this.changeDiscountCouponSelectCloths.length > 0) {
  900. // this.$message.error('该优惠券为单件抵扣,无法抵扣第二件衣物')
  901. // }
  902. // var coupon = this.selectCoupons[this.changeDiscountCouponIndex]
  903. // var cloth = this.changeDiscountCouponCanSelectCloths[index]
  904. // if (coupon.isUnique == 'Y') {
  905. // //单件,只减一件
  906. // //抵扣所有衣服里金额最大的
  907. // if (cloth.totalPrice - cloth.deductAmount >= coupon.deductAmount) {
  908. // this.changeDiscountCouponSelectCloths.push({ clothIndex: cloth.index, id: cloth.id, deductAmount: coupon.deductAmount, clothName: this.calculateClothNameByInfo(cloth), cloth: cloth })
  909. // cloth.deductAmount += coupon.deductAmount
  910. // } else {
  911. // this.changeDiscountCouponSelectCloths.push({ clothIndex: cloth.index, id: cloth.id, deductAmount: cloth.totalPrice - cloth.deductAmount, clothName: this.calculateClothNameByInfo(cloth), cloth: cloth })
  912. // cloth.deductAmount = cloth.totalPrice
  913. // }
  914. // } else {
  915. // //非单件,可减多件
  916. // var deductAmount = this.selectCoupons[this.changeDiscountCouponIndex].deductAmount - hasDeductAmount
  917. // if (cloth.totalPrice - cloth.deductAmount >= deductAmount) {
  918. // this.changeDiscountCouponSelectCloths.push({ clothIndex: cloth.index, id: cloth.id, deductAmount: deductAmount, clothName: this.calculateClothNameByInfo(cloth), cloth: cloth })
  919. // cloth.deductAmount += deductAmount
  920. // } else {
  921. // this.changeDiscountCouponSelectCloths.push({ clothIndex: cloth.index, id: cloth.id, deductAmount: cloth.totalPrice - cloth.deductAmount, clothName: this.calculateClothNameByInfo(cloth), cloth: cloth })
  922. // cloth.deductAmount = cloth.totalPrice
  923. // }
  924. // }
  925. // this.changeDiscountCouponCanSelectCloths.splice(index, 1)
  926. },
  927. submitChangeCouponRelateCloth() {
  928. // let changeDiscountCouponSelectCloths = [];
  929. let item = this.changeDiscountCouponCanSelectCloths.find((object) => object.isSelected)
  930. this.selectCoupons[0].orderCouponClothDTOS = [item]
  931. // this.changeDiscountCouponCanSelectCloths.forEach((item) => {
  932. // this.calculateClothDiscountAmount(item.index)
  933. // })
  934. // this.changeDiscountCouponSelectCloths.forEach((item) => {
  935. // this.calculateClothDiscountAmount(item.clothIndex)
  936. // })
  937. this.orderClothItemDTOS.forEach((e) => {
  938. e.deductAmount = item.clothItemId == e.id ? item.deductAmount : 0
  939. })
  940. this.selectCoupons = this.selectCoupons.concat()
  941. // this.orderClothItemDTOS = this.orderClothItemDTOS.concat()
  942. this.changeDiscountCouponOpen = false
  943. },
  944. //计算某一件衣服的优惠金额,并配置到orderClothItemDTOS中
  945. calculateClothDiscountAmount(index) {
  946. var cloth = this.orderClothItemDTOS[index]
  947. cloth.deductAmount = 0
  948. this.selectCoupons.forEach((i) => {
  949. var selectCloth = i.orderCouponClothDTOS.find((item) => item.clothIndex == cloth.index)
  950. if (selectCloth) {
  951. cloth.deductAmount = cloth.deductAmount + selectCloth.deductAmount
  952. }
  953. })
  954. this.orderClothItemDTOS[index] = cloth
  955. this.$emit('initOrderList', this.orderClothItemDTOS)
  956. // this.orderClothItemDTOS = this.orderClothItemDTOS.concat()
  957. },
  958. checkClose(done) {
  959. this.$confirm('是否关闭表单,关闭后数据将丢失?')
  960. .then(function () {
  961. done()
  962. })
  963. .then(() => {})
  964. .catch(() => {})
  965. }
  966. }
  967. }
  968. </script>
  969. <style scoped></style>