国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

微信小程序:表格中更改輸入框的值,實(shí)時(shí)獲取表格全部數(shù)據(jù),點(diǎn)擊按鈕更改數(shù)據(jù)庫(kù)指定項(xiàng)數(shù)據(jù)

這篇具有很好參考價(jià)值的文章主要介紹了微信小程序:表格中更改輸入框的值,實(shí)時(shí)獲取表格全部數(shù)據(jù),點(diǎn)擊按鈕更改數(shù)據(jù)庫(kù)指定項(xiàng)數(shù)據(jù)。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

樣例:

樣式展示

點(diǎn)擊按鈕更改數(shù)據(jù)庫(kù),微信小程序,數(shù)據(jù)庫(kù),小程序

數(shù)據(jù)庫(kù)中原始第一條數(shù)據(jù)

點(diǎn)擊按鈕更改數(shù)據(jù)庫(kù),微信小程序,數(shù)據(jù)庫(kù),小程序

?修改表格第一行的數(shù)量:

點(diǎn)擊按鈕更改數(shù)據(jù)庫(kù),微信小程序,數(shù)據(jù)庫(kù),小程序

數(shù)據(jù)庫(kù)結(jié)果?

?點(diǎn)擊按鈕更改數(shù)據(jù)庫(kù),微信小程序,數(shù)據(jù)庫(kù),小程序

?核心代碼

wxml

①wx:for:執(zhí)行循環(huán)將數(shù)組數(shù)據(jù)展示出來(lái)

②在某一單元格加上input樣式

③在input中綁定:文本框改變事件,并且綁定data-index便于知道改變的具體是哪一行的數(shù)據(jù)

<!-- 表格 -->
<view class="table_position">
    <view class="table">
        <view class="table-tr">
            <view class="table-th1">順序</view>
            <view class="table-th2">制程</view>
            <view class="table-th3">數(shù)量</view>
          </view>
        <view class="table-tr" wx:for="{{allinfo}}" wx:key="unique">
           <view class="table-td1">{{item.operation_seq_num}}</view>
           <view class="table-td2">{{item.operation_code}}</view>
           <view class="table-td3">
             <view class="input_position">
               <input type="text" value="{{item.begin_quantity}}" class="input" bindinput="inputChange" data-index="{{index}}"/>
             </view>
           </view>
        </view>
    </view>
</view>
<!--開(kāi)始生產(chǎn)的按鈕-->
<view class="start">
    <view class="button_text" bindtap="start_produce">開(kāi)始生產(chǎn)</view>
</view>

wxss

/* 表格樣式 */
.table_position{
  padding:15px;
}
.table {
  display: table;
  width: 100%;
  border-collapse: collapse;
  box-sizing: border-box;
}
.table-tr {
  display: table-row;
}
.table-th1 {
  width:10%;
  display: table-cell;
  font-weight: bold;
  border: 1rpx solid white;
  background-color:#51aad6;
  text-align: center;
  vertical-align: middle;
  padding: 5px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
}
.table-th2 {
  width:20%;
  display: table-cell;
  font-weight: bold;
  border: 1rpx solid white;
  background-color:#51aad6;
  text-align: center;
  vertical-align: middle;
  padding: 5px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
}
.table-th3 {
  width:15%;
  display: table-cell;
  font-weight: bold;
  border: 1rpx solid white;
  background-color:#51aad6;
  text-align: center;
  vertical-align: middle;
  padding: 5px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
}
.table-td1{
  width:10%;
  display: table-cell;
  text-align: center;
  vertical-align: middle;
  padding: 5px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
  border: 1rpx solid white;
  background-color:#aacee0;
}
.table-td2 {
  width:20%;
  display: table-cell;
  text-align: center;
  vertical-align: middle;
  padding: 5px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
  border: 1rpx solid white;
  background-color:#aacee0;
}
.table-td3 {
  width:15%;
  display: table-cell;
  text-align: center;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
  border: 1rpx solid white;
  background-color:#aacee0;
  /* padding: 5px 0; */
}
/* 輸入框的樣式 */
.input_position{
  display: flex;
  justify-content: center;
  align-items: center;
}
.input{
  background-color:rgb(255, 255, 255);
  width:70%;
  text-align:left;
}
/* 開(kāi)始訓(xùn)練的按鈕 */
.start{
  margin-top:10%;
  width:100%;
  display: flex;
  justify-content:center;
  align-items: center;
}
.button_text{
  background-color:rgb(245, 196, 196);
  width:90%;
  text-align:center;
  padding:2%;
}

js

①變更input,獲取表格的全部數(shù)據(jù)

event.currentTarget.dataset.index:獲取行信息

2°?event.detail.value:獲取輸入的數(shù)據(jù)值

3°?this.data.allinfo:獲取原數(shù)組的信息

4°?allinfo[index].begin_quantity = newValue;:找到修改的行的信息,將這一行對(duì)應(yīng)的文本框的值修改為用戶輸入的值

// 輸入框內(nèi)容改變時(shí),更新對(duì)應(yīng)數(shù)據(jù)
  inputChange: function (event) {
    var index = event.currentTarget.dataset.index;
    var newValue = event.detail.value;
    var allinfo = this.data.allinfo;
    allinfo[index].begin_quantity = newValue;
    this.setData({
      allinfo: allinfo
    });
    console.log(this.data.allinfo)
  },

②點(diǎn)擊開(kāi)始按鈕執(zhí)行事件

1°提示確認(rèn)圖片展示

點(diǎn)擊按鈕更改數(shù)據(jù)庫(kù),微信小程序,數(shù)據(jù)庫(kù),小程序

JSON.stringify(this.data.allinfo):將數(shù)組轉(zhuǎn)換為json格式便于后端處理

  //開(kāi)始生產(chǎn)
  start_produce(){
    wx.showModal({
      title:'生產(chǎn)確認(rèn)',
      content: '確認(rèn)生產(chǎn)'+this.data.order_number+'?',
      success:res=>{
        //點(diǎn)擊確認(rèn)
        if(res.confirm){
          wx.request({
            url: app.globalData.position + 'Produce/start_produce',
            data: {
              order_number: this.data.order_number,
              username: app.globalData.username,
              allinfo:JSON.stringify(this.data.allinfo)
            },
            header: {
              "Content-Type": "application/x-www-form-urlencoded"
            },
            method: 'POST',
            dataType: 'json',
            success: res => {
              console.log(res.data)
              this.onLoad()
            },
            fail(res) {
              console.log("查詢失敗")
            }
          })
        }
        //點(diǎn)擊取消
        else{
          console.log('用戶點(diǎn)擊了取消')
        }
      }
    })
  }

js完整代碼

const app = getApp()
Page({
  //數(shù)據(jù)信息
  data: {},
  //剛進(jìn)入頁(yè)面執(zhí)行的操作
  onLoad(options) {
    var pages = getCurrentPages()
    var currentPage = pages[pages.length - 1] //獲取當(dāng)前頁(yè)面的對(duì)象
    var options = currentPage.options //如果要獲取url中所帶的參數(shù)可以查看options
    this.setData({
      order_number: options.order_number
    })
    //查詢單號(hào)對(duì)應(yīng)的信息
    wx.request({
      url: app.globalData.position + 'Produce/select_operation',
      data: {
        order_number: this.data.order_number,
        username: app.globalData.username
      },
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      method: 'POST',
      dataType: 'json',
      success: res => {
        console.log(res.data)
        this.setData({
          allinfo: res.data.info,
          employee_name: res.data.employee_name
        })
      },
      fail(res) {
        console.log("查詢失敗")
      }
    })
    // console.log(options.order_number) 
  },
  // 輸入框內(nèi)容改變時(shí),更新對(duì)應(yīng)數(shù)據(jù)
  inputChange: function (event) {
    var index = event.currentTarget.dataset.index;
    var newValue = event.detail.value;
    var allinfo = this.data.allinfo;
    allinfo[index].begin_quantity = newValue;
    this.setData({
      allinfo: allinfo
    });
    console.log(this.data.allinfo)
  },
  //開(kāi)始生產(chǎn)
  start_produce(){
    wx.showModal({
      title:'生產(chǎn)確認(rèn)',
      content: '確認(rèn)生產(chǎn)'+this.data.order_number+'?',
      success:res=>{
        //點(diǎn)擊確認(rèn)
        if(res.confirm){
          wx.request({
            url: app.globalData.position + 'Produce/start_produce',
            data: {
              order_number: this.data.order_number,
              username: app.globalData.username,
              allinfo:JSON.stringify(this.data.allinfo)
            },
            header: {
              "Content-Type": "application/x-www-form-urlencoded"
            },
            method: 'POST',
            dataType: 'json',
            success: res => {
              console.log(res.data)
              this.onLoad()
            },
            fail(res) {
              console.log("查詢失敗")
            }
          })
        }
        //點(diǎn)擊取消
        else{
          console.log('用戶點(diǎn)擊了取消')
        }
      }
    })
  }
})

PHP

json_decode($_POST['allinfo'], true);將前端傳來(lái)的json格式的數(shù)組解析為普通數(shù)組

②對(duì)數(shù)組進(jìn)行循環(huán)

③獲取數(shù)組中每項(xiàng)對(duì)應(yīng)的id

④根據(jù)id,去修改數(shù)據(jù)庫(kù)中的單項(xiàng)值文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-601599.html

 public function start_produce(){
      $wip_entity_name = input('post.order_number');
      $username = input('post.username');
      $allinfo = json_decode($_POST['allinfo'], true);
      for($i = 0 ; $i<count($allinfo); $i++){
        //獲取數(shù)組中的每行的id
        $id = $allinfo[$i]['wip_operation_id'];
        // 更改數(shù)據(jù)庫(kù)中每站開(kāi)始數(shù)量的值
        db::table('wip_operation_plan')
        ->where(
          [
            'wip_operation_id'=>$id
          ]
        )
        ->update(
          [
            'begin_quantity'=>$allinfo[$i]['begin_quantity']
          ]
        );
       
      }
      $data['info'] = db::table('wip_operation_plan')->where(['wip_entity_name'=>$wip_entity_name])->select();
      echo json_encode($data);
    }

到了這里,關(guān)于微信小程序:表格中更改輸入框的值,實(shí)時(shí)獲取表格全部數(shù)據(jù),點(diǎn)擊按鈕更改數(shù)據(jù)庫(kù)指定項(xiàng)數(shù)據(jù)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • element-ui 表單中,下拉框選中某個(gè)值后,同步更新其他輸入框的值

    element-ui 表單中,下拉框選中某個(gè)值后,同步更新其他輸入框的值

    設(shè)置選擇后的@change事件 參考鏈接: https://www.cnblogs.com/zhangxue521/p/14518175.html

    2024年02月16日
    瀏覽(25)
  • 微信小程序(第七章)- 搜索框的實(shí)現(xiàn)

    外部容器i 內(nèi)部容器 兩者關(guān)系:外部容器包裹內(nèi)部容器,而且內(nèi)部容器正好在we外部容器的居中(水平垂直居中)位置。 可在微信小程序中使用view,可以在view里面定義內(nèi)容。 wxml文件 - html文件 wxss文件 - css文件 js文件 -js文件 json文件 - 配置文件 刪除index.wxml里面的demo(模板)代

    2024年02月09日
    瀏覽(22)
  • vue+Element UI 實(shí)現(xiàn)動(dòng)態(tài)表單(點(diǎn)擊按鈕增刪表格及嵌套輸入框的增刪)(1)

    vue+Element UI 實(shí)現(xiàn)動(dòng)態(tài)表單(點(diǎn)擊按鈕增刪表格及嵌套輸入框的增刪)(1)

    el-button size=“small” @click=“addTable”新增 el-button size=“small” @click=“delTable”刪除 el-table ref=“table” :data=“tableDataBind.taAssessltems” tooltip-effect=“dark” border @selection-change=“selectRow” 規(guī)格: 重量: 數(shù)量: 加工費(fèi): el-button size=“mini” type=“primary” icon=“el-icon-circle-plus-ou

    2024年04月13日
    瀏覽(36)
  • 關(guān)于微信小程序,如何更改微信小程序的名字

    關(guān)于微信小程序,如何更改微信小程序的名字

    當(dāng)我們前期開(kāi)始創(chuàng)作小程序的時(shí)候,因?yàn)闃I(yè)務(wù)范圍不確定也好,或者是隨便起了名字 在發(fā)布前或者發(fā)布后覺(jué)得不恰當(dāng)想要更改小程序的名字 ? 方法: 1.百度搜索\\\"微信公眾平臺(tái)\\\",或者直接進(jìn)入網(wǎng)址:?? 微信公眾平臺(tái) 微信公眾平臺(tái),給個(gè)人、企業(yè)和組織提供業(yè)務(wù)服務(wù)與用戶管理能力

    2024年02月09日
    瀏覽(24)
  • 微信小程序多列下拉框的實(shí)現(xiàn)(樹(shù)形數(shù)據(jù)結(jié)構(gòu)和單數(shù)組數(shù)據(jù)結(jié)構(gòu)形式)

    微信小程序多列下拉框的實(shí)現(xiàn)(樹(shù)形數(shù)據(jù)結(jié)構(gòu)和單數(shù)組數(shù)據(jù)結(jié)構(gòu)形式)

    利用微信小程序api,實(shí)現(xiàn)不同傳輸數(shù)據(jù)格式下的多列下拉框?qū)崿F(xiàn) 首先了解一下picker中的事件 這里是官方文檔,具體意思就是 當(dāng)你滑動(dòng)多列中的某一列的時(shí)候, bindcolumnchange 事件就會(huì)觸發(fā)。當(dāng)選擇完畢點(diǎn)擊確定的時(shí)候 bindchange 事件就會(huì)觸發(fā) 微信小程序的多列下拉框是真的反人

    2024年02月07日
    瀏覽(25)
  • 微信小程序更改頭像昵稱

    目錄 背景 解決思路 前面寫了一篇關(guān)于小程序頭像昵稱獲取更改的方案,有很多小伙伴私信我發(fā)一個(gè)整體的邏輯思路! 前面的這篇文章中我們給出了頁(yè)面中獲取頭像昵稱的代碼: 上方代碼中我們可以很清晰的看到用戶的頭像和昵稱,使用button和input輸入框來(lái)填充或者更改的。

    2024年02月09日
    瀏覽(22)
  • 微信小程序this.setData修改對(duì)象、數(shù)組中的值

    在微信小程序的[前端開(kāi)發(fā)]中,使用this.setData方法修改data中的值,其格式為: 需要注意的是,如果是簡(jiǎn)單變量,這里的參數(shù)名可以不加引號(hào)。 經(jīng)過(guò)測(cè)試,可以使用3種方式對(duì)data中的對(duì)象、數(shù)組中的數(shù)據(jù)進(jìn)行修改。 假設(shè)原數(shù)據(jù)為: 方式一: 使用字符串,例如: 方式二: 構(gòu)造

    2024年02月10日
    瀏覽(21)
  • 微信小程序checkbox,checkbox-group多選框的簡(jiǎn)易用法,代碼簡(jiǎn)潔,可復(fù)用性高

    首先這是官網(wǎng)的用法: 代碼非常的長(zhǎng),而且很難復(fù)用 (不能多個(gè)復(fù)選框共用這個(gè)checkboxChange方法) 劃分線,下面是更好的寫法 觸發(fā)checkboxChange的時(shí)候傳一個(gè)key值過(guò)去,之后值對(duì)應(yīng)的是一個(gè)新數(shù)組(與下面wx:for的數(shù)組不同),用來(lái)存放已選擇的項(xiàng) 因?yàn)?微信小程序中我們不能直

    2024年02月11日
    瀏覽(20)
  • 微信小程序button按鈕無(wú)法更改尺寸解決

    微信小程序button按鈕無(wú)法更改尺寸解決

    在微信小程序新版本中, button按鈕 無(wú)法支持在wxss文件中 直接自定義width 和 height? ?解決方法有兩種: ? ? ? ? 1. 推薦使用: 在根目錄中的app.json文件中, 刪除其中的 即可, 但影響性較大, 如果項(xiàng)目中的其他樣式 使用了新版本的特性, 則 刪除該行代碼后 項(xiàng)目中的其他樣式 可能會(huì)

    2024年02月15日
    瀏覽(91)
  • 微信小程序基礎(chǔ)庫(kù)的介紹與更改

    微信小程序基礎(chǔ)庫(kù)的介紹與更改

    一、什么是基礎(chǔ)庫(kù)? 1、基礎(chǔ)庫(kù)是小程序運(yùn)行的必要環(huán)境, 我們的開(kāi)發(fā)主要就是面向基礎(chǔ)庫(kù)開(kāi)發(fā)的 ?;A(chǔ)庫(kù)封裝了微信和手機(jī)的能力并提供給小程序使用,我們使用基礎(chǔ)庫(kù)提供的組件和API開(kāi)發(fā)起來(lái)非常的方便。 2、基礎(chǔ)庫(kù)存在于我們的微信客戶端中,它和微信一樣,也有其自

    2024年02月13日
    瀏覽(24)

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包