血透系统PC前端

stockInDialog.vue 5.3KB

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