From 76795e84d3d8399ce5804998fe877b57d1666849 Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期日, 07 四月 2024 18:29:39 +0800
Subject: [PATCH] 获取纤度登记表列表的接口联调和字段调试+获取纤度登记表的详情接口联调字段调试+删纤度登记表的接口联调

---
 src/views/productManage/silkRegisterForm/addPage.vue |  240 +++++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 165 insertions(+), 75 deletions(-)

diff --git a/src/views/productManage/silkRegisterForm/addPage.vue b/src/views/productManage/silkRegisterForm/addPage.vue
index 62f66a8..db3ef01 100644
--- a/src/views/productManage/silkRegisterForm/addPage.vue
+++ b/src/views/productManage/silkRegisterForm/addPage.vue
@@ -13,7 +13,7 @@
                         placeholder="璇疯緭鍏ュ叧閿瘝" @searchClick="onFilterSearch">
                         <template slot="leftButton">
                             <el-button size="small" type="primary" @click="cancelClickOne">鏀惧純</el-button>
-                            <el-button size="small" type="primary" @click="saveClickOne('form')">淇濆瓨</el-button>
+                            <el-button size="small" type="primary" :loading="isAddloading"  @click="saveClickOne('form')">淇濆瓨</el-button>
                         </template>
                     </CommonSearch>
                 </div>
@@ -47,13 +47,13 @@
                             </el-select>
                         </el-form-item>
                         <el-form-item label="瑙勬牸" prop="spec" class="form-item">
-                            <el-input v-model="form.spec" placeholder="璇疯緭鍏�">
-                            </el-input>
-                            <!-- <el-select v-model="form.spec" placeholder="璇烽�夋嫨" class="select-width">
-                                <el-option v-for="item in deliveryTypeList" :key="item.id" :label="item.name"
-                                    :value="item.id">
+                            <el-select v-model="form.spec" placeholder="璇烽�夋嫨" class="select-width">
+                                <el-option v-for="item in specList" :key="item.ID" :label="item.name"
+                                    :value="item.name">
                                 </el-option>
-                            </el-select> -->
+                            </el-select>
+                            <!-- <el-input v-model="form.spec" placeholder="璇疯緭鍏�">
+                            </el-input> -->
                         </el-form-item>
                         <el-form-item label="缁勫埆" prop="workshopGroup" class="form-item">
                             <el-select v-model="form.workshopGroup" placeholder="璇烽�夋嫨" class="select-width">
@@ -86,9 +86,20 @@
                         </el-form-item>
                     </el-form>
                     <div class="list-view">
-                        <TableCommonView ref="tableListRef" :colOpenShow="false" v-loading="loading" :table-list="tableList"
+                        <!-- <TableCommonView ref="tableListRef" :colOpenShow="false" v-loading="loading" :table-list="tableList"
                             @selTableCol="selTableCol">
-                        </TableCommonView>
+                        </TableCommonView> -->
+                        <!-- 淇敼涓鸿緭鍏� -->
+                        <CommonFormTableView
+                        ref="commonFormTableView"
+                        :detail-enter="isView ? true : false"
+                        :selectBox="false"
+                        :detailEnter="true"
+                        :show-summary="showSummary"
+                        :product-table-list="tableList"
+                        @inputContent="inputContent"
+                        @addProductClick="addProductClick"
+                        ></CommonFormTableView>
                     </div>
                 </div>
                 <div class="body-r">
@@ -98,24 +109,24 @@
             </div>
         </template>
         <template v-if="activeName == 'second'">
-            <!-- <div class="body-two body" v-if="activeName == 'second'">
+            <div class="body-two body" v-if="activeName == 'second'">
                 <div class="body-two-t">绾ゅ害妫�楠岃〃</div>
                 <el-form ref="form" class="form-box" :model="form" :rules="rules" label-position="right" label-width="60px">
                     <div class="form-box-t">
                         <el-form-item label="缂栧彿" prop="clientName" class="form-item">
                             1234546677
                         </el-form-item>
-                        <el-form-item label="杞﹂棿" prop="deliverType" class="form-item">
-                            <el-select v-model="form.deliverType" placeholder="璇烽�夋嫨">
-                                <el-option v-for="item in deliveryTypeList" :key="item.id" :label="item.name"
-                                    :value="item.id">
+                        <el-form-item label="杞﹂棿" prop="name" class="form-item">
+                            <el-select v-model="form.name" placeholder="璇烽�夋嫨" class="select-width">
+                                <el-option v-for="item in nameList" :key="item.ID" :label="item.name"
+                                    :value="item.name">
                                 </el-option>
                             </el-select>
                         </el-form-item>
-                        <el-form-item label="缁勫埆" prop="deliverType" class="form-item">
-                            <el-select v-model="form.deliverType" placeholder="璇烽�夋嫨" style="width: 100%">
-                                <el-option v-for="item in deliveryTypeList" :key="item.id" :label="item.name"
-                                    :value="item.id">
+                        <el-form-item label="缁勫埆" prop="workshopGroup" class="form-item">
+                            <el-select v-model="form.workshopGroup" placeholder="璇烽�夋嫨" class="select-width">
+                                <el-option v-for="item in workshopGroupList" :key="item.ID" :label="item.name"
+                                    :value="item.ID">
                                 </el-option>
                             </el-select>
                         </el-form-item>
@@ -123,9 +134,14 @@
                             <el-input v-model.number="form.amount" placeholder="璇疯緭鍏�" show-word-limit
                                 style="width: 100%"></el-input>
                         </el-form-item>
-                        <el-form-item label="瑙勬牸" prop="clientName" class="form-item">
-                            <el-input v-model="form.clientName" placeholder="璇疯緭鍏�">
-                            </el-input>
+                        <el-form-item label="瑙勬牸" prop="spec" class="form-item">
+                            <el-select v-model="form.spec" placeholder="璇烽�夋嫨" style="width: 100%">
+                                <el-option v-for="item in specList" :key="item.id" :label="item.name"
+                                    :value="item.id">
+                                </el-option>
+                            </el-select>
+                            <!-- <el-input v-model="form.spec" placeholder="璇疯緭鍏�">
+                            </el-input> -->
                         </el-form-item>
                         <el-form-item label="鏃ユ湡" prop="signTime" class="form-item">
                             <el-date-picker v-model="form.signTime" value-format="yyyy-MM-dd" type="date" placeholder="閫夋嫨鏃ユ湡"
@@ -223,40 +239,35 @@
                         </el-form-item>
                     </div>
                 </el-form>
-            </div> -->
+            </div>
         </template>
     </div>
 </template>
   
 <script>
-import { getRegisterList,saveRegister,getDictList } from "@/api/productManage/silkRegisterForm.js"
+import { getRegisterList,saveRegister,getDictList,getWorkshopManageList,getRegisterDetails } from "@/api/productManage/silkRegisterForm.js"
 import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
+import CommonFormTableView from "@/components/makepager/CommonFormTableView"
 export default {
     name: "silkRegisterAddPage",
     props: {},
     mixins: [pageMixin],
     components: {
+        CommonFormTableView,
     },
     computed: {},
     data() {
         return {
-            tableList: {},
             loading: false,
             activeName: "first",
             searchOptions: [],
             search_map: {},
             is_public: true,
-            tableColumn: [
-                { label: "杞﹀彿", prop: "position", min: 100, default: true }, // 瀹㈡埛鍚嶇О
-                { label: "绾ゅ害鍊�", prop: "fineness", default: true }, // 閿�鍞礋璐d汉
-                { label: "鏁伴噺", prop: "quantity", default: true }, // 閲嶈绾у埆
-                { label: "绾ゅ害鍚堣", prop: "sum", min: 90, default: true }, // 涓嬫鍥炶鏃ユ湡
-            ],
-            showCol: ['杞﹀彿', '绾ゅ害鍊�', '鏁伴噺', '绾ゅ害鍚堣'],
             marketList:[], //搴勫彛
             nameList:[], //杞﹂棿
             workshopGroupList:[], //缁勫埆
             deliveryTypeList: [],
+            specList:[], //瑙勬牸
             form: {
                 number:'',
                 finishDate:'',
@@ -276,14 +287,16 @@
                 finishDate: [
                     { required: true, message: "璇烽�夋嫨", trigger: ["change", 'blur'] },
                 ],
+                // 杞﹂棿 搴旇true
                 name: [
                     { required: true, message: "璇烽�夋嫨", trigger: ["change", 'blur'] },
                 ],
                 spec: [
                     { required: true, message: "璇峰~鍐�", trigger: ["change", 'blur'] },
                 ],
+                // 缁勫埆 搴旇true
                 workshopGroup: [
-                    { required: true, message: "璇烽�夋嫨", trigger: ["change", 'blur'] },
+                    { required: false, message: "璇烽�夋嫨", trigger: ["change", 'blur'] },
                 ],
                 circle: [
                     { required: true, message: "璇峰~鍐�", trigger: ["change", 'blur'] },
@@ -333,41 +346,94 @@
                     { label: "26.5", prop: "next_visit_time", min: 90, default: true },
                 ],
             },
+            // 鏂板绾ゅ害鐧昏琛�
+            isAddloading:false,
+            isView: true,
+            showSummary: {
+                show: true,
+                total: true,
+                totalLabel:'鍚堣:',
+                sumProp: ["fineness", "quantity",'sum'],
+                mergeNumber: 0
+            },
+            productId: 1,
+            tableList: {
+                allcol: [],
+                headerColor:'red',
+                showcol: ['杞﹀彿', '绾ゅ害鍊�', '鏁伴噺', '绾ゅ害鍚堣'],
+                tableData: [
+                    {
+                        productId:1,
+                        position: '',
+                        fineness: 0,
+                        quantity: 0,
+                        sum: "",
+                    }
+                ],
+                tableColumn:[
+                    { label: "杞﹀彿", prop: "position", input: true }, // 瀹㈡埛鍚嶇О
+                    { label: "绾ゅ害鍊�", prop: "fineness", inputNumber: true, isRequird: true, }, // 閿�鍞礋璐d汉
+                    { label: "鏁伴噺", prop: "quantity", inputNumber: true , isRequird: true,}, // 閲嶈绾у埆
+                    { label: "绾ゅ害鍚堣", prop: "sum", inputNumber: true}, // 涓嬫鍥炶鏃ユ湡
+                ],
+            },
+            tableData:[],
+            registerId:'',
         }
     },
     created() {
         let query = this.$route.query;
         if (query) {
             this.activeName = query.activeName ? query.activeName : "first";
+            this.registerId= query.id ? query.id : "";
         }
-        this.setTable()
         this.getSelectDataList()
         this.search_map = {
             is_public: this.is_public
         }
+        this.getDetailsData()
         this.getData()
     },
     methods: {
+        getDetailsData(){
+            if(this.registerId){
+                getRegisterDetails({ id: this.registerId }).then((response) => {
+                    if (response.code === 200) {
+                    let config=JSON.parse(JSON.stringify(response.data?response.data:{}));
+                    this.form=config;
+                    this.tableList.tableData=config.finenessList?config.finenessList:[]
+                    this.tableData=config.finenessList?config.finenessList:[]
+                    } 
+                })
+            }
+            
+        },
         getSelectDataList(){
             //杞﹂棿
             getDictList({
-                dictType: 0,
+                dictType: 1,
             }).then((res) => {
                     if (res.code == 200) {
                         this.nameList=res.data||[]
                     }
                 })
-                //缁勫埆
-            getDictList({
-                dictType: 1,
+                 //瑙勬牸
+                 getDictList({
+                dictType: 3,
             }).then((res) => {
+                    if (res.code == 200) {
+                        this.specList=res.data||[]
+                    }
+                })
+                //缁勫埆
+                getWorkshopManageList().then((res) => {
                     if (res.code == 200) {
                         this.workshopGroupList=res.data||[]
                     }
                 })
                 //搴勫彛
                 getDictList({
-                dictType: 2,
+                dictType: 0,
             }).then((res) => {
                     if (res.code == 200) {
                         this.marketList=res.data||[]
@@ -376,37 +442,30 @@
         },
         inputStart(){
             this.form.circle=this.form.startCircle+'-'+this.form.endCircle
-        },  
-        setTable() {
-            this.tableList = {
-                selectIndex: false,
-                headerColor: 'red',
-                tableInfomation: [],
-                allcol: [],
-                showcol: this.showCol,
-                tableColumn: this.setColumnVisible(this.showCol)
-            }
-            this.tableList.allcol = this.tableList.tableColumn.filter(ele => !ele.default).map(ele => ele.label);
-            this.searchOptions = []
-            for (let i = 0; i < this.tableList.tableColumn.length; i++) {
-                const label = this.tableList.tableColumn[i].label
-                const value = this.tableList.tableColumn[i].prop
-                this.searchOptions.push({ value: value, label: label })
-            }
+        }, 
+        // 浜у搧鏂板
+        addProductClick() {
+            this.productId++
+            this.tableData.push({
+                productId: this.productId,
+                position: '',
+                        fineness: 0,
+                        quantity: 0,
+                        sum: "",
+            })
+            this.tableList.tableData=this.tableData
+            this.showSummary.show = true
         },
-        setColumnVisible(showCol) {
-            return this.tableColumn.map(ele => {
-                return {
-                    ...ele,
-                    isShowColumn: showCol.includes(ele.label)
+         // 浜у搧鍒楄〃杈撳叆
+        inputContent(val, prop, row) {
+            this.productId = row.productId
+            this.tableData.map((item) => {
+                if (item.productId === row.productId) {
+                    item[prop] = val
                 }
             })
-        },
-        selTableCol(val) {
-            this.showcol = val;
-            this.tableList.tableColumn = this.setColumnVisible(val);
-        },
-        // 璇锋眰鏁版嵁
+        }, 
+            // 璇锋眰鏁版嵁
         async getData() {
             this.loading = true
             await getRegisterList({
@@ -450,21 +509,18 @@
                                     position: position
                                 }
                             })
-                            this.tableList.tableInfomation = list || []
-                            this.tableTwoList.tableInfomation = []
+                            this.tableTwoList.tableInfomation =list|| []
                             this.pagerOptions.totalCount = res.data.count
                         } else {
-                            this.tableList.tableInfomation = []
+                            this.tableTwoList.tableInfomation = []
                         }
                     } else {
-                        this.tableList.tableInfomation = []
                         this.tableTwoList.tableInfomation = []
                     }
                     this.loading = false
                 })
                 .catch((err) => {
                     console.log(err)
-                    this.tableList.tableInfomation = []
                     this.loading = false
                 })
         },
@@ -493,7 +549,29 @@
         // 绾ゅ害鐧昏琛�
         // 鏀惧純
         cancelClickOne() {
-
+            if(this.activeName == 'first'){
+                this.form={
+                    number:'',
+                    finishDate:'',
+                    market:'',
+                    name:'', 
+                    spec:'',
+                    workshopGroup:'',
+                    circle:'',
+                    startCircle:'',
+                    endCircle:'',
+                    position:'',
+                }
+                this.$refs.form.resetFields();
+                this.productId=1
+                this.tableList.tableData=[{
+                    productId:1,
+                        position: '',
+                        fineness: 0,
+                        quantity: 0,
+                        sum: "",
+                }]
+            }
         },
         // 淇濆瓨
         saveClickOne(formName) {
@@ -501,10 +579,15 @@
                 if (valid) {
                     let form = JSON.parse(JSON.stringify(this.form));
                     delete form.circle
+                    let finenessList= JSON.parse(JSON.stringify(this.tableList.tableData));
+                    for(let i in finenessList){
+                        delete finenessList[i].productId
+                    }
                     let params = {
-                        finenessList: this.tableList.tableInfomation,
+                        finenessList:finenessList,
                         ...form
                     }
+                    this.isAddloading=true
                     saveRegister(params).then((res) => {
                         if (res.code == 200) {
                             this.$message({
@@ -512,9 +595,15 @@
                                 type: "success",
                             });
                         }
-                    });
+                        this.isAddloading=false
+                    }).catch(() => {
+                        setTimeout(() => {
+                            this.isAddloading = false;
+                            }, 3000);
+                    })
                 } else {
                     console.log('error submit!!');
+                    
                     return false;
                 }
             });
@@ -570,7 +659,7 @@
         box-sizing: border-box;
         padding: 10px 10px;
         border-radius: 12px;
-        height: calc(100% - 139px - 10px);
+        height: calc(100% - 139px - 10px - 20px);
         width: calc(100% - 20px);
         margin: 0 auto;
         margin-top: 10px;
@@ -613,6 +702,7 @@
 
             .list-view {
                 height: calc(100% - 0px);
+                min-height:200px;
                 overflow: hidden;
             }
         }

--
Gitblit v1.8.0