detection_details.vue 7.1 KB

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