task-goods-dialog.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <el-dialog title="添加商品" :visible.sync="visible" width="1200px" :close-on-click-modal="false" :show-close="false">
  3. <div class="filter-container">
  4. <div class="filter-control">
  5. <span>商品ID:</span>
  6. <el-input
  7. v-model="listQuery.productId"
  8. placeholder="商品ID"
  9. clearable
  10. style="width: 160px"
  11. @keyup.enter.native="getList"
  12. @clear="getList"
  13. />
  14. </div>
  15. <div class="filter-control">
  16. <span>商品名称:</span>
  17. <el-input
  18. v-model="listQuery.name"
  19. placeholder="商品名称"
  20. clearable
  21. style="width: 160px"
  22. @keyup.enter.native="getList"
  23. @clear="getList"
  24. />
  25. </div>
  26. <div class="filter-control">
  27. <span>供应商名称:</span>
  28. <el-input
  29. v-model="listQuery.shopName"
  30. placeholder="供应商名称"
  31. clearable
  32. style="width: 160px"
  33. @keyup.enter.native="getList"
  34. @clear="getList"
  35. />
  36. </div>
  37. <div class="filter-control">
  38. <el-button type="primary" @click="getList"> 查询 </el-button>
  39. </div>
  40. </div>
  41. <el-table
  42. ref="table"
  43. v-loading="isLoading"
  44. :data="list"
  45. height="400px"
  46. border
  47. @selection-change="handleSelectionChange"
  48. >
  49. <el-table-column type="selection" width="55" />
  50. <el-table-column label="商品ID" prop="productId" align="center" width="100" />
  51. <el-table-column prop="mainImage" label="商品图片" align="center" width="120">
  52. <template slot-scope="{ row }">
  53. <img v-if="row.mainImage" :src="row.mainImage" alt="" style="width: 50px; height: 50px" />
  54. <span v-else>---</span>
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="商品名称" prop="productName" align="center" />
  58. <el-table-column label="供应商名称" prop="shopName" align="center" />
  59. </el-table>
  60. <!-- 页码 -->
  61. <pagination
  62. :total="total"
  63. :page-sizes="[10, 20]"
  64. :page-size="10"
  65. :page.sync="listQuery.pageNum"
  66. :limit.sync="listQuery.pageSize"
  67. @pagination="getTaskProducts"
  68. />
  69. <div slot="footer">
  70. <el-button @click="handleCanle"> 取 消 </el-button>
  71. <el-button type="primary" :disabled="disabled" @click="handleConfirm"> 确 定 </el-button>
  72. </div>
  73. </el-dialog>
  74. </template>
  75. <script>
  76. import { getTaskProducts } from '@/api/serviceSettlement/task'
  77. export default {
  78. name: 'GoodsDialog',
  79. data() {
  80. return {
  81. visible: true,
  82. listQuery: {
  83. name: '',
  84. shopName: '',
  85. productId: '',
  86. pageNum: 1, // 页码
  87. pageSize: 10 // 页面数据数
  88. },
  89. list: [],
  90. total: 0,
  91. shopsRadio: null,
  92. isLoading: true
  93. }
  94. },
  95. computed: {
  96. disabled() {
  97. return this.shopsRadio === null
  98. }
  99. },
  100. created() {
  101. this.getList()
  102. },
  103. methods: {
  104. // 获取所有供应商列表
  105. async getList() {
  106. this.list = []
  107. this.listQuery.pageNum = 1
  108. this.getTaskProducts()
  109. },
  110. // 获取所有供应商列表
  111. async getTaskProducts() {
  112. try {
  113. const res = await getTaskProducts(this.listQuery)
  114. this.list = res.data.results
  115. this.total = res.data.totalRecord
  116. this.isLoading = false
  117. } catch (error) {
  118. console.log(error)
  119. }
  120. },
  121. // 选择供应商
  122. handleSelectionChange(row) {
  123. this.shopsRadio = row
  124. console.log('row', row)
  125. },
  126. // 确认选择供应商
  127. handleConfirm() {
  128. this.$emit('confirm', this.shopsRadio)
  129. },
  130. handleCanle() {
  131. // 取消弹窗
  132. this.$emit('cancel')
  133. },
  134. // 已选择的禁用勾选框
  135. selectable(row) {
  136. if (row.flag) {
  137. return true
  138. } else {
  139. return false
  140. }
  141. },
  142. checkedInput(event, type) {
  143. let pattern = ''
  144. switch (type) {
  145. case 1:
  146. pattern = /[^\d]/g
  147. break
  148. case 2:
  149. pattern = /[^u4E00-u9FA5|d|a-zA-Z|rns,.?!,。?!…—&$=()-+/*{}[]]|s/g
  150. break
  151. }
  152. return event.replace(pattern, '')
  153. }
  154. }
  155. }
  156. </script>
  157. <style lang="scss" scoped></style>