gridding.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  1. <template>
  2. <view>
  3. <!-- 入口列表 -->
  4. <view class="list">
  5. <view class="item" @click="go_query()">
  6. <view class="icon">
  7. <image src="./icon/icon_1.png" mode=""></image>
  8. </view>
  9. <view class="name">网格化查询</view>
  10. </view>
  11. <view class="item" @click="go_chart_statistics()">
  12. <view class="icon">
  13. <image src="./icon/icon_2.png" mode=""></image>
  14. </view>
  15. <view class="name">图表统计</view>
  16. </view>
  17. <view class="item" @click="go_timeline_details()">
  18. <view class="icon">
  19. <image src="./icon/icon_3.png" mode=""></image>
  20. </view>
  21. <view class="name">记录详情</view>
  22. </view>
  23. </view>
  24. <!-- 提交内容 -->
  25. <view class="content">
  26. <view class="title">网格化管理巡回检查</view>
  27. <view class="inner">
  28. <view class="input_box">
  29. <view class="label"><text> * </text>网格编号(单选):</view>
  30. <view class="box" @click="change_bianhao()">
  31. {{array_text_bianhao}}
  32. </view>
  33. </view>
  34. <view class="input_box" v-if="array_fanwei.length != 0">
  35. <view class="label"><text> * </text>网格范围(单选):</view>
  36. <view class="box" @click="change_fanwei()">
  37. {{array_text_fanwei}}
  38. </view>
  39. </view>
  40. <view class="input_box" v-if="array_quyu.length != 0">
  41. <view class="label"><text> * </text>网格区域(多选):(选择网格范围后自动出现)</view>
  42. <view class="box" @click="open">
  43. {{array_text_quyu}}
  44. </view>
  45. </view>
  46. <view class="input_box">
  47. <view class="label"><text> * </text>巡检日期(单选):</view>
  48. <view class="box">
  49. <uni-datetime-picker type="date" :value="single" @change="change_time" />
  50. </view>
  51. </view>
  52. <view class="input_box">
  53. <view class="label"><text> * </text>巡检人员:</view>
  54. <view class="box" @click="open_renyuan">
  55. {{array_text_renyuan}}
  56. </view>
  57. </view>
  58. <!-- 图片 -->
  59. <view class="input_box">
  60. <view class="label">现场照片:</view>
  61. <view class="img_box">
  62. <view class="item" v-for="(item,index) in up_img_list" :key="index"
  63. @click="open_img(item.path)">
  64. <image :src="item.path" mode="aspectFill"></image>
  65. <view class="clear" @click.stop="del_img(index)">
  66. <uni-icons type="clear" size="20" color="red"></uni-icons>
  67. </view>
  68. </view>
  69. <view class="item" v-if="up_img_list.length < 1" @click="up_img()">
  70. <view class="image">+</view>
  71. </view>
  72. </view>
  73. </view>
  74. <view class="btn" @click="tijiao()">提交</view>
  75. </view>
  76. </view>
  77. <!-- 弹出层 -->
  78. <!-- 网格区域 -->
  79. <uni-popup ref="popup" type="bottom">
  80. <view class="select_box">
  81. <checkbox-group @change="checkboxChange">
  82. <view class="item" v-for="item in array_quyu" :key="item.value">
  83. <view class="text">{{item.name}}</view>
  84. <view class="box">
  85. <checkbox style="transform:scale(0.7)" :value="item.value" :checked="item.checked" />
  86. </view>
  87. </view>
  88. </checkbox-group>
  89. </view>
  90. </uni-popup>
  91. <!-- 巡检人员 -->
  92. <uni-popup ref="popup_renyuan" type="bottom">
  93. <view class="select_box">
  94. <checkbox-group @change="checkboxChange_renyuan">
  95. <view class="item" v-for="item in array_renyuan" :key="item.value">
  96. <view class="text">{{item.name}}</view>
  97. <view class="box">
  98. <checkbox style="transform:scale(0.7)" :value="item.value" :checked="item.checked" />
  99. </view>
  100. </view>
  101. </checkbox-group>
  102. </view>
  103. </uni-popup>
  104. </view>
  105. </template>
  106. <script>
  107. import {
  108. set_base_url
  109. } from '@/common/set_base_url.js'
  110. export default {
  111. data() {
  112. return {
  113. // 当前煤矿编码
  114. mine_code: "",
  115. // 上传图片的基础路径
  116. base_url: "",
  117. // 当前选中的网格编号文本
  118. array_text_bianhao: "请选择",
  119. // 网格编号的配置参数
  120. array_bianhao: [],
  121. // 网格编号的原始数据
  122. array_data_bianhao: [],
  123. // 选中网格编号的id
  124. array_id_bianhao: "",
  125. // 网格范围
  126. // 文本
  127. array_text_fanwei: "请选择",
  128. // 配置参数
  129. array_fanwei: [],
  130. // 原始数据
  131. array_data_fanwei: [],
  132. // id
  133. array_id_fanwei: "",
  134. // 网格区域
  135. // 文本
  136. array_text_quyu: "请选择",
  137. // 配置参数
  138. array_quyu: [],
  139. // 原始数据
  140. array_data_quyu: [],
  141. array_id_quyu: "",
  142. // 巡检人员
  143. // 文本
  144. array_text_renyuan: "请选择",
  145. // 配置参数
  146. array_renyuan: [],
  147. // 原始数据
  148. array_data_renyuan: [],
  149. array_id_renyuan: "",
  150. // 已上传图片列表
  151. up_img_list: [],
  152. // 巡检时间
  153. single: "",
  154. // 提交的图片地址
  155. img_url: ""
  156. };
  157. },
  158. onLoad() {
  159. // 初始化当前煤矿编码
  160. this.mine_code = uni.getStorageSync('mine_code')
  161. // 根据矿编码切换首页接口不同的请求基础路径
  162. this.base_url = set_base_url(this.mine_code)
  163. this.get_trouble_grid_number_list()
  164. },
  165. methods: {
  166. // 查询页
  167. go_query() {
  168. uni.navigateTo({
  169. url: "./grid_query/grid_query"
  170. })
  171. },
  172. // 图表统计页
  173. go_chart_statistics() {
  174. uni.navigateTo({
  175. url: "./chart_statistics/chart_statistics"
  176. })
  177. },
  178. // 时间线详情
  179. go_timeline_details() {
  180. uni.navigateTo({
  181. url: "./timeline_details/timeline_details"
  182. })
  183. },
  184. // 配置参数 网格编号
  185. get_trouble_grid_number_list() {
  186. uni.showLoading({
  187. mask: true
  188. })
  189. this.$api.trouble_grid_number_list({
  190. type: 1
  191. }).then((res) => {
  192. uni.hideLoading()
  193. console.log(res.data.data)
  194. this.array_data_bianhao = res.data.data
  195. const data = res.data.data
  196. data.forEach((item, index) => {
  197. this.array_bianhao.push(item.itemValue)
  198. })
  199. })
  200. },
  201. change_bianhao() {
  202. uni.showActionSheet({
  203. itemList: this.array_bianhao,
  204. success: (res) => {
  205. // 当前显示的名称
  206. this.array_text_bianhao = this.array_data_bianhao[res.tapIndex].itemValue
  207. // 当前选中的网格id
  208. this.array_id_bianhao = this.array_data_bianhao[res.tapIndex].id
  209. console.log(this.array_id_bianhao)
  210. // 获取前先清空
  211. // 网格范围
  212. // 文本
  213. this.array_text_fanwei = "请选择"
  214. // 配置参数
  215. this.array_fanwei = []
  216. // 原始数据
  217. this.array_data_fanwei = []
  218. // id
  219. this.array_id_fanwei = ""
  220. // 获取前先清空
  221. // 网格区域
  222. // 文本
  223. this.array_text_quyu = "请选择"
  224. // 配置参数
  225. this.array_quyu = []
  226. // 原始数据
  227. this.array_data_quyu = []
  228. // id
  229. this.array_id_quyu = ""
  230. // 巡检人员
  231. // 文本
  232. this.array_text_renyuan = "请选择"
  233. // 配置参数
  234. this.array_renyuan = []
  235. // 原始数据
  236. this.array_data_renyuan = []
  237. // id
  238. this.array_id_renyuan = ""
  239. // 获取网格范围
  240. uni.showLoading({
  241. mask: true
  242. })
  243. this.$api.trouble_grid_range_list({
  244. type: 1,
  245. grid_number_id: this.array_id_bianhao
  246. }).then((res) => {
  247. uni.hideLoading()
  248. console.log(res.data.data)
  249. this.array_data_fanwei = res.data.data
  250. const data = res.data.data
  251. data.forEach((item, index) => {
  252. this.array_fanwei.push(item.itemValue)
  253. })
  254. })
  255. // 获取巡检人员
  256. this.$api.trouble_grid_owner_list({
  257. type: 1,
  258. member_id: this.array_data_bianhao[res.tapIndex].member_id
  259. }).then((res) => {
  260. uni.hideLoading()
  261. console.log(res.data.data)
  262. this.array_data_renyuan = res.data.data
  263. const data = res.data.data
  264. const series = []
  265. data.map((item, index) => {
  266. //新数组的项,用来盛放每一项中的各个参数,每次清空,这样避免改变sevm的值
  267. var sevm = {};
  268. //给每一项中的参数初始化并赋值
  269. sevm['value'] = '"' + item.id + '"'
  270. sevm['name'] = item.itemValue
  271. //将项放进新的数组
  272. series.push(sevm)
  273. })
  274. this.array_renyuan = series
  275. this.$set(this.array_renyuan)
  276. console.log(this.array_renyuan)
  277. })
  278. }
  279. });
  280. },
  281. change_fanwei() {
  282. uni.showActionSheet({
  283. itemList: this.array_fanwei,
  284. success: (res) => {
  285. // 当前显示的名称
  286. this.array_text_fanwei = this.array_data_fanwei[res.tapIndex].itemValue
  287. // 当前选中的网格id
  288. this.array_id_fanwei = this.array_data_fanwei[res.tapIndex].id
  289. console.log(this.array_id_fanwei)
  290. // 获取前先清空
  291. // 网格区域
  292. // 文本
  293. this.array_text_quyu = "请选择"
  294. // 配置参数
  295. this.array_quyu = []
  296. // 原始数据
  297. this.array_data_quyu = []
  298. // id
  299. this.array_id_quyu = ""
  300. // 获取网格区域
  301. uni.showLoading({
  302. mask: true
  303. })
  304. this.$api.trouble_grid_region_list({
  305. type: 1,
  306. grid_range_id: this.array_id_fanwei
  307. }).then((res) => {
  308. uni.hideLoading()
  309. console.log(res.data.data)
  310. this.array_data_quyu = res.data.data
  311. const data = res.data.data
  312. const series = []
  313. data.map((item, index) => {
  314. //新数组的项,用来盛放每一项中的各个参数,每次清空,这样避免改变sevm的值
  315. var sevm = {};
  316. //给每一项中的参数初始化并赋值
  317. sevm['value'] = '"' + item.id + '"'
  318. sevm['name'] = item.itemValue
  319. //将项放进新的数组
  320. series.push(sevm)
  321. })
  322. this.array_quyu = series
  323. this.$set(this.array_quyu)
  324. console.log(this.array_quyu)
  325. })
  326. }
  327. });
  328. },
  329. open() {
  330. this.$refs.popup.open()
  331. },
  332. open_renyuan() {
  333. this.$refs.popup_renyuan.open()
  334. },
  335. // 多选区域
  336. checkboxChange: function(e) {
  337. var items = this.array_quyu,
  338. values = e.detail.value;
  339. for (var i = 0, lenI = items.length; i < lenI; ++i) {
  340. const item = items[i]
  341. if (values.includes(item.value)) {
  342. this.$set(item, 'checked', true)
  343. } else {
  344. this.$set(item, 'checked', false)
  345. }
  346. }
  347. console.log(values)
  348. this.array_id_quyu = ""
  349. this.array_text_quyu = ""
  350. values.forEach((item, index) => {
  351. // console.log(item)
  352. this.array_id_quyu += item + ','
  353. this.array_quyu.forEach((item_2, index_2) => {
  354. console.log(item_2.value)
  355. if (item == item_2.value) {
  356. this.array_text_quyu += this.array_quyu[index_2].name + ','
  357. }
  358. })
  359. })
  360. },
  361. // 巡检人员
  362. checkboxChange_renyuan: function(e) {
  363. var items = this.array_renyuan,
  364. values = e.detail.value;
  365. for (var i = 0, lenI = items.length; i < lenI; ++i) {
  366. const item = items[i]
  367. if (values.includes(item.value)) {
  368. this.$set(item, 'checked', true)
  369. } else {
  370. this.$set(item, 'checked', false)
  371. }
  372. }
  373. console.log(values)
  374. this.array_id_renyuan = values
  375. this.array_id_renyuan = ""
  376. this.array_text_renyuan = ""
  377. values.forEach((item, index) => {
  378. // console.log(item)
  379. this.array_id_renyuan += item + ','
  380. console.log(this.array_id_renyuan)
  381. this.array_renyuan.forEach((item_2, index_2) => {
  382. console.log(item_2.value)
  383. if (item == item_2.value) {
  384. this.array_text_renyuan += this.array_renyuan[index_2].name + ','
  385. }
  386. })
  387. })
  388. },
  389. // 巡检时间
  390. change_time(e) {
  391. this.single = e;
  392. console.log("-change事件:", e);
  393. },
  394. // 上传图片
  395. up_img() {
  396. uni.chooseImage({
  397. count: 1,
  398. success: (chooseImageRes) => {
  399. const tempFilePaths = chooseImageRes.tempFilePaths;
  400. console.log(chooseImageRes.tempFiles[0]);
  401. uni.showLoading({
  402. mask: true,
  403. title: "上传中..."
  404. })
  405. uni.uploadFile({
  406. url: this.base_url + "/worksheet/design/up_images",
  407. header: {
  408. 'Authorization': uni.getStorageSync('token_type') + ' ' + uni
  409. .getStorageSync('Authorization')
  410. },
  411. filePath: tempFilePaths[0],
  412. name: 'file',
  413. // formData只有H5存在
  414. formData: {
  415. image: chooseImageRes.tempFiles[0]
  416. },
  417. success: (uploadFileRes) => {
  418. // console.log(uploadFileRes.data);
  419. console.log(JSON.parse(uploadFileRes.data));
  420. const img = JSON.parse(uploadFileRes.data)
  421. this.up_img_list.push(img.data)
  422. console.log(this.up_img_list)
  423. uni.hideLoading()
  424. uni.showToast({
  425. icon: "none",
  426. title: "上传成功"
  427. })
  428. this.$forceUpdate()
  429. }
  430. })
  431. }
  432. })
  433. },
  434. // 删除已上传图片
  435. del_img(index) {
  436. this.up_img_list.splice(index, 1)
  437. console.log(this.up_img_list)
  438. uni.showToast({
  439. icon: "none",
  440. title: "删除成功"
  441. })
  442. this.$forceUpdate()
  443. },
  444. open_img(path) {
  445. console.log(path)
  446. let urls = []
  447. urls[0] = path
  448. uni.previewImage({
  449. urls: urls
  450. });
  451. },
  452. // 提交
  453. tijiao() {
  454. this.array_id_quyu = this.array_id_quyu.substring(0, this.array_id_quyu.lastIndexOf(','))
  455. this.array_id_renyuan = this.array_id_renyuan.substring(0, this.array_id_renyuan.lastIndexOf(','))
  456. if (this.up_img_list.length != 0) {
  457. this.img_url = this.up_img_list[0].path
  458. }
  459. if (this.array_id_bianhao != "" && this.array_id_fanwei != "" && this.array_id_quyu != "" && this.single !=
  460. "" && this.array_id_renyuan != "") {
  461. console.log("网格编号:" + this.array_id_bianhao)
  462. console.log("网格范围:" + this.array_id_fanwei)
  463. console.log("网格区域:" + this.array_id_quyu)
  464. console.log("巡检日期:" + this.single)
  465. console.log("巡检人员:" + this.array_id_renyuan)
  466. console.log("现场照片:" + this.img_url)
  467. uni.showLoading({
  468. mask: true,
  469. title: "提交中..."
  470. })
  471. this.$api.trouble_grid_check_add({
  472. type: 1,
  473. grid_number_id: this.array_id_bianhao,
  474. grid_range_id: this.array_id_fanwei,
  475. grid_region_id: this.array_id_quyu,
  476. grid_owner_id: this.array_id_renyuan,
  477. img_url: this.img_url,
  478. }).then((res) => {
  479. uni.hideLoading()
  480. uni.showToast({
  481. icon: "none",
  482. title: "提交成功"
  483. })
  484. console.log(res)
  485. setTimeout(() => {
  486. this.go_timeline_details()
  487. }, 1500)
  488. })
  489. } else {
  490. uni.showToast({
  491. icon: "none",
  492. title: "请补充必填项"
  493. })
  494. }
  495. }
  496. }
  497. }
  498. </script>
  499. <style lang="scss">
  500. page {
  501. background-color: #009FE8;
  502. box-sizing: border-box;
  503. padding: 25rpx;
  504. }
  505. .list {
  506. background-color: #FFFFFF;
  507. border-radius: 10rpx;
  508. box-sizing: border-box;
  509. padding: 50rpx 0;
  510. display: flex;
  511. justify-content: space-around;
  512. align-items: center;
  513. .item {
  514. font-size: 32rpx;
  515. text-align: center;
  516. .icon {
  517. image {
  518. width: 70rpx;
  519. height: 70rpx;
  520. }
  521. }
  522. .name {
  523. margin-top: 20rpx;
  524. }
  525. }
  526. }
  527. .content {
  528. margin-top: 20rpx;
  529. background-color: #FFFFFF;
  530. border-radius: 10rpx;
  531. box-sizing: border-box;
  532. padding: 30rpx 25rpx;
  533. .title {
  534. line-height: 80rpx;
  535. color: #2980B9;
  536. font-size: 38rpx;
  537. font-weight: 500;
  538. }
  539. .inner {
  540. padding-top: 10rpx;
  541. .input_box {
  542. margin-bottom: 20rpx;
  543. font-size: 32rpx;
  544. .label {
  545. min-height: 80rpx;
  546. line-height: 80rpx;
  547. color: #6C6F74;
  548. text {
  549. color: red;
  550. }
  551. }
  552. .box {
  553. width: 650rpx;
  554. min-height: 90rpx;
  555. line-height: 90rpx;
  556. background: #FFFFFF;
  557. border-radius: 8rpx;
  558. border: 2rpx solid #E9EBF2;
  559. box-sizing: border-box;
  560. padding: 0 25rpx;
  561. /deep/.uni-date-editor--x {
  562. .uniui-clear {
  563. display: none;
  564. }
  565. }
  566. /deep/.uni-date-x--border {
  567. box-sizing: border-box;
  568. border-radius: 4px;
  569. border: none;
  570. }
  571. /deep/.uni-date-x {
  572. padding: 0;
  573. }
  574. }
  575. .img_box {
  576. width: 650rpx;
  577. min-height: 160rpx;
  578. background: #FFFFFF;
  579. border-radius: 8rpx;
  580. border: 2rpx solid #E9EBF2;
  581. box-sizing: border-box;
  582. padding: 30rpx 25rpx 0;
  583. overflow: hidden;
  584. .item {
  585. position: relative;
  586. float: left;
  587. width: 180rpx;
  588. height: 170rpx;
  589. margin-right: 25rpx;
  590. margin-bottom: 25rpx;
  591. image {
  592. width: 180rpx;
  593. height: 170rpx;
  594. }
  595. .image {
  596. width: 180rpx;
  597. line-height: 170rpx;
  598. text-align: center;
  599. border: 1rpx solid #E9EBF2;
  600. font-size: 120rpx;
  601. color: #E9EBF2;
  602. }
  603. .clear {
  604. position: absolute;
  605. right: -10px;
  606. top: -10px;
  607. }
  608. }
  609. .item:nth-child(3n) {
  610. margin-right: 0;
  611. }
  612. }
  613. }
  614. }
  615. }
  616. .select_box {
  617. background-color: #FFFFFF;
  618. border-radius: 10rpx 10rpx 0 0;
  619. width: 750rpx;
  620. box-sizing: border-box;
  621. padding: 30rpx 50rpx;
  622. .item {
  623. display: flex;
  624. justify-content: space-between;
  625. align-items: center;
  626. border-bottom: 1rpx solid #E9EBF2;
  627. box-sizing: border-box;
  628. padding: 15rpx 0;
  629. .box {}
  630. .text {}
  631. }
  632. }
  633. .btn {
  634. margin-top: 40rpx;
  635. background-color: #009FE8;
  636. padding: 25rpx 50rpx;
  637. color: #FFFFFF;
  638. text-align: center;
  639. }
  640. </style>