methods.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import { value as _value } from "./config";
  2. import { chineseNumber } from "./ChinaNumToEnglishNum";
  3. const methods = {
  4. //组件石林进入页面接节点树执行
  5. async init () {
  6. try {
  7. // 商品请求
  8. var laompany = [];
  9. let res = await wx.$request({ method: "get", url: "/order/productDict/" });
  10. laompany = res.data.map(item => ({ key: item.id, value: item.name, month: item.month }));
  11. let { type, value, switchs } = this.data;
  12. switchs['laompany'] = laompany;
  13. switch (type) {
  14. // 已填报查看
  15. case 'watch':
  16. var resA = await wx.$request({ url: `/order/${this.data.key}/`, method: "get" });
  17. var { data, edit_file2 } = resA.data;
  18. // 附件已上传的图片
  19. this.edit_file2 = edit_file2;
  20. value = this.watchFunc(value, data, switchs);
  21. break;
  22. case 'draftsupdate':
  23. // 修改草稿
  24. var resA = await wx.$request({ url: `/order/${this.data.key}/`, method: "get" });
  25. console.log(resA)
  26. var { data, edit_file2 } = resA.data;
  27. // 附件已上传的图片
  28. this.edit_file2 = edit_file2;
  29. value = this.draftUpdataFunc(value, data, switchs);
  30. break;
  31. case 'providedupdate':
  32. // 修改已填报
  33. var resA = await wx.$request({ url: `/order/${this.data.key}/`, method: "get" });
  34. var { data, edit_values, edit_file, edit_file2 } = resA.data;
  35. // 图片错误原因
  36. this.edit_file = edit_file;
  37. // 附件已上传的图片
  38. this.edit_file2 = edit_file2;
  39. value = this.updataFunc(value, data, edit_values, switchs);
  40. default:
  41. // 新增
  42. this.data.key && laompany.forEach((item, index) => {
  43. if (item.key == this.data.key) {
  44. value[0][10]["value"] = item.key;
  45. value[0][10]["index"] = index;
  46. value[0][11]['value'] = item['month'] + '个月';
  47. }
  48. })
  49. break;
  50. }
  51. this.setData({ value, switchs })
  52. } catch (err) { wx.$err(err) }
  53. },
  54. // 输入
  55. inputFunc (e) {
  56. let { value } = this.data, { index } = e.currentTarget.dataset;
  57. value[index[0]][index[1]]['value'] = e.detail.value;
  58. if (value[index[0]][index[1]].hasOwnProperty("add")) value[index[0]][index[1]]['add'] = chineseNumber(e.detail.value);
  59. this.setData({ value })
  60. },
  61. // switch
  62. switchFunc (e) {
  63. let { value, switchs } = this.data, { index } = e.currentTarget.dataset;
  64. let { name } = value[index[0]][index[1]];
  65. if (switchs.hasOwnProperty(name)) {
  66. this.setData({ switchB: true, active: name, activeIndex: index })
  67. }
  68. },
  69. // 隐藏单选框
  70. hideModal () { this.setData({ switchB: false }) },
  71. // 单选框赋值
  72. changeFunc (e) {
  73. let { activeIndex, value, switchs } = this.data;
  74. let _value = e.detail.value.split(",");
  75. value[activeIndex[0]][activeIndex[1]]['value'] = _value[0] * 1;
  76. value[activeIndex[0]][activeIndex[1]]['index'] = _value[1] * 1;
  77. // 申请贷款产品 申请贷款期限关联
  78. if (value[activeIndex[0]][activeIndex[1]]['name'] == 'laompany') {
  79. value[0][11]['value'] = switchs['laompany'][_value[1] * 1]['month'] + '个月';
  80. }
  81. // 第一借款人与申请人关系特殊处理
  82. if (value[activeIndex[0]][activeIndex[1]]['name'] == 'mstatus') {
  83. value[2][2] = {
  84. ...value[2][2], value: _value[0] == 1 ? 0 : '', index: _value[0] == 1 ? 0 : ''
  85. }
  86. }
  87. if (value[activeIndex[0]][activeIndex[1]].hasOwnProperty('forlen')) {
  88. for (let i = 1; i < (value[activeIndex[0]][activeIndex[1]]['forlen'] + 1); i++) {
  89. value[activeIndex[0]][(activeIndex[1] + i)]['norequire'] = _value[0] == 1 ? false : true;
  90. }
  91. }
  92. this.setData({ value, switchB: false })
  93. },
  94. // 日期
  95. DateChange (e) {
  96. let { value } = this.data, { index } = e.currentTarget.dataset;
  97. value[index[0]][index[1]]['value'] = e.detail.value;
  98. this.setData({ value })
  99. },
  100. // 已填报查看附件
  101. seeAccessoryFunc () {
  102. wx.navigateTo({ url: `/pages/accessory/index?data=&imgs=${JSON.stringify([])}&images=${JSON.stringify(this.edit_file2)}` });
  103. }
  104. };
  105. module.exports = methods;