InspectionDetail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. <template>
  2. <div class="inspedtionDetail">
  3. <div class="label">巡检信息</div>
  4. <div class="head">
  5. <p>
  6. <i class="iconfont icon-zuixinbaoxiu newPapir"></i>
  7. 巡检单号
  8. <span class="num">{{ baseInfo.sign }}</span>
  9. <span class="btn zhixingzhong">{{ baseInfo.stateName }}</span>
  10. </p>
  11. </div>
  12. <div class="info">
  13. <p>
  14. <span class="fl">巡检类型</span>
  15. <span class="fr">{{ baseInfo.inspectionType.type }}</span>
  16. </p>
  17. <p>
  18. <span class="fl">计划主题</span>
  19. <span class="fr">{{ baseInfo.inspection.title }}</span>
  20. </p>
  21. <p>
  22. <span class="fl">计划内容</span>
  23. <span class="fr showwrap">{{ baseInfo.inspection.content }}</span>
  24. </p>
  25. <p>
  26. <span class="fl">巡检状态</span>
  27. <span class="fr">{{ baseInfo.stateName }}</span>
  28. </p>
  29. <p>
  30. <span class="fl">巡检策略</span>
  31. <span class="fr">{{ baseInfo.inspection.planStrategy.name }}</span>
  32. </p>
  33. <p>
  34. <span class="fl">执行时长</span>
  35. <span class="fr">{{ baseInfo.inspection.executionTime }}分钟</span>
  36. </p>
  37. <p>
  38. <span class="fl">开始时间</span>
  39. <span class="fr">{{
  40. baseInfo.inspection.planStartTime.slice(
  41. 0,
  42. baseInfo.inspection.planStartTime.length - 2
  43. )
  44. }}</span>
  45. </p>
  46. <p>
  47. <span class="fl">逾期时间</span>
  48. <span class="fr">{{ baseInfo.overdueTime }}</span>
  49. </p>
  50. </div>
  51. <div class="label">巡检结果</div>
  52. <div class="form">
  53. <p v-for="(item, index) in forms" :key="index">
  54. <span>{{ item.name }}:</span>
  55. <cube-switch
  56. v-model="param[item.key]"
  57. :class="{ abnormal: !param[item.key] }"
  58. :data-label="item.key"
  59. ></cube-switch>
  60. </p>
  61. </div>
  62. <div class="label formLabel">
  63. {{ xj_beizhu.name }}
  64. </div>
  65. <div class="textarea_div">
  66. <cube-textarea
  67. class="textarea"
  68. v-model="param[xj_beizhu.key]"
  69. placeholder="请输入整改意见"
  70. ></cube-textarea>
  71. </div>
  72. <div></div>
  73. <div class="label formLabel">
  74. 图片上传
  75. <span>(最多可上传3张JPG或PNG,每张不能超过10M)</span>
  76. </div>
  77. <div class="uplod">
  78. <cube-upload
  79. ref="upload"
  80. :max="3"
  81. :action="action"
  82. :simultaneous-uploads="3"
  83. @files-added="filesAdded"
  84. @file-submitted="fileSubmitted"
  85. />
  86. </div>
  87. <div class="btns">
  88. <div class="btn" @click="createIncident()">生成事件</div>
  89. <div class="btn submit" @click="getLocation()">提交</div>
  90. <div class="btn cancel" @click="cancle()">取消</div>
  91. </div>
  92. </div>
  93. </template>
  94. <script>
  95. let sdk = new jssdk(3, "https://wx2.zuel.edu.cn"); // 域名更换为对应环境域名, 204 更换为对应环境wid
  96. sdk.config(0); //1表示调试模式,生产环境传0
  97. import { GL } from "./../http/http";
  98. export default {
  99. data() {
  100. return {
  101. action: {
  102. target:
  103. this.$host + "/service/common/common/uploadAttachment/inspection/",
  104. data: {}
  105. },
  106. loginUser: JSON.parse(localStorage.getItem("loginUser")),
  107. valConfig: JSON.parse(localStorage.getItem("valConfig")) - 0, //报修主体
  108. baseInfo: {}, //巡检基础信息
  109. items: [], //巡检项目
  110. xj_arr: [], //巡检项目数组key和name
  111. xj_beizhu: {}, //巡检-整改意见(备注)
  112. forms: [], //巡检结果
  113. abnormal: "", //异常项
  114. param: {
  115. sdCheckEnable1: true,
  116. sdCheckEnable2: true,
  117. sdCheckEnable3: true,
  118. sdCheckEnable4: true,
  119. sdCheckEnable5: true,
  120. sdCheckEnable6: true,
  121. sdCheckEnable7: true,
  122. sdCheckEnable8: true,
  123. sdCheckEnable9: true,
  124. sdCheckEnable10: true,
  125. sdCheckEnable11: true,
  126. sdCheckEnable12: true,
  127. descriptionTextarea: "",
  128. inspectionProcessActual: {}
  129. },
  130. model: {}
  131. };
  132. },
  133. methods: {
  134. //获取位置,经纬度
  135. getLocation() {
  136. // 判断是否处于微信浏览器环境
  137. if (!/MicroMessenger/i.test(window.navigator.userAgent)) {
  138. this.$createToast({
  139. txt: "请前往微信中操作",
  140. type: "warn",
  141. mask: true,
  142. }).show();
  143. return;
  144. }
  145. this.toast = this.$createToast({
  146. time: 0,
  147. mask: true,
  148. txt: "正在加载中",
  149. });
  150. this.toast.show();
  151. // 中南财大
  152. if (this.isZncd) {
  153. //第二个参数 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
  154. sdk.getLocation((res) => {
  155. // alert(JSON.stringify(res));
  156. // latitude
  157. // longitude
  158. this.gl(res);
  159. });
  160. } else {
  161. GL(this).then((res) => {
  162. this.gl(res);
  163. });
  164. }
  165. },
  166. //获取地理位置方法
  167. gl(res) {
  168. let _this = this;
  169. $.ajax({
  170. url: "https://apis.map.qq.com/ws/geocoder/v1",
  171. data: {
  172. location: res.latitude + "," + res.longitude,
  173. key: "TADBZ-IRBWU-QAXVE-2IWED-UW2F5-YVF66",
  174. output: "jsonp",
  175. },
  176. dataType: "jsonp",
  177. success(result) {
  178. if (result.status === 0) {
  179. let address = result.result.formatted_addresses.recommend;
  180. _this.submit(address);
  181. }
  182. },
  183. });
  184. },
  185. fileSubmitted(files) {
  186. this.action.data = { fileName: files.name };
  187. },
  188. filesAdded(files) {
  189. let hasIgnore = false;
  190. const maxSize = 10 * 1024 * 1024; // 10M
  191. for (let k in files) {
  192. const file = files[k];
  193. if (file.size > maxSize) {
  194. file.ignore = true;
  195. hasIgnore = true;
  196. }
  197. }
  198. hasIgnore &&
  199. this.$createToast({
  200. type: "warn",
  201. time: 1000,
  202. txt: "不能上传超过10M的文件"
  203. }).show();
  204. },
  205. // 获取项目异常状态
  206. getItems() {
  207. var that = this;
  208. that.$http
  209. .get(
  210. "/service/form/renderForm/inspection_LinHu_confirm/" +
  211. that.baseInfo.processInstanceId +
  212. "/" +
  213. that.loginUser.id +
  214. "/" +
  215. that.baseInfo.id,
  216. {}
  217. )
  218. .then(function(res) {
  219. console.log(res.data);
  220. that.model = res.data.model;
  221. var fields = res.data.fields;
  222. console.log(fields);
  223. fields.forEach(v => {
  224. v.key = (v.key || "").toString();
  225. if (v.key.indexOf("sdCheckEnable") > -1) {
  226. that.xj_arr.push(v);
  227. }
  228. if (v.key.indexOf("descriptionTextarea") > -1) {
  229. that.xj_beizhu = {
  230. key: v.key,
  231. name: v.templateOptions.label
  232. };
  233. }
  234. });
  235. console.log(that.xj_arr);
  236. console.log(that.xj_beizhu);
  237. that.forms = that.xj_arr.map(v => ({
  238. key: v.key,
  239. name: v.templateOptions.label
  240. }));
  241. window.localStorage.setItem("forms", JSON.stringify(that.forms));
  242. });
  243. },
  244. // 提交
  245. submit(address) {
  246. this.param.loginUser = this.loginUser;
  247. this.param.save = this.model.save;
  248. this.param.close = this.model.close;
  249. this.param.submit = this.model.submit;
  250. this.param.toIncident = this.model.toIncident;
  251. this.param.handler_code = "resolve";
  252. this.param.inspectionProcessActual = this.baseInfo;
  253. this.param.address = address;
  254. console.log(this.param);
  255. var that = this;
  256. that.$http
  257. .post(
  258. "/service/bpm/bpm/completeTask/" +
  259. that.baseInfo.processInstanceId +
  260. "/" +
  261. that.loginUser.id,
  262. that.param
  263. )
  264. .then(function(res) {
  265. console.log(res.data);
  266. if (res.data.status == 200) {
  267. that.toast.hide();
  268. that.action.target =
  269. that.action.target +
  270. that.param.inspectionProcessActual.processInstanceId;
  271. setTimeout(function() {
  272. that.$refs.upload.start();
  273. }, 100);
  274. $("#fade").fadeIn();
  275. that.promptingConent = "恭喜您,提交成功!";
  276. that.promptingStatus = true;
  277. that.dialog = that
  278. .$createDialog({
  279. type: "alert",
  280. title: "提交成功",
  281. content: "点击返回列表",
  282. icon: "cubeic-right",
  283. onConfirm: (e, promptValue) => {
  284. that.$router.push({ path: "/main/inspection" });
  285. }
  286. })
  287. .show();
  288. setTimeout(function() {
  289. $("#fade").fadeOut();
  290. }, 2000);
  291. }
  292. });
  293. },
  294. // 取消
  295. cancle() {
  296. var that = this;
  297. that.$router.go(-1);
  298. },
  299. // 生成事件
  300. createIncident() {
  301. for (var i = 0; i < $(".cube-switch.abnormal").length; i++) {
  302. this.abnormal += $(".cube-switch.abnormal")[i].dataset.label + ",";
  303. }
  304. this.$router.push({
  305. name: "NewIncident",
  306. params: { data: this.baseInfo, abnormal: this.abnormal }
  307. });
  308. }
  309. },
  310. created() {
  311. this.baseInfo =
  312. this.$route.params.data ||
  313. JSON.parse(window.localStorage.getItem("insDetailInfo"));
  314. this.forms = JSON.parse(window.localStorage.getItem("forms")) || [];
  315. this.title = this.baseInfo.inspectionType.type;
  316. this.getItems();
  317. },
  318. mounted() {
  319. this.$refs.upload.pause();
  320. }
  321. };
  322. </script>
  323. <style lang="less" scoped>
  324. .inspedtionDetail {
  325. .textarea_div {
  326. margin: 0.4rem;
  327. .textarea {
  328. height: 2rem;
  329. }
  330. }
  331. .uplod {
  332. padding: 0.24rem;
  333. border-bottom: 0.02rem solid rgb(245, 245, 245);
  334. }
  335. .label {
  336. background-color: #eee;
  337. height: 0.6rem;
  338. line-height: 0.6rem;
  339. padding-left: 0.2rem;
  340. font-size: 0.24rem;
  341. color: #666;
  342. }
  343. .head {
  344. font-size: 0.34rem;
  345. line-height: 0.45rem;
  346. border-bottom: 0.01rem solid #e6e6e6;
  347. p {
  348. padding: 0.24rem 0.48rem;
  349. i {
  350. color: #00559d;
  351. }
  352. .num {
  353. margin-left: 1rem;
  354. }
  355. .btn {
  356. float: right;
  357. }
  358. }
  359. }
  360. .info {
  361. color: #999;
  362. font-size: 0.28rem;
  363. overflow: hidden;
  364. p {
  365. line-height: 0.4rem;
  366. padding: 0.1rem 0.24rem;
  367. overflow: hidden;
  368. .overflowEllipsis2 {
  369. margin-left: 1.96rem;
  370. }
  371. }
  372. }
  373. .form {
  374. font-size: 0.32rem;
  375. color: #333;
  376. line-height: 0.86rem;
  377. overflow: hidden;
  378. display: flex;
  379. justify-content: space-between;
  380. align-items: center;
  381. flex-wrap: wrap;
  382. .cube-switch {
  383. margin-top: 0.2rem;
  384. }
  385. p {
  386. line-height: 0.4rem;
  387. padding: 0.2rem 0.24rem;
  388. width: 100%;
  389. }
  390. }
  391. .btns {
  392. font-size: 0.32px;
  393. display: flex;
  394. justify-content: space-between;
  395. align-items: center;
  396. padding: 0.24rem;
  397. display: flex;
  398. .btn {
  399. border: 0.01rem solid #005395;
  400. color: #005395;
  401. background-color: #fff;
  402. flex: 1;
  403. margin: 0 0.1rem;
  404. height: 0.88rem;
  405. line-height: 0.88rem;
  406. text-align: center;
  407. border-radius: 0.1rem;
  408. &.submit {
  409. background-color: #005395;
  410. color: #fff;
  411. }
  412. &.cancel {
  413. border-color: #ccc;
  414. color: #333;
  415. }
  416. }
  417. }
  418. .showwrap {
  419. width: 75%;
  420. text-align: right;
  421. }
  422. }
  423. </style>