华西海圻ELN前端工程
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
3.0 KiB

  1. <template>
  2. <div>
  3. <div style="display: flex;">
  4. <el-select v-model="type" :placeholder="$t('form.placeholderSelect')" @change="typeChange" style="width: 200px;">
  5. <el-option :label="$t('page.business.resource.resource.common.tj')" :value="1"></el-option>
  6. <el-option :label="$t('page.business.resource.resource.common.zl')" :value="3"></el-option>
  7. </el-select>
  8. <template v-if="type == 1">
  9. <el-input v-model="srz" :placeholder="$t('form.placeholderInput')" maxlength="20" @change="inputChange">
  10. <template slot="append">{{ dw||'' }}
  11. </template>
  12. </el-input>
  13. </template>
  14. <template v-if="type == 3">
  15. <div>
  16. <el-input v-model="tpName" :placeholder="$t('form.xztp')" readonly @click.native="showSelectBalance"
  17. style="width: 80px;" />
  18. </div>
  19. <div>
  20. <el-input v-model="tpz" :placeholder="$t('form.placeholderInput')" maxlength="20" @change="tpzChange">
  21. <template slot="append">{{ tpdw||'' }}
  22. </template>
  23. </el-input>
  24. </div>
  25. <div>
  26. <el-button type="primary" @click="getBalanceValue">{{ $t('form.hqz') }}</el-button>
  27. </div>
  28. </template>
  29. </div>
  30. <SelectInstrumentDialog ref="selectInstrumentDialog" @change="selectInstrumentChange" />
  31. </div>
  32. </template>
  33. <script>
  34. import SelectInstrumentDialog from '@/views/business/comps/select/SelectInstrumentDialog';
  35. import { getBalance } from "@/utils/tpph";
  36. export default {
  37. name: "SelectBalanceValue",
  38. components: { SelectInstrumentDialog },
  39. props: {
  40. value: {
  41. type: [Number, String],
  42. default: ''
  43. },
  44. selectkey: {
  45. type: String,
  46. default: ''
  47. },
  48. dw: {
  49. type: String,
  50. default: ''
  51. },
  52. },
  53. watch: {
  54. value: {
  55. immediate: true,
  56. handler(v) {
  57. this.tpz = v || ''
  58. }
  59. }
  60. },
  61. data() {
  62. return {
  63. type: '',
  64. srz: '',
  65. tpName: '',
  66. tpz: '',
  67. tpdw: '',
  68. yq: {}
  69. };
  70. },
  71. mounted() {
  72. },
  73. methods: {
  74. showSelectBalance() {
  75. this.$refs.selectInstrumentDialog.show()
  76. },
  77. selectInstrumentChange(val, row) {
  78. this.tpName = row.mc
  79. this.yq = row
  80. },
  81. async getBalanceValue() {
  82. if (!this.yq || !this.yq.bh) {
  83. this.$message.error('请选择仪器')
  84. return
  85. }
  86. this.tpz = ''
  87. let x = await getBalance({ yq: this.yq, dw: null })
  88. if (x && x.success) {
  89. this.tpz = x.value
  90. this.tpdw = x.unit
  91. } else {
  92. this.$message.error(x.message || '获取值失败')
  93. }
  94. this.tpzChange()
  95. },
  96. tpzChange() {
  97. this.$emit('change', { tpz: this.tpz, dw: this.tpdw,selectkey:this.selectkey})
  98. this.$emit('input', this.tpz)
  99. },
  100. inputChange() {
  101. this.$emit('change', { tpz: this.srz, dw: this.dw,selectkey:this.selectkey })
  102. this.$emit('input', this.srz)
  103. },
  104. typeChange(){
  105. this.$emit('change', null)
  106. this.$emit('input', null)
  107. this.srz=null
  108. this.tpz=null
  109. this.tpdw=null
  110. }
  111. }
  112. };
  113. </script>