| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- const util = require('../../utils/util')
- const app = getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- hotelList: [],
- searchParams: {
- hotelId: '',
- hotelName: '',
- },
- stockList: []
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.bindHotelList()
- this.bindProductStockList()
- },
- bindHotelPickerChange: function (e) {
- var item = this.data.hotelList[e.detail.value]
- console.log(item)
- this.setData({
- ['searchParams.hotelName']: item.hotelName,
- ['searchParams.hotelId']: item.id
- })
- this.bindProductStockList()
- },
- bindHotelList() {
- var that = this
- util.request(util.api.hotelList, {}, "GET", false, true, app.globalData.token).then((res) => {
- if (res.code == 200) {
- that.setData({
- hotelList: res.result
- })
- }
- }).catch((res) => {})
- },
- formSubmit: function (e) {
- var that = this
- 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
- itemProduct.skuStock = value
- list.splice(index, 1, itemProduct)
- that.setData({
- stockList: list
- })
- },
- bindProductStockList() {
- var that = this
- util.request(util.api.productStockList, that.data.searchParams, "GET", true, true, app.globalData.token).then((res) => {
- if (res.code == 200) {
- that.setData({
- stockList: res.result
- })
- }
- }).catch((res) => {})
- }
- })
|