detection_details.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <view class=" uni-container" v-if="formData.id">
  3. <view class="example container" :style="'height: ' + (screenHeight - wheight - 75) + 'px'">
  4. <!-- 自定义表单校验 1-->
  5. <u--form ref="customForm" :model="formData" labelPosition="top" labelWidth="150" labelAlign="left">
  6. <u-form-item label="检测项目" prop="detinspect" :required="true">
  7. <u-input v-model="formData.detinspect" disabled placeholder="请输入检测项目" />
  8. </u-form-item>
  9. <u-form-item label="预计检测时间" prop="detdate">
  10. <uni-datetime-picker v-model="formData.detdate" type="datetime" closeOnClickOverlay
  11. disabled></uni-datetime-picker>
  12. </u-form-item>
  13. <u-form-item label="检测维保结果" prop="detresult">
  14. <u-input v-model="formData.detresult.name" disabled placeholder="请输入检测维保结果" />
  15. </u-form-item>
  16. <u-form-item label="所属单位" prop="orgName" :required="true">
  17. <u-input v-model="formData.orgName" disabled placeholder="" />
  18. </u-form-item>
  19. <u-form-item label="附件">
  20. <view class="buju">
  21. <text v-if="formData.att == '' || formData.att == null">无</text>
  22. <!-- #ifdef MP-WEIXIN -->
  23. <text v-else style="color:#00a3f4;cursor: pointer;"
  24. @click.native="down(formData.att)">点击预览文件</text>
  25. <!-- #endif -->
  26. <!-- #ifdef H5 -->
  27. <a v-else style="color:#00a3f4;cursor: pointer;" @click="down(formData.att)">点击预览文件</a>
  28. <!-- #endif -->
  29. </view>
  30. </u-form-item>
  31. </u--form>
  32. </view>
  33. <uni-row class="heigthButton">
  34. <u-button v-if="historyView" @click="gotoDetection()" class="hBtn" shape="circle" size="large"
  35. color="#4cb2b6" style="width: 60%;" text="返回"></u-button>
  36. <u-button v-else @click="gotoEditDetection(formData)" class="hBtn" shape="circle" size="large" color="#4cb2b6"
  37. style="width: 60%;" text="修改信息"></u-button>
  38. </uni-row>
  39. </view>
  40. </template>
  41. <script>
  42. import {
  43. createFpdDetection, //创建消防设备维护和检测台账
  44. updateFpdDetection, //更新消防设备维护和检测台账
  45. deleteFpdDetection, //删除消防设备维护和检测台账
  46. getFpdDetection, //获得消防设备维护和检测台账
  47. getFpdDetectionPage, //获得消防设备维护和检测台账分页
  48. exportFpdDetectionExcel, //导出消防设备维护和检测台账 Excel
  49. getOrgId
  50. } from '@/api/fpdDetection/index.js';
  51. import {
  52. DICT_TYPE,
  53. getDictDatas
  54. } from '@/utils/dict';
  55. import {
  56. downSee
  57. } from '@/utils/common'
  58. export default {
  59. data() {
  60. return {
  61. formData: {
  62. orgName: ''
  63. },
  64. screenHeight: this.$screenHeight,
  65. wheight: '',
  66. //当前id
  67. thisId: '',
  68. historyView: false
  69. };
  70. },
  71. watch: {
  72. loading: {
  73. handler(newLength, oldLength) {
  74. this.$modal.isLoadingModel(this.loading)
  75. },
  76. immediate: true
  77. }
  78. },
  79. mounted() {
  80. // uni.createSelectorQuery().in(this).select('.heigthButton').boundingClientRect(data => {
  81. // console.log('data',data);
  82. // this.wheight = data.height
  83. // }).exec()
  84. // const query = uni.createSelectorQuery().in(this)
  85. // console.log('query', query);
  86. // const thisNode = query.select(".heigthButton")
  87. // console.log('thisNode', thisNode);
  88. // thisNode.boundingClientRect(data => {
  89. // console.log('data', data);
  90. // this.wheight = data.height
  91. // }).exec()
  92. },
  93. onShow() {
  94. if (this.thisId) {
  95. getFpdDetection(this.thisId).then(res => {
  96. // console.log('thisform', res);
  97. //对检测结果进行初始化
  98. const reArr = getDictDatas(DICT_TYPE.BACKEND_DET_RESULT)
  99. // console.log('reArr',reArr);
  100. const thisItem = reArr.find(par => par.value === res.data.detresult)
  101. // console.log('thisItem',thisItem);
  102. if (thisItem) {
  103. res.data.detresult = {
  104. id: thisItem.value,
  105. name: thisItem.label
  106. }
  107. }
  108. this.formData = res.data
  109. // 获取单位id
  110. getOrgId({
  111. pageNo: this.pageNo,
  112. pageSize: this.pageSize,
  113. userId: this.$store.state.user.id
  114. }).then(response => {
  115. // console.log(response, 'response');
  116. // 取到用户对应的单位名称与id
  117. response.data.forEach(v => {
  118. if (this.formData.orgId === v.dwid) {
  119. this.$set(this.formData, 'orgName', v.orgName)
  120. }
  121. });
  122. });
  123. //dom生成之后再获取节点计算高度
  124. this.$nextTick(() => {
  125. uni.createSelectorQuery().in(this).select('.heigthButton').boundingClientRect(
  126. data => {
  127. // console.log('data', data);
  128. this.wheight = data.height
  129. }).exec()
  130. })
  131. })
  132. }
  133. },
  134. onLoad: function(option) {
  135. if (option.historyView == 'historyView') {
  136. this.historyView = true
  137. }
  138. this.thisId = option.id
  139. //获取当前表单数据
  140. getFpdDetection(option.id).then(res => {
  141. // console.log('thisform', res);
  142. //对检测结果进行初始化
  143. const reArr = getDictDatas(DICT_TYPE.BACKEND_DET_RESULT)
  144. // console.log('reArr',reArr);
  145. const thisItem = reArr.find(par => par.value === res.data.detresult)
  146. // console.log('thisItem',thisItem);
  147. if (thisItem) {
  148. res.data.detresult = {
  149. id: thisItem.value,
  150. name: thisItem.label
  151. }
  152. }
  153. this.formData = res.data
  154. // 获取单位id
  155. getOrgId({
  156. pageNo: this.pageNo,
  157. pageSize: this.pageSize,
  158. userId: this.$store.state.user.id
  159. }).then(response => {
  160. // console.log(response, 'response');
  161. // 取到用户对应的单位名称与id
  162. response.data.forEach(v => {
  163. if (this.formData.orgId === v.dwid) {
  164. this.$set(this.formData, 'orgName', v.orgName)
  165. }
  166. });
  167. });
  168. // var File = this.formData.File = []
  169. // if (this.formData.att != '') {
  170. // File.push({
  171. // url: this.formData.att,
  172. // name: this.formData.att
  173. // });
  174. // } else {
  175. // File = null
  176. // }
  177. // uni.createSelectorQuery().in(this).select('.heigthButton').boundingClientRect(data => {
  178. // console.log('data',data);
  179. // this.wheight = data.height
  180. // }).exec()
  181. // console.log('edit页面的val的值', this.formData);
  182. })
  183. // 接收来自上个页面传递的参数
  184. // const navData = JSON.parse(option.navData)
  185. // that.formData = navData;
  186. // const eventChannel = this.getOpenerEventChannel();
  187. // eventChannel.on('acceptDataFromOpenerPage', function(val) {
  188. // that.formData = val;
  189. // console.log('val+++++++++++++++++++', that.formData);
  190. // });
  191. // this.formData.orgName = option.orgName
  192. },
  193. methods: {
  194. gotoDetection() {
  195. uni.navigateBack()
  196. },
  197. // 下载附件
  198. down(attId) {
  199. // console.log(attId, 'sdf');
  200. downSee(attId)
  201. },
  202. // 传递当前页面数据到 ‘修改信息’
  203. gotoEditDetection(val) {
  204. // console.log('val',val);
  205. // const navData = JSON.stringify(this.formData)
  206. uni.navigateTo({
  207. url: '/pagesA/fire/fpd_detection/edit_detection/edit_detection?id=' + val.id,
  208. });
  209. }
  210. }
  211. };
  212. </script>
  213. <style lang="scss" scoped>
  214. page {
  215. background-color: #F5F7F9;
  216. }
  217. .container {
  218. position: relative;
  219. // height: 220vh;
  220. background-color: rgb(245, 247, 249);
  221. overflow: auto;
  222. .buju {
  223. margin: 40rpx;
  224. }
  225. }
  226. .cont {}
  227. .weiwan {
  228. color: #d51a52;
  229. background: rgba(213, 26, 82, 0.2);
  230. padding: 5rpx 20rpx;
  231. border-radius: 2px;
  232. border: 1px solid #d51a52;
  233. }
  234. .yiwan {
  235. color: #4cb2b6;
  236. background: rgba(76, 178, 182, 0.2);
  237. padding: 5rpx 20rpx;
  238. border-radius: 2px;
  239. border: 1px solid #4cb2b6;
  240. }
  241. .miaoshu {
  242. margin-right: 20rpx;
  243. color: #274647;
  244. font-weight: 600;
  245. }
  246. </style>