index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <template>
  2. <view class="container">
  3. <view class="goods-box" v-if="list.cart_info">
  4. <view class="header">订单号:{{ list.order_id }}</view>
  5. <view class='item acea-row' v-for="(item,index) in list.cart_info">
  6. <view class='pictrue'>
  7. <image :src="item.cart_info.productInfo.attrInfo.image" mode=""></image>
  8. </view>
  9. <view class='text acea-row row-column row-between'>
  10. <view class="title line2">{{ item.cart_info.productInfo.store_name }}</view>
  11. <view class='money acea-row row-between row-middle'>
  12. <view class="orangcol">
  13. 已核销:<text>{{item.write_times - item.surplus_num}}</text>/{{item.write_times}}
  14. </view>
  15. <view v-if="item.is_writeoff == 1" class="txt acea-row row-middle">
  16. 核销已完成
  17. </view>
  18. <view v-else class="txt acea-row row-middle">
  19. 本次核销:
  20. <view class='carnum acea-row row-center-wrapper'>
  21. <view v-if="item.surplus_num_input == 1" class="reduce bggary">
  22. <text class="iconfont icon-ic_Reduce"></text>
  23. </view>
  24. <view v-else class="reduce" @click.stop='subCart(item,index)'>
  25. <text class="iconfont icon-ic_Reduce"></text>
  26. </view>
  27. <!-- <view class='nums'>{{item.surplus_num_input}}</view> -->
  28. <input v-model="item.surplus_num_input" class='nums' type="number" @input="numInput" @blur="numBlur" />
  29. <view v-if="item.surplus_num_input == item.surplus_num" class="plus bggary">
  30. <text class="iconfont icon-ic_increase"></text>
  31. </view>
  32. <view v-else class="plus" @click.stop='addCart(item,index)'>
  33. <text class="iconfont icon-ic_increase"></text>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="record-box" v-if="recordList.length">
  42. <view class="header">核销记录</view>
  43. <view class="list">
  44. <view class="item acea-row row-middle row-between" v-for="(item, index) in recordList" :key="index">
  45. <view class="left">{{ item.add_time }}</view>
  46. <view class="right">核销{{item.writeoff_num}}次</view>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="footer acea-row row-middle row-between">
  51. <navigator class="btn" :url="storeNum?'/pages/admin/work/index':'/pages/admin/work/store'" hover-class="none">返回工作台</navigator>
  52. <view v-if="list.cart_info && list.cart_info[0].surplus_num" class="btn" @click="verification">确认核销</view>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. import {
  58. orderCartInfo,
  59. orderWriteoff,
  60. storeWirteOffRecords,
  61. orderWirteOffRecords,
  62. } from '@/api/admin'
  63. export default {
  64. data() {
  65. return {
  66. list: {},
  67. recordList: [],
  68. lists: {},
  69. checkModel: [],
  70. nums: [],
  71. auth: 1,
  72. id: 0,
  73. storeNum:1 //1:平台;2:门店
  74. }
  75. },
  76. watch: {
  77. checkModel() {
  78. if (this.lengt == this.checkModel.length) {
  79. this.checked = true;
  80. } else {
  81. this.checked = false;
  82. }
  83. }
  84. },
  85. onLoad(option) {
  86. this.auth = option.auth || 1;
  87. this.id = option.id;
  88. this.storeNum = parseInt(option.storeNum);
  89. this.getCartList()
  90. this.orderWirteOffRecords()
  91. },
  92. methods: {
  93. numInput(event) {
  94. let value = event.detail.value;
  95. if (value) {
  96. value = Number(value);
  97. this.$nextTick(() => {
  98. if (value > this.list.cart_info[0].surplus_num) {
  99. this.list.cart_info[0].surplus_num_input = this.list.cart_info[0].surplus_num;
  100. } else if (value < 1) {
  101. this.list.cart_info[0].surplus_num_input = 1;
  102. }
  103. });
  104. }
  105. },
  106. numBlur(event) {
  107. let value = event.detail.value;
  108. if (!value) {
  109. this.$nextTick(() => {
  110. this.list.cart_info[0].surplus_num_input = 1;
  111. });
  112. }
  113. },
  114. orderWirteOffRecords() {
  115. let funApi = '';
  116. if(this.storeNum){
  117. funApi = orderWirteOffRecords;
  118. }else{
  119. funApi = storeWirteOffRecords;
  120. }
  121. funApi(this.id, {
  122. product_type: 4
  123. }).then(res => {
  124. this.recordList = res.data.list;
  125. });
  126. },
  127. num() {
  128. for (let index = 0; index < this.lists.cart_info.length; index++) {
  129. this.nums.push({
  130. num: 0
  131. });
  132. }
  133. },
  134. getCartList: function() {
  135. orderCartInfo({
  136. oid: this.id,
  137. auth: this.auth,
  138. }).then(res => {
  139. let list = res.data;
  140. for (let i = 0; i < list.cart_info.length; i++) {
  141. list.cart_info[i].surplus_num_input = 1
  142. }
  143. this.list = res.data
  144. this.lists = JSON.parse(JSON.stringify(res.data))
  145. this.listlet = res.data.cart_info.length
  146. this.$set(this.attr, 'id', this.list.id);
  147. this.num()
  148. }).catch(res => {
  149. this.$util.Tips({
  150. title: res
  151. });
  152. });
  153. },
  154. subCart(item, index) {
  155. this.list.cart_info[index].surplus_num_input--;
  156. },
  157. addCart(item, index) {
  158. this.list.cart_info[index].surplus_num_input++;
  159. },
  160. verification() {
  161. let that = this;
  162. let cart_ids = [];
  163. for (let i = 0; i < this.list.cart_info.length; i++) {
  164. cart_ids.push({
  165. cart_id: this.list.cart_info[i].cart_id,
  166. cart_num: this.list.cart_info[i].surplus_num_input,
  167. });
  168. }
  169. orderWriteoff({
  170. auth: this.auth,
  171. oid: this.id,
  172. cart_ids: cart_ids
  173. }).then(res => {
  174. // uni.hideLoading();
  175. this.$util.Tips({
  176. title: res.msg
  177. }, () => {
  178. this.orderWirteOffRecords();
  179. });
  180. this.list.cart_info[0].surplus_num = this.list.cart_info[0].surplus_num - this.list.cart_info[0].surplus_num_input;
  181. // that.getCartList();
  182. }).catch(err => {
  183. this.$util.Tips({
  184. title: err
  185. });
  186. // uni.hideLoading();
  187. });
  188. }
  189. },
  190. }
  191. </script>
  192. <style lang="scss" scoped>
  193. .container {
  194. padding: 22rpx 20rpx;
  195. }
  196. .goods-box {
  197. padding: 32rpx 24rpx;
  198. border-radius: 24rpx;
  199. background: #FFFFFF;
  200. .header {
  201. margin-bottom: 26rpx;
  202. font-size: 28rpx;
  203. line-height: 40rpx;
  204. color: #333333;
  205. }
  206. .pictrue {
  207. width: 136rpx;
  208. height: 136rpx;
  209. border-radius: 16rpx;
  210. }
  211. image {
  212. width: 100%;
  213. height: 100%;
  214. border-radius: 16rpx;
  215. }
  216. .text {
  217. flex: 1;
  218. padding-left: 20rpx;
  219. }
  220. .title {
  221. font-size: 28rpx;
  222. line-height: 40rpx;
  223. color: #333333;
  224. }
  225. .orangcol {
  226. font-size: 24rpx;
  227. line-height: 34rpx;
  228. color: #666666;
  229. text {
  230. color: #2A7EFB;
  231. }
  232. }
  233. .txt {
  234. font-size: 24rpx;
  235. line-height: 34rpx;
  236. color: #666666;
  237. }
  238. .reduce {
  239. width: 32rpx;
  240. height: 36rpx;
  241. text-align: left;
  242. line-height: 36rpx;
  243. .iconfont {
  244. font-size: 24rpx;
  245. color: #333333;
  246. }
  247. &.bggary {
  248. .iconfont {
  249. color: #CCCCCC;
  250. }
  251. }
  252. }
  253. .plus {
  254. width: 32rpx;
  255. height: 36rpx;
  256. text-align: right;
  257. line-height: 36rpx;
  258. .iconfont {
  259. font-size: 24rpx;
  260. color: #333333;
  261. }
  262. &.bggary {
  263. .iconfont {
  264. color: #CCCCCC;
  265. }
  266. }
  267. }
  268. .nums {
  269. width: 72rpx;
  270. height: 36rpx;
  271. border-radius: 4rpx;
  272. background: #F5F5F5;
  273. text-align: center;
  274. font-family: SemiBold;
  275. font-weight: 600;
  276. font-size: 24rpx;
  277. line-height: 36rpx;
  278. color: #333333;
  279. }
  280. .iconfont {
  281. font-size: 24rpx;
  282. }
  283. }
  284. .record-box {
  285. padding-bottom: 30rpx;
  286. border-radius: 24rpx;
  287. margin-top: 20rpx;
  288. background: #FFFFFF;
  289. .header {
  290. padding: 32rpx 0 16rpx 24rpx;
  291. font-weight: 500;
  292. font-size: 30rpx;
  293. line-height: 42rpx;
  294. color: #333333;
  295. }
  296. .list {
  297. padding: 0 40rpx;
  298. }
  299. .item {
  300. height: 88rpx;
  301. border-bottom: 1rpx solid #F1F1F1;
  302. font-size: 28rpx;
  303. color: #333333;
  304. .right {
  305. color: #666666;
  306. }
  307. }
  308. }
  309. .footer {
  310. position: fixed;
  311. bottom: 0;
  312. left: 0;
  313. width: 100%;
  314. height: 112rpx;
  315. height: calc(112rpx + constant(safe-area-inset-bottom));
  316. height: calc(112rpx + env(safe-area-inset-bottom));
  317. padding: 0 20rpx;
  318. padding-bottom: constant(safe-area-inset-bottom);
  319. padding-bottom: env(safe-area-inset-bottom);
  320. background: #FFFFFF;
  321. .btn {
  322. flex: 1;
  323. height: 72rpx;
  324. border: 2rpx solid #2A7EFB;
  325. border-radius: 36rpx;
  326. margin-right: 16rpx;
  327. text-align: center;
  328. font-weight: 500;
  329. font-size: 26rpx;
  330. line-height: 68rpx;
  331. color: #2A7EFB;
  332. &:last-child {
  333. margin-right: 0;
  334. background: #2A7EFB;
  335. color: #FFFFFF;
  336. }
  337. }
  338. }
  339. .item ~ .item{
  340. margin-top: 40rpx;
  341. }
  342. </style>