123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- const util = require('../../utils/util')
- const app = getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- storeList: [],
- userInfo: {},
- searchParams: {
- agentName:''
- },
- stockList: []
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- // this.bindStoreList()
- this.setData({
- userInfo: app.globalData.userInfo,
- })
- console.log(this.data.userInfo)
- this.bindProductStockList()
- },
- bindStorePickerChange: function (e) {
- var item = this.data.storeList[e.detail.value]
- console.log(item)
- this.setData({
- ['searchParams.storeName']: item.storeName,
- ['searchParams.storeId']: item.id
- })
- this.bindProductStockList()
- },
- // bindStoreList() {
- // var that = this
- // util.request(util.api.storeList, {}, "GET", false, true, app.globalData.token).then((res) => {
- // if (res.code == 200) {
- // that.setData({
- // storeList: res.result
- // })
- // }
- // }).catch((res) => {})
- // },
- formSubmit: function (e) {
- var that = this
- console.log(that.data.stockList)
- util.request(util.api.editVmProductStock, that.data.stockList, "POST", false, true, app.globalData.token).then((res) => {
- if (res.code == 200) {
- util.toast('保存成功')
- setTimeout(() => {
- wx.navigateBack()
- }, 500)
- }
- }).catch((res) => {})
- },
- formReset: function (e) {
- console.log("清空数据")
- },
- inputedit: function (e) {
- let _this = this;
- let dataset = e.currentTarget.dataset;
- let value = e.detail.value;
- let name = dataset.name;
- _this.data[name] = value;
- _this.setData({
- [name]: _this.data[name]
- });
- },
- inputeditRow: function (e) {
- let that = this;
- let dataset = e.currentTarget.dataset;
- let value = e.detail.value;
- let name = dataset.name;
- var list = that.data.stockList
- var index = dataset.index;
- var itemProduct = dataset.item
- console.log(name)
- console.log(itemProduct)
- itemProduct.skuStock = value
- list.splice(index, 1, itemProduct)
- that.setData({
- stockList: list
- })
- },
- bindProductStockList() {
- var that = this
-
- console.log( this.data.userInfo)
- util.request(util.api.productStockList, this.data.searchParams, "GET", true, true, app.globalData.token).then((res) => {
- console.log(res)
- if (res.code == 200) {
- that.setData({
- stockList: res.result
- })
- }
- }).catch((res) => {})
- },
- btnsearch(){
- this.bindProductStockList()
- }
- })
|