| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- const _Http = getApp().globalData.http;
- let sys_workreportmodelid = null;
- import {
- formatTime
- } from "../../utils/getTime"
- Page({
- data: {
- date: formatTime(new Date(), "-").split(" ")[0],
- loading: true,
- loading1: false
- },
- onLoad(options) {
- getApp().globalData.Language.getLanguagePackage(this)
- let model = JSON.parse(options.model)
- sys_workreportmodelid = model.sys_workreportmodelid;
- wx.setNavigationBarTitle({
- title: model.reportname,
- })
- _Http.basic({
- "id": "20230523131702",
- "content": {
- sys_workreportmodelid
- }
- }).then(res => {
- console.log("查询模板数据", res)
- if (res.code != '1') {
- wx.showToast({
- title: res.msg,
- icon: "none",
- mask: true
- })
- setTimeout(() => {
- wx.navigateBack()
- }, 500)
- } else {
- this.setData({
- reportname: model.reportname,
- list: res.data.map(v => {
- v.content = v.content.map(s => {
- return v.editable == 1 && s.content != "" ? `${s.rowindex}、${s.content}` : s.content
- }).join('\n\n');
- return v
- }),
- loading: false
- })
- }
- })
- },
- /* 绑定媒体 */
- insertImgEdit({
- detail
- }) {
- _Http.basic({
- "classname": "system.attachment.Attachment",
- "method": "createFileLink",
- "content": {
- "ownertable": "sys_workreport",
- "ownerid": 0,
- "usetype": "default",
- "attachmentids": detail
- }
- }).then(res => {
- console.log('跟进记录绑定附件', res)
- if (res.code != '1') return wx.showToast({
- title: res.msg,
- icon: "none"
- })
- this.selectComponent("#Yl_Files").handleFiles(res.data)
- })
- },
- onInput(e) {
- let {
- item,
- index
- } = e.currentTarget.dataset;
- item.content = e.detail.value;
- this.setData({
- [`list[${index}]`]: item
- })
- },
- onVoiceInput(e) {
- let {
- item,
- index
- } = e.currentTarget.dataset;
- item.content = e.detail;
- this.setData({
- [`list[${index}]`]: item
- })
- },
- /* 取消汇报 */
- onCancel() {
- wx.showModal({
- title: getApp().globalData.Language.getMapText('提示'),
- content: getApp().globalData.Language.getMapText('是否确定取消汇报,确认后将丢失填写/修改进度'),
- cancelText: getApp().globalData.Language.getMapText('取消'),
- confirmText: getApp().globalData.Language.getMapText('确定'),
- complete: (res) => {
- if (res.confirm) wx.navigateBack()
- }
- })
- },
- /* 提交汇报 */
- submit() {
- console.log()
- const that = this;
- wx.showModal({
- title: getApp().globalData.Language.getMapText('提示'),
- content: getApp().globalData.Language.getMapText('是否确认提交汇报') + '?',
- cancelText: getApp().globalData.Language.getMapText('取消'),
- confirmText: getApp().globalData.Language.getMapText('确定'),
- complete: ({
- confirm
- }) => {
- if (confirm) {
- this.setData({
- loading1: true
- })
- _Http.basic({
- "id": "20230523094702",
- "content": {
- sys_workreportmodelid,
- "items": that.data.list.map(v => {
- v.content = [{
- rouindex: 1,
- content: v.content
- }]
- return v
- })
- },
- }).then(res => {
- console.log("提交汇报", res)
- that.setData({
- loading1: false
- })
- wx.showToast({
- title: res.code == '1' ? getApp().globalData.Language.getMapText('提交成功') : res.msg,
- icon: "none",
- mask: true
- });
- let {
- attachmentids
- } = this.selectComponent("#Yl_Files").getFiles();
- if (attachmentids.length == 0) return setTimeout(() => {
- wx.redirectTo({
- url: '/packageA/report/detail?id=' + res.data.sys_workreportid,
- })
- }, 500)
- _Http.basic({
- "classname": "system.attachment.Attachment",
- "method": "createFileLink",
- "content": {
- "ownertable": "sys_workreport",
- "ownerid": res.data.sys_workreportid,
- "usetype": "default",
- attachmentids
- }
- }).then(s => {
- console.log('附件改绑', s)
- if (s.code != '1') wx.showToast({
- title: s.msg,
- icon: "none",
- mask: true
- });
- setTimeout(() => {
- wx.redirectTo({
- url: '/packageA/report/detail?id=' + res.data.sys_workreportid,
- })
- }, 300)
- })
- })
- }
- }
- })
- }
- })
|