|
@@ -2,7 +2,6 @@ const _Http = getApp().globalData.http,
|
|
|
MFT = require("../../utils/matchingFeilType"),
|
|
|
CF = require("../../utils/checkFile");
|
|
|
Page({
|
|
|
-
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
@@ -19,22 +18,146 @@ Page({
|
|
|
detailsData: {},
|
|
|
editRichText: false, //编辑富文本
|
|
|
richTextFile: [],
|
|
|
+ items: [],
|
|
|
+ activeName: "",
|
|
|
+ activeId: "",
|
|
|
+ selectShow: false,
|
|
|
+ loading: false
|
|
|
},
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad(options) {
|
|
|
+ if (options.item) {
|
|
|
+ this.setData({
|
|
|
+ items: JSON.parse(options.item)
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.selectMenu();
|
|
|
+ };
|
|
|
_Http.basic({
|
|
|
"classname": "webmanage.saletool.sharematerial.sharematerial",
|
|
|
"method": "insertOrUpdate",
|
|
|
content: this.data.content
|
|
|
}).then(res => {
|
|
|
console.log("新增", res)
|
|
|
+ this.setData({
|
|
|
+ detailsData: res.data[0],
|
|
|
+ "content.sat_sharematerialid": res.data[0].sat_sharematerialid
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ submit() {
|
|
|
+ let content = this.data.content;
|
|
|
+ if (content.title == '' || content.sat_sharematerial_classid == 9999) return wx.showToast({
|
|
|
+ title: '请检查素材标题或所属分类',
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ if (this.data.loading || this.data.detailsData.status == "审核") return wx.showToast({
|
|
|
+ title: '正在提交中',
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ this.setData({
|
|
|
+ loading: true
|
|
|
+ })
|
|
|
+ _Http.basic({
|
|
|
+ "classname": "webmanage.saletool.sharematerial.sharematerial",
|
|
|
+ "method": "insertOrUpdate",
|
|
|
+ content: this.data.content
|
|
|
+ }).then(res => {
|
|
|
+ if (res.msg != '成功') {
|
|
|
+ wx.showToast({
|
|
|
+ title: res.data,
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ this.setData({
|
|
|
+ loading: false
|
|
|
+ })
|
|
|
+ return;
|
|
|
+ }
|
|
|
this.setData({
|
|
|
detailsData: res.data[0]
|
|
|
})
|
|
|
+ _Http.basic({
|
|
|
+ "classname": "webmanage.saletool.sharematerial.sharematerial",
|
|
|
+ "method": "audit",
|
|
|
+ "content": {
|
|
|
+ "sat_sharematerialid": res.data[0].sat_sharematerialid,
|
|
|
+ "type": 1
|
|
|
+ }
|
|
|
+ }).then(s => {
|
|
|
+ this.setData({
|
|
|
+ loading: false
|
|
|
+ })
|
|
|
+ if (res.msg != '成功') return wx.showToast({
|
|
|
+ title: "保存失败,请重新尝试",
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ wx.showToast({
|
|
|
+ title: "修改成功",
|
|
|
+ });
|
|
|
+ this.setData({
|
|
|
+ "detailsData.status": "审核"
|
|
|
+ })
|
|
|
+ let pages = getCurrentPages();
|
|
|
+ let prevPage = pages[pages.length - 2];
|
|
|
+ prevPage.getList(true);
|
|
|
+ setTimeout(() => {
|
|
|
+ wx.navigateBack({
|
|
|
+ delta: 0,
|
|
|
+ })
|
|
|
+ }, 300)
|
|
|
+ })
|
|
|
})
|
|
|
},
|
|
|
+ openSelect() {
|
|
|
+ this.setData({
|
|
|
+ selectShow: true
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onClose() {
|
|
|
+ this.setData({
|
|
|
+ selectShow: false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 查询分类 */
|
|
|
+ selectMenu(index = 0, res) {
|
|
|
+ if (index == 5) return wx.showToast({
|
|
|
+ title: res.data,
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ _Http.basic({
|
|
|
+ "classname": "saletool.sharematerial.sharematerial",
|
|
|
+ "method": "select",
|
|
|
+ "content": {
|
|
|
+ "parentid": 0
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ if (res.msg != '成功') return this.selectMenu(index + 1, res);
|
|
|
+ let str = JSON.stringify(res.data).replace(/classname/g, 'text').replace(/sat_sharematerial_classid/g, 'id');
|
|
|
+ this.setData({
|
|
|
+ items: JSON.parse(str)
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /* 切换分类 */
|
|
|
+ onClickItem({
|
|
|
+ detail = {}
|
|
|
+ }) {
|
|
|
+ this.setData({
|
|
|
+ "content.sat_sharematerial_classid": detail.id,
|
|
|
+ activeName: detail.text
|
|
|
+ });
|
|
|
+ this.onClose();
|
|
|
+ },
|
|
|
+ onClickNav({
|
|
|
+ detail = {}
|
|
|
+ }) {
|
|
|
+ this.setData({
|
|
|
+ mainActiveIndex: detail.index || 0,
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /* 上传文件 */
|
|
|
getFile({
|
|
|
detail
|
|
|
}) {
|
|
@@ -48,8 +171,9 @@ Page({
|
|
|
"attachmentids": detail
|
|
|
}
|
|
|
}).then(res => {
|
|
|
+ console.log("上传成功", res)
|
|
|
if (res.msg != '成功') return wx.showToast({
|
|
|
- title: res.data,
|
|
|
+ title: res.msg,
|
|
|
icon: "none"
|
|
|
});
|
|
|
this.setData({
|
|
@@ -84,7 +208,6 @@ Page({
|
|
|
"content.content": detail
|
|
|
})
|
|
|
},
|
|
|
-
|
|
|
deleteFile(e) {
|
|
|
const {
|
|
|
item,
|
|
@@ -125,7 +248,8 @@ Page({
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
*/
|
|
|
onUnload() {
|
|
|
- if (this.data.detailsData.status == '新建') _Http.basic({
|
|
|
+ if (this.data.detailsData.status != '新建') return;
|
|
|
+ _Http.basic({
|
|
|
"classname": "webmanage.saletool.sharematerial.sharematerial",
|
|
|
"method": "delete",
|
|
|
"content": {
|