combine.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <div>
  3. <div class="container" v-if="isCombine === true">
  4. <div style="padding: 10px 0 20px;">找到{{ goods.length }}个属于"{{ goods[0].recipient
  5. }}"&部门"{{ goods[0].departmentId }}"&座位号:"{{ goods[0].sendSeat }}"的快件:</div>
  6. <van-checkbox style="margin-bottom: 10px;" v-model="isAllChecked" shape="square">全选</van-checkbox>
  7. <van-form @submit="onSubmit">
  8. <van-field name="checkboxGroup">
  9. <template #input>
  10. <van-checkbox-group v-model="checkedGoods">
  11. <van-checkbox style="margin-bottom: 10px;" :checked="good.checked" v-for="good in goods"
  12. :name="good.id" :key="good.id" shape="square">
  13. {{ good.expressNo }} & {{ good.expressType }} & {{ good.expressQuantity }}件 &{{
  14. good.isPayOnDelivery == '否' ? '非到付' : '到付' }}
  15. </van-checkbox>
  16. </van-checkbox-group>
  17. </template>
  18. </van-field>
  19. <van-button style="float: right;" class="sureSign" type="info" native-type="submit">合并签收</van-button>
  20. <!-- <van-button style="height: 40px; width: 150px; border-radius: 8px;" type="default"
  21. @click="back">返回上一级</van-button> -->
  22. </van-form>
  23. </div>
  24. <SureCombine v-else :isCombine="isCombine" :goodsList="goodsList" @isCombine="sureCombine"></SureCombine>
  25. </div>
  26. </template>
  27. <script>
  28. import SureCombine from './sureCombine.vue'
  29. export default {
  30. props: ['signList'],
  31. components: {
  32. SureCombine
  33. },
  34. data() {
  35. return {
  36. goods: this.signList,
  37. isCombine: true,
  38. checkedGoods: [], // 选中的商品ID集合
  39. goodsList: [],//筛选后的数据
  40. };
  41. },
  42. methods: {
  43. toggleAll() {
  44. this.$refs.checkboxGroup.toggleAll();
  45. this.qwe = !this.qwe
  46. },
  47. // 合并签收
  48. onSubmit(values) {
  49. if (this.checkedGoods.length > 0) {
  50. this.isCombine = false
  51. this.$emit("onIsCombine", this.isCombine)
  52. console.log('submit', values);
  53. // let data = this.goods.filter((good) => values.checkboxGroup.includes(good.id))
  54. let data = []
  55. this.goods.forEach((good) => {
  56. if (values.checkboxGroup.find((goodId) => goodId === good.id)) {
  57. data.push(good)
  58. }
  59. })
  60. this.goodsList = data
  61. console.log('data', data);
  62. this.$emit('isSearch', false)
  63. } else {
  64. this.$toast('请至少选择一个')
  65. }
  66. },
  67. // 控制页面
  68. sureCombine(value) {
  69. console.log(value)
  70. this.isCombine = value
  71. this.$emit("onIsCombine", this.isCombine)
  72. },
  73. },
  74. computed: {
  75. isAllChecked: {
  76. // 计算是否全选
  77. get() {
  78. return this.goods.length === this.checkedGoods.length;
  79. },
  80. // 设置全选
  81. set(value) {
  82. this.checkedGoods = value ? this.goods.map(good => good.id) : [];
  83. }
  84. }
  85. },
  86. watch: {
  87. signList(newValue) {
  88. this.goods = newValue
  89. this.checkedGoods = []; // 选中的商品ID集合
  90. this.goodsList = [];//筛选后的数据
  91. }
  92. }
  93. };
  94. </script>
  95. <style lang="less" scoped>
  96. * {
  97. font-size: 16px;
  98. }
  99. .van-cell {
  100. padding: 0;
  101. }
  102. .container {
  103. padding: 2px 10px 0 10px;
  104. background-color: #fff;
  105. height: 100%;
  106. .sureSign {
  107. height: 40px;
  108. width: 150px;
  109. border-radius: 8px;
  110. margin-right: 20px;
  111. margin-top: 20px;
  112. }
  113. }
  114. </style>