import { value as _value } from "./config"; import { chineseNumber } from "./ChinaNumToEnglishNum"; const methods = { //组件石林进入页面接节点树执行 async init () { try { // 商品请求 var laompany = []; let res = await wx.$request({ method: "get", url: "/order/productDict/" }); laompany = res.data.map(item => ({ key: item.id, value: item.name, month: item.month })); let { type, value, switchs } = this.data; switchs['laompany'] = laompany; switch (type) { // 已填报查看 case 'watch': var resA = await wx.$request({ url: `/order/${this.data.key}/`, method: "get" }); var { data, edit_file2 } = resA.data; // 附件已上传的图片 this.edit_file2 = edit_file2; value = this.watchFunc(value, data, switchs); break; case 'draftsupdate': // 修改草稿 var resA = await wx.$request({ url: `/order/${this.data.key}/`, method: "get" }); console.log(resA) var { data, edit_file2 } = resA.data; // 附件已上传的图片 this.edit_file2 = edit_file2; value = this.draftUpdataFunc(value, data, switchs); break; case 'providedupdate': // 修改已填报 var resA = await wx.$request({ url: `/order/${this.data.key}/`, method: "get" }); var { data, edit_values, edit_file, edit_file2 } = resA.data; // 图片错误原因 this.edit_file = edit_file; // 附件已上传的图片 this.edit_file2 = edit_file2; value = this.updataFunc(value, data, edit_values, switchs); default: // 新增 this.data.key && laompany.forEach((item, index) => { if (item.key == this.data.key) { value[0][10]["value"] = item.key; value[0][10]["index"] = index; value[0][11]['value'] = item['month'] + '个月'; } }) break; } this.setData({ value, switchs }) } catch (err) { wx.$err(err) } }, // 输入 inputFunc (e) { let { value } = this.data, { index } = e.currentTarget.dataset; value[index[0]][index[1]]['value'] = e.detail.value; if (value[index[0]][index[1]].hasOwnProperty("add")) value[index[0]][index[1]]['add'] = chineseNumber(e.detail.value); this.setData({ value }) }, // switch switchFunc (e) { let { value, switchs } = this.data, { index } = e.currentTarget.dataset; let { name } = value[index[0]][index[1]]; if (switchs.hasOwnProperty(name)) { this.setData({ switchB: true, active: name, activeIndex: index }) } }, // 隐藏单选框 hideModal () { this.setData({ switchB: false }) }, // 单选框赋值 changeFunc (e) { let { activeIndex, value, switchs } = this.data; let _value = e.detail.value.split(","); value[activeIndex[0]][activeIndex[1]]['value'] = _value[0] * 1; value[activeIndex[0]][activeIndex[1]]['index'] = _value[1] * 1; // 申请贷款产品 申请贷款期限关联 if (value[activeIndex[0]][activeIndex[1]]['name'] == 'laompany') { value[0][11]['value'] = switchs['laompany'][_value[1] * 1]['month'] + '个月'; } // 第一借款人与申请人关系特殊处理 if (value[activeIndex[0]][activeIndex[1]]['name'] == 'mstatus') { value[2][2] = { ...value[2][2], value: _value[0] == 1 ? 0 : '', index: _value[0] == 1 ? 0 : '' } } if (value[activeIndex[0]][activeIndex[1]].hasOwnProperty('forlen')) { for (let i = 1; i < (value[activeIndex[0]][activeIndex[1]]['forlen'] + 1); i++) { value[activeIndex[0]][(activeIndex[1] + i)]['norequire'] = _value[0] == 1 ? false : true; } } this.setData({ value, switchB: false }) }, // 日期 DateChange (e) { let { value } = this.data, { index } = e.currentTarget.dataset; value[index[0]][index[1]]['value'] = e.detail.value; this.setData({ value }) }, // 已填报查看附件 seeAccessoryFunc () { wx.navigateTo({ url: `/pages/accessory/index?data=&imgs=${JSON.stringify([])}&images=${JSON.stringify(this.edit_file2)}` }); } }; module.exports = methods;