zouyu
2023-11-16 c3148091b5adfde56ebb18898c3b44dfc8d38eb2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<template>
  <el-dialog
    :title="!dataForm.id ? '新增参数集' : '修改参数集'"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm"  label-width="100px" class="l-mes">
    <el-form-item label="名称"prop="templateName">
      <el-input v-model="dataForm.templateName" placeholder="名称"></el-input>
    </el-form-item>
    <el-form-item label="类型" prop="templateType">
      <el-select v-model="dataForm.templateType" placeholder="类型" filterable style="width: 100%" clearable>
        <el-option
          v-for="item in operationTemplateTypeList"
          :key="item.id"
          :label="item.templateTypeName"
          :value="item.templateTypeName"/>
      </el-select>
    </el-form-item>
    <el-form-item label="备注">
      <el-input v-model="dataForm.remark" placeholder="备注"></el-input>
    </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>
 
<script>
    import {getTemplateTypes} from '@/api/basic/template';
 
    export default {
    data () {
      return {
        operationTemplateTypeList:[],
        visible: false,
        dataForm: {
          id: 0,
          templateName: '',
          templateNo: '',
          templateType: '',
          dataType:'',
          remark: ''
        },
        dataRule: {
          templateType: [
            { required: true, message: '类型不能为空', trigger: 'blur' }
          ]
        }
      }
    },
      created() {
        this.getDict()
      },
    methods: {
      init (id) {
        this.dataForm.id = id || 0
        this.visible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          if (this.dataForm.id) {
 
          }
        })
      },
      getDict() {
        getTemplateTypes(Object.assign({
          dataType: '生产要求'
        })).then(response => {
          if (response.data.code === 0) {
            this.operationTemplateTypeList = response.data.data
            console.info( this.operationTemplateTypeList )
          }else{
            this.operationTemplateTypeList=[];
          }
        })
      },
      // 表单提交
      dataFormSubmit () {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            if (this.dataForm.id) {
                this.visible = false
            } else {
                this.visible = false
                this.dataForm.dataType='生产要求'
                this.$emit('comfirmCustomizeTemplate',this.dataForm);
 
            }
          }
        })
      }
    }
  }
</script>