importProduct.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <vxe-modal v-model="value" id="importProduct" width="70%" height="80%" @show="show" show-zoom resize transfer v-loading="load">
  3. <template #title>
  4. <span>关联商品</span>
  5. </template>
  6. <template #default>
  7. <div class="i-box">
  8. <div class="table" id="t1">
  9. <by-table :propConfig="config" ref="table"></by-table>
  10. </div>
  11. <!-- <div class="icon">
  12. <i class="el-icon-right" style="font-size: 30px;"></i>
  13. </div>
  14. <div class="table t2">
  15. <by-table :propConfig="config2" ref="table2"></by-table>
  16. </div> -->
  17. </div>
  18. <product-modal ref="product" @confirm="confirmProduct" />
  19. </template>
  20. </vxe-modal>
  21. </template>
  22. <script lang="ts">
  23. import { Component, Prop, Vue, Watch } from "vue-property-decorator";
  24. import { maindataMaterialRelevancy,materialrelevancy } from '@/api/omsOrder'
  25. import ProductModal from "@/components/skuModal/productModal.vue";
  26. @Component({components:{ProductModal}})
  27. export default class ImportProduct extends Vue {
  28. value = false;
  29. load = false;
  30. syncProduct:Array<any>=[];
  31. currentRow:any=null;
  32. config:any={
  33. attr:{
  34. size:'mini',
  35. align:'center'
  36. },
  37. columns:[{
  38. title:'商品编码',
  39. field:'goodsSkuId'
  40. },{
  41. title:'商品名称',
  42. field:'goodsName'
  43. },{
  44. title:'操作',
  45. action:true,
  46. width:170,
  47. plugins:[{
  48. name:'关联商品',
  49. audit:'',
  50. event:{
  51. show:(row:any) => {
  52. return row.isSync != 1
  53. },
  54. click:(item:any) => {
  55. (this.$refs.product as any).setShow(true);
  56. this.setCurrentRow(item);
  57. }
  58. }
  59. },{
  60. name:'直接注册',
  61. audit:'',
  62. event:{
  63. show:(row:any) => {
  64. return row.isSync != 1
  65. },
  66. click:(item:any) => {
  67. this.$message('尚未开发!');
  68. console.log('该行数据:',item)
  69. }
  70. }
  71. }]
  72. }]
  73. }
  74. config2:any={
  75. attr:{
  76. size:'mini',
  77. align:'center'
  78. },
  79. columns:[{
  80. title:'名称',
  81. field:'name'
  82. }]
  83. }
  84. mounted(){
  85. }
  86. setCurrentRow(row:any){
  87. this.currentRow = row;
  88. }
  89. show(){
  90. const h = document.getElementById('t1')?.offsetHeight;
  91. if(h){
  92. this.config.attr.height = h - 48;
  93. this.config2.attr.height = h - 48;
  94. }
  95. this.getSyncData()
  96. }
  97. setShow(v:boolean){
  98. this.value = v;
  99. }
  100. getSyncData(){
  101. let page = (this.$refs.table as any).getPage();
  102. let data:any={
  103. pageNo:page.pageNo,
  104. pageSize:page.pageSize
  105. }
  106. this.load = true;
  107. maindataMaterialRelevancy(data).then((res:any) => {
  108. this.load = false;
  109. if(this.$refs.table){
  110. (this.$refs.table as any).setValue(res.data.records);
  111. page.pageNo = res.data.current;
  112. page.total = res.data.total;
  113. (this.$refs.table as any).setPage(page);
  114. }
  115. }).catch((err:any) => {
  116. this.load = false;
  117. })
  118. }
  119. confirmProduct(data:Array<any>){
  120. if(data.length == 0){
  121. this.$message('请选择商品!');
  122. return;
  123. }
  124. let value:any={
  125. lid:this.currentRow.id,
  126. mskuid:data[0].id
  127. }
  128. this.load = true;
  129. materialrelevancy(value).then((res:any) => {
  130. this.load = false;
  131. this.$message({
  132. message:'商品关联成功!',
  133. type:'success'
  134. })
  135. this.getSyncData();
  136. }).catch((err:any) => {
  137. this.load = false;
  138. this.$message.error('商品关联失败!')
  139. })
  140. }
  141. }
  142. </script>
  143. <style lang="scss" scoped>
  144. .i-box{
  145. width: 100%;
  146. display: flex;
  147. justify-content: space-between;
  148. height: 100%;
  149. .table{
  150. width: 100%;
  151. height: 100%;
  152. overflow: auto;
  153. box-shadow: 0 0 10px rgba(86,86,86,.1);
  154. // background-color: aliceblue;
  155. }
  156. .t1{
  157. width: 52%;
  158. // box-shadow: 5px -5px 5px rgba(127,127,127,.1);
  159. }
  160. .t2{
  161. width: 40%;
  162. // box-shadow: -5px -5px 5px rgba(127,127,127,.1);
  163. }
  164. .icon{
  165. width: 8%;
  166. height: 100%;
  167. display: flex;
  168. justify-content: center;
  169. align-items: center;
  170. }
  171. }
  172. </style>