Forráskód Böngészése

Finish Hotfix-mo-76

莫绍宝 3 éve
szülő
commit
03aafc06dc

+ 27 - 4
src/views/supply/engin/components/engin_detail.vue

@@ -92,16 +92,33 @@
     </div>
 
     <div class="table" style="margin-top: 20px">
-      <el-table :data="detailData.items" element-loading-text="Loading" border fit highlight-current-row stripe max-height="400">
+      <el-table
+        :data="detailData.items"
+        element-loading-text="Loading"
+        border
+        fit
+        highlight-current-row
+        stripe
+        max-height="400"
+        show-summary
+        :summary-method="$getSummaries">
         <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
         <el-table-column align="center" label="销售类型" prop="saleTypeName" min-width="100" show-overflow-tooltip></el-table-column>
         <el-table-column align="center" label="产品编码" prop="materialNumber" min-width="160" show-overflow-tooltip></el-table-column>
         <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
         <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
         <el-table-column align="center" label="单位" prop="unit" min-width="100" show-overflow-tooltip></el-table-column>
-        <el-table-column align="center" label="单价" prop="price" min-width="100" show-overflow-tooltip></el-table-column>
-        <el-table-column align="center" label="数量" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
-        <el-table-column align="center" label="订单金额" prop="totalAmount" min-width="100" show-overflow-tooltip></el-table-column>
+        <el-table-column align="right" label="单价" prop="price" min-width="100" show-overflow-tooltip>
+          <template slot-scope="scope">
+            {{ scope.row.price | numToFixed }}
+          </template>
+        </el-table-column>
+        <el-table-column align="right" label="数量" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
+        <el-table-column align="right" label="订单金额" prop="totalAmount" min-width="100" show-overflow-tooltip>
+          <template slot-scope="scope">
+            {{ scope.row.totalAmount | numToFixed }}
+          </template>
+        </el-table-column>
         <el-table-column align="center" label="备注" prop="remark" min-width="200" show-overflow-tooltip></el-table-column>
         <el-table-column align="center" label="税率" prop="taxRate" min-width="100" show-overflow-tooltip></el-table-column>
       </el-table>
@@ -187,6 +204,12 @@ export default {
     // 获取详情
     getDetail() {
       getEnginDetail({id: this.listItem.enginInfoId}).then(res => {
+        if(res.data.items) {
+          res.data.items.forEach(item => {
+            item.sums1 = ['qty'];
+            item.sums2 = ['totalAmount', 'price'];
+          })
+        }
         this.detailData = res.data;
       })
     },

+ 270 - 70
src/views/supply/engin/components/engin_form.vue

@@ -151,39 +151,30 @@
 
     <div class="main-title">
       <div class="title">货品信息</div>
+      <div>
+        <el-button type="primary" size="small" icon="el-icon-plus" @click="openDialog">添加货品</el-button>
+      </div>
     </div>
 
     <div class="table" style="margin-top: 20px">
       <el-table :data="goodsList" element-loading-text="Loading" border fit highlight-current-row stripe max-height="400">
         <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
-        <el-table-column align="center" label="销售类型" prop="saleTypeId" min-width="160" show-overflow-tooltip>
+        <el-table-column align="center" label="销售类型" prop="saleTypeName" min-width="120" show-overflow-tooltip></el-table-column>
+        <el-table-column align="center" label="产品编码" prop="materialNumber" min-width="160" show-overflow-tooltip></el-table-column>
+        <el-table-column align="center" label="物料代码" prop="materialOldNumber" min-width="160" show-overflow-tooltip></el-table-column>
+        <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
+        <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip>
           <template slot-scope="scope">
-            <el-select v-model="scope.row.saleTypeId" placeholder="选择销售类型" size="small" @change="changeSaleType(scope.$index)">
-              <el-option
-                v-for="item in salesTypeList"
-                :key="item.id"
-                :label="item.saleName"
-                :value="item.id">
-              </el-option>
-            </el-select>
+            <el-input v-model="scope.row.specification" size="small" v-if="listItem"></el-input>
+            <div v-else>{{scope.row.specification}}</div>
           </template>
         </el-table-column>
-        <el-table-column align="center" label="产品名称" prop="materialNumber" min-width="160" show-overflow-tooltip>
+        <el-table-column align="center" label="单位" prop="unit" min-width="100" show-overflow-tooltip></el-table-column>
+        <el-table-column align="center" label="单价" prop="price" min-width="100" show-overflow-tooltip>
           <template slot-scope="scope">
-            <el-select v-model="scope.row.materialNumber" placeholder="选择产品" size="small" @change="changeGoods(scope.$index)" :disabled="!scope.row.saleTypeId">
-              <el-option
-                v-for="item in scope.row.productList"
-                :key="item.number"
-                :label="item.name"
-                :value="item.number">
-              </el-option>
-            </el-select>
+            <el-input v-model="scope.row.price" size="small" type="number"></el-input>
           </template>
         </el-table-column>
-        <el-table-column align="center" label="产品编码" prop="materialNumber" min-width="120" show-overflow-tooltip></el-table-column>
-        <el-table-column align="center" label="规格型号" prop="specification" min-width="200" show-overflow-tooltip></el-table-column>
-        <el-table-column align="center" label="单位" prop="unit" min-width="100" show-overflow-tooltip></el-table-column>
-        <el-table-column align="center" label="单价" prop="price" min-width="100" show-overflow-tooltip></el-table-column>
         <el-table-column align="center" label="数量" prop="qty" min-width="100" show-overflow-tooltip>
           <template slot-scope="scope">
             <el-input v-model="scope.row.qty" size="small" type="number"></el-input>
@@ -206,7 +197,6 @@
           </template>
         </el-table-column>
       </el-table>
-      <div class="add"><el-button type="text" icon="el-icon-plus" @click="addGoods">添加产品</el-button></div>
     </div>
 
     <div class="page-footer">
@@ -219,6 +209,93 @@
       </div>
     </div>
 
+    <el-dialog title="添加产品" :visible.sync="isShowGoodsDialog" width="80%">
+      <el-form ref="goodsScreenForm" :model="goodsScreenForm" size="small" label-position="left">
+        <el-row :gutter="20">
+          <el-col :xs="12" :sm="6" :lg="6">
+            <el-form-item prop="salesType">
+              <el-select v-model="goodsScreenForm.salesType" placeholder="选择销售类型" style="width: 100%" clearable>
+                <el-option v-for="item in salesTypeList" :key="item.id" :label="item.saleName" :value="item.id"></el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :xs="12" :sm="6" :lg="6">
+            <el-form-item prop="proNum">
+              <el-input v-model="goodsScreenForm.proNum" placeholder="请输入产品编码"></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :xs="12" :sm="6" :lg="6">
+            <el-form-item prop="proName">
+              <el-input v-model="goodsScreenForm.proName" placeholder="请输入产品名称"></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :xs="12" :sm="6" :lg="6">
+            <el-form-item prop="proModel">
+              <el-input v-model="goodsScreenForm.proModel" placeholder="请输入产品型号"></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :xs="12" :sm="6" :lg="6">
+            <el-form-item prop="price1"  style="display: flex">
+              <el-input v-model="goodsScreenForm.price1" placeholder="请输入价格" style="width: 46%"></el-input>
+              <span> - </span>
+              <el-input v-model="goodsScreenForm.price2" placeholder="请输入价格" style="width: 46%"></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :xs="12" :sm="18" :lg="18" class="tr">
+            <el-form-item label="">
+              <el-button size="small" @click="resetGoodsScreenForm">清空</el-button>
+              <el-button size="small" type="primary" @click="submitGoodsScreenForm">搜索</el-button>
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+
+      <div class="tables">
+        <div class="table">
+          <el-table :data="leftGoodsList" element-loading-text="Loading" border fit highlight-current-row stripe height="400" @selection-change="leftSelectionChange">
+            <el-table-column align="center" type="selection" width="55" :selectable='checkboxSelect'></el-table-column>
+            <el-table-column align="center" label="产品编码" prop="number" min-width="100" show-overflow-tooltip></el-table-column>
+            <el-table-column align="center" label="产品名称" prop="name" min-width="160" show-overflow-tooltip></el-table-column>
+            <el-table-column align="center" label="产品型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
+            <el-table-column align="center" label="产品价格" prop="batchPrice" min-width="80" show-overflow-tooltip></el-table-column>
+          </el-table>
+          <div class="pagination clearfix" style="margin-top: 10px">
+            <div class="fr">
+              <el-pagination
+                @current-change="handleTableCurrentChange"
+                :current-page="currentPage"
+                :page-size="10"
+                background
+                layout="prev, pager, next"
+                :total="listTotal">
+              </el-pagination>
+            </div>
+          </div>
+        </div>
+        <div class="buttons">
+          <el-button size="small" type="primary" @click="addAllGoods">全部添加</el-button>
+          <el-button size="small" type="primary" @click="addGoods">添&emsp;加</el-button>
+          <el-button size="small" type="danger" @click="deleteGoods">删&emsp;除</el-button>
+          <el-button size="small" type="danger" @click="deleteAllGoods">全部删除</el-button>
+        </div>
+        <div class="table">
+          <el-table :data="rightGoodsList" element-loading-text="Loading" border fit highlight-current-row stripe height="400" @selection-change="rightSelectionChange">
+            <el-table-column align="center" type="selection" width="55"></el-table-column>
+            <el-table-column align="center" label="产品编码" prop="number" min-width="100" show-overflow-tooltip></el-table-column>
+            <el-table-column align="center" label="产品名称" prop="name" min-width="160" show-overflow-tooltip></el-table-column>
+            <el-table-column align="center" label="产品型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
+            <el-table-column align="center" label="产品价格" prop="batchPrice" min-width="80" show-overflow-tooltip></el-table-column>
+          </el-table>
+        </div>
+      </div>
+
+
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="closeDialog">取 消</el-button>
+        <el-button type="primary" @click="submitAddGoods">确 定</el-button>
+      </span>
+    </el-dialog>
+
   </div>
 </template>
 
@@ -272,8 +349,25 @@ export default {
 
       typeList: [],
       salesTypeList: [],
-      retailProductList: [],
       salesmanList: [],
+
+      isShowGoodsDialog: false,
+      goodsScreenForm: {
+        proNum: '',
+        proName: '',
+        proModel: '',
+        price1: '',
+        price2: '',
+        salesType: '',
+      },
+      currentPage: 1,
+      listTotal: 0,
+
+      leftGoodsList: [],
+      rightGoodsList: [],
+
+      leftSelection: [],
+      rightSelection: [],
     }
   },
 
@@ -340,10 +434,6 @@ export default {
         this.mainForm.contractDate = data.contractExpireDate;
 
         this.goodsList = data.items;
-
-        for (let i = 0; i < this.goodsList.length; i++) {
-          this.getRetailProductList(i);
-        }
       })
     },
 
@@ -375,53 +465,152 @@ export default {
     },
 
     // 获取商品列表
-    getRetailProductList(index) {
+    getGoodsList() {
       getRetailProductList({
-        pageNum: 1,
-        pageSize: -1,
-        saleId: this.goodsList[index].saleTypeId
+        pageNum: this.currentPage,
+        pageSize: 10,
+        saleId: this.goodsScreenForm.salesType,
+        materialCode: this.goodsScreenForm.proNum,
+        materialName: this.goodsScreenForm.proName,
+        specification: this.goodsScreenForm.proModel,
+        price1: this.goodsScreenForm.price1,
+        price2: this.goodsScreenForm.price2,
       }).then(res => {
-        let item = this.goodsList[index];
-        item.productList = res.data.records;
-        this.$set(this.goodsList, index, item);
+        let oldGoodsList = this.goodsList;
+        let newGoodsList = res.data.records;
+        for(let i = 0; i < oldGoodsList.length; i++) {
+          let oldItem = oldGoodsList[i]
+          for(let j = 0; j < newGoodsList.length; j++) {
+            let newItem = newGoodsList[j]
+            if(newItem.id === oldItem.id){
+              newGoodsList[j].selected = true;
+              break;
+            }
+          }
+        }
+        res.data.records.forEach(item => {
+          item.materialName = item.name;
+          item.materialCode = item.number;
+          item.saleTypeName = item.saleName;
+          item.unit = item.baseUnit;
+          item.price = item.batchPrice;
+          item.tax = item.taxRate;
+          item.isDirectTransfer = false;
+          item.directTransferQty = '';
+          item.status1 = '';
+          item.status2 = '';
+          item.rebateAmount = '';
+          item.rebateRate = '';
+          item.productPriceId = item.id;
+          // item.customerWalletId = (item.wallets && item.wallets.length) ? item.wallets[0].customerWalletId : '';
+        });
+        this.leftGoodsList = res.data.records;
+        this.listTotal = res.data.total;
       })
     },
 
-    // 修改销售类型
-    changeSaleType(index) {
-      if(this.goodsList[index].saleTypeId) {
-        let obj = this.salesTypeList.find(o => o.id == this.goodsList[index].saleTypeId);
-        this.goodsList[index].saleTypeName = obj.saleName;
-        this.goodsList[index].saleTypeCode = obj.saleCode;
+    // 查询重复值并禁选
+    checkboxSelect(row, rowIndex) {
+      if (row.selected) {
+        return false // 禁用
+      }else{
+        return true // 不禁用
       }
-      this.goodsList[index].materialNumber = '';
-      this.goodsList[index].materialName = '';
-      this.goodsList[index].materialId = '';
-      this.goodsList[index].specification = '';
-      this.goodsList[index].unit = '';
-      this.goodsList[index].price = '';
-      this.goodsList[index].taxRate = '';
-      this.getRetailProductList(index);
     },
 
-    // 修改产品
-    changeGoods(index) {
-      if(this.goodsList[index].materialNumber) {
-        let obj = this.goodsList[index].productList.find(o => o.number == this.goodsList[index].materialNumber);
-        let item = this.goodsList[index];
-        item.materialName = obj.name;
-        item.materialId = obj.materialId;
-        item.specification = obj.specification;
-        item.unit = obj.unit;
-        item.price = obj.batchPrice;
-        item.taxRate = obj.taxRate;
-        this.$set(this.goodsList, index, item);
+    // 点击 选择商品
+    openDialog() {
+      this.isShowGoodsDialog = true;
+      this.getGoodsList();
+    },
+
+    // 提交筛选表单
+    submitGoodsScreenForm() {
+      this.currentPage = 1;
+      this.getGoodsList();
+    },
+
+    // 重置筛选表单
+    resetGoodsScreenForm() {
+      this.$refs.goodsScreenForm.resetFields();
+      this.currentPage = 1;
+      this.getGoodsList();
+    },
+
+    // 更改列表当前页
+    handleTableCurrentChange(val) {
+      this.currentPage = val;
+      this.getGoodsList();
+    },
+
+    // 关闭 弹窗
+    closeDialog() {
+      this.isShowGoodsDialog = false;
+    },
+
+    // 左侧列表选择
+    leftSelectionChange(val) {
+      this.leftSelection = val;
+    },
+
+    // 右侧列表选择
+    rightSelectionChange(val) {
+      this.rightSelection = val;
+    },
+
+    // 数组去重
+    delRepeat(arr1, arr2) {
+      let allArr = arr1.concat(arr2); // 两个数组对象合并
+      let newArr = []; // 存放去重后数据的新数组
+      for(let i=0; i<allArr.length; i++){  // 循环allArr数组对象的内容
+        let flag = true;  // 建立标记,判断数据是否重复,true为不重复
+        for(let j=0; j<newArr.length; j++){  // 循环新数组的内容
+          if(allArr[i].id == newArr[j].id){ // 让allArr数组对象的内容与新数组的内容作比较,相同的话,改变标记为false
+            flag = false;
+          }
+        }
+        if(flag){ // 判断是否重复
+          newArr.push(allArr[i]); // 不重复的放入新数组。  新数组的内容会继续进行上边的循环。
+        }
       }
+      return newArr;
+    },
+
+    // 全部添加
+    addAllGoods() {
+      this.rightGoodsList = this.delRepeat(this.leftGoodsList, this.rightGoodsList);
     },
 
-    // 添加产品
+    // 添加
     addGoods() {
-      this.goodsList.push({})
+      this.rightGoodsList = this.delRepeat(this.leftSelection, this.rightGoodsList);
+    },
+
+    // 删除
+    deleteGoods() {
+      let rightGoodsList = this.rightGoodsList;
+      let rightSelection = this.rightSelection;
+      for(let i = 0; i < rightGoodsList.length; i++) {
+        for(let j = 0; j < rightSelection.length; j++) {
+          if(rightSelection[j].materialId == rightGoodsList[i].materialId){
+            this.rightGoodsList.splice(i, 1);
+          }
+        }
+      }
+    },
+
+    // 全部删除
+    deleteAllGoods() {
+      this.rightGoodsList = [];
+    },
+
+    // 确定 添加产品
+    submitAddGoods() {
+      // this.goodsList = this.delRepeat(this.rightGoodsList, this.goodsList);
+      this.goodsList = this.goodsList.concat(this.rightGoodsList);
+      this.isShowGoodsDialog = false;
+      this.leftGoodsList = [];
+      this.rightGoodsList = [];
     },
 
     // 删除产品
@@ -453,6 +642,7 @@ export default {
             delete item.productList;
           })
 
+          let saleManItem = this.mainForm.salesMan ? this.salesmanList.find(o => o.adminUserId == this.mainForm.salesMan) : '';
           let params = {
             // orderDate: this.mainForm.orderDate + ' 00:00:00',
             // mainId: this.mainForm.mainId,
@@ -466,6 +656,7 @@ export default {
             linkman: this.mainForm.linkman,
             phone: this.mainForm.phone,
             serviceId: this.mainForm.salesMan,
+            serviceName: saleManItem.nickName,
             tel: this.mainForm.tel,
             remark: this.mainForm.remark,
             contractExpireDate: this.mainForm.contractDate,
@@ -522,14 +713,23 @@ export default {
       padding-left: 10px;
     }
   }
-
-  .add {
+  .tables {
     display: flex;
-    align-items: center;
-    justify-content: center;
-    border: 1px solid #EBEEF5;
-    border-top: none;
-    height: 50px;
+    margin-top: 10px;
+    .table {
+      width: 45%;
+    }
+    .buttons {
+      display: flex;
+      flex-direction: column;
+      justify-content: center;
+      align-items: center;
+      padding: 0 10px;
+      button {
+        margin: 0;
+        margin-top: 10px;
+      }
+    }
   }
 
   ::v-deep input::-webkit-outer-spin-button,