supplierModal.vue 4.0 KB

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