heatUnitConversion.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <div style="display: flex; flex-wrap: wrap; width: 1200px; margin: auto">
  3. <div style="width: 90%; margin-left: 5%">
  4. <div style="width: 60%; margin: 1% 5%">
  5. <div style="display: flex">
  6. <ul class="text-title" style="width: 30%">
  7. <li>{{ $i18n.locale === 'zh' ? '吨标煤(tce)' : 'tce' }}</li>
  8. <li>{{ $i18n.locale === 'zh' ? '吨标油(toe)' : 'toe' }}</li>
  9. <li>{{ $i18n.locale === 'zh' ? '吉焦(GJ)' : 'GJ' }}</li>
  10. <li>{{ $i18n.locale === 'zh' ? '吉卡(Gcal)' : 'Gcal' }}</li>
  11. <li>
  12. {{ $i18n.locale === 'zh' ? '百万英热单位(MBtu)' : 'MBtu' }}
  13. </li>
  14. <li>{{ $i18n.locale === 'zh' ? '兆瓦时(MWh)' : 'MWh' }}</li>
  15. </ul>
  16. <ul style="width: 70%">
  17. <li>
  18. <el-input
  19. type="number"
  20. v-model="a"
  21. :placeholder="this.$i18n.locale === 'zh' ? textInfo : textInfo1"
  22. @focus="getFocus('1')"
  23. @blur="lostBlur"
  24. @input="getNum('a')"
  25. :class="focusClass == 1 ? 'focusClass2' : 'focusClass1'"
  26. /><el-button class="user-btn" @click="getNum('a')">{{
  27. $i18n.locale === 'zh' ? '换算' : 'Conversion'
  28. }}</el-button>
  29. </li>
  30. <li>
  31. <el-input
  32. type="number"
  33. v-model="b"
  34. :placeholder="this.$i18n.locale === 'zh' ? textInfo : textInfo1"
  35. @focus="getFocus('2')"
  36. @blur="lostBlur"
  37. @input="getNum('b')"
  38. :class="focusClass == 2 ? 'focusClass2' : 'focusClass1'"
  39. /><el-button class="user-btn" @click="getNum('b')">{{
  40. $i18n.locale === 'zh' ? '换算' : 'Conversion'
  41. }}</el-button>
  42. </li>
  43. <li>
  44. <el-input
  45. type="number"
  46. v-model="c"
  47. :placeholder="this.$i18n.locale === 'zh' ? textInfo : textInfo1"
  48. @focus="getFocus('3')"
  49. @blur="lostBlur"
  50. @input="getNum('c')"
  51. :class="focusClass == 3 ? 'focusClass2' : 'focusClass1'"
  52. /><el-button class="user-btn" @click="getNum('c')">{{
  53. $i18n.locale === 'zh' ? '换算' : 'Conversion'
  54. }}</el-button>
  55. </li>
  56. <li>
  57. <el-input
  58. type="number"
  59. v-model="d"
  60. :placeholder="this.$i18n.locale === 'zh' ? textInfo : textInfo1"
  61. @focus="getFocus('4')"
  62. @blur="lostBlur"
  63. @input="getNum('d')"
  64. :class="focusClass == 4 ? 'focusClass2' : 'focusClass1'"
  65. /><el-button class="user-btn" @click="getNum('d')">{{
  66. $i18n.locale === 'zh' ? '换算' : 'Conversion'
  67. }}</el-button>
  68. </li>
  69. <li>
  70. <el-input
  71. type="number"
  72. v-model="e"
  73. :placeholder="this.$i18n.locale === 'zh' ? textInfo : textInfo1"
  74. @focus="getFocus('5')"
  75. @blur="lostBlur"
  76. @input="getNum('e')"
  77. :class="focusClass == 5 ? 'focusClass2' : 'focusClass1'"
  78. /><el-button class="user-btn" @click="getNum('e')">{{
  79. $i18n.locale === 'zh' ? '换算' : 'Conversion'
  80. }}</el-button>
  81. </li>
  82. <li>
  83. <el-input
  84. type="number"
  85. v-model="f"
  86. :placeholder="this.$i18n.locale === 'zh' ? textInfo : textInfo1"
  87. @focus="getFocus('6')"
  88. @blur="lostBlur"
  89. @input="getNum('f')"
  90. :class="focusClass == 6 ? 'focusClass2' : 'focusClass1'"
  91. /><el-button class="user-btn" @click="getNum('f')">{{
  92. $i18n.locale === 'zh' ? '换算' : 'Conversion'
  93. }}</el-button>
  94. </li>
  95. </ul>
  96. </div>
  97. <div>
  98. <el-button class="user-btn-clear" @click="getNum('0')">{{
  99. $i18n.locale === 'zh' ? '数 据 重 置' : 'Data reset'
  100. }}</el-button>
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. </template>
  106. <script>
  107. export default {
  108. name: 'unitConversion',
  109. data() {
  110. return {
  111. focusClass: '',
  112. textInfo: '请输入数值',
  113. textInfo1: 'Please enter a value',
  114. a: '',
  115. b: '',
  116. c: '',
  117. d: '',
  118. e: '',
  119. f: '',
  120. }
  121. },
  122. mounted() {},
  123. methods: {
  124. lostBlur() {
  125. this.focusClass = ''
  126. },
  127. getFocus(num) {
  128. this.focusClass = num
  129. },
  130. getNum(num) {
  131. if (num == 'a') {
  132. if (this.a == '') {
  133. this.getNum('0')
  134. } else {
  135. let a1 = Number(this.a)
  136. this.b = (a1 * Number(0.7)).toFixed(3)
  137. this.c = (a1 * Number(29.31)).toFixed(3)
  138. this.d = (a1 * Number(7.005)).toFixed(3)
  139. this.e = (a1 * Number(27.78)).toFixed(3)
  140. this.f = (a1 * Number(8.141)).toFixed(3)
  141. }
  142. } else if (num == 'b') {
  143. if (this.b == '') {
  144. this.getNum('0')
  145. } else {
  146. let b1 = Number(this.b)
  147. this.a = (b1 / Number(0.7)).toFixed(3)
  148. let a2 = Number(this.a)
  149. this.c = (a2 * Number(29.31)).toFixed(3)
  150. this.d = (a2 * Number(7.005)).toFixed(3)
  151. this.e = (a2 * Number(27.78)).toFixed(3)
  152. this.f = (a2 * Number(8.141)).toFixed(3)
  153. }
  154. } else if (num == 'c') {
  155. if (this.c == '') {
  156. this.getNum('0')
  157. } else {
  158. let c1 = Number(this.c)
  159. this.a = (c1 / Number(29.31)).toFixed(3)
  160. let a3 = Number(this.a)
  161. this.b = (a3 * Number(0.7)).toFixed(3)
  162. this.d = (a3 * Number(7.005)).toFixed(3)
  163. this.e = (a3 * Number(27.78)).toFixed(3)
  164. this.f = (a3 * Number(8.141)).toFixed(3)
  165. }
  166. } else if (num == 'd') {
  167. if (this.d == '') {
  168. this.getNum('0')
  169. } else {
  170. let d1 = Number(this.d)
  171. this.a = (d1 / Number(7.005)).toFixed(3)
  172. let a4 = Number(this.a)
  173. this.b = (a4 * Number(0.7)).toFixed(3)
  174. this.c = (a4 * Number(29.31)).toFixed(3)
  175. this.e = (a4 * Number(27.78)).toFixed(3)
  176. this.f = (a4 * Number(8.141)).toFixed(3)
  177. }
  178. } else if (num == 'e') {
  179. if (this.e == '') {
  180. this.getNum('0')
  181. } else {
  182. let e1 = Number(this.e)
  183. this.a = (e1 / Number(27.78)).toFixed(3)
  184. let a5 = Number(this.a)
  185. this.b = (a5 * Number(0.7)).toFixed(3)
  186. this.c = (a5 * Number(29.31)).toFixed(3)
  187. this.d = (a5 * Number(7.005)).toFixed(3)
  188. this.f = (a5 * Number(8.141)).toFixed(3)
  189. }
  190. } else if (num == 'f') {
  191. if (this.f == '') {
  192. this.getNum('0')
  193. } else {
  194. let f1 = Number(this.f)
  195. this.a = (f1 / Number(8.141)).toFixed(3)
  196. let a6 = Number(this.a)
  197. this.b = (a6 * Number(0.7)).toFixed(3)
  198. this.c = (a6 * Number(29.31)).toFixed(3)
  199. this.d = (a6 * Number(7.005)).toFixed(3)
  200. this.e = (a6 * Number(27.78)).toFixed(3)
  201. }
  202. } else if (num == '0') {
  203. this.a = ''
  204. this.b = ''
  205. this.c = ''
  206. this.d = ''
  207. this.e = ''
  208. this.f = ''
  209. }
  210. },
  211. },
  212. }
  213. </script>
  214. <style lang="less" scoped>
  215. ul > li {
  216. height: 41px;
  217. margin: 20px 0;
  218. line-height: 41px;
  219. border-top: 1px solid #dbdbdb;
  220. border-right: 1px solid #dbdbdb;
  221. border-bottom: 1px solid #dbdbdb;
  222. display: flex;
  223. }
  224. .none-title > li {
  225. border: none !important;
  226. height: 41px;
  227. line-height: 41px;
  228. }
  229. .text-title > li {
  230. padding-left: 10px;
  231. border-left: 1px solid #dbdbdb;
  232. }
  233. ul > li /deep/.el-input__inner {
  234. width: 100% !important;
  235. height: 100% !important;
  236. border: none;
  237. border-radius: 0;
  238. background-color: rgba(255, 255, 255, 0);
  239. color: #000;
  240. }
  241. .focusClass1 {
  242. border: none;
  243. }
  244. .focusClass2 {
  245. border: 2px solid #c7d1dd;
  246. background-color: #f1f1f1;
  247. }
  248. .user-btn {
  249. background-color: #105dbc;
  250. color: #fff;
  251. }
  252. // .user-btn:hover {
  253. // background-color: #18caf7;
  254. // color: #000;
  255. // }
  256. .user-btn-clear {
  257. width: 60%;
  258. margin-left: 20%;
  259. margin-top: 2%;
  260. font-size: 16px;
  261. font-weight: 700;
  262. border-bottom: 1px;
  263. border-right: 1px;
  264. box-shadow: 5px 5px 5px rgb(63, 62, 62);
  265. background: linear-gradient(90deg, #3f9eff, #1674d5);
  266. color: #fff;
  267. border-radius: 50px;
  268. }
  269. // .user-btn-clear:hover {
  270. // width: 60%;
  271. // margin-left: 20%;
  272. // margin-top: 2%;
  273. // font-size: 16px;
  274. // font-weight: 700;
  275. // background: linear-gradient(90deg, #4d98e4, #18caf7);
  276. // color: #000;
  277. // border-radius: 50px;
  278. // }
  279. /deep/ input::-webkit-outer-spin-button,
  280. /deep/ input::-webkit-inner-spin-button {
  281. -webkit-appearance: none !important;
  282. }
  283. /deep/ input[type='number'] {
  284. -moz-appearance: textfield !important;
  285. }
  286. </style>