towInOne.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <div class="clearfix parentC">
  3. <div class="inputC">{{propValue}}</div>
  4. <div v-if="getPropConfig">
  5. <div class="selectC" v-if="propValue" key="propValue1" @click="openModal">更换</div>
  6. <div class="selectC" v-else key="propValue2" @click="vxeValue = true;">选择</div>
  7. </div>
  8. <vxe-modal v-model="vxeValue" width="800" height="170" show-zoom resize transfer show-footer>
  9. <template #title>
  10. <span>选择仓库、仓位</span>
  11. </template>
  12. <template #default>
  13. <by-form :propConfig="config" ref="form" style="margin-top: 10px;"></by-form>
  14. </template>
  15. <template #footer>
  16. <div class="btn">
  17. <el-button type="primary" size="small" @click="doConfirm">确定</el-button>
  18. </div>
  19. </template>
  20. </vxe-modal>
  21. </div>
  22. </template>
  23. <script lang="ts">
  24. import { Component, Prop, Vue, Watch } from "vue-property-decorator";
  25. import api from "@/api/order";
  26. @Component
  27. export default class TowInOne extends Vue {
  28. vxeValue : any = false
  29. @Prop()
  30. propValue : any;
  31. @Prop()
  32. parentValue : any;
  33. @Prop()
  34. propConfig : any;
  35. get getPropConfig() {
  36. return this.propConfig?.isSelect;
  37. }
  38. config = {
  39. attr: {
  40. size: 'small',
  41. height: 43,
  42. },
  43. columns: [
  44. [{
  45. span: 11,
  46. label: '仓库',
  47. prop: 'storehouseName',
  48. component: 'warehouse',
  49. compConfig: {
  50. attr: {
  51. placeholder: '请选择仓库',
  52. retConfig: {
  53. storehouseName: 'name',
  54. storehouseId: 'id'
  55. },
  56. },
  57. }
  58. }, {
  59. span: 11,
  60. label: '仓位',
  61. prop: 'storingLocationName',
  62. component: 'warehouse-position',
  63. compConfig: {
  64. attr: {
  65. placeholder: '请选择仓位',
  66. retConfig: {
  67. storingLocationName: 'name',
  68. storingLocationId: 'id'
  69. },
  70. }
  71. }
  72. }]
  73. ]
  74. }
  75. // 打开弹窗
  76. openModal() {
  77. let data = (this as any).$lodash.cloneDeep(this.propValue);
  78. data = data.split(',');
  79. console.log(data);
  80. console.log(this.parentValue);
  81. setTimeout(() => {
  82. (this as any).$refs.form.setValue({
  83. storehouseName: this.parentValue.storehouseName,
  84. storehouseId: this.parentValue.storehouseId,
  85. storingLocationName: this.parentValue.storingLocationName,
  86. storingLocationId: this.parentValue.storingLocationId,
  87. })
  88. }, 0)
  89. this.vxeValue = true;
  90. }
  91. // 确定仓库仓位
  92. doConfirm() {
  93. let data : any = (this as any).$refs.form.getValue();
  94. // console.log(data);
  95. // console.log(this.parentValue);
  96. if (!data.storehouseId || !data.storingLocationId) return this.$message.warning('仓库仓位为必填项');
  97. data.towInOne = data.storehouseName + ',' + data.storingLocationName;
  98. if (this.parentValue.materialSku) {
  99. let loading = this.$loading({ target: '.main-container' });
  100. api.getInventoryByStoridAndSkuid({
  101. storidId: data.storehouseId,
  102. skuid: this.parentValue.materialSku,
  103. }).then((res : any) => {
  104. if (res.code === 200) {
  105. data.inventory = res.data;
  106. this.$emit('onChange', data);
  107. loading.close();
  108. this.vxeValue = false;
  109. }
  110. }).catch(() => loading.close())
  111. } else {
  112. this.$emit('onChange', data);
  113. this.vxeValue = false;
  114. }
  115. }
  116. }
  117. </script>
  118. <style scoped lang="scss">
  119. .parentC {
  120. display: flex;
  121. align-items: center;
  122. .inputC {
  123. float: left;
  124. width: calc(100% - 54px);
  125. }
  126. .selectC {
  127. float: left;
  128. margin-left: 10px;
  129. color: #fff;
  130. background-color: #0089ff;
  131. padding: 0 10px;
  132. border-radius: 12px;
  133. cursor: pointer;
  134. }
  135. }
  136. </style>