ns-justmoney.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <template>
  2. <view class="justmoney">
  3. <view class="title">
  4. 订单调价
  5. <text class="iconfont iconguanbi1" @click="close('orderAdjustMoney')"></text>
  6. </view>
  7. <view class="table-box" v-if="goods_list.length > 0">
  8. <view class="table" style="width:76%">
  9. <view class="table-th">
  10. <view class="table-td" style="width: 30%;">商品信息</view>
  11. <view class="table-td" style="width: 10%;">单价</view>
  12. <view class="table-td" style="width: 12%;">数量</view>
  13. <view class="table-td" style="width: 12%;">小计</view>
  14. <view class="table-td" style="width: 12%;">商品总额</view>
  15. <view class="table-td" style="width: 12%;">店内优惠</view>
  16. <view class="table-td" style="width: 12%;">抵扣金额</view>
  17. </view>
  18. <view class="table-tb">
  19. <view class="table-tb-item" v-for="(item, index) in new_list" :key="index">
  20. <view class="table-td" style="width: 30%;">
  21. <image class="goods-image" :src="$util.img(item.goods_image, { size: 'small' })" mode="widthFix"></image>
  22. <view class="goods-name">{{ item.goods_name }}</view>
  23. </view>
  24. <view class="table-td" style="width: 10%;">{{ item.price }}</view>
  25. <view class="table-td" style="width: 12%;">{{ item.num }}</view>
  26. <view class="table-td" style="width: 12%;">{{ item.goods_money }}</view>
  27. <view class="table-td" style="width: 12%;">{{ item.goods_money }}</view>
  28. <view class="table-td" style="width: 12%;">{{ discount_money }}</view>
  29. <view class="table-td" style="width: 12%;">{{ offset_money }}</view>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="table-unit" style="width:14%">
  34. <view class="table-th">调整金额</view>
  35. <view class="table-td table-td-unit"><input placeholder="请输入调整金额" type="number" v-model="adjust_money" @input="adjust" /></view>
  36. </view>
  37. <view class="table-unit" style="width:10%">
  38. <view class="table-th">实付金额</view>
  39. <view class="table-tb">{{ pay_money_unit }}</view>
  40. </view>
  41. </view>
  42. <view class="die-but">
  43. <button type="primary" class="default-btn btn save" @click="close('orderAdjustMoney')">取消</button>
  44. <button type="primary" class="primary-btn btn" @click="save({ adjust_money: adjust_money })">保存</button>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. export default {
  50. data() {
  51. return {
  52. pay_money_unit: '',
  53. //防止浅拷贝影响全局
  54. new_list: [],
  55. // 金额调整
  56. adjust_money: 0,
  57. //防重复操作
  58. judge: false
  59. };
  60. },
  61. props: {
  62. goods_list: {
  63. type: Array,
  64. default: () => {
  65. return [];
  66. }
  67. },
  68. pay_money: {
  69. type: [String, Number],
  70. default: () => {
  71. return '0';
  72. }
  73. },
  74. discount_money: {
  75. type: [String, Number],
  76. default: () => {
  77. return 0;
  78. }
  79. },
  80. offset_money: {
  81. type: [String, Number],
  82. default: () => {
  83. return 0;
  84. }
  85. }
  86. },
  87. created() {
  88. this.pay_money_unit = JSON.parse(JSON.stringify(this.pay_money));
  89. //防止浅拷贝影响全局
  90. this.new_list = JSON.parse(JSON.stringify(this.goods_list));
  91. this.adjust_money = JSON.parse(JSON.stringify(this.goods_list[0].adjust_money));
  92. },
  93. methods: {
  94. /**
  95. * 调价修改
  96. */
  97. adjust() {
  98. if (!this.adjust_money) {
  99. this.adjust_money = 0;
  100. }
  101. let obj = JSON.parse(JSON.stringify(this.new_list[0]));
  102. let goods_money = parseFloat(obj.goods_money);
  103. let discount_money = parseFloat(this.discount_money);
  104. let offset_money = parseFloat(this.offset_money);
  105. let shipping_money = 0.0;
  106. var real_goods_money = parseFloat(goods_money) + parseFloat(this.adjust_money) - parseFloat(discount_money);
  107. var total_money = parseFloat(real_goods_money) + parseFloat(shipping_money);
  108. total_money = Math.round(total_money * 100) / 100;
  109. this.pay_money_unit = parseFloat(total_money - offset_money).toFixed(2);
  110. this.$forceUpdate();
  111. },
  112. /**
  113. * 调价修改提交
  114. */
  115. save(data) {
  116. if (this.judge) return false;
  117. this.judge = true;
  118. this.$emit('orderAdjustMoney', data, () => {
  119. this.judge = false;
  120. });
  121. },
  122. /**
  123. * 弹窗关闭
  124. */
  125. close() {
  126. this.$emit('close', 'orderAdjustMoney');
  127. }
  128. }
  129. };
  130. </script>
  131. <style lang="scss" scoped>
  132. .justmoney {
  133. width: 80vw;
  134. background: #ffffff;
  135. border-radius: 0.06rem;
  136. padding-bottom: 0.2rem;
  137. min-width: 10rem;
  138. .title {
  139. display: flex;
  140. align-items: center;
  141. justify-content: space-between;
  142. padding: 0 0.15rem;
  143. height: 0.5rem;
  144. box-sizing: border-box;
  145. border-bottom: 0.01rem solid #e6e6e6;
  146. font-size: 0.16rem;
  147. .iconfont {
  148. font-size: 0.18rem;
  149. }
  150. }
  151. .table-box {
  152. display: flex;
  153. padding: 0 0.3rem;
  154. box-sizing: border-box;
  155. margin-top: 0.2rem;
  156. width: 100%;
  157. .table {
  158. .table-th {
  159. width: 100%;
  160. height: 0.4rem;
  161. display: flex;
  162. align-items: center;
  163. justify-content: space-between;
  164. background: #f8f6f9;
  165. border-bottom: 0.01rem solid #e6e6e6;
  166. box-sizing: border-box;
  167. }
  168. .table-td {
  169. padding: 0 0.15rem;
  170. box-sizing: border-box;
  171. }
  172. .table-tb {
  173. .table-tb-item {
  174. display: flex;
  175. align-items: center;
  176. justify-content: space-between;
  177. height: 0.5rem;
  178. border-bottom: 0.01rem solid #e6e6e6;
  179. .table-td {
  180. border-left: 0.01rem solid #e6e6e6;
  181. height: 100%;
  182. display: flex;
  183. align-items: center;
  184. .goods-image {
  185. width: 0.4rem;
  186. height: 0.4rem;
  187. margin-right: 0.1rem;
  188. }
  189. .goods-name {
  190. font-size: 0.14rem;
  191. color: #333333;
  192. text-overflow: -o-ellipsis-lastline;
  193. overflow: hidden;
  194. text-overflow: ellipsis;
  195. display: -webkit-box;
  196. -webkit-line-clamp: 2;
  197. line-clamp: 2;
  198. -webkit-box-orient: vertical;
  199. }
  200. }
  201. .table-td:last-child {
  202. border-right: 0.01rem solid #e6e6e6;
  203. }
  204. }
  205. }
  206. }
  207. .table-unit {
  208. .table-th {
  209. width: 100%;
  210. height: 0.4rem;
  211. background: #f8f6f9;
  212. border-bottom: 0.01rem solid #e6e6e6;
  213. padding-left: 0.15rem;
  214. box-sizing: border-box;
  215. display: flex;
  216. align-items: center;
  217. }
  218. .table-tb {
  219. height: calc(100% - 0.4rem);
  220. display: flex;
  221. align-items: center;
  222. padding-left: 0.15rem;
  223. box-sizing: border-box;
  224. border-right: 0.01rem solid #e6e6e6;
  225. border-bottom: 0.01rem solid #e6e6e6;
  226. white-space: nowrap;
  227. overflow: hidden;
  228. }
  229. .table-td-unit {
  230. padding: 0 0.15rem;
  231. box-sizing: border-box;
  232. height: calc(100% - 0.4rem);
  233. display: flex;
  234. align-items: center;
  235. padding-left: 0.15rem;
  236. box-sizing: border-box;
  237. border-right: 0.01rem solid #e6e6e6;
  238. border-bottom: 0.01rem solid #e6e6e6;
  239. input {
  240. width: 100%;
  241. height: 60%;
  242. font-size: 0.14rem;
  243. border: 0.01rem solid #e6e6e6;
  244. padding-left: 0.1rem;
  245. }
  246. }
  247. }
  248. }
  249. .die-but {
  250. margin-top: 0.2rem;
  251. .btn {
  252. width: auto;
  253. height: auto;
  254. padding: 0 0.2rem;
  255. float: right;
  256. }
  257. .save {
  258. margin: 0 0.15rem;
  259. }
  260. }
  261. .die-but:after {
  262. overflow: hidden;
  263. content: '';
  264. height: 0;
  265. clear: both;
  266. display: block;
  267. }
  268. }
  269. </style>