血透系统PC前端

stockInDialog.vue 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <el-dialog title="选择商品" :visible.sync="visibility" :close-on-click-modal="isClose"
  3. :close-on-press-escape="isClose">
  4. <div class="filter-container">
  5. <el-input style="width: 150px;" class="filter-item" placeholder="规格名称" v-model="keywords"/>
  6. <el-button class="filter-item" type="primary" icon="el-icon-search" @click="search">搜索</el-button>
  7. </div>
  8. <el-row :gutter="20">
  9. <el-col :span="8">
  10. <el-table
  11. :data="propForm.goodType"
  12. ref="templatetable"
  13. border
  14. highlight-current-row
  15. max-height="250"
  16. @current-change="goodTypeTableChange"
  17. :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)'}"
  18. style="width: 100%">
  19. <el-table-column
  20. prop="type_name"
  21. label="商品类型">
  22. </el-table-column>
  23. </el-table>
  24. </el-col>
  25. <el-col :span="16">
  26. <el-table
  27. :data="goodInfoTableData"
  28. border
  29. ref="multipleTable"
  30. max-height="250"
  31. @row-click="clickRow"
  32. @selection-change="changeGoodInfoTableData"
  33. @select-all="changeAllGoodInfoTableData"
  34. row-key="row_key"
  35. style="width: 100%"
  36. :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)'}"
  37. >
  38. <el-table-column
  39. type="selection"
  40. width="55">
  41. </el-table-column>
  42. <el-table-column
  43. label="规格名称"
  44. property="specification_name"
  45. style="word-break: keep-all;white-space:nowrap;"
  46. ></el-table-column>
  47. <el-table-column
  48. label="单位"
  49. property="good_unit"
  50. >
  51. <template slot-scope="scope">
  52. <span>{{getName(scope.row.good_unit)}}</span>
  53. </template>
  54. </el-table-column>
  55. </el-table>
  56. </el-col>
  57. </el-row>
  58. <span slot="footer" class="dialog-footer">
  59. <el-button @click="cancle('form')">取 消</el-button>
  60. <el-button type="primary" @click="comfirm('form')">保 存</el-button>
  61. </span>
  62. </el-dialog>
  63. </template>
  64. <script>
  65. import { GetGoodInfoByGoodId } from '@/api/stock'
  66. export default {
  67. name: 'stockInDialog',
  68. data() {
  69. return {
  70. goodInfo: [],
  71. goodInfoTableData: [],
  72. keywords: '',
  73. multipleSelection: [],
  74. currentGoodTypeId: 0,
  75. isClose: false,
  76. visibility: false,
  77. }
  78. },
  79. props: {
  80. propForm: {
  81. type: Object
  82. },
  83. },
  84. methods: {
  85. hide:function(){
  86. this.visibility = false
  87. },
  88. show:function(){
  89. this.visibility = true
  90. },
  91. goodTypeTableChange: function(currentRow, oldCurrentRow) {
  92. this.currentGoodTypeId = currentRow.id
  93. const params = {
  94. id: currentRow.id
  95. }
  96. this.goodInfoTableData = []
  97. this.goodInfo = []
  98. GetGoodInfoByGoodId(params).then(response => {
  99. if (response.data.state == 0) {
  100. this.$message.error(response.data.msg)
  101. return false
  102. } else {
  103. for (let i = 0; i < response.data.data.list.length; i++) {
  104. this.goodInfo.push(response.data.data.list[i])
  105. this.goodInfoTableData.push(response.data.data.list[i])
  106. }
  107. }
  108. })
  109. },
  110. cancle: function(formName) {
  111. this.goodInfo = []
  112. this.goodInfoTableData = []
  113. this.$emit('dialog-cancle', this.getValue())
  114. this.$refs.multipleTable.clearSelection()
  115. },
  116. comfirm: function(formName) {
  117. this.goodInfo = []
  118. this.goodInfoTableData = []
  119. this.$emit('dialog-comfirm', this.getValue())
  120. this.$refs.multipleTable.clearSelection()
  121. },
  122. getValue: function() {
  123. const obj = {
  124. selectedGoodInfo: this.multipleSelection,
  125. goodTypeId: this.currentGoodTypeId
  126. }
  127. return obj
  128. }, goodTypeSelect: function(id) {
  129. this.tempGoodInfo = []
  130. this.goodInfo = []
  131. for (let i = 0; i < this.propForm.goodInfo.length; i++) {
  132. if (this.propForm.goodInfo[i].good_type_id == id) {
  133. this.tempGoodInfo.push(this.propForm.goodInfo[i])
  134. }
  135. }
  136. }, goodInfoSelect: function(id) {
  137. let index = 0
  138. for (let i = 0; i < this.propForm.goodInfo.length; i++) {
  139. if (this.propForm.goodInfo[i].id == id) {
  140. index = i
  141. }
  142. }
  143. this.form.good_type_id = this.propForm.goodInfo[index].good_type_id
  144. }, getName: function(id) {
  145. if (id == 0) {
  146. return ''
  147. }
  148. for (let i = 0; i < this.propForm.goodUnit.length; i++) {
  149. if (this.propForm.goodUnit[i].id == id) {
  150. return this.propForm.goodUnit[i].name
  151. }
  152. }
  153. }, search: function() {
  154. if (this.keywords.length <= 0) {
  155. this.$message.error('搜索关键字不能为空')
  156. return
  157. }
  158. const searchArr = []
  159. for (let i = 0; i < this.goodInfoTableData.length; i++) {
  160. if (this.goodInfoTableData[i].specification_name.indexOf(this.keywords) != -1) {
  161. searchArr.push(this.goodInfoTableData[i])
  162. }
  163. }
  164. this.goodInfoTableData = []
  165. for (let i = 0; i < searchArr.length; i++) {
  166. this.goodInfoTableData.push(searchArr[i])
  167. }
  168. }, changeGoodInfoTableData: function(val) {
  169. this.multipleSelection = val
  170. }, changeAllGoodInfoTableData: function(val) {
  171. this.multipleSelection = val
  172. },clickRow:function(row) {
  173. this.$refs.multipleTable.toggleRowSelection(row)
  174. }
  175. }
  176. }
  177. </script>
  178. <style scoped>
  179. </style>