index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. <template>
  2. <div>
  3. <!-- 标题 -->
  4. <el-row>
  5. <el-col
  6. :span="24"
  7. class="first-row"
  8. >
  9. <div class="tag">处置情况</div>
  10. </el-col>
  11. </el-row>
  12. <!-- 分割线 -->
  13. <hr style="background-color: #CCCCCC;height: 1px;border: 0;">
  14. <div style="margin: 32px 0;"></div>
  15. <el-row>
  16. <el-col :span="3">
  17. 1、扑救火灾
  18. </el-col>
  19. <el-col :span="6">
  20. <el-input
  21. class="input-new-tag"
  22. v-if="inputVisible1"
  23. v-model="inputValue1"
  24. ref="saveTagInput1"
  25. size="small"
  26. @keyup.enter.native="handleInputConfirm(1)"
  27. @blur="handleInputConfirm(1)"
  28. >
  29. </el-input>
  30. <el-button
  31. v-else
  32. class="button-new-tag"
  33. size="small"
  34. @click="showInput(1)"
  35. >{{inputValue1}}</el-button>
  36. </el-col>
  37. <el-col :span="3">
  38. 5、维护社会治安
  39. </el-col>
  40. <el-col :span="6">
  41. <el-input
  42. class="input-new-tag"
  43. v-if="inputVisible5"
  44. v-model="inputValue5"
  45. ref="saveTagInput5"
  46. size="small"
  47. @keyup.enter.native="handleInputConfirm(5)"
  48. @blur="handleInputConfirm(5)"
  49. >
  50. </el-input>
  51. <el-button
  52. v-else
  53. class="button-new-tag"
  54. size="small"
  55. @click="showInput(5)"
  56. >{{inputValue5}}</el-button>
  57. </el-col>
  58. </el-row>
  59. <div style="margin: 32px 0;"></div>
  60. <el-row>
  61. <el-col :span="3">
  62. 2、转移安置人员
  63. </el-col>
  64. <el-col :span="6">
  65. <el-input
  66. class="input-new-tag"
  67. v-if="inputVisible2"
  68. v-model="inputValue2"
  69. ref="saveTagInput2"
  70. size="small"
  71. @keyup.enter.native="handleInputConfirm(2)"
  72. @blur="handleInputConfirm(2)"
  73. >
  74. </el-input>
  75. <el-button
  76. v-else
  77. class="button-new-tag"
  78. size="small"
  79. @click="showInput(2)"
  80. >{{inputValue2}}</el-button>
  81. </el-col>
  82. <el-col :span="3">
  83. 6、发布信息
  84. </el-col>
  85. <el-col :span="6">
  86. <el-input
  87. class="input-new-tag"
  88. v-if="inputVisible6"
  89. v-model="inputValue6"
  90. ref="saveTagInput6"
  91. size="small"
  92. @keyup.enter.native="handleInputConfirm(6)"
  93. @blur="handleInputConfirm(6)"
  94. >
  95. </el-input>
  96. <el-button
  97. v-else
  98. class="button-new-tag"
  99. size="small"
  100. @click="showInput(6)"
  101. >{{inputValue6}}</el-button>
  102. </el-col>
  103. </el-row>
  104. <div style="margin: 32px 0;"></div>
  105. <el-row>
  106. <el-col :span="3">
  107. 3、救治伤员
  108. </el-col>
  109. <el-col :span="6">
  110. <el-input
  111. class="input-new-tag"
  112. v-if="inputVisible3"
  113. v-model="inputValue3"
  114. ref="saveTagInput3"
  115. size="small"
  116. @keyup.enter.native="handleInputConfirm(3)"
  117. @blur="handleInputConfirm(3)"
  118. >
  119. </el-input>
  120. <el-button
  121. v-else
  122. class="button-new-tag"
  123. size="small"
  124. @click="showInput(3)"
  125. >{{inputValue3}}</el-button>
  126. </el-col>
  127. <el-col :span="3">
  128. 7、善后处置
  129. </el-col>
  130. <el-col :span="6">
  131. <el-input
  132. class="input-new-tag"
  133. v-if="inputVisible7"
  134. v-model="inputValue7"
  135. ref="saveTagInput7"
  136. size="small"
  137. @keyup.enter.native="handleInputConfirm(7)"
  138. @blur="handleInputConfirm(7)"
  139. >
  140. </el-input>
  141. <el-button
  142. v-else
  143. class="button-new-tag"
  144. size="small"
  145. @click="showInput(7)"
  146. >{{inputValue7}}</el-button>
  147. </el-col>
  148. </el-row>
  149. <div style="margin: 32px 0;"></div>
  150. <el-row>
  151. <el-col :span="3">
  152. 4、保护重要目标
  153. </el-col>
  154. <el-col :span="6">
  155. <el-input
  156. class="input-new-tag"
  157. v-if="inputVisible4"
  158. v-model="inputValue4"
  159. ref="saveTagInput4"
  160. size="small"
  161. @keyup.enter.native="handleInputConfirm(4)"
  162. @blur="handleInputConfirm(4)"
  163. >
  164. </el-input>
  165. <el-button
  166. v-else
  167. class="button-new-tag"
  168. size="small"
  169. @click="showInput(4)"
  170. >{{inputValue4}}</el-button>
  171. </el-col>
  172. <el-col :span="3">
  173. 8、火场清理
  174. </el-col>
  175. <el-col :span="6">
  176. <el-input
  177. class="input-new-tag"
  178. v-if="inputVisible8"
  179. v-model="inputValue8"
  180. ref="saveTagInput8"
  181. size="small"
  182. @keyup.enter.native="handleInputConfirm(8)"
  183. @blur="handleInputConfirm(8)"
  184. >
  185. </el-input>
  186. <el-button
  187. v-else
  188. class="button-new-tag"
  189. size="small"
  190. @click="showInput(8)"
  191. >{{inputValue8}}</el-button>
  192. </el-col>
  193. </el-row>
  194. </div>
  195. </template>
  196. <script>
  197. export default {
  198. name: "",
  199. data() {
  200. return {
  201. // 控制输入框和按钮框切换
  202. inputVisible1: false,
  203. inputVisible2: false,
  204. inputVisible3: false,
  205. inputVisible4: false,
  206. inputVisible5: false,
  207. inputVisible6: false,
  208. inputVisible7: false,
  209. inputVisible8: false,
  210. // 按钮框绑定的数据
  211. inputValue1: "", // 扑灭火灾次数
  212. inputValue2: "", // 转移安置人员人数
  213. inputValue3: "", // 救治伤员人数
  214. inputValue4: "", // 保护重要目标次数
  215. inputValue5: "", // 维护社会治安次数
  216. inputValue6: "", // 发布信息次数
  217. inputValue7: "", // 善后处置次数
  218. inputValue8: "", // 火场清理次数
  219. inputValue9: "", // 冒烟警告次数
  220. };
  221. },
  222. mounted() {
  223. this.getDisposeData();
  224. },
  225. methods: {
  226. // 点击按钮 切换输入框 并聚焦
  227. showInput(i) {
  228. if (i == 1) {
  229. this.inputVisible1 = true;
  230. this.$nextTick(() => {
  231. this.$refs.saveTagInput1.$refs.input.focus();
  232. });
  233. } else if (i == 2) {
  234. this.inputVisible2 = true;
  235. this.$nextTick(() => {
  236. this.$refs.saveTagInput2.$refs.input.focus();
  237. });
  238. } else if (i == 3) {
  239. this.inputVisible3 = true;
  240. this.$nextTick(() => {
  241. this.$refs.saveTagInput3.$refs.input.focus();
  242. });
  243. } else if (i == 4) {
  244. this.inputVisible4 = true;
  245. this.$nextTick(() => {
  246. this.$refs.saveTagInput4.$refs.input.focus();
  247. });
  248. } else if (i == 5) {
  249. this.inputVisible5 = true;
  250. this.$nextTick(() => {
  251. this.$refs.saveTagInput5.$refs.input.focus();
  252. });
  253. } else if (i == 6) {
  254. this.inputVisible6 = true;
  255. this.$nextTick(() => {
  256. this.$refs.saveTagInput6.$refs.input.focus();
  257. });
  258. } else if (i == 7) {
  259. this.inputVisible7 = true;
  260. this.$nextTick(() => {
  261. this.$refs.saveTagInput7.$refs.input.focus();
  262. });
  263. } else {
  264. this.inputVisible8 = true;
  265. this.$nextTick(() => {
  266. this.$refs.saveTagInput8.$refs.input.focus();
  267. });
  268. }
  269. },
  270. // 失去焦点或者回车 切换回按钮框 并更新数据
  271. handleInputConfirm(i) {
  272. if (i == 1) {
  273. this.inputVisible1 = false;
  274. this.inputValue1 = this.inputValue1;
  275. } else if (i == 2) {
  276. this.inputVisible2 = false;
  277. this.inputValue2 = this.inputValue2;
  278. } else if (i == 3) {
  279. this.inputVisible3 = false;
  280. this.inputValue3 = this.inputValue3;
  281. } else if (i == 4) {
  282. this.inputVisible4 = false;
  283. this.inputValue4 = this.inputValue4;
  284. } else if (i == 5) {
  285. this.inputVisible5 = false;
  286. this.inputValue5 = this.inputValue5;
  287. } else if (i == 6) {
  288. this.inputVisible6 = false;
  289. this.inputValue6 = this.inputValue6;
  290. } else if (i == 7) {
  291. this.inputVisible7 = false;
  292. this.inputValue7 = this.inputValue7;
  293. } else {
  294. this.inputVisible8 = false;
  295. this.inputValue8 = this.inputValue8;
  296. }
  297. this.reDisposeData();
  298. },
  299. // 获取应急处置信息
  300. async getDisposeData() {
  301. let res = await this.$axios({
  302. url: "/diseaseRight/emergencyDisposalStatistics/info",
  303. method: "get",
  304. // headers: {
  305. // "Admin-Token": sessionStorage.getItem("token"),
  306. // },
  307. });
  308. // console.log(res);
  309. if (res.status == 200) {
  310. this.inputValue1 = res.data.data.numOfPutOutTheFire;
  311. this.inputValue2 = res.data.data.numOfTransfer;
  312. this.inputValue3 = res.data.data.numOfCure;
  313. this.inputValue4 = res.data.data.numOfImportantTarget;
  314. this.inputValue5 = res.data.data.numOfPublicSecurity;
  315. this.inputValue6 = res.data.data.numOfInfo;
  316. this.inputValue7 = res.data.data.numOfAftermath;
  317. this.inputValue8 = res.data.data.numOfFireClean;
  318. this.inputValue9 = res.data.data.numOfSmoke;
  319. } else {
  320. console.log("获取 应急处置信息 请求失败");
  321. }
  322. },
  323. // 修改应急处置信息
  324. async reDisposeData() {
  325. let data = {
  326. id: 1,
  327. numOfPutOutTheFire: this.inputValue1,
  328. numOfTransfer: this.inputValue2,
  329. numOfCure: this.inputValue3,
  330. numOfImportantTarget: this.inputValue4,
  331. numOfPublicSecurity: this.inputValue5,
  332. numOfInfo: this.inputValue6,
  333. numOfAftermath: this.inputValue7,
  334. numOfFireClean: this.inputValue8,
  335. numOfSmoke: this.inputValue9,
  336. };
  337. let res = await this.$axios({
  338. url: "/diseaseRight/emergencyDisposalStatistics/update",
  339. method: "put",
  340. data: data,
  341. headers: {
  342. "Admin-Token": sessionStorage.getItem("token"),
  343. },
  344. });
  345. // console.log(res);
  346. if (res.status == 200 && res.data.success) {
  347. this.$message({
  348. showClose: true,
  349. message: "修改成功",
  350. type: "success",
  351. });
  352. } else {
  353. this.$message({
  354. showClose: true,
  355. message: "修改失败",
  356. type: "error",
  357. });
  358. this.getDisposeData();
  359. }
  360. },
  361. },
  362. };
  363. </script>
  364. <style scoped>
  365. .first-row {
  366. display: flex;
  367. justify-content: space-between;
  368. align-items: center;
  369. height: 50px;
  370. }
  371. .tag {
  372. width: 108px;
  373. height: 40px;
  374. font-size: 24px;
  375. font-family: Microsoft YaHei-3970(82674968);
  376. font-weight: bold;
  377. color: #000000;
  378. line-height: 54px;
  379. }
  380. .input-new-tag {
  381. width: 90px;
  382. margin-left: 10px;
  383. vertical-align: middle;
  384. }
  385. .button-new-tag {
  386. width: 90px;
  387. margin-left: 10px;
  388. height: 32px;
  389. line-height: 30px;
  390. padding-top: 0;
  391. padding-bottom: 0;
  392. vertical-align: middle;
  393. }
  394. </style>