select-warehouse-input.vue 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <view class="flex1">
  3. <slot>
  4. <template v-for="(item, index) in values" :key="index">
  5. <view class="pd-24 mb-12 warehouse-item p-rtv f-s-32 c-#333 f-w-500">
  6. {{ item.warehouseName }}{{ item.shelvesName ? '-' : '' }}{{ item.shelvesName || '' }}
  7. <view class="close-icon pd-16" @click="deleteItem(index)">
  8. <up-icon color="#F81242" name="close" size="32rpx"></up-icon>
  9. </view>
  10. </view>
  11. </template>
  12. <up-button @click="clickSlot" type="primary" plain>
  13. <image class="w-36 h-36 mr-10" src="https://ta.zycpzs.cn/oss-file/smart-trace/szyy/images-plt/common/select_push_icon.png" mode="widthFix" />
  14. <span>请{{ title }}</span>
  15. </up-button>
  16. </slot>
  17. </view>
  18. <SelectWarehouseDialog v-model="values" v-if="showWarehouse" v-model:show="showWarehouse" :title="title" :params="params" @confirm="confirmSelection"></SelectWarehouseDialog>
  19. </template>
  20. <script setup lang="ts">
  21. import SelectWarehouseDialog from '../select-warehouse-dialog/select-warehouse-dialog.vue';
  22. const props = defineProps({
  23. modelValue: {
  24. type: Array,
  25. default: () => [],
  26. },
  27. title: {
  28. type: String,
  29. default: '请选择存放库房',
  30. },
  31. params: {
  32. type: Object,
  33. default: () => ({}),
  34. },
  35. });
  36. const emit = defineEmits(['update:modelValue']);
  37. const values = ref<any[]>(props.modelValue);
  38. const showWarehouse = ref(false);
  39. const clickSlot = () => {
  40. showWarehouse.value = true;
  41. };
  42. const confirmSelection = (selectedValues: any[]) => {
  43. values.value = selectedValues;
  44. emit('update:modelValue', selectedValues);
  45. };
  46. const deleteItem = (index: number) => {
  47. values.value.splice(index, 1);
  48. emit('update:modelValue', values.value);
  49. };
  50. </script>
  51. <script lang="ts">
  52. export default {
  53. options: {
  54. // 微信小程序中 options 选项
  55. multipleSlots: true, // 在组件定义时的选项中启动多slot支持,默认启用
  56. styleIsolation: 'shared', // 启动样式隔离。当使用页面自定义组件,希望父组件影响子组件样式时可能需要配置。具体配置选项参见:微信小程序自定义组件的样式
  57. addGlobalClass: true, // 表示页面样式将影响到自定义组件,但自定义组件中指定的样式不会影响页面。这个选项等价于设置 styleIsolation: apply-shared
  58. virtualHost: true, // 将自定义节点设置成虚拟的,更加接近Vue组件的表现。我们不希望自定义组件的这个节点本身可以设置样式、响应 flex 布局等,而是希望自定义组件内部的第一层节点能够响应 flex 布局或者样式由自定义组件本身完全决定
  59. },
  60. };
  61. </script>
  62. <style lang="scss" scoped>
  63. .warehouse-item {
  64. background-color: #fbfdfb;
  65. border: 1px solid #afddbb;
  66. border-radius: 10px;
  67. }
  68. .close-icon {
  69. position: absolute;
  70. top: 0rpx;
  71. right: 0rpx;
  72. }
  73. </style>