checkInfo.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <view class="zhcx-table entRiskPointCheck-wrap">
  3. <view class="task-desc">
  4. <view>
  5. <view class="uni-title uni-common-pl">措施分类:{{formData.measureTypeTitle}}</view>
  6. <view class="uni-title uni-common-pl">管控措施:{{formData.measureContent}}</view>
  7. <view class="uni-title uni-common-pl">法律依据:{{formData.measureReference}}</view>
  8. <view class="uni-title uni-common-pl">措施描述:{{formData.measureDesc}}</view>
  9. </view>
  10. <view>
  11. <view class="uni-title uni-common-pl">描述:</view>
  12. <view class="uni-textarea uni-common-pl">
  13. <textarea @blur="bindTextAreaBlur" auto-height />
  14. </view>
  15. </view>
  16. <view class="uni-title uni-common-pl">附件:
  17. <p class="tip">支持各类图片,文件不大于10M</p>
  18. <view class="zhcx-upload" @click="uploadBt">
  19. <div class="icon"></div>
  20. <text class="uploadTitle">点击上传</text>
  21. </view>
  22. <view class="preview-wrap" v-if="previewImage">
  23. <image class="preview" :src="previewImage" mode="widthFix"></image>
  24. </view>
  25. </view>
  26. <view class="handle-wrap">
  27. <button type="primary" @click="addPass(1)" size="mini">通过</button>
  28. <button type="default" @click="addPass(2)" size="mini">不通过</button>
  29. <button type="warn" @click="addDanger" size="mini" :disabled="dangerStatus">有隐患</button>
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. import { upload } from '@/api/index';
  36. import { updateCheckTaskDoingRecord} from '@/api/checkRecord.js'
  37. import {manageTaskById} from '@/api/task'
  38. import {deepClone} from '@/libs'
  39. export default {
  40. data() {
  41. return {
  42. taskId:undefined,
  43. riskPointId:undefined,
  44. previewImage:undefined,
  45. uploadImage:undefined,
  46. fromType:undefined,
  47. dataList: [],
  48. dangerStatus:false,
  49. formData: {
  50. riskPointId: '',
  51. measureTypeTitle: '',
  52. measureContent: '',
  53. measureReference: '',
  54. measureDesc: '',
  55. checklistId: '',
  56. hazardTitle: '',
  57. hazardId: '',
  58. hazardCode: '',
  59. measureId: '',
  60. measureTypeId: '',
  61. riskCode: '',
  62. riskSource: '',
  63. riskId: '',
  64. attachList: []
  65. }
  66. }
  67. },
  68. onLoad(options) {
  69. console.log({
  70. "检查结果":options
  71. })
  72. if(options.taskId)
  73. {
  74. this.taskId = options.taskId
  75. this.riskPointId = options.riskPointId
  76. this.fromType=options.type
  77. }
  78. let measure = uni.getStorageSync("entRiskPointMeasure");
  79. measure.taskId=options.taskId;
  80. measure.riskPointId=options.riskPointId
  81. //隐患状态
  82. this.dangerStatus=measure.checkResult==3;
  83. if(measure){this.formData = measure}
  84. },
  85. methods: {
  86. bindTextAreaBlur: function(e) {
  87. this.formData.checkDesc = e.detail.value
  88. },
  89. //上传隐患
  90. addDanger() {
  91. //跳转到隐患上传页面,传值 风险点ID 管控措施ID 措施内容
  92. uni.navigateTo({
  93. url:'/views/danger/taskDanger?riskPointId=' + this.riskPointId + '&taskId=' + this.taskId
  94. });
  95. },
  96. addPass(v) {
  97. //提交,传值 风险点ID 管控措施ID 措施内容
  98. this.formData.checkResult = v
  99. this.create(this.formData);
  100. },
  101. //提交保存
  102. create(data) {
  103. const taskId=this.taskId;
  104. const riskPointId=this.riskPointId;
  105. console.log({
  106. "检查结果":taskId
  107. })
  108. updateCheckTaskDoingRecord(data).then((res) => {
  109. const { code, data, count } = res
  110. if (code === 0) {
  111. //跳转到上一页
  112. if(this.fromType==='taskdetail')
  113. {
  114. uni.reLaunch({
  115. url: `/views/task/detail/detail?id=${taskId}&riskPointId=${riskPointId}`
  116. });
  117. return;
  118. }
  119. uni.reLaunch({
  120. url: `/views/entRiskPointCheck/table?taskId=${taskId}&riskPointId=${riskPointId}`
  121. });
  122. }
  123. })
  124. },
  125. //上传入口
  126. uploadBt() {
  127. uni.chooseImage({
  128. success: (chooseImageRes) => {
  129. const tempFilePaths = chooseImageRes.tempFilePaths;
  130. this.uploadSubmit(tempFilePaths[0])
  131. this.previewImage =tempFilePaths[0];
  132. },
  133. complete(res) {
  134. console.log(res)
  135. }
  136. });
  137. },
  138. uploadSubmit(filePath) {
  139. upload({
  140. filePath
  141. }).then((res) => {
  142. let result=JSON.parse(res);
  143. if(result.code===0){
  144. let attachList=[];
  145. let path=result.data.path;
  146. let thumbnailsFileUrl=path.split('$')[0];
  147. let fileUrl=path.split('$')[1];
  148. let uploadImgInfo={
  149. thumbnailsFileUrl,
  150. fileUrl,
  151. fileSize:result.data.size,
  152. fileExt:result.data.ext,
  153. fileTitle:result.data.oriFileName,
  154. opCode:0
  155. };
  156. attachList.push(uploadImgInfo);
  157. this.$set(this.formData,'attachList',attachList)
  158. }else{
  159. uni.showToast({
  160. title: result.msg||"上传失败"
  161. })
  162. }
  163. }).catch((msg) => {
  164. uni.showToast({
  165. title: "上传失败"
  166. })
  167. })
  168. }
  169. }
  170. }
  171. </script>
  172. <style lang="scss" scoped>
  173. .entRiskPointCheck-wrap{
  174. background-color: #fff;
  175. min-height: 100vh;
  176. .handle-wrap{
  177. display: flex;
  178. justify-content: space-between;
  179. align-items: center;
  180. padding: 20upx 0;
  181. }
  182. .tip {
  183. padding: 8upx 0 16upx 59upx;
  184. font-size: 24upx;
  185. color: #3584FF;
  186. }
  187. .preview-wrap{
  188. display: flex;
  189. justify-content: flex-start;
  190. flex-wrap: wrap;
  191. border: 1px dashed #CCE6FF;
  192. margin-top: 15upx;
  193. .preview{
  194. display: block;
  195. width: 150upx;
  196. height: 150upx;
  197. margin: 10upx;
  198. }
  199. }
  200. }
  201. </style>