supplierModal.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <vxe-modal v-model="value" id="supplierModal" :width="width?width+'px':'60%'" @show="show" :height="height?height+'px':'80%'" min-width="500" min-height="400"
  3. show-zoom resize transfer show-footer @confirm="confirm">
  4. <template #title>
  5. <span>{{title?title:'选择供应商'}}</span>
  6. </template>
  7. <template #default>
  8. <module-view :propConfig="config" ref="view" @pagination="getList" @search="getList" @resert="getList" @clickHandle="clickHandle" />
  9. </template>
  10. </vxe-modal>
  11. </template>
  12. <script lang="ts">
  13. import { Component, Prop, Vue, Watch } from "vue-property-decorator";
  14. @Component
  15. export default class SupplierModal extends Vue {
  16. value=false
  17. data:Array<any>=[]
  18. time:any;
  19. timeNum = 0;
  20. @Prop()
  21. title?:string
  22. @Prop()
  23. width?:number
  24. @Prop()
  25. height?:number
  26. @Prop()
  27. mulit?:boolean
  28. config:any={
  29. search:{
  30. attr:{
  31. size:'mini',
  32. },
  33. columns:[
  34. [{
  35. labelWidth:'50px',
  36. span:8,
  37. label:'名称',
  38. prop:'name',
  39. component:'by-input',
  40. compConfig:{
  41. attr:{
  42. clearable:true,
  43. placeholder:'请输入名称'
  44. }
  45. }
  46. },{
  47. labelWidth:'70px',
  48. span:8,
  49. label:'负责人',
  50. prop:'contacts',
  51. component:'by-input',
  52. compConfig:{
  53. attr:{
  54. clearable:true,
  55. placeholder:'请输入负责人'
  56. }
  57. }
  58. }]
  59. ]
  60. },
  61. tool:{
  62. tools:{
  63. search:true,
  64. refresh:true
  65. }
  66. },
  67. table:{
  68. attr:{
  69. size:'mini',
  70. seq:true,
  71. align:'center',
  72. // radio:true,
  73. pageSize:10
  74. },
  75. columns:[{
  76. title:'名称',
  77. field:'name'
  78. },{
  79. title:'负责人',
  80. field:'contacts'
  81. }]
  82. },
  83. }
  84. clickHandle(n:string){
  85. if(n == 'onRefresh'){
  86. this.getList()
  87. }
  88. }
  89. setShow(v:boolean){
  90. this.value = v;
  91. }
  92. created(){
  93. if(this.mulit){
  94. this.config.table.attr.checkbox = true
  95. }else{
  96. this.config.table.attr.radio = true
  97. }
  98. }
  99. //确定
  100. confirm(){
  101. let data:Array<any>=this.getSelectdata();
  102. this.$emit('confirm',data);
  103. this.value = false;
  104. }
  105. //获取已选中表格数据
  106. getSelectdata(){
  107. let data:Array<any>=[];
  108. if(this.$refs.view){
  109. data = (this.$refs.view as any).getSelectData()
  110. }
  111. return data;
  112. }
  113. //显示弹窗
  114. show(){
  115. if(this.data.length ==0){
  116. this.time =setInterval(()=>{
  117. this.getList()
  118. },500)
  119. }
  120. if(this.$refs.view){
  121. (this.$refs.view as any).clearCheckboxRow();
  122. }
  123. }
  124. getList(){
  125. if(!this.$refs.view){
  126. if(this.timeNum > 5){
  127. clearInterval(this.time)
  128. }
  129. this.timeNum ++;
  130. return
  131. }
  132. clearInterval(this.time)
  133. let query:any = (this.$refs.view as any).getQuery();
  134. query.isLikeSearch = '1';
  135. this.$emit('supplierRequestAfter',query);
  136. (this as any).$request({
  137. url: '/maindata/maindataMaterialSupplier/page',
  138. method: 'get',
  139. params:query
  140. }).then((res:any) => {
  141. if(res.data.records){
  142. (this.$refs.view as any).setTableValue(res.data.records);
  143. this.data = res.data.records;
  144. let page={
  145. pageNo: res.data.current, //当前页
  146. pageSize: res.data.size, //每页条数
  147. total: res.data.total //总条数
  148. };
  149. (this.$refs.view as any).setPage(page)
  150. }
  151. })
  152. }
  153. }
  154. </script>