Quellcode durchsuchen

【新增】调整工程信息单-审批

莫绍宝 vor 3 Jahren
Ursprung
Commit
734204b786

+ 298 - 59
src/views/supply/engin/components/engin_examine.vue

@@ -91,49 +91,45 @@
         </el-col>
         <el-col :span="16" class="item">
           <div class="label">备注</div>
-          <div class="value">{{detailData.remark}}</div>
+          <div class="value">
+            <el-input v-model="detailData.remark" placeholder="请输入备注"></el-input>
+          </div>
         </el-col>
         <el-col :span="8" class="item">
           <div class="label">业务员</div>
-          <div class="value">{{detailData.serviceName}}</div>
+          <div class="value">
+            <el-select v-model="detailData.serviceId" placeholder="选择业务员" size="small" filterable clearable style="width: 100%">
+              <el-option
+                v-for="item in salesmanList"
+                :key="item.adminUserId"
+                :label="item.nickName"
+                :value="item.adminUserId">
+              </el-option>
+            </el-select>
+          </div>
         </el-col>
       </el-row>
     </div>
 
     <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="120" show-overflow-tooltip></el-table-column>
+        <el-table-column align="center" label="产品编码" prop="materialOldNumber" min-width="120" 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"></el-input>
           </template>
         </el-table-column>
-        <el-table-column align="center" label="产品名称" prop="materialNumber" min-width="160" show-overflow-tooltip>
-          <template slot-scope="scope">
-            <el-select v-model="scope.row.materialNumber" placeholder="选择产品" size="small" @change="changeGoods(scope.$index)">
-              <el-option
-                v-for="item in retailProductList"
-                :key="item.id"
-                :label="item.name"
-                :value="item.number">
-              </el-option>
-            </el-select>
-          </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="materialOldNumber" 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>
           <template slot-scope="scope">
@@ -162,7 +158,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="main-title">
@@ -203,12 +198,99 @@
       </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>
 
 <script>
 import { getEnginDetail, getRetailProductList, examineEngin } from "@/api/supply/engin";
-import { getTypeList } from "@/api/common";
+import { getTypeList, getSalesmanList } from "@/api/common";
 
 export default {
   name: 'EnginExamine',
@@ -240,14 +322,32 @@ export default {
       },
 
       salesTypeList: [],
-      retailProductList: [],
+      salesmanList: [],
+      
+      isShowGoodsDialog: false,
+      goodsScreenForm: {
+        proNum: '',
+        proName: '',
+        proModel: '',
+        price1: '',
+        price2: '',
+        salesType: '',
+      },
+      currentPage: 1,
+      listTotal: 0,
+
+      leftGoodsList: [],
+      rightGoodsList: [],
+
+      leftSelection: [],
+      rightSelection: [],
     }
   },
 
   created() {
     this.getDetail();
     this.getTypeList();
-    this.getRetailProductList();
+    this.getSalesmanList();
   },
 
   methods: {
@@ -274,42 +374,164 @@ export default {
       });
     },
 
-    // 获取商品列表
-    getRetailProductList() {
-      getRetailProductList({
+    getSalesmanList() {
+      getSalesmanList({
         pageNum: 1,
         pageSize: -1,
+        isCustomer: 0,
+        status: true,
+      }).then(res => {
+        this.salesmanList = res.data.records;
+      })
+    },
+
+    // 获取商品列表
+    getGoodsList() {
+      getRetailProductList({
+        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 => {
-        this.retailProductList = res.data.records;
+        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 // 不禁用
       }
     },
 
-    // 修改产品
-    changeGoods(index) {
-      if(this.goodsList[index].materialNumber) {
-        let obj = this.retailProductList.find(o => o.number == this.goodsList[index].materialNumber);
-        this.goodsList[index].materialName = obj.name;
-        this.goodsList[index].materialId = obj.materialId;
-        this.goodsList[index].specification = obj.specification;
-        this.goodsList[index].baseUnitId = obj.baseUnit;
-        this.goodsList[index].price = obj.batchPrice;
-        this.goodsList[index].taxRate = obj.taxRate;
-        this.goodsList[index].mainId = obj.mainId;
+    // 点击 选择商品
+    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 = [];
     },
 
     // 删除产品
@@ -318,6 +540,10 @@ export default {
     },
 
     clickSubmitForm() {
+      if(!this.detailData.serviceId) {
+        return this.$errorMsg('请选择业务员');
+      }
+      let saleManItem = this.detailData.serviceId ? this.salesmanList.find(o => o.adminUserId == this.detailData.serviceId) : '';
       this.formLoading = true;
       examineEngin({
         enginInfoId: this.listItem.enginInfoId,
@@ -325,6 +551,9 @@ export default {
         examineResult: this.examineForm.examineResult,
         examineNote: this.examineForm.remark,
         contractExpireDate: this.detailData.contractExpireDate,
+        serviceId: this.detailData.serviceId,
+        serviceName: saleManItem.nickName,
+        remark: this.detailData.remark,
         items: this.goodsList,
       }).then(res => {
         this.$successMsg('审批成功');
@@ -359,13 +588,23 @@ export default {
     }
   }
 
-  .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,

+ 1 - 1
src/views/supply/retail/components/retail_form.vue

@@ -90,7 +90,7 @@
         <el-table-column align="center" label="单位" prop="unit" 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">
-            <el-input v-model="scope.row.price" size="small" type="number" v-if="listItem && !isDealer"></el-input>
+            <el-input v-model="scope.row.price" size="small" type="number" v-if="listItem"></el-input>
             <div v-else>{{scope.row.price}}</div>
           </template>
         </el-table-column>