ludc
2023-06-06 9d50e7641ecad235e8b98583d65d6f485adf712e
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<template>
  <div>
    <el-table
      :data="tableData"
      v-loading="loading"
      height="250"
      :border="true"
      size="small"
    >
      <el-table-column
        v-if="column.length > 0"
        type="index"
        width="60"
        label="序号"
        align="center"
      ></el-table-column>
      <el-table-column
        v-for="item in column[0]"
        :key="item.field"
        :prop="item.field"
        :label="item.title"
        :min-width="item.width"
        align="center"
      >
        <template #default="{ row }" v-if="item.field === 'id'">
          <el-button type="text" @click="openFormTemlpate(row)">{{
            row.id
          }}</el-button>
        </template>
        <template #default="{ row }" v-else>
          <span>{{ row[item.field] }}</span>
        </template>
      </el-table-column>
    </el-table>
    <FormTemplateDialog
      ref="FormTemplateDialog"
      type="detail"
      :visible.sync="formTemplateVisible"
      :templateOid="this.resembleTemplateOid"
      :rowOid="rowOid"
      :codeClassifyOid="this.resembleCodeClassifyOid"
    ></FormTemplateDialog>
  </div>
</template>
 
<script>
import { findLike } from "@/api/formTemplate.js";
 
export default {
  name: "ResembleQuery",
  components: { FormTemplateDialog: () => import('./index.vue') },
  props: {
    column: {
      type: Array,
      default: () => [],
    },
    codeClassifyOid: {
      type: String,
      default: "",
    },
    templateOid: {
      type: String,
      default: "",
    },
    codeRuleOid: {
      type: String,
      default: "",
    },
    type: {
      type: String,
      default: "add",
    },
    form: {
      type: Object,
      default: () => ({}),
    },
  },
  data() {
    return {
      formTemplateVisible: false,
      activeName: "findlike",
      tableData: [
        {id: '*****', materialclassifyText: '001', tuhao: 'tuhao', iod: '123123131312'}
      ],
      loading: false,
      resembleTemplateOid: "78B8C7C5-A042-0B96-FE6D-65421451782A",
      resembleCodeClassifyOid: "4524E801-6CC6-92E8-1AC3-2AB9604E8F96",
      rowOid: '',
      defaultValue: {},
      secVOList: [],
      defaultKeys: [
        "oid",
        "id",
        "name",
        "description",
        "revisionoid",
        "nameoid",
        "btmname",
        "lastr",
        "firstr",
        "lastv",
        "firstv",
        "creator",
        "createtime",
        "lastModifier",
        "lastmodifytime",
        "revisionrule",
        "revisionseq",
        "revisionvalue",
        "versionrule",
        "versionseq",
        "versionvalue",
        "lcstatus",
        "ts",
        "owner",
        "checkinby",
        "checkintime",
        "checkoutby",
        "checkouttime",
        "copyfromversion",
        "secretgrade",
      ],
      formItems: [],
    };
  },
  methods: {
    // 相似项查询
    resembleQuery(form) {
      this.loading = true;
      this.activeName = "findlike";
      const { defaultValue, formValue } =
        this.getDefaultValueAndFormValues(form);
      let params = {
        codeClassifyOid: this.codeClassifyOid,
        codeRuleOid: this.codeRuleOid,
        templateOid: this.templateOid,
        data: formValue,
      };
      params = Object.assign(params, defaultValue);
      findLike(params).then((res) => {
        this.loading = false;
        // this.tableData = res.data.data || [];
      });
    },
 
    openFormTemlpate(row) {
      this.$forceUpdate()
      console.log(row, 'row.oid');
      this.codetemplateoid = row.codetemplateoid;
      this.rowOid = row.oid
      this.formTemplateVisible = true;
    },
    getDefaultValueAndFormValues(form) {
      let defaultValue = {};
      let formValue = {};
      for (const key in form) {
        if (Object.hasOwnProperty.call(form, key)) {
          const element = form[key];
          if (this.defaultKeys.includes(key)) {
            defaultValue[key] = element;
          } else {
            formValue[key] = element;
          }
        }
      }
      return {
        defaultValue,
        formValue,
      };
    },
  },
};
</script>