<template>
  <div class="eContainer">
    <!-- <el-button size="small"
         type="primary"
         @click="handleSave">save</el-button> -->
    <!-- <el-button size="small" @click="handletak">tak</el-button> -->
    <div class="m-Btn-eContainer">
        <div class="m-funcBtn-eContainer">
 
        <el-button size="small" type="primary" @click="handleSave">{{ $t('buttons.submit') }}</el-button>
        <el-button size="small" @click="handleCancel">{{ $t('buttons.quit') }}</el-button>
        </div>
    </div>
    <el-form :model="model" :rules="rules" ref="modelForm" label-width="200px" size="small" :validate-on-rule-change="false">
       <c-tabs v-model="tabVal" ref="elment" type="card" @tab-click="tabClick">
        
            <!--PD000052 -->
           <el-tab-pane label="Items Overview" name="sptroup" v-if="false">
                <m-sptroup :model="model" :codes="codes"/>
           </el-tab-pane>
 
            <!--PD000035 -->
           <el-tab-pane label="Pending Item" name="sptnegp">
                <m-sptnegp ref="sptnegp" :model="model" :codes="codes"/>
           </el-tab-pane>
 
            <!--PD000090 -->
           <el-tab-pane label="Configure Print Reroute" name="prtcfg">
                <m-prtcfg :model="model" :codes="codes"/>
           </el-tab-pane>
       </c-tabs>

       <c-grid-ety-prompt-dialog
        ref="etyDialog"
        :isPty="false"
        :promptData="promptData"
        @select-ety="selectMsg"
      >
      </c-grid-ety-prompt-dialog>
    </el-form>
  </div>
</template>
<script>
import Api from "~/service/Api"
import CodeTable from "~/config/CodeTable"
import Sptrou from "~/model/Sptrou"
import commonProcess from "~/mixin/commonProcess"
import Check from "~/model/Sptrou/Check"
import Default from "~/model/Sptrou/Default"
import Pattern from "~/model/Sptrou/Pattern"
// import Sptroup from "./Sptroup"
import Sptnegp from "./Sptnegp"
import Prtcfg from "./Prtcfg"


export default {
    name: 'Sptrou',
    components:{
        // "m-sptroup" : Sptroup,
        "m-sptnegp" : Sptnegp,
        "m-prtcfg" : Prtcfg,
    },
    provide() {
        return {
            root: this
        }
    },
    mixins: [commonProcess],    // 里面包含了Default、Check等的公共处理
    data(){
        return {
            tabVal: "sptnegp",
            trnName: "sptrou",
            model: new Sptrou().data,
            checkRules: Check,
            defaultRules: Default,
            pattern: Pattern,
            rules: null,
            codes: { ...CodeTable },
            
        }
    },
    methods:{
        tabClick(){

        },
        async handleSave(){
            let rtnmsg = await this.executeRule("sav")
            if(rtnmsg.respCode == SUCCESS)
            {
                this.$notify({
                title: "成功",
                message: "保存成功",
                type: "success",
                });
                this.$store.dispatch("TagsView/delView", this.$route)
                this.$router.history.push("/taskList", () => {
                this.$store.commit("setTaskListTabVal", 'sptsel')
                //修改待复核界面刷新状态为需要刷新
                this.$store.commit("setLoadingFreshSptsel", true)
                });

            }
            else
            {
                this.$notify.error({title: '错误',message: '服务请求失败！'});
            }

        },
        handletak(){

        },
    },
    created:async function(){
        console.log("进入sptrou交易");
        let rtnmsg = await this.init({})
        if(rtnmsg.respCode == SUCCESS)
        {
            //TODO 处理数据逻辑
            this.updateModel(rtnmsg.data)
            const wrkgrp = this.codes.codeSet['spt.wrkgrp']
            const wrkgrpArr = [];
            for (let i = 0; i < wrkgrp.length; i++) {
                const wrk = wrkgrp[i];
                const ss = wrk.split('\t')
                wrkgrpArr.push({
                    label: ss[1],
                    value: ss[0]
                })
            }
            this.$refs.sptnegp.sptWrkgrp = wrkgrpArr;
        }
        else
        {
            this.$notify.error({title: '错误',message: '服务请求失败！'});
        }
    },
    
}
</script>
<style>
    .m-Btn-eContainer {
        display: flex; /*flex布局*/
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: space-between;
        align-items: flex-start;
        height: 24px;
        margin-bottom: 5px;
        }
        .m-funcBtn-eContainer {
  order: 1;
}
        .m-funcBtn-eContainer button,
.m-funcBtn-eContainer .el-button + .el-button {
  margin: 0px 0px 0px 0px;
}
.m-funcBtn-eContainer .el-button--default {
  background-image: linear-gradient(#fff,#dedede);
  border: 1px solid #ccc;
}
.m-funcBtn-eContainer .el-button--primary {
  border: 1px solid #0D4FBD;
}
</style>
