riskDetail.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. <template>
  2. <view class="main">
  3. <view class="title">
  4. 基础信息
  5. </view>
  6. <view class="main_box">
  7. <view class="text">
  8. <view class="label">
  9. 管线名称
  10. </view>
  11. <view class="value">
  12. {{dataForm.lineName}}
  13. </view>
  14. </view>
  15. <view class="text">
  16. <view class="label">
  17. 管线单元名称
  18. </view>
  19. <view class="value">
  20. {{dataForm.lineUnitName}}
  21. </view>
  22. </view>
  23. <view class="text">
  24. <view class="label">
  25. 风险类型
  26. </view>
  27. <view class="value">
  28. {{dataForm.riskCategory}}
  29. </view>
  30. </view>
  31. <view class="text">
  32. <view class="label">
  33. 处理用户
  34. </view>
  35. <view class="value">
  36. {{dataForm.handleUserNames}}
  37. </view>
  38. </view>
  39. <view class="text">
  40. <view class="label">
  41. 风险照片
  42. </view>
  43. <view class="value">
  44. <img @click="privew(dataForm.picUrl)" style="width: 400rpx;height: 300rpx;" :src="dataForm.picUrl"
  45. alt="" />
  46. </view>
  47. </view>
  48. <view class="text">
  49. <view class="label">
  50. 风险点位置
  51. </view>
  52. <view class="value">
  53. <u-text class="success" type="primary" text="点击前往"
  54. @click="changelang(dataForm.photoLongitude,dataForm.photoLatitude)"></u-text>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="title" v-if="dataForm.handleRiskDTO &&dataForm.handleRiskDTO.length>0">
  59. 处理意见
  60. </view>
  61. <view class="main_box" v-if="dataForm.handleRiskDTO &&dataForm.handleRiskDTO.length>0">
  62. <view class="">
  63. <view class="value" v-for="item in dataForm.handleRiskDTO" :key="item.id">
  64. <div class="time">{{ item.createDate }}&nbsp;{{ item.createName }}</div>
  65. <div class="imgs">
  66. <img @click="privew(x.url)" v-for="(x, i) in item.fileList" :src="x.url" :key="x.id"
  67. style="width: 100%; height: 170rpx" />
  68. </div>
  69. <div class="remarks">
  70. {{ item.remarks ? item.remarks : "-" }}
  71. </div>
  72. </view>
  73. </view>
  74. </view>
  75. <view class="title">
  76. 处理信息
  77. </view>
  78. <view class="main_box" v-if="dataForm.isHandle">
  79. <view class="text">
  80. <view class="label">
  81. 图片
  82. </view>
  83. <view class="value">
  84. <u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple
  85. :maxCount="10"></u-upload>
  86. </view>
  87. </view>
  88. <view class="text">
  89. <view class="label">
  90. 风险类型
  91. </view>
  92. <view class="value" @click='show=true'>
  93. <u--input placeholder="请选择" border="none" readonly v-model="dataForm.riskTypeName"></u--input>
  94. </view>
  95. <u-picker :show="show" :columns="selectData" keyName="dictLabel" @confirm='confirm'
  96. @cancel='show=false'></u-picker>
  97. </view>
  98. <view class="text">
  99. <view class="label">
  100. 处理意见
  101. </view>
  102. <view class="value">
  103. <u--input placeholder="请输入内容" border="none" v-model="dataForm.remarks"></u--input>
  104. </view>
  105. </view>
  106. </view>
  107. <selectPeople ref="selectPeople" :checkof="true" v-model:value="dataForm.handleUserId"
  108. @selectPeople='selectPeople'>
  109. </selectPeople>
  110. <view class="" style="height:200rpx">
  111. </view>
  112. <view class="btns">
  113. <u-button class="success" v-if="dataForm.isHandle" type="primary" text="阶段填报"
  114. @click="completeTaskArrange(1)"></u-button>
  115. <u-button class="success" v-if="dataForm.isHandle" type="primary" text="处理完成"
  116. @click="completeTaskArrange(0)"></u-button>
  117. </view>
  118. </view>
  119. </template>
  120. <script>
  121. import selectPeople from '@/components/selectPeople/selectPeople.vue'
  122. import Config from '@/common/Config.js'
  123. export default {
  124. components: {
  125. selectPeople
  126. },
  127. data() {
  128. return {
  129. fileList1: [],
  130. selectData: [],
  131. show: false,
  132. dataForm: {
  133. handleUserName: "",
  134. remarks: "",
  135. riskTypeId: "1897947555707232258",
  136. riskTypeName: "正常施工",
  137. handleRiskDTO: {
  138. remarks: '',
  139. handleUserName: '',
  140. }
  141. }
  142. }
  143. },
  144. onLoad(x) {
  145. Object.assign(this.dataForm, JSON.parse(x.data));
  146. this.getInfo()
  147. this.getInit()
  148. },
  149. methods: {
  150. changelang(long, lat) {
  151. let that = this
  152. uni.request({
  153. url: `https://restapi.amap.com/v3/assistant/coordinate/convert?locations=${long},${lat}&coordsys=gps&key=74d5aa7c4270effe9a18d9cfa6149abf`,
  154. success(res) {
  155. let locations = res.data.locations.split(',')
  156. that.topicUrl(locations[0], locations[1])
  157. },
  158. fail(fail) {
  159. console.log(fail);
  160. }
  161. })
  162. },
  163. confirm(x) {
  164. this.dataForm.riskTypeId = x.value[0].id
  165. this.dataForm.riskTypeName = x.value[0].dictLabel
  166. this.show = false
  167. },
  168. topicUrl(photoLongitude, photoLatitude) {
  169. // 定义目的地的坐标和名称
  170. const latitude = photoLatitude; // 纬度
  171. const longitude = photoLongitude; // 经度
  172. const name = '风险点'; // 地点名称
  173. const address = '风险点'; // 地址
  174. // 调用uni.openLocation方法
  175. uni.openLocation({
  176. latitude: Number(latitude), // 目标纬度
  177. longitude: Number(longitude), // 目标经度
  178. name: name, // 地点名称
  179. // address: address, // 详细地址
  180. success: function() {
  181. console.log('成功打开地图');
  182. },
  183. fail: function(err) {
  184. console.error('打开地图失败', err);
  185. }
  186. });
  187. },
  188. privew(url) {
  189. wx.previewImage({
  190. urls: [url],
  191. })
  192. },
  193. // 删除图片
  194. deletePic(event) {
  195. this.fileList1.splice(event.index, 1);
  196. },
  197. // 新增图片
  198. async afterRead(event) {
  199. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  200. let lists = [].concat(event.file);
  201. let fileListLen = this.fileList1.length;
  202. lists.map((item) => {
  203. this.fileList1.push({
  204. ...item,
  205. status: "uploading",
  206. message: "上传中",
  207. });
  208. });
  209. for (let i = 0; i < lists.length; i++) {
  210. const result = await this.uploadFilePromise(lists[i].url);
  211. console.log(result);
  212. let item = this.fileList1[fileListLen];
  213. this.fileList1.splice(
  214. fileListLen,
  215. 1,
  216. Object.assign(item, {
  217. status: "success",
  218. message: "",
  219. url: result,
  220. })
  221. );
  222. fileListLen++;
  223. }
  224. },
  225. uploadFilePromise(url) {
  226. return new Promise((resolve, reject) => {
  227. let a = uni.uploadFile({
  228. url: Config.baseUrl + "/sys/oss/general/upload",
  229. filePath: url,
  230. name: "file",
  231. formData: {
  232. folderNames: [this.dataForm.lineName, this.dataForm.lineUnitName].toString()
  233. },
  234. success: (res) => {
  235. setTimeout(() => {
  236. resolve(JSON.parse(res.data).src);
  237. }, 1000);
  238. },
  239. });
  240. });
  241. },
  242. selectPeople(x) {
  243. this.dataForm.handleUserName = []
  244. this.dataForm.handleUserId = []
  245. x.forEach((k) => {
  246. this.dataForm.handleUserName.push(k.name)
  247. this.dataForm.handleUserId.push(k.id)
  248. })
  249. this.dataForm.handleUserName = this.dataForm.handleUserName.toString()
  250. this.dataForm.handleUserId = this.dataForm.handleUserId.toString()
  251. },
  252. getInit() {
  253. this.$api.to_http(`/handle/zhkjwurenjihandlerisk/optionInit`).then((res) => {
  254. if (res.data.code != 0) {
  255. return uni.$u.toast(res.data.msg)
  256. }
  257. this.selectData = [res.data.data.options1]
  258. })
  259. },
  260. getInfo() {
  261. this.$api.to_http(`/pipe/zhkjwurenjipiperisk/${this.dataForm.id}`).then((res) => {
  262. if (res.data.code != 0) {
  263. return uni.$u.toast(res.data.msg)
  264. }
  265. if (res.data.data.handleRiskDTO?.length > 0) {
  266. res.data.data.handleRiskDTO.forEach((x) => {
  267. if (x.annex) {
  268. if (JSON.parse(x.annex)) {
  269. x.fileList = JSON.parse(x.annex);
  270. } else {
  271. x.fileList = [JSON.parse(x.annex)];
  272. }
  273. }
  274. });
  275. res.data.data.handleRiskDTO.forEach((x) => {
  276. x.preview = [];
  277. if (Array.isArray(x.fileList)) {
  278. x.fileList.forEach((t) => {
  279. x.preview.push(t.url);
  280. });
  281. } else {
  282. x.fileList = [x.fileList];
  283. x.preview.push(x.fileList.url);
  284. }
  285. });
  286. }
  287. Object.assign(this.dataForm, res.data.data);
  288. })
  289. },
  290. completeTaskArrange(isHandle) {
  291. let data = {
  292. id: "",
  293. pipeRiskId: 0,
  294. handleUserName: "",
  295. riskTypeId: "",
  296. riskTypeName: "",
  297. handleUserId: "",
  298. remarks: "",
  299. isHandle,
  300. annex: []
  301. };
  302. data.pipeRiskId = this.dataForm.id;
  303. data.handleUserName = this.dataForm.handleUserNames;
  304. data.handleUserId = this.dataForm.handleUserIds;
  305. data.remarks = this.dataForm.remarks;
  306. data.riskTypeId = this.dataForm.riskTypeId;
  307. data.riskTypeName = this.dataForm.riskTypeName;
  308. let filedata = [];
  309. this.fileList1.forEach((x, i) => {
  310. filedata.push(x.url);
  311. });
  312. data.annex = JSON.stringify(filedata);
  313. this.$api.to_http(`/handle/zhkjwurenjihandlerisk`, data, 'POST')
  314. .then((res) => {
  315. if (res.data.code != 0) {
  316. return uni.$u.toast(res.data.msg)
  317. }
  318. uni.showToast({
  319. title: '操作成功',
  320. icon: 'success'
  321. })
  322. setTimeout(() => {
  323. uni.navigateBack(-1)
  324. }, 500)
  325. })
  326. },
  327. }
  328. }
  329. </script>
  330. <style lang="less" scoped>
  331. .btns {
  332. padding: 0 20rpx;
  333. box-sizing: border-box;
  334. position: fixed;
  335. width: 100%;
  336. bottom: 1%;
  337. display: grid;
  338. grid-gap: 20rpx;
  339. grid-template-columns: 1fr 1fr;
  340. z-index: 2;
  341. }
  342. .success {
  343. position: fixed;
  344. width: 100%;
  345. bottom: 1%;
  346. }
  347. .title {
  348. color: #000;
  349. font-weight: bold;
  350. padding: 10rpx 20rpx;
  351. }
  352. .main_box {
  353. background: #fff;
  354. padding: 0rpx 20rpx;
  355. color: #323233;
  356. .imgs {
  357. display: grid;
  358. grid-gap: 20rpx;
  359. grid-template-columns: 1fr 1fr 1fr 1fr;
  360. image {
  361. border-radius: 20rpx;
  362. }
  363. }
  364. .text {
  365. display: flex;
  366. padding: 21rpx 0;
  367. margin: 8rpx 0;
  368. border-bottom: 1px solid rgb(235, 237, 240);
  369. font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Segoe UI, Arial, Roboto, "PingFang SC", "miui", "Hiragino Sans GB", "Microsoft Yahei", sans-serif;
  370. .label {
  371. width: 220rpx;
  372. }
  373. }
  374. }
  375. </style>