fujunling
2023-06-01 2210c590f886d75bc760fa08caa18dd0181026b5
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
<template>
  <div></div>
</template>
 
<script>
import { getCodeRule } from "@/api/formTemplate.js";
 
export default {
  name: "CodeApply",
  props: {
    codeClassifyOid: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      secVOList: [],
      formItems: [],
      trendsSpan: 8
    };
  },
  created() {
    this.handleResize();
    this.getCodeRule();
  },
  mounted() {
    
  },
  methods: {
    getCodeRule() {
      getCodeRule({ codeClassifyOid: this.codeClassifyOid }).then((res) => {
        if (res.data && res.data.code === 200) {
          this.defaultValue = res.data.data;
          this.secVOList = res.data.data.secVOList || [];
          this.codeRuleOid = res.data.data.oid;
        }
      });
    },
    handleResize() {
      let windowWidth = document.body.clientWidth;
      this.trendsSpan = 24 / Math.floor(windowWidth / 500);
    },
  },
  watch: {
    secVOList: {
      deep: true,
      handler(newV) {
        this.formItems = [];
        newV.forEach((item) => {
          let itemObj = {};
          let options = [];
          //固定码段
          if (item.sectype == "codefixedsec") {
            options = item.fixedValueVOList.map((item) => {
              item.key = item.id;
              item.value = item.id;
            });
            itemObj = {
              field: item.oid,
              title: item.name,
              required: item.nullableFlag != "true",
              type: "combox",
              data: options,
              search: true,
            };
            //可变码段
          } else if (item.sectype == "codevariablesec") {
            itemObj = {
              field: item.oid,
              title: item.name,
              required: item.nullableFlag != "true",
              type: "text",
            };
          }
          itemObj.span = item.type === "textarea" ? 24 : this.trendsSpan,
          this.formItems.push(itemObj);
        });
      },
    },
  },
};
</script>
 
<style lang="less" scoped></style>