detection_details.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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. uni.createSelectorQuery().in(this).select('.heigthButton').boundingClientRect(data => {
  121. console.log('data',data);
  122. this.wheight = data.height
  123. }).exec()
  124. console.log('edit页面的val的值', this.formData);
  125. })
  126. }
  127. },
  128. onLoad: function(option) {
  129. this.thisId = option.id
  130. //获取当前表单数据
  131. getFpdDetection(option.id).then(res => {
  132. console.log('thisform', res);
  133. //对检测结果进行初始化
  134. const reArr = getDictDatas(DICT_TYPE.BACKEND_DET_RESULT)
  135. // console.log('reArr',reArr);
  136. const thisItem = reArr.find(par => par.value === res.data.detresult)
  137. // console.log('thisItem',thisItem);
  138. if (thisItem) {
  139. res.data.detresult = {
  140. id: thisItem.value,
  141. name: thisItem.label
  142. }
  143. }
  144. this.formData = res.data
  145. // 获取单位id
  146. getOrgId({
  147. pageNo: this.pageNo,
  148. pageSize: this.pageSize,
  149. userId: this.$store.state.user.id
  150. }).then(response => {
  151. console.log(response, 'response');
  152. // 取到用户对应的单位名称与id
  153. response.data.forEach(v => {
  154. if (this.formData.orgId === v.dwid) {
  155. this.$set(this.formData, 'orgName', v.orgName)
  156. }
  157. });
  158. });
  159. // var File = this.formData.File = []
  160. // if (this.formData.att != '') {
  161. // File.push({
  162. // url: this.formData.att,
  163. // name: this.formData.att
  164. // });
  165. // } else {
  166. // File = null
  167. // }
  168. // uni.createSelectorQuery().in(this).select('.heigthButton').boundingClientRect(data => {
  169. // console.log('data',data);
  170. // this.wheight = data.height
  171. // }).exec()
  172. console.log('edit页面的val的值', this.formData);
  173. })
  174. // 接收来自上个页面传递的参数
  175. // const navData = JSON.parse(option.navData)
  176. // that.formData = navData;
  177. // const eventChannel = this.getOpenerEventChannel();
  178. // eventChannel.on('acceptDataFromOpenerPage', function(val) {
  179. // that.formData = val;
  180. // console.log('val+++++++++++++++++++', that.formData);
  181. // });
  182. // this.formData.orgName = option.orgName
  183. },
  184. methods: {
  185. // 下载附件
  186. down(attId) {
  187. console.log(attId, 'sdf');
  188. downSee(attId)
  189. },
  190. // 传递当前页面数据到 ‘修改信息’
  191. gotoEditDetection(val) {
  192. // console.log('val',val);
  193. // const navData = JSON.stringify(this.formData)
  194. uni.navigateTo({
  195. url: '/pagesA/fire/fpd_detection/edit_detection/edit_detection?id=' + val.id,
  196. });
  197. }
  198. }
  199. };
  200. </script>
  201. <style lang="scss" scoped>
  202. page {
  203. background-color: #F5F7F9;
  204. }
  205. .container {
  206. position: relative;
  207. // height: 220vh;
  208. background-color: rgb(245, 247, 249);
  209. overflow: auto;
  210. .buju {
  211. margin: 40rpx;
  212. }
  213. }
  214. .cont {}
  215. .weiwan {
  216. color: #d51a52;
  217. background: rgba(213, 26, 82, 0.2);
  218. padding: 5rpx 20rpx;
  219. border-radius: 2px;
  220. border: 1px solid #d51a52;
  221. }
  222. .yiwan {
  223. color: #4cb2b6;
  224. background: rgba(76, 178, 182, 0.2);
  225. padding: 5rpx 20rpx;
  226. border-radius: 2px;
  227. border: 1px solid #4cb2b6;
  228. }
  229. .miaoshu {
  230. margin-right: 20rpx;
  231. color: #274647;
  232. font-weight: 600;
  233. }
  234. </style>