|
|
|
@ -1,5 +1,4 @@ |
|
|
|
// pages/moment/create/index.js
|
|
|
|
import { getMomentDetail, postMoment, updateMoment } from "../../../api/moment" |
|
|
|
import { getPreferType, getMomentDetail, postMoment, updateMoment } from "../../../api/moment" |
|
|
|
import { getFactoryList } from "../../../api/ztb" |
|
|
|
const util = require('../../../utils/util') |
|
|
|
const event = require('../../../utils/event.js') |
|
|
|
@ -12,7 +11,8 @@ Page({ |
|
|
|
form: {}, |
|
|
|
requesting: false, |
|
|
|
factoryFlag: true, |
|
|
|
factoryList: [] |
|
|
|
factoryList: [], |
|
|
|
typeList: [] |
|
|
|
}, |
|
|
|
/** |
|
|
|
* 生命周期函数--监听页面加载 |
|
|
|
@ -34,6 +34,13 @@ Page({ |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
getPreferType().then(result => { |
|
|
|
this.data.typeList = [] |
|
|
|
for (let index = 0; index < result.data.length; index++) { |
|
|
|
const element = result.data[index] |
|
|
|
this.data.typeList.push({value: element.id, text: element.name }) |
|
|
|
} |
|
|
|
}) |
|
|
|
if(options.id){ |
|
|
|
wx.showLoading({ title: '加载中', mask: true }) |
|
|
|
getMomentDetail(options.id).then(result => { |
|
|
|
@ -111,27 +118,50 @@ Page({ |
|
|
|
} |
|
|
|
this.pickerView = this.pickerView || this.selectComponent('#picker-view') |
|
|
|
if(this.data.factoryList.length > 0){ |
|
|
|
this.pickerView.showPicker(this.data.factoryList) |
|
|
|
this.pickerView.showPicker(this.data.factoryList, this.data.form.millPaperId, 0) |
|
|
|
} else { |
|
|
|
wx.showLoading({ title: '加载中', mask: true }) |
|
|
|
getFactoryList().then(result => { |
|
|
|
this.data.factoryList = [] |
|
|
|
for (let index = 0; index < result.data.records.length; index++) { |
|
|
|
const element = result.data.records[index] |
|
|
|
this.data.factoryList.push({value: element.paperMillId, text: element.name }) |
|
|
|
getPreferType().then(result => { |
|
|
|
this.data.typeList = [] |
|
|
|
for (let index = 0; index < result.data.length; index++) { |
|
|
|
const element = result.data[index] |
|
|
|
this.data.typeList.push({value: element.id, text: element.name }) |
|
|
|
} |
|
|
|
this.pickerView.showPicker(this.data.factoryList) |
|
|
|
this.pickerView.showPicker(this.data.factoryList, this.data.form.millPaperId, 0) |
|
|
|
wx.hideLoading() |
|
|
|
}).catch(err => { |
|
|
|
wx.hideLoading() |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
onPickerChange: function (e) { |
|
|
|
if(!e.detail){ |
|
|
|
selectType: function(){ |
|
|
|
this.pickerView = this.pickerView || this.selectComponent('#picker-view') |
|
|
|
if(this.data.typeList.length > 0){ |
|
|
|
this.pickerView.showPicker(this.data.typeList, this.data.form.categoryId, 1) |
|
|
|
} else { |
|
|
|
wx.showLoading({ title: '加载中', mask: true }) |
|
|
|
getPreferType().then(result => { |
|
|
|
tthis.data.typeList = [] |
|
|
|
for (let index = 0; index < result.data.length; index++) { |
|
|
|
const element = result.data[index] |
|
|
|
this.data.typeList.push({value: element.id, text: element.name }) |
|
|
|
} |
|
|
|
this.pickerView.showPicker(this.data.typeList, this.data.form.categoryId, 1) |
|
|
|
wx.hideLoading() |
|
|
|
}).catch(err => { |
|
|
|
wx.hideLoading() |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
onPickerChange: function ({detail}) { |
|
|
|
if(!detail){ |
|
|
|
return |
|
|
|
} |
|
|
|
this.setData({ ['form.millPaperId']: e.detail.value, ['form.millPaperName']: e.detail.text }) |
|
|
|
if(detail.type == 1) { |
|
|
|
this.setData({ ['form.categoryId']: detail.value, ['form.typeName']: detail.text }) |
|
|
|
} else { |
|
|
|
this.setData({ ['form.millPaperId']: detail.value, ['form.millPaperName']: detail.text }) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}) |