index.vue 10 KB

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