riskPointDanger.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. <template>
  2. <view class="riskPointDanger-form zhcx-table">
  3. <uni-forms :modelValue="formData" ref="form" :rules="rules">
  4. <uni-forms-item label="标题" name="dangerTitle" required>
  5. <uni-easyinput type="text" v-model="formData.dangerTitle" placeholder="请填写隐患标题" />
  6. </uni-forms-item>
  7. <uni-forms-item label="等级">
  8. <radio-group v-model="formData.dangerLevel" style="transform:scale(0.85)" @change="radioChange">
  9. <label>
  10. <radio value="2" /><text>重大隐患</text>
  11. </label>
  12. <label>
  13. <radio value="1" checked="true" /><text>一般隐患</text>
  14. </label>
  15. </radio-group>
  16. </uni-forms-item>
  17. <uni-forms-item label="隐患来源">
  18. <picker @change="bindPickerChange" :value="index" :range="array">
  19. <view class="uni-input">{{array[index]}}</view>
  20. </picker>
  21. </uni-forms-item>
  22. <uni-forms-item label="隐患类别">
  23. <picker :range="dangerCatList" range-key="dangerCatTitle" @change="bindPickerChangeCat" :value="indexs">
  24. <view class="uni-input">{{dangerCatList[indexs].dangerCatTitle}}</view>
  25. </picker>
  26. </uni-forms-item>
  27. <uni-forms-item label="所属部门">
  28. <uni-data-picker :localdata="groupItem" popup-title="请选择隐患所属部门" @change="onchange"
  29. @nodeclick="onnodeclick"></uni-data-picker>
  30. </uni-forms-item>
  31. <uni-forms-item label="截止时间">
  32. <uni-datetime-picker class="uni-datetime" @change="onChangeDateTime"></uni-datetime-picker>
  33. </uni-forms-item>
  34. <p class="tip">支持各类图片,文件不大于10M</p>
  35. <uni-forms-item label="隐患照片">
  36. <view class="zhcx-upload" @click="uploadBt">
  37. <div class="icon"></div>
  38. <text class="uploadTitle">点击上传</text>
  39. </view>
  40. <view class="attachList" v-if="formData.attachList.length>0">
  41. <image class="dangerimage" :src="formData.attachList[0].thumbnailsFileUrl" mode="widthFix"></image>
  42. </view>
  43. </uni-forms-item>
  44. <uni-forms-item label="描述" name="dangerDesc">
  45. <textarea name="dangerDesc" v-model="formData.dangerDesc"
  46. class="textarea"
  47. placeholder-style="color:grey"
  48. placeholder="请输入隐患描述" />
  49. </uni-forms-item>
  50. <uni-forms-item label="下一关" >
  51. <view style="margin-top: 9px;">
  52. <text>评审任务</text>
  53. </view>
  54. </uni-forms-item>
  55. <uni-forms-item label="执行人">
  56. <!-- <uni-forms-item label="所属部门">
  57. <uni-data-picker :localdata="userList" popup-title="请选择执行人" @change="onchange"
  58. @nodeclick="onnodeclick"></uni-data-picker>
  59. </uni-forms-item> -->
  60. <picker :range="userList" range-key="accountRealName" class="picker"
  61. @change="bindPickerChangeUser" :value="indexUser">
  62. <view class="uni-input">{{userList[indexUser].accountRealName}}</view>
  63. </picker>
  64. </uni-forms-item>
  65. <uni-forms-item label="说明" name="actionRemark">
  66. <textarea name="actionRemark" class="textarea"
  67. v-model="formData.actionRemark"
  68. placeholder-style="color:grey"
  69. placeholder="请输入隐患说明/备注" />
  70. </uni-forms-item>
  71. </uni-forms>
  72. <view class="uni-btn-v">
  73. <!--<button type="primary" @click="submit">提交</button>-->
  74. <button v-for="(item,index) in flowData.taskIns.actionList" :key="index" type="primary"
  75. @click="submit('form', item.actionId, item.actionCode)">{{ item.actionTitle }} </button>
  76. <button type="default" @click="Cancel()">取消</button>
  77. </view>
  78. </view>
  79. </template>
  80. <script>
  81. import { upload } from '@/api/index';
  82. import graceChecker from "@/libs/graceChecker.js"
  83. import { getGroupTree, getDangerCatList, getUserList, add, createDangerIns } from "@/api/danger.js"
  84. import { toTreeText } from "@/libs/tool.js"
  85. import { isEmpty } from "@/libs"
  86. export default {
  87. data() {
  88. const currentDate = this.getDate({
  89. format: true
  90. })
  91. return {
  92. riskPointId: '',
  93. date: currentDate,
  94. groupItem: [],
  95. FilePaths: [],
  96. userList: [{}, { accountRealName: '' }],
  97. dangerCatList: [{ dangerCatTitle: '' }],
  98. index: 0,
  99. indexs: 0,
  100. indexUser: 1,
  101. array: ['自查', '内部反馈', '上级检查', '政府执法'],
  102. rules: {
  103. dangerTitle: {
  104. rules: [{
  105. required: true,
  106. errorMessage: '请输入隐患标题',
  107. }]
  108. },
  109. dangerDeadLine: {
  110. rules: [{
  111. required: true,
  112. errorMessage: '请选择截止时间',
  113. }]
  114. },
  115. accountId: {
  116. rules: [{
  117. required: true,
  118. errorMessage: '请选择执行人',
  119. }]
  120. },
  121. validateTrigger: 'submit'
  122. },
  123. formData: {
  124. dangerId: undefined,
  125. groupId: undefined, // 所属部门
  126. riskPointId: undefined, // 风险点:所属区域
  127. dangerCode: '', // 隐患编码
  128. dangerTitle: '', // 隐患标题
  129. dangerCatId: undefined, // 隐患类别ID
  130. dangerLevel: 1, // 隐患等级
  131. dangerDesc: '', // 描述
  132. dangerDeadLine: '', // 截止时间
  133. dangerSource: 0, // 隐患来源
  134. wfDefId: undefined,
  135. wfInsId: undefined,
  136. taskDefId: undefined,
  137. taskInsId: undefined,
  138. taskCode: '',
  139. actionId: undefined,
  140. actionCode: '',
  141. groupIdTo: undefined,
  142. positionIdTo: undefined,
  143. accountIdTo: undefined, // 执行人
  144. actionRemark: '', // 说明
  145. attachList: []
  146. },
  147. flowData: {
  148. taskIns: {
  149. actionList: []
  150. }
  151. },
  152. }
  153. },
  154. computed: {
  155. startDate() {
  156. return this.getDate('start');
  157. },
  158. endDate() {
  159. return this.getDate('end');
  160. },
  161. },
  162. filters:{
  163. previewImage(val){
  164. let imgsrc=val.split("$");
  165. return imgsrc[0];
  166. }
  167. },
  168. onLoad(options) {
  169. //调用页面请求数据接口
  170. this.riskPointId = options.riskPointId;
  171. this.groupTree();
  172. this.getDangerCatList();
  173. this.getUserList();
  174. this.createDangerIns();
  175. },
  176. methods: {
  177. Cancel() {
  178. //取消
  179. uni.navigateBack();
  180. },
  181. handleSelectUser(item) {
  182. this.formData.accountIdTo = item.accountId
  183. this.formData.groupIdTo = item.groupId
  184. this.formData.positionIdTo = item.positionId
  185. console.log("item", item);
  186. },
  187. radioChange: function(evt) {
  188. this.formData.dangerLevel = evt.detail.value
  189. },
  190. bindPickerChange: function(e1) {
  191. this.index = e1.target.value
  192. console.log("隐患来源", this.index)
  193. this.formData.dangerSource = this.index
  194. },
  195. bindPickerChangeCat: function(e2) {
  196. this.indexs = e2.target.value
  197. console.log("隐患类别", this.indexs)
  198. this.formData.dangerCatId = this.dangerCatList[this.indexs].dangerCatId
  199. },
  200. bindPickerChangeUser: function(e3) {
  201. this.indexUser = e3.target.value
  202. console.log("执行人", this.indexUser)
  203. this.formData.accountId = this.userList[this.indexUser].accountId
  204. this.formData.accountId = this.userList[this.indexUser].accountId
  205. this.formData.accountIdTo = this.userList[this.indexUser].accountId
  206. this.formData.groupIdTo = this.userList[this.indexUser].groupId
  207. this.formData.positionIdTo = this.userList[this.indexUser].positionId
  208. },
  209. //初始化流程 写死流程ID
  210. createDangerIns() {
  211. createDangerIns(1).then((resp) => {
  212. const { code, data, msg } = resp
  213. if (code === 0) {
  214. this.flowData = data
  215. this.formData.wfDefId = data.wfDefId
  216. this.formData.wfInsId = data.wfInsId
  217. this.formData.taskDefId = data.taskIns.taskDefId
  218. this.formData.taskInsId = data.taskIns.taskInsId
  219. this.formData.taskCode = data.taskIns.taskCode
  220. } else {
  221. this.$message.error(msg)
  222. }
  223. }).catch((error) => {
  224. console.log(error)
  225. })
  226. },
  227. /**z
  228. * 提交
  229. */
  230. submit(formName, actionId, actionCode) {
  231. this.$refs.form.validate().then(res => {
  232. this.formData.actionId = actionId;
  233. this.formData.actionCode = actionCode;
  234. this.formData.riskPointId = this.riskPointId;
  235. this.formData.groupId = this.formData.groupIdS[this.formData.groupIdS.length - 1].value
  236. add(this.formData).then((resp) => {
  237. const { code, data, msg } = resp
  238. if (code === 0) {
  239. console.log("提交成功")
  240. uni.showToast({
  241. icon:'success',
  242. title:"提交成功!",
  243. complete(res) {
  244. if(!isEmpty(this.riskPointId)){
  245. uni.navigateTo({
  246. url: '/views/entRiskPoint/details/details?id=' + this.riskPointId,
  247. });
  248. }else{
  249. uni.reLaunch({
  250. url:'/pages/index/index'
  251. })
  252. }
  253. }
  254. })
  255. } else {
  256. uni.showToast({
  257. icon: 'error',
  258. title: msg
  259. })
  260. }
  261. })
  262. }).catch(err => {
  263. uni.showToast({
  264. icon: 'none',
  265. // title: err[0].errorMessage
  266. title: err
  267. })
  268. })
  269. },
  270. formReset: function(e) {
  271. console.log('清空数据')
  272. },
  273. bindDateChange: function(e) {
  274. this.date = e.target.value
  275. },
  276. getDate(type) {
  277. const date = new Date();
  278. let year = date.getFullYear();
  279. let month = date.getMonth() + 1;
  280. let day = date.getDate();
  281. if (type === 'start') {
  282. year = year - 0;
  283. } else if (type === 'end') {
  284. year = year + 2;
  285. }
  286. month = month > 9 ? month : '0' + month;
  287. day = day > 9 ? day : '0' + day;
  288. return `${year}-${month}-${day}`;
  289. },
  290. onchange(e) {
  291. const value = e.detail.value
  292. this.formData.groupIdS = value
  293. },
  294. onChangeDateTime(e) {
  295. this.formData.dangerDeadLine = e
  296. console.log("dangerDeadLine", e)
  297. },
  298. onnodeclick(node) {},
  299. //初始化group
  300. groupTree() {
  301. getGroupTree().then((res) => {
  302. if (res.data) {
  303. let temp = toTreeText(res.data)
  304. this.groupItem = temp;
  305. } else {
  306. console.log("group无数据,请检查!")
  307. }
  308. });
  309. },
  310. //隐患类别列表
  311. getDangerCatList() {
  312. getDangerCatList().then((resp) => {
  313. const { code, data } = resp
  314. if (code === 0) {
  315. this.dangerCatList = data
  316. //默认值
  317. this.formData.dangerCatId = this.dangerCatList[0].dangerCatId
  318. }
  319. }).catch((error) => {
  320. console.log(error)
  321. })
  322. },
  323. //用户列表
  324. getUserList() {
  325. getUserList().then((resp) => {
  326. const { code, data } = resp
  327. if (code === 0) {
  328. this.userList = data
  329. this.formData.accountId = this.userList[1].accountId
  330. this.formData.accountIdTo = this.userList[1].accountId
  331. this.formData.groupIdTo = this.userList[1].groupId
  332. this.formData.positionIdTo = this.userList[1].positionId
  333. }
  334. }).catch((error) => {
  335. console.log(error)
  336. })
  337. },
  338. //上传入口
  339. uploadBt() {
  340. uni.chooseImage({
  341. success: (chooseImageRes) => {
  342. const tempFilePaths = chooseImageRes.tempFilePaths;
  343. this.uploadSubmit(tempFilePaths[0])
  344. }
  345. });
  346. },
  347. uploadSubmit(filePath) {
  348. upload({ filePath}).then((res) => {
  349. let result=JSON.parse(res);
  350. if(result.code===0){
  351. let attachList=[];
  352. let path=result.data.path;
  353. let thumbnailsFileUrl=path.split('$')[0];
  354. let fileUrl=path.split('$')[1];
  355. let uploadImgInfo={
  356. thumbnailsFileUrl,
  357. fileUrl,
  358. fileSize:result.data.size,
  359. fileExt:result.data.ext,
  360. fileTitle:result.data.oriFileName,
  361. opCode:0
  362. };
  363. attachList.push(uploadImgInfo);
  364. this.$set(this.formData,'attachList',attachList)
  365. }else{
  366. uni.showToast({
  367. title: result.msg||"上传失败"
  368. })
  369. }
  370. }).catch((msg) => {
  371. uni.showToast({
  372. title: "上传失败"
  373. })
  374. })
  375. }
  376. }
  377. }
  378. </script>
  379. <style lang="scss" scoped>
  380. .riskPointDanger-form{
  381. padding: 0rpx 10px;
  382. padding-top: 100upx;
  383. background-color: #fff;
  384. .dangerimage{
  385. display: block;
  386. width: 200upx;
  387. height: 200upx;
  388. }
  389. .textarea{
  390. width: 530upx;
  391. border: 1upx solid #d7d6d6;
  392. padding: 10upx;
  393. font-size: 30upx;
  394. }
  395. .head {
  396. padding-left: 59upx;
  397. font-size: 30upx;
  398. color: #333;
  399. }
  400. .tip {
  401. padding: 8upx 0 16upx 59upx;
  402. font-size: 24upx;
  403. color: #3584FF;
  404. }
  405. .picker{
  406. .uni-input{
  407. border: 1upx solid #ccc;
  408. }
  409. }
  410. }
  411. </style>