shish 2 лет назад
Родитель
Сommit
b4b2258dea
1 измененных файлов с 38 добавлено и 23 удалено
  1. 38 23
      ghs/src/views/order/add.vue

+ 38 - 23
ghs/src/views/order/add.vue

@@ -16,12 +16,27 @@
         <span>删除:Delete</span>
         <span>删除所有:Page Down</span>
       </p>
-      <el-table ref="singleTable" :data="tableData" highlight-current-row style="width: 100%" border :header-cell-style="{background:'#fdfdfd', color: '#01060a', fontWeight:800}" class="tableBox active">
-        <el-table-column prop="index" label="编号" width="190" align="center"></el-table-column>
+      <el-table ref="singleTable" :data="tableData" highlight-current-row style="width:95%" border :header-cell-style="{background:'#fdfdfd', color: '#01060a', fontWeight:800}" class="tableBox active">
+        <el-table-column prop="index" label="编号" width="120" align="center"></el-table-column>
+
+        <el-table-column prop="cover" label="图片" align="center" width="130">
+          <template slot-scope="scope">
+            <img :src="scope.row.cover" style="width:40px;margin:0 auto;" />
+          </template>
+        </el-table-column>
+
         <el-table-column prop="name" label="名称" align="center"></el-table-column>
         <el-table-column prop="price" label="单价" width="250" align="center"></el-table-column>
         <el-table-column prop="big" label="数量" width="250" align="center"></el-table-column>
-        <el-table-column prop="totalMoney" label="金额" width="250" align="center"></el-table-column>
+        <el-table-column prop="totalAmount" label="金额" width="250" align="center"></el-table-column>
+
+        <el-table-column prop="ratioType" label="单位比" align="center" width="180">
+          <template slot-scope="scope">
+            <span v-if="scope.row.ratioType == 0">{{ scope.row.ratio }}{{ scope.row.smallUnit }}/{{ scope.row.bigUnit }}</span>
+            <span v-else>若干{{ scope.row.smallUnit }}/{{ scope.row.bigUnit }}</span>
+          </template>
+        </el-table-column>
+
       </el-table>
     </div>
     <div class="seek-list-box" v-if="getItemList!=''">
@@ -39,17 +54,17 @@
     </div>
     <div class="bottom_input">
         <span style="margin-right:10px;font-weight: 700;">花材</span>
-        <el-input style="width: 280px;font-size:13px" @input="beginSearchItem" @keyup.enter.native="confirmCurrentItem" @focus="clearSeachVal" placeholder="这里搜索,光标插入 Ctrl + Q" type="text" ref="itemSearchRef" v-model="searchVal"></el-input>
-        <div style="display: inline-block;" class="allPrice">总金额:¥{{ parseFloat(totalMoney.toFixed(2)) }}</div>
-        <div style="display: inline-block;" class="allPrice">总数量:{{tableData.length}}</div>
+        <el-input style="width: 280px;font-size:13px" @input="beginSearchItem" @keyup.enter.native="selectCurrentItem" @focus="clearSeachVal" placeholder="这里搜索,光标插入 Ctrl + Q" type="text" ref="itemSearchRef" v-model="searchVal"></el-input>
+        <div style="display: inline-block;" class="allPrice">{{tableData.length}}种</div>
+        <div style="display: inline-block;" class="allPrice">¥{{ totalMoney }}</div>
         <div style="display: inline-block;" class="allPrice active"></div>
     </div>
 
     <el-dialog :title="getItemList[getIndex].name" v-if="showConfirmNum" :visible.sync="showConfirmNum" width="30%" center>
       <div class="el-dialog-center">
-        <el-input ref="bigInput" style="width: 130px;margin-left: 15px" placeholder="数量" @keyup.key-backspace.native="backspaceFun('big')" @keyup.enter.native="enterFun()" type="number" v-model="big"></el-input>
+        <el-input ref="bigInput" style="width: 130px;margin-left: 15px" placeholder="数量" @keyup.key-backspace.native="backspaceFun('big')" @keyup.enter.native="confirmNumPrice()" type="number" v-model="big"></el-input>
         <span>{{getItemList[getIndex].bigUnit}}</span>
-        <el-input style="width: 130px;margin-left: 15px" placeholder="价格" @keyup.key-backspace.native="backspaceFun('price')" @keyup.enter.native="enterFun()" type="number" v-model="price"></el-input>
+        <el-input style="width: 130px;margin-left: 15px" placeholder="价格" @keyup.key-backspace.native="backspaceFun('price')" @keyup.enter.native="confirmNumPrice()" type="number" v-model="price"></el-input>
         <span>元</span>
       </div>
       <div class="remark">Enter 确定,Backspace 清0,Esc 取消</div>
@@ -377,7 +392,7 @@ export default {
       this.searchVal = ''
       this.getItemList = []
     },
-    confirmCurrentItem(){
+    selectCurrentItem(){
       this.big = 1
       this.price = this.getItemList[this.getIndex].price
       this.isSeek = false;
@@ -418,18 +433,16 @@ export default {
         that.$refs.showItemRef.setCurrentRow(that.getItemList[0])
       }
     },
-    enterFun(){
+    confirmNumPrice(){
       let currentItem = this.getItemList[this.getIndex];
-      let big = this.big;
-      let small = this.small;
-      big==null?Number(0):big;
+      let big = this.big == null ? 0 : Number(this.big)
       if(big<=0){
         this.$message({message: '请先输入数量',type: 'warning'});
         return;
       }
       let money = Number(currentItem.price) * Number(big)
       for (let i=0;i<this.tableData.length;i++){
-        if(this.tableData[i].name==currentItem.name){
+        if(this.tableData[i].id == currentItem.id){
           this.tableData.splice(i,1)
         }
       }
@@ -438,14 +451,15 @@ export default {
             index:currentItem.id,
             id:currentItem.id,
             name:currentItem.name,
-            lv:currentItem.rank,
-            unit:currentItem.bigUnit+'/'+currentItem.smallUnit,
-            big:Number(big),
+            cover:currentItem.cover,
+            big:parseFloat(Number(big)),
             ratio:Number(currentItem.ratio),
-            stock:Number(currentItem.stock),
-            price:currentItem.price,
-            totalMoney:money.toFixed(2),
-            money:money,
+            ratioType:currentItem.ratioType,
+            bigUnit:currentItem.bigUnit,
+            smallUnit:currentItem.smallUnit,
+            stock:parseFloat(Number(currentItem.stock)),
+            price:parseFloat(Number(currentItem.price)),
+            totalAmount:money.toFixed(2)
           }
       )
       this.tableDataIndex = this.tableData.length-1;
@@ -459,9 +473,10 @@ export default {
     getAllTableDataMoney(){
       let totalMoney = 0;
       this.tableData.forEach(ele => {
-        totalMoney= totalMoney + ele.money
+        totalMoney= totalMoney + ele.totalAmount
       })
-      this.totalMoney = totalMoney;
+      totalMoney = Number(totalMoney)
+      this.totalMoney = parseFloat(totalMoney.toFixed(2))
       this.number = this.totalMoney
       this.modifyPrice = this.totalMoney;
     },