|
@@ -1,10 +1,18 @@
|
|
|
-const _Http = getApp().globalData.http;
|
|
|
+const _Http = getApp().globalData.http,
|
|
|
+ MFT = require("../../../../../utils/matchingFeilType");
|
|
|
Page({
|
|
|
data: {
|
|
|
isNew: false, //是否为新增
|
|
|
ownerid: null,
|
|
|
ownertable: null,
|
|
|
sys_datafollowupid: 0, //数据ID
|
|
|
+ files: {
|
|
|
+ images: [],
|
|
|
+ viewImages: [],
|
|
|
+ videos: [],
|
|
|
+ viewVideos: [],
|
|
|
+ files: []
|
|
|
+ },
|
|
|
type: "",
|
|
|
content: "",
|
|
|
user: {}, //联系人
|
|
@@ -25,7 +33,142 @@ Page({
|
|
|
...options
|
|
|
})
|
|
|
};
|
|
|
- if (!options.sys_datafollowupid) this.initTemplate();
|
|
|
+ //编辑获取原信息,新建初始化模板
|
|
|
+ if (options.sys_datafollowupid) {
|
|
|
+ _Http.basic({
|
|
|
+ "id": 20221026085601,
|
|
|
+ "content": {
|
|
|
+ "sys_datafollowupid": options.sys_datafollowupid
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ console.log("跟进详情", res)
|
|
|
+ if (res.msg != '成功') {
|
|
|
+ wx.showToast({
|
|
|
+ title: res.data,
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ setTimeout(() => {
|
|
|
+ wx.navigateBack()
|
|
|
+ }, 300)
|
|
|
+ };
|
|
|
+ this.handleFiles(MFT.fileList(res.data.attinfos));
|
|
|
+ this.setData({
|
|
|
+ type: res.data.type,
|
|
|
+ content: res.data.content
|
|
|
+ })
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.initTemplate()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ deleteFile(e) {
|
|
|
+ let item = e.detail.attachmentid ? e.detail : e.currentTarget.dataset.item,
|
|
|
+ that = this;
|
|
|
+ if (!e.detail.attachmentid) {
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '是否确认删除该附件',
|
|
|
+ complete: ({
|
|
|
+ confirm
|
|
|
+ }) => {
|
|
|
+ if (confirm) that.handleDelete([item.linksid]).then(res => {
|
|
|
+ if (res.msg != '成功') return wx.showToast({
|
|
|
+ title: res.data,
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ let files = that.data.files,
|
|
|
+ name = item.fileType == "image" ? "images" : "videos",
|
|
|
+ name2 = item.fileType == "image" ? "viewImages" : "viewVideos",
|
|
|
+ data = that.data.files[name].find(v => v.url == item.url);
|
|
|
+ files[name] = files[name].filter(v => v.url != data.url);
|
|
|
+ files[name2] = files[name2].filter(v => v.url != data.url);
|
|
|
+ that.setData({
|
|
|
+ files
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ that.handleDelete([item.linksid]).then(res => {
|
|
|
+ if (res.msg != '成功') return wx.showToast({
|
|
|
+ title: res.data,
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ let files = that.data.files;
|
|
|
+ files.files = files.files.filter(v => v.url != item.url);
|
|
|
+ that.setData({
|
|
|
+ files
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleDelete(linksid) {
|
|
|
+ return _Http.basic({
|
|
|
+ "classname": "system.attachment.Attachment",
|
|
|
+ "method": "deleteFileLink",
|
|
|
+ "content": {
|
|
|
+ "linksids": linksid
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 绑定媒体 */
|
|
|
+ insertImgEdit({
|
|
|
+ detail
|
|
|
+ }) {
|
|
|
+ _Http.basic({
|
|
|
+ "classname": "system.attachment.Attachment",
|
|
|
+ "method": "createFileLink",
|
|
|
+ "content": {
|
|
|
+ "ownertable": "sys_datafollowup",
|
|
|
+ "ownerid": this.data.sys_datafollowupid,
|
|
|
+ "usetype": "default",
|
|
|
+ "attachmentids": detail
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ console.log('跟进记录绑定附件', res)
|
|
|
+ this.handleFiles(MFT.fileList(res.data));
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 处理附件 */
|
|
|
+ handleFiles(list) {
|
|
|
+ let files = this.data.files;
|
|
|
+
|
|
|
+ list.forEach(v => {
|
|
|
+ switch (v.fileType) {
|
|
|
+ case "video":
|
|
|
+ files.videos.push(v)
|
|
|
+ files.viewVideos.push({
|
|
|
+ url: v.url,
|
|
|
+ type: "video",
|
|
|
+ poster: v.subfiles[0].url
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ case "image":
|
|
|
+ files.images.push(v)
|
|
|
+ files.viewImages.push({
|
|
|
+ url: v.url,
|
|
|
+ type: "image"
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ files.files.push(v)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.setData({
|
|
|
+ files
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 预览媒体 */
|
|
|
+ viewMedias(e) {
|
|
|
+ const {
|
|
|
+ index,
|
|
|
+ type
|
|
|
+ } = e.currentTarget.dataset;
|
|
|
+ wx.previewMedia({
|
|
|
+ current: index,
|
|
|
+ sources: type == 'image' ? this.data.files.viewImages : this.data.files.viewVideos,
|
|
|
+ })
|
|
|
},
|
|
|
/* 初始化模板 */
|
|
|
initTemplate() {
|
|
@@ -39,24 +182,25 @@ Page({
|
|
|
sys_datafollowupid: this.data.sys_datafollowupid
|
|
|
}
|
|
|
}).then(res => {
|
|
|
- console.log("新增初始化模板", res)
|
|
|
-
|
|
|
this.setData({
|
|
|
sys_datafollowupid: res.data.sys_datafollowupid,
|
|
|
isNew: true
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
+ //开始选择跟进方式
|
|
|
openSelect() {
|
|
|
this.setData({
|
|
|
show: true
|
|
|
})
|
|
|
},
|
|
|
+ //取消选择
|
|
|
onCancel() {
|
|
|
this.setData({
|
|
|
show: false
|
|
|
})
|
|
|
},
|
|
|
+ //确定选择
|
|
|
onSelect({
|
|
|
detail
|
|
|
}) {
|
|
@@ -65,26 +209,12 @@ Page({
|
|
|
})
|
|
|
this.onCancel();
|
|
|
},
|
|
|
+ //文本域输入
|
|
|
onInput(e) {
|
|
|
this.setData({
|
|
|
content: e.detail.value
|
|
|
})
|
|
|
},
|
|
|
- selectUser() {
|
|
|
- let result = this.data.user.userid ? [this.data.user.userid] : [];
|
|
|
- wx.navigateTo({
|
|
|
- url: `/packageA/group/select?data=${JSON.stringify({
|
|
|
- ownertable:this.data.ownertable,
|
|
|
- ownerid:this.data.ownerid
|
|
|
- })}&radio=true&obj=true&result=${result}`,
|
|
|
- })
|
|
|
- },
|
|
|
- handelSubmit(arr) {
|
|
|
- wx.navigateBack();
|
|
|
- this.setData({
|
|
|
- user: arr[0]
|
|
|
- })
|
|
|
- },
|
|
|
submit() {
|
|
|
const content = {
|
|
|
type: this.data.type,
|
|
@@ -98,7 +228,6 @@ Page({
|
|
|
"id": 20220930121601,
|
|
|
content
|
|
|
}).then(res => {
|
|
|
- console.log("新增或编辑", res)
|
|
|
if (res.msg != '成功') return wx.showToast({
|
|
|
title: res.data,
|
|
|
icon: "none"
|
|
@@ -107,6 +236,9 @@ Page({
|
|
|
title: '保存成功',
|
|
|
icon: "none"
|
|
|
});
|
|
|
+ this.setData({
|
|
|
+ isNew: false
|
|
|
+ })
|
|
|
setTimeout(() => {
|
|
|
getCurrentPages().forEach(v => {
|
|
|
//详情界面更新数据
|
|
@@ -144,4 +276,15 @@ Page({
|
|
|
}, 300)
|
|
|
})
|
|
|
},
|
|
|
+ onUnload() {
|
|
|
+ if (this.data.isNew) _Http.basic({
|
|
|
+ "id": 20220930121701,
|
|
|
+ "content": {
|
|
|
+ "sys_datafollowupid": this.data.sys_datafollowupid,
|
|
|
+ "deletereason": "系统删除"
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ console.log("初始化模板后未保存删除", res)
|
|
|
+ })
|
|
|
+ }
|
|
|
})
|