123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 |
- // StepPage/pages/lin/lin.js
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- productList:[{
- basic_material_id: "",basic_material_name: "",code: "",mark: "",material_id: "",name: "",number: "",size: "",price:'',total_price:'',unit:''}],
- chooseIndex:'',
- materialList:[],
- searchRList:[],
- searchCList:[],
- searchRValue:'',
- roll_film_number_arr:[],
- set_status:""
- },
-
- onSearchC(event){
- let arr = this.data.materialList.filter(v=>v.code.indexOf(event.detail)!=-1);
- this.setData({
- searchCList:arr
- })
- },
- onSearchR(event){
- let arr = this.data.materialList.filter(v=>v.name.indexOf(event.detail)!=-1);
- this.setData({
- searchRList:arr
- })
- },
- onChooseC(data){
- this.setData({
- c_show:true,
- searchCList:this.data.materialList,
- chooseIndex:data.target.dataset.index
- })
- },
- onChooseR(data){
- this.setData({
- r_show:true,
- searchRList:this.data.materialList,
- chooseIndex:data.target.dataset.index
- })
- },
- handleCancelR(){
- this.setData({
- r_show:false
- })
- },
- handleCancelC(){
- this.setData({
- c_show:false,
- })
- },
- handleChooseR(item){
- let arr = this.data.productList;
- arr[this.data.chooseIndex].basic_material_name = item.target.dataset.item.basic_material_name;
- arr[this.data.chooseIndex].basic_material_id = item.target.dataset.item.material_id;
- arr[this.data.chooseIndex].code = item.target.dataset.item.code;
- arr[this.data.chooseIndex].material_id = item.target.dataset.item.id;
- arr[this.data.chooseIndex].name = item.target.dataset.item.name;
- arr[this.data.chooseIndex].size = item.target.dataset.item.size;
- arr[this.data.chooseIndex].price = item.target.dataset.item.price;
- arr[this.data.chooseIndex].unit = item.target.dataset.item.unit;
- arr[this.data.chooseIndex].total_price = '';
- arr[this.data.chooseIndex].number = '';
- this.setData({
- searchRValue:'',
- r_show:false,
- productList:arr,
- c_show:false,
- searchCValue:''
- })
- },
- handleChangePrice(e){
- let arr = this.data.productList;
- if(isNaN(e.detail.value*1)){
- arr[e.target.dataset.index].price = '';
- this.setData({
- productList:arr
- })
- return wx.showToast({
- icon:'error',
- title: '请输入数字',
- })
- }
- arr[e.target.dataset.index].price = e.detail.value;
- arr[e.target.dataset.index].total_price = (e.detail.value*1*(arr[e.target.dataset.index].number?arr[e.target.dataset.index].number*1:0)).toFixed(2);
- this.setData({
- productList:arr
- })
- },
- handleChangeTotalPrice(e){
- let arr = this.data.productList;
- if(isNaN(e.detail.value*1)){
- arr[e.target.dataset.index].total_price = '';
- arr[e.target.dataset.index].number = '';
- this.setData({
- productList:arr
- })
- return wx.showToast({
- icon:'error',
- title: '请输入数字',
- })
- }
- arr[e.target.dataset.index].total_price = e.detail.value;
- arr[e.target.dataset.index].number =arr[e.target.dataset.index].price*1? (e.detail.value*1/arr[e.target.dataset.index].price*1).toFixed(2):0;
- this.setData({
- productList:arr
- })
- },
- handleChangeMark(e){
- let arr = this.data.productList;
- arr[e.target.dataset.index].mark = e.detail.value;
- this.setData({
- productList:arr
- })
- },
- handleChangeNumber(e){
- let arr = this.data.productList;
- if(isNaN(e.detail.value*1)){
- arr[e.target.dataset.index].number = '';
- this.setData({
- productList:arr
- })
- return wx.showToast({
- icon:'error',
- title: '请输入数字',
- })
- }
- arr[e.target.dataset.index].number = e.detail.value;
- arr[e.target.dataset.index].total_price = (e.detail.value*1*(arr[e.target.dataset.index].price?arr[e.target.dataset.index].price*1:0)).toFixed(2);
- this.setData({
- productList:arr
- })
- },
- handleAddItem(data){
- let arr = this.data.productList;
- let index = data.target.dataset.index;
- arr.splice(index+1,0,{basic_material_id: "",basic_material_name: "",code: "",mark: "",material_id: "",name: "",number: "",size: "",price:'',total_price:'',unit:''})
- this.setData({
- productList : arr
- })
- },
- handleDeleteItem(data){
- let arr = this.data.productList;
- let index = data.target.dataset.index;
- if(arr.length === 1 ){
- arr = [
- {basic_material_id: "",basic_material_name: "",code: "",mark: "",material_id: "",name: "",number: "",size: "",price:'',total_price:'',unit:''}
- ]
- }else{
- arr.splice(index,1);
- }
- this.setData({
- productList:arr
- })
- },
- handleReturn(){
- wx.navigateBack({
- delta:1
- })
- },
- handleBack(){
- let app = getApp();
- app.globalData={
- stepData:[],
- openID:app.globalData.openID,
- url:'https://zhapi.qingyaokeji.com/'
- }
- wx.navigateBack({
- delta:3
- })
- },
- handleNext(){
- const app = getApp();
- let data = {
- address:app.globalData.address,
- area:app.globalData.area,
- mark:app.globalData.mark,
- regional_manager:app.globalData.regional_manager,
- sub:this.data.productList,
- openid:app.globalData.openID
- }
- if(this.data.set_status){
- data.order_number = app.globalData.detailData.order_number
- console.log(data);
- wx.p.request({
- method:'post',
- url:`${app.globalData.url}wx/materialChargeEdit`,
- data
- }).then(res=>{
- if(res.data.code==200){
- wx.showToast({
- title: res.data.msg,
- })
- app.globalData={
- stepData:[],
- openID:app.globalData.openID,
- url:'https://zhapi.qingyaokeji.com/'
- }
- wx.navigateBack({
- delta:3
- })
- }
- })
- }else{
- wx.p.request({
- method:'post',
- url:`${app.globalData.url}wx/materialChargeAdd`,
- data
- }).then(res=>{
- if(res.data.code==200){
- wx.showToast({
- title: res.data.msg,
- })
- app.globalData={
- stepData:[],
- openID:app.globalData.openID,
- url:'https://zhapi.qingyaokeji.com/'
- }
- wx.navigateBack({
- delta:3
- })
- }
- })
- }
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- const app = getApp();
- const openid = app.globalData.openID;
- //获取卷膜型号
- wx.p.request({
- url: `${app.globalData.url}wx/materialList`,
- method:'POST',
- data:{
- openid
- }
- }).then(res=>{
- if(res.data.code==200){
- this.setData({
- materialList:res.data.data.data,
- })
- }
- })
- if(app.globalData.set_status){
- this.setData({
- productList:app.globalData.detailData.sub,
- set_status:app.globalData.set_status
- })
- }else{
- this.setData({
- set_status:''
- })
- }
- console.log(app.globalData)
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|