<template>
  <div>
    <el-button size="small" type="primary" @click="dialogFormVisible = true">创建打印模板</el-button>
    <el-dialog title="创建模板" :visible.sync="dialogFormVisible" width="400px" append-to-body>
      <el-form size="small" :inline="false" :model="param" class="demo-form-inline" label-position="left" label-width="80px">
        <el-form-item label="模板名称">
          <el-input v-model="param.modelname" placeholder="输入模板名称"></el-input>
        </el-form-item>
        <el-form-item label="应用">
          <!-- <el-input v-model="param.systemappid" placeholder="应用ID"></el-input> -->
          <el-select style="width:100%" v-model="param.systemappid" placeholder="请选择">
            <el-option
              v-for="item in applist"
              :key="item.systemappid"
              :label="item.systemappname"
              :value="item.systemappid">
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false" size="small">取 消</el-button>
        <el-button type="primary" @click="addMode(dialogFormVisible = false)" size="small">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
 
<script>
import panel from './mode'
export default {
  data () {
    return {
      panel,
      dialogFormVisible:false,
      param:{
        "sys_printmodelid": 0,
        "systemappid":'',
        "modelname":"",
        "modeljson":"json",
        "isused":1
      },
      applist:[]
    }
  },
  methods:{
    async addMode () {
      this.panel.panels[0].printElements[0].options.title = this.param.modelname
      this.param.modeljson = this.panel
      const res = await this.$api.requested({
        "id": 20221121160001,
        "content": this.param
      })
      this.tool.showMessage(res,()=>{
        this.$emit('onSuccess')
      })
    },
    async aueryApplist () {
      const res = await this.$api.requested({
       "id": 20221122171801,
        "content": { 
          
        }
      })
      this.applist = res.data
    }
  },
  mounted () {
    this.aueryApplist()
  }
}

</script>
<style>
</style>