fujunling
2023-06-02 33c8db885ab2b5117c064d064f6e7c7eb0357a1c
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<template>
  <FormTempalte
    ref="FormTempalte"
    :visible="visible"
    :selfColumnType="selfColumnType"
    :selfColumnConfig="selfColumnConfig"
    :columnList="columnList"
  ></FormTempalte>
</template>
 
<script>
import { getCodeRule } from "@/api/formTemplate.js";
import FormTempalte from "./FormTempalte.vue";
export default {
  name: "CodeApply",
  components: { FormTempalte },
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    codeClassifyOid: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      secVOList: [],
      formItems: [],
      trendsSpan: 8,
      selfColumnType: {
        codefixedsec: "combox",
        codeclassifysec: "refer",
        codevariablesec: "text",
        coderefersec: "refer",
      },
      selfColumnConfig: {
        function: {
          required: this.isRequired,
          dicData: this.getOptionList,
          type: this.getType,
        },
        exchange: {
          text: "name",
          field: "oid",
          prop: "oid",
          showField: "name",
          parentClassifySecOid: "parentClassifySecOid",
          label: "name",
          maxlength: "codeSecLength",
          data: "fixedValueVOList",
        },
        directVoluation: {
          search: true,
          props: {
            label: "id",
            value: "id",
          },
        },
      },
      columnList: [],
    };
  },
  created() {
    this.handleResize();
  },
  mounted() {},
  methods: {
    getType(item) {
      return this.selfColumnType[item.sectype];
    },
    getCodeRule() {
      getCodeRule({ codeClassifyOid: this.codeClassifyOid }).then((res) => {
        if (res.data && res.data.code === 200) {
          this.defaultValue = res.data.data;
          this.columnList = res.data.data.secVOList || [];
          console.log(res.data.data.secVOList, 'res.data.data.secVOList');
          this.codeRuleOid = res.data.data.oid;
          this.$nextTick(() => {
            this.$refs.FormTempalte.init(res.data.data.secVOList)
          })
        }
      });
    },
    handleResize() {
      let windowWidth = document.body.clientWidth;
      this.trendsSpan = 24 / Math.floor(windowWidth / 500);
    },
    isRequired(item) {
      return item.nullableFlag != "true";
    },
    getOptionList(item) {
      if (
        Array.isArray(item.fixedValueVOList) &&
        item.fixedValueVOList.length > 0
      ) {
        const configAttr = {
          key: "id",
          value: "id",
        };
        const optionList = item.fixedValueVOList.map((item) => {
          for (const key in configAttr) {
            if (Object.hasOwnProperty.call(configAttr, key)) {
              const element = configAttr[key];
              item[key] = item[element];
            }
          }
          return item;
        });
        return optionList;
      } else {
        return [];
      }
    },
  },
  watch: {
  },
};
</script>
 
<style lang="less" scoped></style>