Elizabeth's proactive approach involves introducing urinal toilet attachment , an ingenious concept that optimizes space and functionality.

index.vue 7.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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.goods"
  12. ref="table"
  13. border
  14. highlight-current-row
  15. max-height="250"
  16. :row-class-name="tableRows"
  17. @row-click="onRowClicks"
  18. @current-change="goodTypeTableChange"
  19. :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)'}"
  20. style="width: 100%">
  21. <el-table-column
  22. align="center"
  23. label="药品规格">
  24. <template slot-scope="scope">
  25. <span>{{scope.row.drug_name}}</span>
  26. </template>
  27. </el-table-column>
  28. </el-table>
  29. </el-col>
  30. <el-col :span="16">
  31. <el-table
  32. :data="goodInfoTableData"
  33. border
  34. ref="multipleTable"
  35. max-height="250"
  36. @row-click="clickRow"
  37. @selection-change="changeGoodInfoTableData"
  38. @select="selectGoodInfo"
  39. @select-all="changeAllGoodInfoTableData"
  40. row-key="row_key"
  41. style="width: 100%"
  42. :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)'}"
  43. >
  44. <el-table-column
  45. align="center"
  46. type="selection"
  47. width="55">
  48. </el-table-column>
  49. <el-table-column
  50. align="center"
  51. label="规格名称"
  52. property="drug_spec"
  53. style="word-break: keep-all;white-space:nowrap;"
  54. ></el-table-column>
  55. <!--<el-table-column-->
  56. <!--align="center"-->
  57. <!--label="单位"-->
  58. <!--property="good_unit"-->
  59. <!--&gt;-->
  60. <!--<template slot-scope="scope">-->
  61. <!--&lt;!&ndash;<span>{{getName(scope.row.good_unit)}}</span>&ndash;&gt;-->
  62. <!--</template>-->
  63. <!--</el-table-column>-->
  64. <el-table-column
  65. align="center"
  66. label="上次进货价"
  67. property="buy_price"
  68. >
  69. <template slot-scope="scope">
  70. <span>{{scope.row.last_price}}</span>
  71. </template>
  72. </el-table-column>
  73. <el-table-column
  74. align="center"
  75. label="零售价"
  76. property="buy_price"
  77. >
  78. <template slot-scope="scope">
  79. <span>{{scope.row.retail_price}}</span>
  80. </template>
  81. </el-table-column>
  82. </el-table>
  83. </el-col>
  84. </el-row>
  85. <span slot="footer" class="dialog-footer">
  86. <el-button @click="cancle('form')">取 消</el-button>
  87. <el-button type="primary" @click="comfirm('form')">保 存</el-button>
  88. </span>
  89. </el-dialog>
  90. </template>
  91. <script>
  92. import { GetGoodInfoByGoodId } from '@/api/stock'
  93. export default {
  94. name: 'drugsStockDialog',
  95. data() {
  96. return {
  97. goodInfo: [],
  98. goodInfoTableData: [],
  99. keywords: '',
  100. multipleSelection: [],
  101. currentGoodTypeId: 0,
  102. isClose: false,
  103. visibility: false,
  104. SelectedDatas: [],
  105. table_current_index: -1
  106. }
  107. },
  108. props: {
  109. propForm: {
  110. type: Object
  111. }
  112. },
  113. methods: {
  114. hide: function() {
  115. this.visibility = false
  116. },
  117. show: function() {
  118. this.visibility = true
  119. },
  120. goodTypeTableChange: function(currentRow, oldCurrentRow) {
  121. this.goodInfoTableData = currentRow.drug_specs != null ? currentRow.drug_specs : []
  122. for (let i = 0; i < this.goodInfoTableData.length; i++) {
  123. if (this.goodInfoTableData[i].isSelected) {
  124. this.$nextTick(function() {
  125. this.$refs.multipleTable.toggleRowSelection(this.goodInfoTableData[i])
  126. })
  127. }
  128. }
  129. },
  130. cancle: function(formName) {
  131. this.goodInfoTableData = []
  132. this.$emit('dialog-cancle', this.getValue())
  133. this.$refs.multipleTable.clearSelection()
  134. this.$refs.table.setCurrentRow(null)
  135. },
  136. comfirm: function(formName) {
  137. this.goodInfoTableData = []
  138. this.$emit('dialog-comfirm', this.getValue())
  139. this.$refs.multipleTable.clearSelection()
  140. this.$refs.table.setCurrentRow(null)
  141. },
  142. getValue: function() {
  143. this.multipleSelection = []
  144. for (let i = 0; i < this.propForm.goods.length; i++) {
  145. for (let a = 0; a < this.propForm.goods[i].drug_specs.length; a++) {
  146. if (this.propForm.goods[i].drug_specs[a].isSelected) {
  147. this.multipleSelection.push(this.propForm.goods[i].drug_specs[a])
  148. }
  149. }
  150. }
  151. const obj = {
  152. selectedGoodInfo: this.multipleSelection,
  153. }
  154. console.log(obj)
  155. return obj
  156. }, goodTypeSelect: function(id) {
  157. this.tempGoodInfo = []
  158. this.goodInfo = []
  159. for (let i = 0; i < this.propForm.goodInfo.length; i++) {
  160. if (this.propForm.goodInfo[i].good_type_id == id) {
  161. this.tempGoodInfo.push(this.propForm.goodInfo[i])
  162. }
  163. }
  164. }, goodInfoSelect: function(id) {
  165. let index = 0
  166. for (let i = 0; i < this.propForm.goodInfo.length; i++) {
  167. if (this.propForm.goodInfo[i].id == id) {
  168. index = i
  169. }
  170. }
  171. this.form.good_type_id = this.propForm.goodInfo[index].good_type_id
  172. }, getName: function(id) {
  173. if (id == 0) {
  174. return ''
  175. }
  176. for (let i = 0; i < this.propForm.goodUnit.length; i++) {
  177. if (this.propForm.goodUnit[i].id == id) {
  178. return this.propForm.goodUnit[i].name
  179. }
  180. }
  181. }, search: function() {
  182. if (this.keywords.length <= 0) {
  183. this.$message.error('搜索关键字不能为空')
  184. return
  185. }
  186. const searchArr = []
  187. for (let i = 0; i < this.goodInfoTableData.length; i++) {
  188. if (this.goodInfoTableData[i].drug_spec.indexOf(this.keywords) != -1) {
  189. searchArr.push(this.goodInfoTableData[i])
  190. }
  191. }
  192. this.goodInfoTableData = []
  193. for (let i = 0; i < searchArr.length; i++) {
  194. this.goodInfoTableData.push(searchArr[i])
  195. }
  196. }, changeGoodInfoTableData: function(val) {
  197. console.log(val)
  198. },
  199. changeAllGoodInfoTableData: function(selection) {
  200. var goodInfos = this.propForm.goods[this.table_current_index].drug_specs
  201. if (selection.length > 0) {
  202. for (let y = 0; y < goodInfos.length; y++) {
  203. for (let i = 0; i < selection.length; i++) {
  204. if (goodInfos[y].id == selection[i].id) {
  205. goodInfos[y].isSelected = true
  206. }
  207. }
  208. }
  209. }
  210. }, clickRow: function(row) {
  211. // this.$refs.multipleTable.toggleRowSelection(row)
  212. },tableRows({ row, rowIndex }) {
  213. // 把每一行的索引放进row
  214. row.index = rowIndex
  215. },
  216. onRowClicks(row, event, column) {
  217. this.table_current_index = row.index
  218. }, selectGoodInfo(selection, row) {
  219. var goodInfos = this.propForm.goods[this.table_current_index].drug_specs
  220. // for (let y = 0; y < goodInfos.length; y++) {
  221. // goodInfos[y].isSelected = false
  222. // }
  223. if (selection.length > 0) {
  224. for (let y = 0; y < goodInfos.length; y++) {
  225. for (let i = 0; i < selection.length; i++) {
  226. if (goodInfos[y].id == selection[i].id) {
  227. goodInfos[y].isSelected = true
  228. }
  229. }
  230. }
  231. }
  232. }
  233. }
  234. }
  235. </script>
  236. <style scoped>
  237. </style>