微信小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

479 lines
13 KiB

  1. // pages/bankDraft/add/add.js
  2. import * as UTIL from '../../../utils/util.js';
  3. import * as API from '../../../utils/API.js';
  4. let EVN_CONFIG = require('../../../env/env');
  5. const app = getApp();
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. isIPX: app.globalData.isIPX,
  12. form:{
  13. eventTime: UTIL.formatDate(new Date()), //开票日期 必填
  14. remark: "",
  15. },
  16. showBtn:true,
  17. showEventTime:false,
  18. status:0,
  19. comment:'',
  20. pageType:'',
  21. fileList:[],
  22. uploadOptions:[],
  23. majorTypeOptions:[]
  24. },
  25. /**
  26. * 生命周期函数--监听页面加载
  27. */
  28. onLoad(options) {
  29. let that = this
  30. that.setData({
  31. taskId:options.taskId,
  32. pageType:options.type
  33. })
  34. let templateQueryParams = {
  35. // 分页
  36. type:'5'
  37. };
  38. UTIL.httpRequest(API.URL_GET_TEMPLATELIST , templateQueryParams, {
  39. success: (res) => {
  40. that.setData({
  41. approvalTemplateList:res.rows,
  42. ["form.approvalTemplateId"]:res.rows[0].id,
  43. ["form.approvalTemplateName"]:res.rows[0].name,
  44. })
  45. }
  46. })
  47. //所属银行
  48. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'major_type', {method:'GET'}, {
  49. success: (res) => {
  50. this.setData({
  51. majorTypeOptions:res.data
  52. });
  53. }
  54. })
  55. if(options.id!=null&&options.id!=""){
  56. this.setData({id:options.id})
  57. UTIL.httpRequest(API.URL_GET_MAJOREVENTGET + this.data.id, {method:'GET'}, {
  58. success: (res) => {
  59. console.log(res);
  60. if(res.data.auditStatus!='0'&&res.data.auditStatus!='2'){
  61. this.setData({'showBtn':false});
  62. }
  63. res.data.majorTypeText = UTIL.getTransform(res.data.majorType,that.data.majorTypeOptions);
  64. let op = that.data.approvalTemplateList.filter(function (e) { return e.id == res.data.approvalTemplateId; });
  65. res.data.approvalTemplateName = op[0].name;
  66. this.setData({'form':res.data})
  67. that.setData({auditbatchNo:res.data.auditbatchNo})
  68. let parData = {
  69. // processInstanceId:res.data.auditbatchNo,
  70. method:'GET'
  71. }
  72. // 查询审批事项流转进度 API.URL_GET_GETPROCESSHISTORY
  73. UTIL.httpRequest( '/approval/audit/historyList/'+res.data.auditbatchNo, parData, {
  74. success: (res) => {
  75. console.log(res);
  76. that.setData({spsxOptions:res.rows})
  77. }
  78. })
  79. this.selectComponent('#hf_editor').setHtml(res.data.eventContent);
  80. this.selectComponent('#hf_editor2').setHtml(res.data.dzbty);
  81. this.selectComponent('#hf_editor3').setHtml(res.data.lwhsy);
  82. this.selectComponent('#hf_editor4').setHtml(res.data.dqyshsyhjy);
  83. this.selectComponent('#hf_editor5').setHtml(res.data.cydbhjy);
  84. this.selectComponent('#hf_editor6').setHtml(res.data.jcjggk);
  85. this.selectComponent('#hf_editor7').setHtml(res.data.ssqkgk);
  86. }
  87. })
  88. //获取附件字典
  89. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'major_attach', {method:'GET'}, {
  90. success: (res) => {
  91. this.setData({
  92. uploadOptions:res.data,
  93. })
  94. this.asyncFun(options.id)
  95. }
  96. })
  97. }else{
  98. this.onShow()
  99. }
  100. },
  101. commentInput(e){
  102. console.log(e);
  103. var that = this;
  104. that.setData({
  105. comment:e.detail.value
  106. })
  107. },
  108. onConfirmEventTime(e){
  109. let data = this.getNewDate(new Date(e.detail.value));
  110. this.setData({'form.eventTime':data});
  111. },
  112. getHtml(e) {//从组件获取值
  113. this.data.form.eventContent = e.detail.content.html
  114. },
  115. insertImage(){ //图片上传插入示例
  116. wx.chooseImage({
  117. count: 1,
  118. success: r => {
  119. // 本地测试图片插入
  120. // this.selectComponent('#hf_editor').insertSrc(res.tempFilePaths[0]);
  121. wx.uploadFile({ //调用图片上传接口
  122. url: wx.getStorageSync('dressCode')+'/common/upload',
  123. filePath: r.tempFilePaths[0],
  124. name: 'imgFile',
  125. success: res => {
  126. console.log();
  127. let imgUrl = JSON.parse(res.data).url
  128. this.selectComponent('#hf_editor').insertSrc(wx.getStorageSync('dressCode')+'/common/upload' + imgUrl);//调用组件insertSrc方法
  129. }
  130. })
  131. }
  132. })
  133. },
  134. getNewDate(date){
  135. //date是传过来的时间戳,注意需为13位,10位需*1000
  136. //也可以不传,获取的就是当前时间
  137. var time
  138. if(date){
  139. time = new Date(date);
  140. }else{
  141. time = new Date();
  142. }
  143. var year= time.getFullYear() //年
  144. var month = ("0" + (time.getMonth() + 1)).slice(-2); //月
  145. var day = ("0" + time.getDate()).slice(-2); //日
  146. var mydate = year + "-" + month + "-" + day;
  147. return mydate
  148. },
  149. asyncFun(id){
  150. let uploadList = this.data.uploadOptions
  151. console.log(uploadList);
  152. let newList = []
  153. let _this = this
  154. uploadList.map( res => {
  155. let oData = {
  156. tableId: id,
  157. tableName: "t_yinnong_majorevent", //上传表
  158. bizPath: "yinnong",
  159. // fileType: res.dictValue, //附件类型 1原始发票 2会议纪要 3会议照片 4 参会人员签字
  160. method:'GET'
  161. }
  162. console.log('aaa');
  163. UTIL.httpRequest(API.URL_GET_ATTACHMENTLIST, oData, {
  164. success: (rr) => {
  165. if(rr.code==200&&rr.rows.length>0){
  166. rr.rows.map((rrr,index) => {
  167. rrr.url = wx.getStorageSync('dressCode') + rrr.fileUrl
  168. if(index==rr.rows.length-1){
  169. newList.push(Object.assign({},res,{"list":rr.rows}))
  170. _this.setData({"fileList":_this.data.fileList.concat(newList)});
  171. _this.setData({"showUpload":true})
  172. }
  173. })
  174. }else{
  175. let newuploadList = uploadList
  176. newuploadList.map(rd => {
  177. rd.list = newList
  178. })
  179. _this.setData({"fileList":newuploadList});
  180. _this.setData({"showUpload":true})
  181. }
  182. },
  183. fail:(rr) =>{
  184. },
  185. complete:(rr) => {
  186. }
  187. })
  188. })
  189. },
  190. /**
  191. * 生命周期函数--监听页面初次渲染完成
  192. */
  193. onReady() {
  194. },
  195. /**
  196. * 生命周期函数--监听页面显示
  197. */
  198. onShow() {
  199. },
  200. openBox(even){
  201. console.log(even.currentTarget.dataset.name);
  202. this.setData({
  203. [even.currentTarget.dataset.name]:true
  204. })
  205. },
  206. onChange(event){
  207. console.log(event);
  208. this.setData({
  209. [event.currentTarget.dataset.value]: event.detail,
  210. })
  211. },
  212. closeBox(even){
  213. console.log(even.currentTarget.dataset.name);
  214. this.setData({
  215. [even.currentTarget.dataset.name]:false
  216. })
  217. },
  218. goSubmit(){
  219. if(this.data.form.eventName===''||this.data.form.eventName==null){ //事项名称
  220. UTIL.showToastNoneIcon('请填写事项名称!');
  221. return false;
  222. }else if(this.data.form.eventTime===''||this.data.form.eventTime==null){ //事项时间
  223. UTIL.showToastNoneIcon('事项时间不能为空!');
  224. return false;
  225. }else if(this.data.form.eventContent===''||this.data.form.eventContent==null){ //事项内容
  226. UTIL.showToastNoneIcon('事项内容不能为空!');
  227. return false;
  228. }else if(this.data.status=='0'){
  229. this.setData({'status':'1'})
  230. var that = this;
  231. that.data.form.method = 'POST';
  232. that.data.form.eventContent = that.data.form.eventContent.replace(/\\/g,"/")
  233. console.log(that.data.form);
  234. if(that.data.form.id==""||that.data.form.id==null){
  235. UTIL.httpRequest(API.URL_POST_MAJOREVENTADD, that.data.form , {
  236. success: (res) => {
  237. this.setData({'status':0})
  238. if(res.code == 200){
  239. UTIL.showToastNoneIcon('新增成功');
  240. setTimeout(function(){
  241. wx.navigateBack({
  242. delta:1
  243. })
  244. },2000)
  245. }else{
  246. UTIL.showToastNoneIcon('新增失败:'+res.msg);
  247. }
  248. }
  249. })
  250. }else{
  251. UTIL.httpRequest(API.URL_POST_MAJOREVENTUPDATE, that.data.form , {
  252. success: (res) => {
  253. this.setData({'status':0})
  254. if(res.code == 200){
  255. UTIL.showToastNoneIcon('修改成功');
  256. setTimeout(function(){
  257. wx.navigateBack({
  258. delta:1
  259. })
  260. },2000)
  261. }else{
  262. UTIL.showToastNoneIcon('修改失败:'+res.msg);
  263. }
  264. }
  265. })
  266. }
  267. }
  268. },
  269. onConfirmTime(event){
  270. this.setData({
  271. [event.currentTarget.dataset.name]: false,
  272. [event.currentTarget.dataset.value]: UTIL.formatDate(event.detail),
  273. });
  274. },
  275. openBox(even){
  276. console.log(even.currentTarget.dataset.name);
  277. this.setData({
  278. [even.currentTarget.dataset.name]:true
  279. })
  280. },
  281. closeBox(even){
  282. console.log(even.currentTarget.dataset.name);
  283. this.setData({
  284. [even.currentTarget.dataset.name]:false
  285. })
  286. },
  287. back:function(){
  288. wx.navigateBack({
  289. delta: 1
  290. })
  291. },
  292. goDis(){
  293. var that = this ;
  294. console.log()
  295. let data = {
  296. taskId:that.data.taskId,
  297. instanceId:that.data.instanceId,
  298. variables:JSON.stringify({
  299. comment:that.data.comment == '' ? '驳回':that.data.comment,
  300. pass:false,
  301. }),
  302. method:'POST'
  303. };
  304. UTIL.httpRequest(API.URL_GET_PROCESSCOMPLETE , data, {
  305. success: (res) => {
  306. console.log(res);
  307. if (res.code == API.SUCCESS_CODE) {
  308. wx.showToast({
  309. title: '审批成功',
  310. icon: 'success',
  311. duration: 2000,
  312. complete(){
  313. setTimeout(function(){
  314. that.back();
  315. },2000)
  316. }
  317. })
  318. }else{
  319. wx.showToast({
  320. title: '操作失败',
  321. icon: 'error',
  322. duration: 2000
  323. })
  324. }
  325. }
  326. })
  327. },
  328. goAgree(){
  329. var that = this ;
  330. let data = {
  331. taskId:that.data.taskId,
  332. instanceId:that.data.instanceId,
  333. variables:JSON.stringify({
  334. "comment":that.data.comment == '' ? '同意':that.data.comment,
  335. "pass":true,
  336. }),
  337. method:'POST'
  338. };
  339. UTIL.httpRequest(API.URL_GET_PROCESSCOMPLETE ,data, {
  340. success: (res) => {
  341. console.log(res);
  342. if (res.code == API.SUCCESS_CODE) {
  343. wx.showToast({
  344. title: '审批成功',
  345. icon: 'success',
  346. duration: 2000,
  347. complete(){
  348. setTimeout(function(){
  349. that.back();
  350. },2000)
  351. }
  352. })
  353. }else{
  354. wx.showToast({
  355. title: '操作失败',
  356. icon: 'error',
  357. duration: 2000
  358. })
  359. }
  360. }
  361. })
  362. },
  363. goAgreeNew(){//2024-7-15审批功能修改 字段名称、接口地址、请求参数格式发生变动
  364. var that = this ;
  365. let data = {
  366. taskId:that.data.taskId,
  367. auditbatchNo:that.data.auditbatchNo,
  368. pass:true,
  369. remark:that.data.comment == '' ? '同意':that.data.comment,
  370. deptId:JSON.parse(wx.getStorageSync('user')).deptId,
  371. method:'POST'
  372. };
  373. console.log(data);
  374. UTIL.httpRequest(API.A_audit ,data, {
  375. success: (res) => {
  376. console.log(res);
  377. if (res.code == API.SUCCESS_CODE) {
  378. wx.showToast({
  379. title: '审批成功',
  380. icon: 'success',
  381. duration: 2000,
  382. complete(){
  383. setTimeout(function(){
  384. that.back();
  385. },2000)
  386. }
  387. })
  388. }else{
  389. wx.showToast({
  390. title: '操作失败',
  391. icon: 'error',
  392. duration: 2000
  393. })
  394. }
  395. }
  396. })
  397. },
  398. goDisNew(){//2024-7-15审批功能修改 字段名称、接口地址、请求参数格式发生变动
  399. var that = this ;
  400. let data = {
  401. taskId:that.data.taskId,
  402. auditbatchNo:that.data.auditbatchNo,
  403. pass:false,
  404. remark:that.data.comment == '' ? '驳回':that.data.comment,
  405. deptId:JSON.parse(wx.getStorageSync('user')).deptId,
  406. method:'POST'
  407. };
  408. console.log(data);
  409. UTIL.httpRequest(API.A_audit ,data, {
  410. success: (res) => {
  411. console.log(res);
  412. if (res.code == API.SUCCESS_CODE) {
  413. wx.showToast({
  414. title: '审批成功',
  415. icon: 'success',
  416. duration: 2000,
  417. complete(){
  418. setTimeout(function(){
  419. that.back();
  420. },2000)
  421. }
  422. })
  423. }else{
  424. wx.showToast({
  425. title: '操作失败',
  426. icon: 'error',
  427. duration: 2000
  428. })
  429. }
  430. }
  431. })
  432. },
  433. /**
  434. * 生命周期函数--监听页面隐藏
  435. */
  436. onHide() {
  437. },
  438. /**
  439. * 生命周期函数--监听页面卸载
  440. */
  441. onUnload() {
  442. },
  443. /**
  444. * 页面相关事件处理函数--监听用户下拉动作
  445. */
  446. onPullDownRefresh() {
  447. },
  448. /**
  449. * 页面上拉触底事件的处理函数
  450. */
  451. onReachBottom() {
  452. },
  453. /**
  454. * 用户点击右上角分享
  455. */
  456. onShareAppMessage() {
  457. }
  458. })