manage.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <template>
  2. <view class="detail-wrap warning zhcx-table">
  3. <view class="handle-wrap" v-if=" flowData.taskIns.actionList.length>0">
  4. <button v-for="(item,index) in flowData.taskIns.actionList"
  5. class="custom-button primary"
  6. @click="submitForm(item.actionCode,item.actionId)">{{ item.actionTitle }}</button>
  7. </view>
  8. <view class="form-wrap">
  9. <uni-forms :modelValue="formData" ref="form" :rules="rules">
  10. <uni-forms-item label="说明" name="actionRemark">
  11. <textarea name="actionRemark" class="textarea"
  12. v-model="formData.actionRemark"
  13. placeholder-style="color:grey"
  14. placeholder="请输入说明/备注" />
  15. </uni-forms-item>
  16. <uni-forms-item label="隐患照片">
  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="attachList" v-if="formData.attachList.length>0">
  23. <image class="dangerimage" :src="formData.attachList[0].thumbnailsFileUrl" mode="widthFix"></image>
  24. </view>
  25. </uni-forms-item>
  26. </uni-forms>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import { upload } from '@/api/index';
  32. import { alertLevel ,alertStatus} from '@/libs/enum';
  33. import { getAlertById,handleAlert} from '@/api/warning';
  34. export default {
  35. data() {
  36. return {
  37. formData:{
  38. alertId: undefined,
  39. alertReason: '',
  40. handleMeasure: '',
  41. wfDefId: undefined,
  42. wfInsId: undefined,
  43. taskDefId: undefined,
  44. taskInsId: undefined,
  45. taskCode: '',
  46. actionId: undefined,
  47. actionCode: '',
  48. actionRemark: '',
  49. attachList: []
  50. },
  51. flowData: {
  52. wfDefId: 1,
  53. wfInsId: undefined,
  54. wfInsTitle: '',
  55. status: undefined,
  56. taskIns: {
  57. actionList: [],
  58. taskInsId: undefined,
  59. taskInsTitle: '',
  60. taskDefId: undefined,
  61. taskCode: ''
  62. },
  63. taskInsRecordList: []
  64. },
  65. rules: {
  66. actionRemark: {
  67. rules: [{
  68. required: true,
  69. errorMessage: '请填写意见,说明',
  70. }]
  71. },
  72. validateTrigger: 'submit'
  73. }
  74. }
  75. },
  76. filters:{
  77. alertLevelFilter(value){
  78. return alertLevel(value);
  79. },
  80. alertStatusFilter(value){
  81. return alertStatus(value);
  82. }
  83. },
  84. methods: {
  85. init(){
  86. let warnInfo=uni.getStorageSync('warnInfo');
  87. this.getDtail(warnInfo.alertId)
  88. },
  89. getDtail(id){
  90. getAlertById(id).then((resp)=>{
  91. const { code, data, msg } = resp
  92. // Flow Data
  93. const flowData = data.flow
  94. this.flowData = flowData
  95. // Form Data
  96. this.formData.alertId = data.data.alertId
  97. this.formData.alertTitle = data.data.alertTitle
  98. this.formData.wfDefId = flowData.wfDefId
  99. this.formData.wfInsId = flowData.wfInsId
  100. this.formData.taskDefId = flowData.taskIns.taskDefId
  101. this.formData.taskInsId = flowData.taskIns.taskInsId
  102. this.formData.taskCode = flowData.taskIns.taskCode
  103. })
  104. },
  105. /**
  106. * 提交
  107. */
  108. submitForm(actionId, actionCode) {
  109. this.formData.actionId = actionId;
  110. this.formData.actionCode = actionCode;
  111. this.$refs.form.validate().then(res => {
  112. handleAlert(this.formData).then((resp) => {
  113. const { code, msg } = resp
  114. if (code === 0) {
  115. uni.showToast({
  116. icon:"none",
  117. title:'提交成功',
  118. complete() {
  119. uni.navigateTo({
  120. url:"/views/warning/index"
  121. })
  122. }
  123. })
  124. } else {
  125. uni.showToast({
  126. icon:"none",
  127. title:"提交失败"
  128. })
  129. }
  130. }).catch((error) => {
  131. uni.showToast({
  132. icon:"none",
  133. title:"提交失败"
  134. })
  135. })
  136. }).catch(err => {
  137. uni.showToast({
  138. icon: 'none',
  139. title: "提交失败,请检查"
  140. })
  141. })
  142. },
  143. //上传入口
  144. uploadBt() {
  145. uni.chooseImage({
  146. success: (chooseImageRes) => {
  147. const tempFilePaths = chooseImageRes.tempFilePaths;
  148. this.uploadSubmit(tempFilePaths[0])
  149. }
  150. });
  151. },
  152. uploadSubmit(filePath) {
  153. upload({ filePath }).then((res) => {
  154. let result=JSON.parse(res);
  155. if(result.code===0){
  156. let attachList=[];
  157. let path=result.data.path;
  158. let thumbnailsFileUrl=path.split('$')[0];
  159. let fileUrl=path.split('$')[1];
  160. let uploadImgInfo={
  161. thumbnailsFileUrl,
  162. fileUrl,
  163. fileSize:result.data.size,
  164. fileExt:result.data.ext,
  165. fileTitle:result.data.oriFileName,
  166. opCode:0
  167. };
  168. attachList.push(uploadImgInfo);
  169. this.$set(this.formData,'attachList',attachList)
  170. }else{
  171. uni.showToast({
  172. title: result.msg||"上传失败"
  173. })
  174. }
  175. }).catch((msg) => {
  176. uni.showToast({
  177. title: "上传失败"
  178. })
  179. })
  180. }
  181. },
  182. onShow(){
  183. this.init();
  184. }
  185. }
  186. </script>
  187. <style lang="scss" scoped>
  188. .detail-wrap{
  189. &.warning{
  190. padding: 20upx 0 120upx 0;
  191. background-color: #fff;
  192. }
  193. .detail-list{
  194. .head{
  195. width: 300upx;
  196. height: 58upx;
  197. line-height: 58upx;
  198. color: #FFFFFF;
  199. background: #00A0FF;
  200. border-radius:0 16upx 16upx 0;
  201. padding: 0 20upx;
  202. }
  203. .table-cont {
  204. padding: 0 26upx;
  205. .row {
  206. height: 78upx;
  207. line-height: 78upx;
  208. border-bottom: 2upx solid #EDE1D9;
  209. padding-left: 10upx;
  210. &.desc{
  211. height: auto;
  212. line-height: 1.5;
  213. min-height: 78upx;
  214. border-bottom: none;
  215. padding-top: 16upx;
  216. display: flex;
  217. justify-content: flex-start;
  218. .desc-txt{
  219. width: 600upx;
  220. word-break: break-word;
  221. }
  222. }
  223. }
  224. }
  225. }
  226. .handle-wrap{
  227. width:710upx;
  228. display: flex;
  229. justify-content: space-around;
  230. padding: 20upx;
  231. position: fixed;
  232. bottom: 0;
  233. left: 0;
  234. z-index: 99;
  235. background-color: rgba(255,255,255,0.6);
  236. .custom-button{
  237. width: 200upx;
  238. line-height: 2;
  239. margin: 0;
  240. margin-right: 20upx;
  241. padding: 15upx 0;
  242. &.warn{
  243. background: #ff4949 ;
  244. color: #fff;
  245. }
  246. &.success{
  247. background:#1aad19;
  248. color: #fff;
  249. }
  250. &.primary{
  251. background: #1890ff;
  252. color: #fff;
  253. }
  254. }
  255. }
  256. .form-wrap{
  257. margin-top: 30upx;
  258. padding: 0rpx 10px;
  259. .dangerimage{
  260. display: block;
  261. width: 200upx;
  262. height: 200upx;
  263. }
  264. .textarea{
  265. width: 530upx;
  266. border: 1upx solid #d7d6d6;
  267. padding: 10upx;
  268. font-size: 30upx;
  269. }
  270. .head {
  271. padding-left: 59upx;
  272. font-size: 30upx;
  273. color: #333;
  274. }
  275. .tip {
  276. padding: 8upx 0 16upx 59upx;
  277. font-size: 24upx;
  278. color: #3584FF;
  279. }
  280. .picker{
  281. .uni-input{
  282. border: 1upx solid #ccc;
  283. }
  284. }
  285. }
  286. }
  287. </style>