zx 1 سال پیش
والد
کامیت
9746e8d203
1فایلهای تغییر یافته به همراه394 افزوده شده و 53 حذف شده
  1. 394 53
      fhKeeper/formulahousekeeper/timesheet-workshop/src/views/product/list.vue

+ 394 - 53
fhKeeper/formulahousekeeper/timesheet-workshop/src/views/product/list.vue

@@ -32,10 +32,73 @@
             </el-form>
         </el-col>
         <!--列表-->
-        <el-table ref="productTbl" v-if="showTable" @cell-mouse-enter="hoverCall" @cell-mouse-leave="handCall" :cell-class-name="tableCellClassName"  :default-expand-all="defaultExpandAllFlg" :data="list" highlight-current-row v-loading="listLoading" :height="tableHeight" style="width: 100%;" @sort-change="tableSort">
-            <el-table-column type="expand" :label="''">
-                
+        <el-table ref="productTbl" v-if="showTable" @cell-mouse-enter="hoverCall" @cell-mouse-leave="handCall" :cell-class-name="tableCellClassName"  :default-expand-all="defaultExpandAllFlg" :data="list" highlight-current-row v-loading="listLoading" :height="tableHeight" style="width: 100%;" @sort-change="tableSort" @expand-change="expandChange"  >
+            <!-- todo 展开 -->
+            <el-table-column type="expand">
+                <template slot-scope="props">
+                    <el-form label-position="left" inline class="demo-table-expand">
+                        <el-form-item label="派工单">
+                            <span>版本号</span>
+                            <el-select v-model="procedureVersion" placeholder="请选择版本号">
+                                 <el-option
+                                    v-for="item in props.row.tableProdProcedure.versions"
+                                    :key="item"
+                                    :label="item"
+                                    :value="item">
+                                </el-option>
+                            </el-select>
+                        </el-form-item>
+                        <el-form-item >
+                            <template>
+                                <el-table
+                                    :data="props.row.tableProdProcedure.procedureList"
+                                    border
+                                    style="width: 100%">
+                                    <el-table-column
+                                    prop="name"
+                                    label="工序名称"
+                                    width="180">
+                                    </el-table-column>
+                                    <el-table-column
+                                    prop="unitPrice"
+                                    label="单件工时"
+                                    width="180">
+                                    </el-table-column>
+                                    <el-table-column
+                                    prop="workingTime"
+                                    label="单件工价">
+                                    </el-table-column>
+                                    <el-table-column
+                                    prop="checkType"
+                                    label="质检类型">
+                                    <span v-if="checkType==0">自检</span>
+                                    <span v-if="checkType == 1">互检</span>
+                                    <span v-if="checkType == 2">专检</span>
+                                    </el-table-column>
+                                </el-table>
+                            </template>
+                        </el-form-item>
+                        <el-form-item label="商品 ID">
+                            <span>{{ props.row.id }}</span>
+                        </el-form-item>
+                        <el-form-item label="店铺 ID">
+                            <span>{{ props.row.shopId }}</span>
+                        </el-form-item>
+                        <el-form-item label="商品分类">
+                            <span>{{ props.row.category }}</span>
+                        </el-form-item>
+                        <el-form-item label="店铺地址">
+                            <span>{{ props.row.address }}</span>
+                        </el-form-item>
+                        <el-form-item label="商品描述">
+                            <span>{{ props.row.desc }}</span>
+                        </el-form-item>
+                    </el-form>
+                </template>
             </el-table-column>
+
+
+
             <el-table-column prop="name" label="产品名称" sortable="custom" width="300"></el-table-column>
             <el-table-column prop="code" label="项目代码" width="200" ></el-table-column>
             <el-table-column prop="orderNumber" label="订单数量" width="100" ></el-table-column>
@@ -122,61 +185,115 @@
                 </div>
                 <div v-if="prodEditActive == 1" >
                     <!--此处是录入工序的模块-->
-                    <el-input placeholder="请输入工序版本号"></el-input>
-                    <el-table :data="projectProfessionList" size="small" :key="Math.random()" :height="'400px'">
-                        <el-table-column prop="professionId" width="200">
-                            <template slot-scope="scope">
-                                <el-select v-model="scope.row.professionId" >
-                                    <el-option v-for="item in professionList" :key="item.id" :label="item.name" :value="item.id"/>
-                                </el-select>
-                            </template>
-                            <template slot="header" >
-                                <span style="font-size:14px;font-weight:normal;">{{ $t('nameprofessional') }}</span>
-                            </template>
-                        </el-table-column>
-                        <el-table-column prop="percentage" width="120" :label="$t('zhan-bi')">
-                            <template slot-scope="scope">
-                                <div><el-input type="number" v-model="scope.row.percentage"></el-input></div>
-                            </template>
-                        </el-table-column>
-                        
-                        <el-table-column prop="membNames" :label="$t('personnelproportion')">
-                            <template slot-scope="scope">
-                                <span style="margin:0 5px;" v-for="item in scope.row.membList" :key="item.membId">
-                                        <span v-if="user.userNameNeedTranslate != 1">{{item.membName}}({{item.percentage}}%)</span>
-                                        <span v-if="user.userNameNeedTranslate == 1"><ww-open-data type='userName' :openid='item.membName'></ww-open-data>({{item.percentage}}%)</span>
-                                    </span>
-                                <el-link @click="showEditPpMembs(scope.row)">{{(scope.row.membList == null || scope.row.membList.length == 0)?$t('professionalparticipants'):$t('setup')}}</el-link>
-                            </template>
-                        </el-table-column>
-                        <el-table-column prop="inchargerName" width="200" :label="$t('head')">
-                            <template slot-scope="scope">
-                                <el-select v-model="scope.row.inchargerId" v-if="user.userNameNeedTranslate != 1">
-                                    <el-option v-for="item in participator" :key="item.id" :label="item.name" :value="item.id"></el-option>
-                                </el-select>
-
-                                <selectCat v-if="user.userNameNeedTranslate == 1" :size="'mini'" :subject="participator" :subjectId="scope.row.inchargerId" :other="scope.$index" :distinction="'4'" @selectCal="selectCal"></selectCat>
-
-                            </template>
-                        </el-table-column>
-                        <el-table-column  width="80">
-                            <template slot-scope="scope">
-                                <el-button icon="el-icon-delete" size="mini" style="margin-left:10px;" @click.stop.native="deleteItem(scope.$index)"></el-button>
-                            </template>
-                            <template slot="header" >
-                                <el-link type="primary" :underline="false" @click="addItem">{{ $t('addTian') }}</el-link>
-                            </template>
-                        </el-table-column>
-                    </el-table>
+                    <el-input placeholder="请输入工序版本号"  v-model="procedureVersion" class="input-pM"></el-input>
+                            <el-table :data="procedureLit"  style="width: 100%">
+                                 <el-table-column
+                                    prop="name"
+                                    label="工序名称"
+                                    width="180">
+                                    <template slot-scope="scope">
+                                        <el-input v-model="scope.row.name" placeholder="请输入"></el-input>
+                                    </template>
+                                </el-table-column>
+                                <el-table-column
+                                    prop="unitPrice"
+                                    label="单件工时"
+                                    width="180">
+                                    <template slot-scope="scope">
+                                        <el-input v-model="scope.row.unitPrice" placeholder="请输入"></el-input>
+                                    </template>
+                                </el-table-column>
+                                <el-table-column
+                                    prop="workingTime"
+                                    label="单件工价">
+                                    <template slot-scope="scope">
+                                        <el-input v-model="scope.row.workingTime" placeholder="请输入"></el-input>
+                                    </template>
+                                </el-table-column>
+                                <el-table-column
+                                    prop="checkType"
+                                    label="质检类型">
+                                    <template slot-scope="scope">
+                                        <el-input v-model="scope.row.checkType" placeholder="请输入"></el-input>
+                                    </template>
+                                </el-table-column>
+                                 <el-table-column label="操作" width="100"  fixed="right" >
+                                    <template slot-scope="scope">
+                                        <el-button size="mini" @click="deleteProcedure(scope.$index, scope.row)">删除</el-button>
+                                    </template>
+                                </el-table-column>
+                            </el-table>
+                            <i class="el-icon-plus" @click="addProcedure()"></i>
+                    
                 </div>
                 <div v-if="prodEditActive == 2" >
                     <!--此处是录入物料的模块-->
-                    <el-input placeholder="请输入物料版本号"></el-input>
+                   
+                        <el-input placeholder="请输入物料版本号" v-model="prodMaterialVersion" class="input-pM"></el-input>
+                        <el-table :data="prodMaterialList"  style="width: 100%">
+                             <el-table-column
+                                prop="name"
+                                label="零件名称"
+                                width="180">
+                                <template slot-scope="scope">
+                                    <el-input v-model="scope.row.name" placeholder="请输入"></el-input>
+                                </template>
+                            </el-table-column>
+                            <el-table-column
+                                prop="companyCode"
+                                label="公司编码"
+                                width="180">
+                                <template slot-scope="scope">
+                                    <el-input v-model="scope.row.companyCode" placeholder="请输入"></el-input>
+                                </template>
+                            </el-table-column>
+                            <el-table-column
+                                prop="companyDrawingNo"
+                                label="公司图号">
+                                <template slot-scope="scope">
+                                    <el-input v-model="scope.row.companyDrawingNo" placeholder="请输入"></el-input>
+                                </template>
+                            </el-table-column>
+                            <el-table-column
+                                prop="materialQuality"
+                                label="材质">
+                                <template slot-scope="scope">
+                                    <el-input v-model="scope.row.materialQuality" placeholder="请输入"></el-input>
+                                </template>
+                            </el-table-column>
+                             <el-table-column
+                                prop="thickness"
+                                label="厚度">
+                                <template slot-scope="scope">
+                                    <el-input v-model="scope.row.thickness" placeholder="请输入"></el-input>
+                                </template>
+                            </el-table-column>
+                             <el-table-column
+                                prop="numberProduct"
+                                label="数量(个/产品)">
+                                <template slot-scope="scope">
+                                    <el-input v-model="scope.row.numberProduct" placeholder="请输入"></el-input>
+                                </template>
+                            </el-table-column>
+                             <el-table-column
+                                    prop="numberVehicle"
+                                    label="数量(个/辆)">
+                                    <template slot-scope="scope">
+                                        <el-input v-model="scope.row.numberVehicle" placeholder="请输入"></el-input>
+                                    </template>
+                                </el-table-column>
+                             <el-table-column label="操作" width="100"  fixed="right" >
+                                <template slot-scope="scope">
+                                    <el-button size="mini" @click="deleteMaterial(scope.$index, scope.row)">删除</el-button>
+                                </template>
+                            </el-table-column>
+                        </el-table>
+                        <i class="el-icon-plus" @click="addMaterial()"></i>
                 </div>
                 
             <div slot="footer" class="dialog-footer;">
                 <el-button @click.native="deletePro(1, addForm)" v-if="addForm.id" style="float:left">{{ $t('btn.delete') }}</el-button>
-                <el-button @click.native="addFormVisible = false">{{ $t('btn.cancel') }}</el-button>
+                <el-button @click.native="prodEditActive = 0;addFormVisible = false ">{{ $t('btn.cancel') }}</el-button>
                 <el-button v-if="prodEditActive == 0" type="primary" @click="submitInsert(0)" :loading="addLoading">保存</el-button>
                 <el-button v-if="prodEditActive == 0" type="primary" @click="submitInsert(1)" :loading="addLoading">保存并编辑工序</el-button>
                 <el-button v-if="prodEditActive == 1" type="primary" @click="submitSequence(0)" :loading="addLoading">保存工序</el-button>
@@ -399,6 +516,9 @@ a {
 .router-link-active {
   text-decoration: none;
 }
+.input-pM{
+    width: 50%;
+}
 </style>
 <script>
     import util from "../../common/js/util";
@@ -410,7 +530,19 @@ a {
         },
         data() {
             return {
+
+        
+                procedureVersion: "",
+                prodMaterialVersion: "",
+                //项目展开的详情
+                procedureVersions: [],  //产品的工序版本集合
+                prodMaterialVersions: [],  //产品的物料版本集合
+                procedureLit: [],//当前版本的工序集合
+                prodMaterialList: [],  //当前版本的物料集合
+
+                
                 prodEditActive: 0,
+                productId: null,
                 cateName: null,
                 cateId: null,
                 name: null,
@@ -492,7 +624,18 @@ a {
                 total: 0,
                 page: 1,
                 size: localStorage.getItem("projectPageSize")==null?20:parseInt(localStorage.getItem("projectPageSize")),
-                list: [],
+                list: [
+                    {
+                        tableProdProcedure:{
+                            versions: [],
+                            procedureList: []
+                        },
+                        tableProdMaterial: {
+                             versions: [],
+                             materialList: []
+                        }
+                    }
+                ],
                 subProjectVisible: false,
                 subProjectList: [],//子项目列表
                 currentProject:{},
@@ -658,6 +801,194 @@ a {
             })
         },
         methods: {
+             // 获取row的key值
+            getRowKeys(row) {
+                return row.id;
+            },
+             // 展开事件----动态获取内嵌表数据(项目)
+        expandChange(row, expandedRows) {
+            // 该处是用于判断是展开还是收起行,只有展开的时候做请求,避免多次请求!
+            // 展开的时候expandedRows有值,收起的时候为空.
+            if (expandedRows.length > 0) {
+
+                 let index = null
+                for (var i in this.list) {
+                    if (this.list[i].id === row.id) {
+                        index = i
+                        break
+                    }
+                }
+                console.log(index, '索引')
+                this.http.post("/prod-procedure/getVersions", { productId: row.id },
+                    res => {
+                        console.log("=======1", this.list[index])
+                        //console.log("version", this.procedureVersion)
+                        this.list[index].tableProdProcedure.versions = res.data
+                        this.procedureVersion = res.data[res.data.length - 1]
+                        getProdProcedureVersion(row.id, index)
+                        console.log("version",this.procedureVersion)
+                    })
+                this.http.post("/prod-material/getVersions", { productId: row.id },
+                    res => {
+                        this.list[index].tableProdMaterial.versions = res.data
+                        this.prodMaterialVersion = res.data[res.data.length - 1]
+                        getProdProcedureVersion(row.id, index)
+                    })
+            }
+        },
+            getProdProcedureVersion(id,index){
+                this.http.post("/prod-procedure/getInfo",{ version: this.procedureVersion,productId: id },
+                res=>{
+                    this.list[index].tableProdProcedure.procedureList=res.data;
+                })
+            },
+             getProdMaterialVersion( id,index) {
+                this.http.post("/prod-material/getInfo", { version: this.prodMaterialVersion, productId: id },
+                 res => {
+                    this.list[index].tableProdMaterial.materialList = res.data;
+                })
+            },
+            submitSequence(addSequence){
+                this.addLoading = true;
+                let procedureString =JSON.stringify(this.procedureLit);
+            this.http.post('/prod-procedure/changeProdProcedure', {
+                productId: this.productId,
+                version: this.procedureVersion,
+                prodProcedures: procedureString
+            },
+                res => {
+                    this.addLoading = false;
+                    if (res.code == "ok") {
+                        this.$message({
+                            message: (this.addForm.id != null ? this.$t('xiu-gai') : this.$t('create')) + this.$t('other.successful'),
+                            type: "success"
+                        });
+                        if (addSequence) {
+                            //进入物料录入
+                           
+                            this.http.post('/prod-material/getProdMaterialList', { productId: this.productId },
+                                res => {
+                                    this.prodMaterialList = res.data.prodMaterialList;
+                                    this.prodMaterialVersion = res.data.version;
+                                })
+                            this.prodEditActive = 2;
+                            
+                            
+                        } else {
+                            this.addFormVisible = false;
+                        }
+                    } else {
+                        this.$message({
+                            message: res.msg,
+                            type: "error"
+                        });
+                    }
+                },
+                error => {
+                    this.addLoading = false;
+                    this.$message({
+                        message: error,
+                        type: "error"
+                    });
+                });
+              
+            },
+
+            //删除工序
+            deleteProcedure(index,row){
+                if(row.id!=null){
+                    this.http.get("/prod-procedure/isDelete",row.id,
+                    res=>{
+                        if(!res.data){
+                            this.procedureLit.splice(index, 1)
+                        }else{
+                            this.$message({
+                                message: '该工序已被使用,不能删除',
+                                type: 'warning'
+                            });
+                        }
+                    })
+                }else{
+                     this.procedureLit.splice(index, 1)
+                }
+                
+            },
+            // 向表格中添加数据
+            addProcedure() {
+                this.procedureLit = [...this.procedureLit, {
+                    name: '',
+                    unitPrice: '',
+                    workingTime: '',
+    
+                }]
+            },
+             // 向表格中添加数据
+            addMaterial() {
+                this.prodMaterialList = [...this.prodMaterialList, {
+                    name: '',
+                    companyCode: '',
+                    companyDrawingNo: '',
+                    materialQuality: '',
+                    thickness: '',
+                    numberProduct: '',
+                    numberVehicle: ''
+
+                }]
+            },
+            submitMaterial(){
+                    this.addLoading = true;
+                let materialString = JSON.stringify(this.prodMaterialList);
+                this.http.post('/prod-material/changeProdMaterial', {
+                    productId: this.productId,
+                    version: this.prodMaterialVersion,
+                    prodMaterials: materialString
+                },
+                res => {
+                    this.addLoading = false;
+                    if (res.code == "ok") {
+                        this.$message({
+                            message: (this.addForm.id != null ? this.$t('xiu-gai') : this.$t('create')) + this.$t('other.successful'),
+                            type: "success"
+                        });
+                       
+                        this.addFormVisible = false;
+                    } else {
+                        this.$message({
+                            message: res.msg,
+                            type: "error"
+                        });
+                    }
+                },
+                error => {
+                    this.addLoading = false;
+                    this.$message({
+                        message: error,
+                        type: "error"
+                    });
+                });
+            },
+             //删除工物料
+            deleteMaterial(index, row) {
+                if (row.id != null) {
+                    console.log(index);
+                    this.http.get("/prod-material/isDelete", row.id,
+                        res => {
+                            if (!res.data) {
+                                this.prodMaterialList.splice(index,1);
+                            } else {
+                                this.$message({
+                                    message: '该物料已被使用,不能删除',
+                                    type: 'warning'
+                                });
+                            }
+                        })
+                }else{
+                    this.prodMaterialList.splice(index, 1)
+                }
+
+            },
+
+
             // 进入页面所执行的函数
             mountedEnter() {
                 this.cateId =  this.$route.params.cateId;
@@ -676,6 +1007,7 @@ a {
                 this.getUsers();
             },
 
+            
             defaultExpandAllFlgCli() {
                 this.defaultExpandAllFlg = !this.defaultExpandAllFlg
                 this.list = JSON.parse(JSON.stringify(this.list))
@@ -2234,6 +2566,7 @@ a {
                     pageSize: this.size,
                     name:this.name,
                     code: this.code,
+                    cateId : this.cateId
                 }
                 
                 this.http.post('/product/getProductPage', parameter,
@@ -2511,17 +2844,25 @@ a {
                 this.$refs.form1.validate(valid => {
                     if (valid) {
                         this.addLoading = true;
-                        
+                        this.addForm.categoryId =this.cateId;
                         this.http.post('/product/saveProductInfo',this.addForm,
                         res => {
                             this.addLoading = false;
                             if (res.code == "ok") {
+                                this.productId=res.data.id;
                                 this.$message({
                                     message: (this.addForm.id!=null?this.$t('xiu-gai'):this.$t('create'))+this.$t('other.successful'),
                                     type: "success"
                                 });
                                 if (addSequence) {
                                     //进入工序录入
+                                     this.http.post('/prod-procedure/getProdProcedureList',{productId: this.productId},
+                                        res=>{
+                                            this.procedureLit=res.data.prodProcedureList;
+                                            this.procedureVersion=res.data.version;
+                                    
+                                    })
+                            
                                     this.prodEditActive = 1;
                                 } else {
                                     this.addFormVisible = false;