productModal.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <vxe-modal v-model="value" id="productDialogModal" :width="width?width+'px':'90%'" @show="show"
  3. :height="height?height+'px':'90%'" show-zoom resize transfer show-footer
  4. @confirm="confirm">
  5. <template #title>
  6. <span>选择商品</span>
  7. </template>
  8. <template #default>
  9. <module-view :propConfig="config" ref="view" @pagination="getList" @search="getList" @resert="getList"
  10. @clickHandle="clickHandle" />
  11. </template>
  12. </vxe-modal>
  13. </template>
  14. <script lang="ts">
  15. import { Component, Prop, Vue, Watch } from "vue-property-decorator";
  16. @Component
  17. export default class ProductModal extends Vue {
  18. value = false
  19. time : any;
  20. timeNum = 0;
  21. data : Array<any> = []
  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. span: 6,
  36. label: '标题',
  37. prop: 'skuTitle',
  38. component: 'by-input',
  39. compConfig: {
  40. attr: {
  41. clearable: true,
  42. placeholder: '请输入名称'
  43. }
  44. }
  45. }]
  46. ]
  47. },
  48. tool: {
  49. tools: {
  50. search: true,
  51. refresh: true
  52. }
  53. },
  54. table: {
  55. attr: {
  56. size: 'mini',
  57. seq: true,
  58. align: 'left',
  59. checkbox:true,
  60. triggerRowCheck: 'row',
  61. calculateH:'100%'
  62. },
  63. columns:
  64. [
  65. {
  66. title: '标题',
  67. field: 'skuTitle',
  68. width: 250
  69. },
  70. {
  71. title: '副标题',
  72. field: 'skuSubtitle',
  73. width: 250
  74. },
  75. {
  76. width: 250,
  77. title: '财务编号',
  78. field: 'financialCode',
  79. },
  80. {
  81. title: '规格',
  82. field: 'materialSpec',
  83. width: 250
  84. },
  85. {
  86. title: '单位',
  87. field: 'unit',
  88. width: 250
  89. },
  90. {
  91. title: '单价',
  92. field: 'price',
  93. width: 250
  94. },
  95. ]
  96. },
  97. }
  98. brandData : Array<any> = []
  99. getBrandData() {
  100. return this.brandData;
  101. }
  102. clickHandle(n : string) {
  103. if (n == 'onRefresh') {
  104. this.getList()
  105. }
  106. }
  107. setShow(v : boolean) {
  108. this.value = v;
  109. }
  110. mounted() { }
  111. //确定
  112. confirm() {
  113. let data : Array<any> = this.getSelectdata();
  114. this.$emit('confirm', data);
  115. this.value = false;
  116. }
  117. //获取已选中表格数据
  118. getSelectdata() {
  119. let data : Array<any> = [];
  120. if (this.$refs.view) {
  121. data = (this.$refs.view as any).getSelectData()
  122. }
  123. return data;
  124. }
  125. //显示弹窗
  126. show() {
  127. if (this.data.length == 0) {
  128. this.time = setInterval(() => {
  129. this.getList()
  130. }, 500)
  131. }
  132. if (this.$refs.view) {
  133. (this.$refs.view as any).clearCheckboxRow();
  134. }
  135. }
  136. getList() {
  137. if (!this.$refs.view) {
  138. if (this.timeNum > 5) {
  139. clearInterval(this.time)
  140. }
  141. this.timeNum++;
  142. return
  143. }
  144. clearInterval(this.time)
  145. let query : any = (this.$refs.view as any).getQuery();
  146. query.isLikeSearch = '1';
  147. (this as any).$request({
  148. url: '/maindata/maindataMaterialSku/page',
  149. method: 'get',
  150. params: query
  151. }).then((res : any) => {
  152. if (res.data.records) {
  153. (this.$refs.view as any).setTableValue(res.data.records);
  154. this.data = res.data.records;
  155. let page = {
  156. pageNo: res.data.current, //当前页
  157. pageSize: res.data.size, //每页条数
  158. total: res.data.total //总条数
  159. };
  160. (this.$refs.view as any).setPage(page)
  161. }
  162. })
  163. }
  164. }
  165. </script>
  166. <style lang="scss" scoped>
  167. </style>