towInOne.vue 3.7 KB

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