selectOutTable.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <div>
  3. <el-select
  4. v-model="drugsId"
  5. @visible-change="visibleChange"
  6. @change="handleDrugsId($event)"
  7. filterable
  8. remote
  9. reserve-keyword
  10. placeholder="药品名称"
  11. :remote-method="remoteMethod"
  12. :loading="loading">
  13. <el-option disabled value="-1">
  14. <table class="select-table select-table-head">
  15. <tr>
  16. <td>名称</td>
  17. <td>规格</td>
  18. <td>产地</td>
  19. <td>零售价</td>
  20. </tr>
  21. </table>
  22. </el-option>
  23. <el-option
  24. v-for="(item,index) in options"
  25. :key="index"
  26. :value="index"
  27. :label="item.drugsName"
  28. >
  29. <table class="select-table">
  30. <tr>
  31. <td>{{ item.drugsName }}</td>
  32. <td>{{item.specsName}}</td>
  33. <td>{{item.priceName}}</td>
  34. <td>{{item.retail||item.retailPrice}}</td>
  35. </tr>
  36. </table>
  37. </el-option>
  38. </el-select>
  39. <!-- 选取规格 -->
  40. <el-dialog title="选择批次" :close-on-click-modal="false" :visible.sync="pvisible" width="600px" :append-to-body="true">
  41. <el-table
  42. size="small"
  43. ref="singleTable"
  44. :data="prows"
  45. highlight-current-row
  46. :row-class-name="setRowClass"
  47. @current-change="handleCurrentChange"
  48. style="width: 100%">
  49. <el-table-column
  50. type="index"
  51. width="50">
  52. </el-table-column>
  53. <el-table-column
  54. property="productionCode"
  55. label="生产批号">
  56. </el-table-column>
  57. <el-table-column
  58. property="purchasePrice"
  59. label="进货单价">
  60. </el-table-column>
  61. <el-table-column
  62. property="stock"
  63. label="库存数量">
  64. </el-table-column>
  65. </el-table>
  66. <!-- <span slot="footer">
  67. <el-button @click="pvisible = false">取 消</el-button>
  68. <el-button type="primary" @click="confirmP">确 定</el-button>
  69. </span> -->
  70. </el-dialog>
  71. </div>
  72. </template>
  73. <script>
  74. import { listAll } from "@/api/drugs/drugs";
  75. import { listSpecs } from "@/api/drugs/specs";
  76. import { listInventory, detailGroupList } from "@/api/inventory/inventory";
  77. export default {
  78. props: {
  79. info: {
  80. type: Object,
  81. default: () => {}
  82. },
  83. toBank: {
  84. type: Boolean,
  85. default: false
  86. },
  87. index: {},
  88. pharmacyId: {},
  89. disableDetails: {
  90. type: Boolean,
  91. default: false
  92. }
  93. },
  94. data () {
  95. return {
  96. pvisible: false,
  97. prevDrugsId: '',
  98. drugsId: '',
  99. drugsType: '',
  100. drugsArr: [],
  101. selectOne: '',
  102. currentRow: '',
  103. name: '',
  104. prows: [],
  105. options: [],
  106. loading: false
  107. }
  108. },
  109. watch: {
  110. drugsId () {
  111. this.$emit('selectChange', {
  112. //val: this.drugsId,
  113. //drugsType: this.drugsType,
  114. index: this.index,
  115. data: this.selectOne
  116. })
  117. }
  118. },
  119. mounted () {
  120. //获取药品名称
  121. if (this.info&&JSON.stringify(this.info) != '{}') {
  122. this.drugsId = this.info.drugsName
  123. this.selectOne = this.info
  124. }
  125. this.getDataList()
  126. },
  127. methods: {
  128. setRowClass (data) {
  129. if (this.toBank) {
  130. return data.row.validState == 3 ? 'row-disabled' : ''
  131. } else {
  132. return ''
  133. }
  134. },
  135. remoteMethod(query) {
  136. if (query !== '') {
  137. this.loading = true;
  138. listInventory({
  139. drugsName: query,
  140. pharmacyId: this.pharmacyId
  141. }).then((res) => {
  142. this.loading = false
  143. this.options = res.rows
  144. })
  145. }
  146. },
  147. handleCurrentChange(val) {
  148. if (!val) {
  149. return
  150. }
  151. if (this.toBank && val.validState == 3) {
  152. return this.$message.warning('过期药品不可选')
  153. }
  154. this.currentRow = val
  155. this.confirmP()
  156. },
  157. confirmP () {
  158. if (!this.currentRow) {
  159. return this.$message.warning('请选择批次')
  160. }
  161. this.selectOne.productionCode = this.currentRow.productionCode;
  162. this.selectOne.purchasePrice = this.currentRow.purchasePrice;
  163. this.selectOne.stock = this.currentRow.stock;
  164. this.selectOne.drugsId = this.currentRow.drugsId;
  165. this.selectOne.priceId = this.currentRow.priceId;
  166. this.selectOne.specsId = this.currentRow.specsId;
  167. this.selectOne.inventoryId = this.currentRow.id;
  168. this.selectOne.dosageSizeUnit = this.currentRow.dosageSizeUnit;
  169. this.selectOne.validTime = this.currentRow.validTime;
  170. this.pvisible = false
  171. this.$emit('selectChange', {
  172. index: this.index,
  173. data: this.selectOne
  174. })
  175. },
  176. getDataList () {
  177. listInventory({
  178. drugsName: this.name,
  179. pharmacyId: this.pharmacyId
  180. }).then((res) => {
  181. this.options = res.rows;
  182. })
  183. },
  184. filterFn (val) {
  185. this.name = val
  186. this.drugsId = val
  187. this.getDataList()
  188. },
  189. visibleChange (e) {
  190. if (e) {
  191. if (this.drugsId !== '') {
  192. this.prevDrugsId = this.drugsId
  193. this.drugsId = ''
  194. }
  195. } else {
  196. if (this.drugsId === '') {
  197. this.drugsId = this.prevDrugsId
  198. this.prevDrugsId = ''
  199. }
  200. }
  201. },
  202. handleDrugsId(e) {
  203. this.drugsId = e
  204. this.selectOne = this.options[e]
  205. // let newArr = this.drugsArr.filter((item) => {
  206. // return item.drugsId === e;
  207. // });
  208. // this.drugsId = e;
  209. // //console.log('newArr', newArr)
  210. // this.drugsType = newArr[0].drugsType
  211. // this.getListSpecs();
  212. this.getSumStockS();
  213. },
  214. getSumStockS () {
  215. let params = {
  216. pharmacyId: this.selectOne.pharmacyId,
  217. drugsId: this.selectOne.drugsId,
  218. specsId: this.selectOne.specsId,
  219. priceId: this.selectOne.priceId,
  220. };
  221. detailGroupList(params).then((res) => {
  222. if (res.rows) {
  223. this.prows = res.rows
  224. this.pvisible = true
  225. this.currentRow = ''
  226. this.$nextTick(() => {
  227. this.$refs.singleTable.setCurrentRow()
  228. })
  229. }
  230. /*res.data
  231. ? this.$set(this.modifyPriceDetails[index], "stock", res.data.stock)
  232. : this.$set(this.modifyPriceDetails[index], "stock", 0);*/
  233. });
  234. },
  235. //获取药品规格
  236. /*getListSpecs() {
  237. var drugsId = this.selectOne.drugsId
  238. listSpecs({ drugsId }).then((res) => {
  239. this.$emit('selectChange', {
  240. //val: this.drugsId,
  241. //drugsType: this.drugsType,
  242. index: this.index,
  243. data: this.selectOne
  244. })
  245. });
  246. },*/
  247. }
  248. }
  249. </script>
  250. <style lang="scss" scoped>
  251. .select-table {
  252. width: 100%;
  253. td {
  254. &:first-of-type {
  255. width: 250px;
  256. }
  257. }
  258. }
  259. </style>
  260. <style scoped>
  261. .el-table >>> tr.row-disabled { cursor: not-allowed; color: #999; background: #eee; }
  262. .select-table-head { background-color: #17C7B1; color: #fff; }
  263. </style>