detection_details.vue 6.3 KB

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