|
@@ -15,7 +15,6 @@ Page({
|
|
|
minDate: Number,
|
|
|
showCalendar: false, //日历显示
|
|
|
tsupplyanddemandid: 0, //ID 0为新增
|
|
|
- newAdd: false, //是否新增 新增未保存直接退出页面会删除该供需
|
|
|
popups: false, //弹出层控制
|
|
|
ftype: "", //供需类型
|
|
|
ftitle: "", //供需标题
|
|
@@ -34,16 +33,8 @@ Page({
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
this.setTime()
|
|
|
- if (options.data == undefined) {
|
|
|
- console.log('新增')
|
|
|
- //新增
|
|
|
- this.addOrModify()
|
|
|
- this.setData({
|
|
|
- newAdd: true
|
|
|
- })
|
|
|
- } else {
|
|
|
- //修改
|
|
|
-
|
|
|
+ if (options.data != undefined) {
|
|
|
+ console.log("修改返回数据")
|
|
|
}
|
|
|
},
|
|
|
setTime() {
|
|
@@ -92,23 +83,17 @@ Page({
|
|
|
title: '请检查表单内容',
|
|
|
icon: "error"
|
|
|
});
|
|
|
- this.setData({
|
|
|
- newAdd: false
|
|
|
- })
|
|
|
this.addOrModify()
|
|
|
},
|
|
|
/* 新增或修改 */
|
|
|
addOrModify() {
|
|
|
let content = {};
|
|
|
- if (this.data.tsupplyanddemandid == 0) {
|
|
|
- //新增产品
|
|
|
- content = {
|
|
|
- "tsupplyanddemandid": 0,
|
|
|
- "fissupply": 0
|
|
|
- }
|
|
|
- } else {
|
|
|
- //修改需求
|
|
|
- content = {
|
|
|
+ /* 发送请求 */
|
|
|
+ _Http.basic({
|
|
|
+ "accesstoken": wx.getStorageSync('userData').token,
|
|
|
+ "classname": "customer.supplyanddemand.supplyanddemand",
|
|
|
+ "method": "insertormodify",
|
|
|
+ "content": {
|
|
|
"tsupplyanddemandid": this.data.tsupplyanddemandid,
|
|
|
"ftype": this.data.ftype,
|
|
|
"ftitle": this.data.ftitle,
|
|
@@ -116,30 +101,16 @@ Page({
|
|
|
"fenddate": this.data.fenddate,
|
|
|
"fissupply": 0
|
|
|
}
|
|
|
- }
|
|
|
- /* 发送请求 */
|
|
|
- _Http.basic({
|
|
|
- "accesstoken": wx.getStorageSync('userData').token,
|
|
|
- "classname": "customer.supplyanddemand.supplyanddemand",
|
|
|
- "method": "insertormodify",
|
|
|
- "content": content
|
|
|
}).then(res => {
|
|
|
- console.log(res)
|
|
|
- if (this.data.newAdd) {
|
|
|
- this.setData({
|
|
|
- tsupplyanddemandid: res.data[0].tsupplyanddemandid
|
|
|
- })
|
|
|
- }else{
|
|
|
- wx.showToast({
|
|
|
- title: '保存成功',
|
|
|
+ if (res.msg != "成功") return
|
|
|
+ wx.showToast({
|
|
|
+ title: '保存成功',
|
|
|
+ })
|
|
|
+ setTimeout(() => {
|
|
|
+ wx.navigateBack({
|
|
|
+ delta: 1,
|
|
|
})
|
|
|
- setTimeout(()=>{
|
|
|
- wx.navigateBack({
|
|
|
- delta: 1,
|
|
|
- })
|
|
|
- },500)
|
|
|
- }
|
|
|
-
|
|
|
+ }, 500)
|
|
|
})
|
|
|
},
|
|
|
/* 弹出层 */
|
|
@@ -207,21 +178,7 @@ Page({
|
|
|
/**
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
*/
|
|
|
- onUnload: function () {
|
|
|
- //新增未保存,退出页面删除新增
|
|
|
- if (this.data.newAdd) {
|
|
|
- _Http.basic({
|
|
|
- "accesstoken": wx.getStorageSync('userData').token,
|
|
|
- "classname": "customer.supplyanddemand.supplyanddemand",
|
|
|
- "method": "deletesupplyanddemand",
|
|
|
- "content": {
|
|
|
- "tsupplyanddemandid": this.data.tsupplyanddemandid
|
|
|
- }
|
|
|
- }).then(res => {
|
|
|
- console.log(res)
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
+ onUnload: function () {},
|
|
|
|
|
|
/**
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|