dialog-selectLot.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <dialog-base class="dialog-body" ref="baseDialog" title="选择批次">
  3. <uni-section title="请选择批次" type="square">
  4. <uni-data-select v-model="selectedLot" :localdata="lotList" :clear="false"
  5. ></uni-data-select>
  6. </uni-section>
  7. <view class="add-btn-container uni-row">
  8. <button type="primary" class="btn" @click="handleConfirm">确认</button>
  9. </view>
  10. </dialog-base>
  11. </template>
  12. <script setup>
  13. import {
  14. ref,
  15. getCurrentInstance
  16. } from 'vue'
  17. const baseDialog = ref(null)
  18. const emit = defineEmits(['submit'])
  19. const lotList = ref([])
  20. const selectedLot = ref(null)
  21. const open = (data) => {
  22. console.log(data)
  23. baseDialog.value.open();
  24. for (var i = 0; i < data.length; i++) {
  25. lotList.value[i] = {
  26. text: data[i].label,
  27. value: data[i].value
  28. }
  29. }
  30. console.log(lotList.value)
  31. selectedLot.value = lotList.value[0].value
  32. }
  33. const close = () => {
  34. baseDialog.value.close()
  35. }
  36. defineExpose({
  37. open
  38. })
  39. function handleConfirm() {
  40. let index = lotList.value.findIndex(item =>item.value == selectedLot.value)
  41. close();
  42. emit('submit',lotList.value[index]);
  43. }
  44. </script>
  45. <style lang="scss">
  46. .selected {
  47. border: 3rpx solid #1684fc;
  48. border-radius: 8rpx;
  49. }
  50. .dialog-body {
  51. overflow: auto;
  52. .list-title {
  53. margin: 10rpx 0 20rpx 0;
  54. .label {
  55. font-size: 32rpx;
  56. font-weight: bold;
  57. }
  58. }
  59. .prompt {
  60. color: red;
  61. margin: 8rpx auto 0;
  62. }
  63. .list-container {
  64. width: 94%;
  65. display: flex;
  66. align-items: flex-start;
  67. margin: 10rpx auto;
  68. padding: 8px 2% 16px 2%;
  69. border-radius: 8rpx;
  70. .list-container-item {
  71. width: 100%;
  72. border-bottom: 1px solid #e1e1e1;
  73. border-left: 1px solid #e1e1e1;
  74. border-right: 1px solid #e1e1e1;
  75. padding: 12rpx 8rpx;
  76. box-sizing: border-box;
  77. .label {
  78. font-size: 28rpx;
  79. color: gray;
  80. width: 140rpx;
  81. &.value {
  82. flex: 1;
  83. }
  84. }
  85. }
  86. }
  87. .add-btn-container {
  88. margin-top: 32rpx;
  89. .btn {
  90. flex: 1;
  91. }
  92. }
  93. }
  94. .selectedProcess {
  95. width: 88%;
  96. margin: 20rpx auto 40rpx;
  97. }
  98. </style>