123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- const _Http = getApp().globalData.http,
- MFT = require("../../utils/matchingFeilType"),
- CF = require("../../utils/checkFile");
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- "content": {
- "title": "",
- "sat_sharematerial_classid": 9999,
- "notes": "",
- "tag": [],
- "canfiledownload": 1,
- "content": "",
- "sat_sharematerialid": 0
- },
- detailsData: {},
- editRichText: false, //编辑富文本
- richTextFile: [],
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- _Http.basic({
- "classname": "webmanage.saletool.sharematerial.sharematerial",
- "method": "insertOrUpdate",
- content: this.data.content
- }).then(res => {
- console.log("新增", res)
- this.setData({
- detailsData: res.data[0]
- })
- })
- },
- getFile({
- detail
- }) {
- _Http.basic({
- "classname": "system.attachment.Attachment",
- "method": "createFileLink",
- "content": {
- "ownertable": "SAT_SHAREMATERIAL",
- "ownerid": this.data.detailsData.sat_sharematerialid,
- "usetype": "default",
- "attachmentids": detail
- }
- }).then(res => {
- if (res.msg != '成功') return wx.showToast({
- title: res.data,
- icon: "none"
- });
- this.setData({
- "detailsData.attinfos": this.data.detailsData.attinfos.concat(MFT.fileList(res.data))
- })
- })
- },
- titleInput({
- detail
- }) {
- this.setData({
- "content.title": detail.value.trim()
- })
- },
- openFile(e) {
- const {
- item
- } = e.currentTarget.dataset;
- CF.checkFile(item);
- },
- /* 打开编辑富文本 */
- openEditRichText() {
- this.setData({
- editRichText: !this.data.editRichText
- })
- },
- /* 得到编辑好的富文本内容 */
- getRichText({
- detail
- }) {
- this.setData({
- "content.content": detail
- })
- },
- deleteFile(e) {
- const {
- item,
- index
- } = e.currentTarget.dataset;
- const that = this;
- wx.showModal({
- title: '提示',
- content: "是否确认删除该文件?",
- success: async s => {
- if (!s.confirm) return;
- let res = await that.handleDelete([item.linksid]);
- if (res.msg != '成功') wx.showToast({
- title: res.data,
- });
- let attinfos = that.data.detailsData.attinfos;
- attinfos.splice(index, 1);
- that.setData({
- "detailsData.attinfos": attinfos
- });
- }
- })
- },
- handleDelete(linksids) {
- return _Http.basic({
- "classname": "system.attachment.Attachment",
- "method": "deleteFileLink",
- "content": {
- linksids
- }
- }).then(res => {
- console.log('删除附件', res)
- return res;
- })
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- if (this.data.detailsData.status == '新建') _Http.basic({
- "classname": "webmanage.saletool.sharematerial.sharematerial",
- "method": "delete",
- "content": {
- "sat_sharematerialid": this.data.detailsData.sat_sharematerialid
- }
- }).then(res => {
- console.log("删除", res)
- });
- let attinfos = this.data.detailsData.attinfos;
- if (attinfos.length) {
- let linksids = [];
- for (let i = 0; i < attinfos.length; i++) {
- linksids.push(attinfos[i].linksid)
- };
- this.handleDelete(linksids)
- }
- },
- })
|