yiqing-tiwen.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. <template>
  2. <div>
  3. <div v-if="shows">
  4. <van-nav-bar
  5. title="体温填报"
  6. left-text="返回"
  7. left-arrow
  8. @click-left="onClickLeft"
  9. >
  10. <template #right>
  11. <van-icon name="records" size="18" @click="tianbao" />
  12. </template>
  13. </van-nav-bar>
  14. </div>
  15. <div class="contents">
  16. <form>
  17. <!-- 地理定位 -->
  18. <!-- <div class="contents_one">
  19. <img src="../../../assets/images/zaoquan/yiqing/定位.png" alt="" />
  20. <p>宁夏自治区灵武市枣泉煤矿东大门</p>
  21. <input type="button" value="重新定位" />
  22. </div> -->
  23. <div class="contents_two">
  24. <van-cell-group>
  25. <van-field v-model="name" label="姓名" placeholder="请输入姓名" />
  26. <van-field
  27. v-model="department"
  28. label="部门"
  29. placeholder="请输入部门"
  30. />
  31. <van-field v-model="mobile" label="工号" placeholder="请输入工号" />
  32. </van-cell-group>
  33. </div>
  34. <div class="contents_three">
  35. <label for="tiwen">体温</label>
  36. <input
  37. type="text"
  38. name="tiwen"
  39. placeholder="请输入30.0~45.0"
  40. dir="rtl"
  41. size="14"
  42. v-model="tiwen"
  43. />
  44. </div>
  45. <div class="contents_six">
  46. <van-field
  47. readonly
  48. clickable
  49. name="picker"
  50. :value="value"
  51. label="身体状况"
  52. placeholder="请选择"
  53. @click="showPicker = true"
  54. />
  55. <van-popup v-model="showPicker" position="bottom">
  56. <van-picker
  57. show-toolbar
  58. :columns="columns"
  59. @confirm="onConfirm"
  60. @cancel="showPicker = false"
  61. />
  62. </van-popup>
  63. </div>
  64. <div class="contents_six">
  65. <van-field
  66. readonly
  67. clickable
  68. name="picker"
  69. :value="value1"
  70. label="来自地点"
  71. placeholder="请选择"
  72. @click="showPicker1 = true"
  73. />
  74. <van-popup v-model="showPicker1" position="bottom">
  75. <van-picker
  76. show-toolbar
  77. :columns="columns1"
  78. @confirm="onConfirm1"
  79. @cancel="showPicker1 = false"
  80. />
  81. </van-popup>
  82. </div>
  83. <div class="contents_six">
  84. <van-field
  85. readonly
  86. clickable
  87. name="picker"
  88. :value="value2"
  89. label="交通方式"
  90. placeholder="请选择"
  91. @click="showPicker2 = true"
  92. />
  93. <van-popup v-model="showPicker2" position="bottom">
  94. <van-picker
  95. show-toolbar
  96. :columns="columns2"
  97. @confirm="onConfirm2"
  98. @cancel="showPicker2 = false"
  99. />
  100. </van-popup>
  101. </div>
  102. <div class="contents_four">
  103. <label for="yimiao">是否接种疫苗</label>
  104. <div>
  105. <el-radio-group v-model="radio1" @change="reasons($event)">
  106. <el-radio-button label="第二剂"></el-radio-button>
  107. <el-radio-button label="第一剂"></el-radio-button>
  108. <el-radio-button label="未接种"></el-radio-button>
  109. </el-radio-group>
  110. </div>
  111. </div>
  112. <div class="contents_four">
  113. <label for="hesuan">是否做过核酸检测</label>
  114. <div>
  115. <el-radio-group v-model="radio2">
  116. <el-radio-button label="是"></el-radio-button>
  117. <el-radio-button label="否"></el-radio-button>
  118. </el-radio-group>
  119. </div>
  120. </div>
  121. <div class="contents_nex">
  122. <div>请上传图片</div>
  123. <van-uploader :after-read="uploadImg" v-model="fileList" multiple />
  124. <!-- <van-uploader :after-read="afterRead" /> -->
  125. <!-- <input type="file" @change="getFile" ref="file" name="image" id="file" class="imgChoose"> -->
  126. </div>
  127. </form>
  128. </div>
  129. <div class="contents" v-show="reason">
  130. <p class="contents_five">未接种疫苗原因</p>
  131. <textarea
  132. placeholder="请说明原因"
  133. class="textareas"
  134. v-model="textareas"
  135. ></textarea>
  136. </div>
  137. <div class="buttons">
  138. <button @click="Submits">提交</button>
  139. </div>
  140. </div>
  141. </template>
  142. <script>
  143. //时间戳
  144. var getTime = function () {
  145. var date = new Date();
  146. var year = date.getFullYear();
  147. var month =
  148. date.getMonth() + 1 < 10
  149. ? "0" + (date.getMonth() + 1)
  150. : date.getMonth() + 1;
  151. var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
  152. var hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
  153. var minutes =
  154. date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
  155. var seconds =
  156. date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
  157. var mytime = `${year}-${month}-${day} ${hour}:${minutes}:${seconds}`;
  158. return mytime;
  159. };
  160. import { location } from "../../../plugins/map.js";
  161. import { getAllUrlParams } from "../../../plugins/url-encapsulation.js";
  162. export default {
  163. data() {
  164. return {
  165. fileList: [], //图片放置数组
  166. shows: false, //tabbar隐藏
  167. name: "", //员工姓名
  168. department: "", //员工部门
  169. mobile: "", //员工工号
  170. reason: false, //控制原因栏的显示或隐藏
  171. tiwen: "", //体温
  172. yimiao: 0, //疫苗
  173. hesuan: 0, //核酸
  174. textareas: "", //未接种疫苗原因
  175. value: "", //身体状况
  176. value1: "", //来自地点
  177. value2: "", //交通方式
  178. values: "", //身体状况
  179. values1: "", //来自地点
  180. values2: "", //交通方式
  181. columns: ["正常", "异常"],
  182. showPicker: false, //是否显示列表
  183. columns1: ["住矿(宿舍)", "银川", "吴忠", "灵武", "宁东", "石嘴山"],
  184. showPicker1: false, //是否显示列表
  185. columns2: ["私家车", "步行", "客运车", "出租车"],
  186. showPicker2: false, //是否显示列表
  187. radio1: "第二剂", //默认为第二剂
  188. radio2: "否",
  189. // token: sessionStorage.getItem("mytoken")
  190. // ? sessionStorage.getItem("mytoken")
  191. // : "", //token值保存在本地,有的话取值,没有为空
  192. remarks: "备注",
  193. location: "gps暂无",
  194. times: getTime(), //填报时间
  195. };
  196. },
  197. // witch: {
  198. // computed: {
  199. // tiwen() {
  200. // if (this.tiwen > 45 || this.tiwen < 30) {
  201. // this.$toast("请输入30-45");
  202. // }
  203. // },
  204. // },
  205. // },
  206. methods: {
  207. /**获取地图定位*/
  208. getLocation() {
  209. let _that = this;
  210. let geolocation = location.initMap("map-container"); //定位
  211. AMap.event.addListener(geolocation, "complete", (result) => {
  212. _that.lat = result.position.lat;
  213. _that.lng = result.position.lng;
  214. _that.province = result.addressComponent.province;
  215. _that.city = result.addressComponent.city;
  216. _that.district = result.addressComponent.district;
  217. });
  218. },
  219. uploadImg(file) {
  220. // 大于3MB的jpeg和png图片都缩小像素上传
  221. if (/\/(?:jpeg|png)/i.test(file.file.type) && file.file.size > 3000000) {
  222. // 创建Canvas对象(画布)
  223. let canvas = document.createElement("canvas");
  224. // 获取对应的CanvasRenderingContext2D对象(画笔)
  225. let context = canvas.getContext("2d");
  226. // 创建新的图片对象
  227. let img = new Image();
  228. // 指定图片的DataURL(图片的base64编码数据)
  229. img.src = file.content;
  230. // 监听浏览器加载图片完成,然后进行绘制
  231. img.onload = () => {
  232. // 指定canvas画布大小,该大小为最后生成图片的大小
  233. canvas.width = 800;
  234. canvas.height = 600;
  235. /* drawImage画布绘制的方法。(0,0)表示以Canvas画布左上角为起点,400,300是将图片按给定的像素进行缩小。*/
  236. /* 如果不指定缩小的像素,图片将以图片原始大小进行绘制,图片像素如果大于画布将会从左上角开始按画布大小部分绘制图片,最后得到的图片就是张局部图。图片小于画布就会有黑边。*/
  237. context.drawImage(img, 0, 0, 800, 600);
  238. // 将绘制完成的图片重新转化为base64编码,file.file.type为图片类型,0.92为默认压缩质量
  239. file.content = canvas.toDataURL(file.file.type, 0.92);
  240. }
  241. }
  242. },
  243. //接种疫苗
  244. reasons(e) {
  245. console.log(e)
  246. if(e == "未接种"){
  247. this.reason = true;
  248. }else{
  249. this.reason = false
  250. }
  251. },
  252. //提交数据到后台
  253. Submits() {
  254. //判断体温是否在30-45区间且不能为空
  255. if (
  256. Number(this.tiwen) > 45 ||
  257. Number(this.tiwen < 30) ||
  258. this.tiwen == ""
  259. ) {
  260. this.$toast("体温请填写30~45");
  261. } else {
  262. // console.log(this.name);
  263. // console.log(this.department);
  264. // console.log(this.tiwen);
  265. // console.log(this.radio1);
  266. // console.log(this.radio2);
  267. //疫苗情况
  268. if (this.radio1 == "第一剂") {
  269. this.yimiao = 1;
  270. } else if (this.radio1 == "未接种") {
  271. this.yimiao = 3;
  272. } else {
  273. this.yimiao = 2;
  274. }
  275. //是否做过核酸
  276. if (this.radio2 == "是") {
  277. this.hesuan = 2;
  278. } else {
  279. this.hesuan = 1;
  280. }
  281. //身体状况
  282. if (this.value == "正常") {
  283. this.values = 2;
  284. } else {
  285. this.values = 1;
  286. }
  287. //来自地点
  288. if (this.value1 == "住矿(宿舍)") {
  289. this.values1 = 1;
  290. } else if (this.value1 == "银川") {
  291. this.values1 = 2;
  292. } else if (this.value1 == "吴忠") {
  293. this.values1 = 3;
  294. } else if (this.value1 == "灵武") {
  295. this.values1 = 4;
  296. } else if (this.value1 == "宁东") {
  297. this.values1 = 5;
  298. } else {
  299. this.values1 = 6;
  300. }
  301. //交通方式
  302. if (this.value2 == "私家车") {
  303. this.values2 = 1;
  304. } else if (this.value2 == "步行") {
  305. this.values2 = 2;
  306. } else if (this.value2 == "客运车") {
  307. this.values2 = 3;
  308. } else {
  309. this.values2 = 4;
  310. }
  311. // console.log(this.yimiao);
  312. // console.log(this.times);
  313. // console.log(typeof this.tiwen);
  314. console.log(this.fileList);
  315. // console.log(images);
  316. // if (this.fileList.length == 0) {
  317. // this.$toast("请上传图片");
  318. // return;
  319. // }
  320. this.$toast.loading({
  321. message: "提交中...",
  322. forbidClick: true,
  323. overlay: true,
  324. duration: this.duration,
  325. });
  326. this.$http
  327. .post(
  328. "http://zaoquan.nxjiewei.com:8011/api/workbench/epidemic_situation/clock_in",
  329. {
  330. temperature: String(this.tiwen),
  331. vaccination: String(this.yimiao),
  332. not_vaccination_cause: this.textareas,
  333. // remarks: this.remarks,
  334. // location: this.location,
  335. nucleic_acid_test: String(this.hesuan),
  336. transport: String(this.values2),
  337. place: String(this.values1),
  338. health: String(this.values),
  339. clock_in_time: this.times,
  340. staff_num: this.mobile,
  341. image_path: this.fileList,
  342. }
  343. )
  344. .then((res) => {
  345. this.$toast.clear();
  346. console.log(res);
  347. if(res.data.code == 1){
  348. this.$toast("请完整填写信息");
  349. return
  350. }
  351. this.$dialog.alert({
  352. message: "提交成功",
  353. });
  354. var myinfo = setInterval(
  355. this.$router.push(
  356. `/zaoquan/yiqing/yiqing?token=${this.gettoken}`
  357. ),
  358. 2000
  359. );
  360. clearInterval(myinfo);
  361. // this.$router.push(`/zaoquan/yiqing/yiqing?token=${this.token}`);
  362. })
  363. .catch((res) => {
  364. this.$toast.clear();
  365. this.$toast("提交失败");
  366. console.log(res);
  367. });
  368. }
  369. },
  370. //跳转至填报列表,填报列表隐藏在tabbar上,shows为true看查看
  371. tianbao() {
  372. this.$router.push(
  373. `/zaoquan/yiqing/yiqing-tianbao?token=${this.token}&mobile=${this.mobile}`
  374. );
  375. },
  376. //弹出层-身体状况
  377. onConfirm(value) {
  378. this.value = value;
  379. this.showPicker = false;
  380. },
  381. //弹出层-来自地点
  382. onConfirm1(value1) {
  383. this.value1 = value1;
  384. this.showPicker1 = false;
  385. },
  386. //弹出层-交通方式
  387. onConfirm2(value2) {
  388. this.value2 = value2;
  389. this.showPicker2 = false;
  390. },
  391. //在有token的情况下获取员工姓名,工号和部门
  392. getxinxi() {
  393. this.$http
  394. .post("http://zaoquan.nxjiewei.com:8011/api/user/info")
  395. .then((res) => {
  396. // console.log(res);
  397. this.name = res.data.data.name;
  398. this.department = res.data.data.section_fullname;
  399. this.mobile = res.data.data.staff_num;
  400. });
  401. },
  402. //返回按钮
  403. onClickLeft() {
  404. window.history.back();
  405. },
  406. },
  407. mounted() {
  408. document.body.style.backgroundColor = "#39f"; //背景色
  409. // this.getLocation();
  410. this.gettoken = getAllUrlParams(window.location.href).token;
  411. // this.gettoken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImU5MDQ2MWNiODRjMTlkMzBlMDRkYjYzY2I5ZTc5OWZlODk0MDU4ZGZlMTQwYjkzODU3ZjEzNWJhNTAxZTNmMmQ1YTA5NmVkZWQyZDRkYWZjIn0.eyJhdWQiOiIyIiwianRpIjoiZTkwNDYxY2I4NGMxOWQzMGUwNGRiNjNjYjllNzk5ZmU4OTQwNThkZmUxNDBiOTM4NTdmMTM1YmE1MDFlM2YyZDVhMDk2ZWRlZDJkNGRhZmMiLCJpYXQiOjE2Mjg1Nzk4NTAsIm5iZiI6MTYyODU3OTg1MCwiZXhwIjoxNjMxMTcxODUwLCJzdWIiOiIyMTA5Iiwic2NvcGVzIjpbIioiXX0.IN0d0HNck3NuGN-HYaKFbn1c0Li9YUgMgr_rtIeaNUt_b5YhT_Pv-5clNy06sKb9ZiQ_wqbfrfveQwZZ2si3zLZYMx8dMuFMdo6UNKZ8v_wKNWE1SwNtE41ug_4bhoMoR-m-hXYe-Euxyz0VImXGKJsfMrR7h40sQJvA6Dx0sVsy-4XPj2bytTlnIYPN-hQ-mzBDpPWBmEef-smRKq8_fUn1CESaJYovJ6CzY9U6P1mB8ZN-lYCSj3C5EWDx31ZRNZo8FQ6UY_59UlZjwiAigu8CozO9u8_ZA0S8_80ZKPRwosMsurHpwqaT9SmPm0fNRxc5hViy0oE6CBiZSo214_W89Qh3EwZWvvrtY1UruWL-PhzIJk00_TWvfVzIzPPM5maOysltAXv6qeOmps7tM-YJKzKJ6X6U3phwz7-n1KTPdTIkVEXzB8zr33XGqc6YytIUfVoo9cCZbwdS6qXf1xdaiJNNl_7CvXhyuM744DaaxUn2T6Vp6PUwHttmC0n7YNvIslSUHoYgdSRWabNoZpLMB2O-VpBdwr314Hvn_BL0k5Pupopa4yBfJLCbg5g_pWYKT_7LGyzXS7Ts29tki-PIcRvOCBoZ4TX4pt66J00VNlG35LGTzsFyZ5wbzHBJYoerAsRT-Q4uCXxRESD8ZtWzO-Z_ZbvXrte3ivL4DO0";
  412. // this.token = `Bearer ${this.gettoken}`; //获取token值
  413. this.token = getAllUrlParams(window.location.href).token;
  414. this.gettoken = getAllUrlParams(window.location.href).gettoken;
  415. // console.log(this.token);
  416. this.tabbar = Boolean(getAllUrlParams(window.location.href).tabbar);
  417. this.shows = this.tabbar;
  418. console.log(this.shows);
  419. // sessionStorage.setItem("mytoken", this.token); //存入token值
  420. this.getxinxi();
  421. // this.myinfo=setInterval(this.Submits,this.$router.push(`/zaoquan/yiqing/yiqing?toen=${this.token}`), 2000);
  422. },
  423. beforeDestroy() {
  424. clearInterval(this.myinfo); //销毁阶段清除定时器
  425. },
  426. };
  427. </script>
  428. <style scoped>
  429. >>> .van-nav-bar {
  430. background: #39f;
  431. }
  432. >>> .van-nav-bar__title {
  433. color: #fff;
  434. }
  435. >>> .van-nav-bar .van-icon {
  436. color: #fff;
  437. }
  438. >>> .van-nav-bar__text {
  439. color: #fff;
  440. }
  441. [class*="van-hairline"]:after {
  442. border: none;
  443. }
  444. .contents1 {
  445. width: 90%;
  446. margin: 7px auto 10px;
  447. background: #fff;
  448. border-radius: 10px;
  449. border: 1px solid transparent;
  450. text-align: center;
  451. }
  452. .contents {
  453. width: 90%;
  454. margin: 7px auto 10px;
  455. background: #fff;
  456. border-radius: 10px;
  457. border: 1px solid transparent;
  458. }
  459. .contents_one {
  460. width: 95%;
  461. margin: 5px auto;
  462. padding-bottom: 10px;
  463. display: flex;
  464. justify-content: left;
  465. border-bottom: 1px solid #f0f0f0;
  466. }
  467. .contents_one > img {
  468. width: 40px;
  469. height: 40px;
  470. }
  471. .contents_one > p {
  472. width: 194px;
  473. font-size: 14px;
  474. margin-left: 15px;
  475. color: #00a1e9;
  476. }
  477. .contents_one > input {
  478. border: none;
  479. width: 77px;
  480. background: #39f;
  481. color: #fff;
  482. border-radius: 10px;
  483. height: 27px;
  484. font-size: 14px;
  485. margin-top: 6px;
  486. margin-left: 13px;
  487. }
  488. .contents_two {
  489. width: 95%;
  490. margin: 0 auto;
  491. border-bottom: 1px solid #f0f0f0;
  492. }
  493. .van-cell {
  494. padding: 10px 5px;
  495. }
  496. .van-cell__value {
  497. color: black;
  498. }
  499. .contents_three {
  500. width: 95%;
  501. margin: 0 auto;
  502. border-bottom: 1px solid #f0f0f0;
  503. display: flex;
  504. justify-content: space-between;
  505. padding: 10px 5px;
  506. }
  507. .contents_three > label {
  508. font-size: 14px;
  509. margin-left: 4px;
  510. }
  511. .contents_three > input {
  512. border: none;
  513. }
  514. input::-webkit-input-placeholder {
  515. color: #969799;
  516. font-size: 14px;
  517. text-align: right;
  518. }
  519. .contents_four {
  520. width: 95%;
  521. margin: 0 auto;
  522. border-bottom: 1px solid #f0f0f0;
  523. display: flex;
  524. justify-content: space-between;
  525. padding: 10px 5px;
  526. }
  527. .contents_four > label {
  528. font-size: 14px;
  529. margin-left: 4px;
  530. }
  531. .contents_five {
  532. width: 95%;
  533. margin: 0 auto;
  534. font-size: 14px;
  535. margin-left: 4px;
  536. border-bottom: 1px solid #f0f0f0;
  537. padding: 10px 5px;
  538. }
  539. .contents_six {
  540. width: 95%;
  541. margin: 0 auto;
  542. border-bottom: 1px solid #f0f0f0;
  543. }
  544. .buttons {
  545. text-align: center;
  546. margin: 25px auto;
  547. }
  548. .buttons > button {
  549. width: 90%;
  550. height: 40px;
  551. border: none;
  552. background: #fff;
  553. color: #39f;
  554. border-radius: 10px;
  555. }
  556. .textareas {
  557. border: none;
  558. margin-left: 8px;
  559. font-size: 15px;
  560. width: 95%;
  561. margin-top: 10px;
  562. resize: none;
  563. }
  564. >>> .van-field__control {
  565. text-align: right;
  566. }
  567. >>> .el-radio-button {
  568. margin-left: 4px;
  569. }
  570. >>> .el-radio-button:last-child .el-radio-button__inner {
  571. border-radius: 14px;
  572. }
  573. >>> .el-radio-button__inner {
  574. white-space: nowrap;
  575. background: #fff;
  576. border: 1px solid #dcdfe6;
  577. font-weight: 500;
  578. /* border-left: 1px; */
  579. color: #606266;
  580. -webkit-appearance: none;
  581. text-align: center;
  582. box-sizing: border-box;
  583. outline: 0;
  584. margin: 0;
  585. position: relative;
  586. cursor: pointer;
  587. transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
  588. padding: 6px 12px;
  589. font-size: 11px;
  590. }
  591. >>> .el-radio-button__inner {
  592. border-radius: 14px;
  593. }
  594. >>> .el-radio-button:first-child .el-radio-button__inner {
  595. border-radius: 14px;
  596. }
  597. .contents_nex {
  598. width: 95%;
  599. margin: 0 auto;
  600. border-bottom: 1px solid #f0f0f0;
  601. padding: 10px 5px;
  602. }
  603. .contents_nex > div {
  604. font-size: 14px;
  605. margin-left: 4px;
  606. margin-bottom: 5px;
  607. }
  608. </style>