田源
2025-01-09 d7e3c8a813f8f85c89c06782f1e36e8089ffc31b
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
<template>
  <basic-container>
    <avue-crud ref="crud"
               v-model="form"
               :data="data"
               :option="option"
               :page.sync="page"
               :permission="permissionList"
               @on-load="getList"
               @row-update="rowUpdate"
               @row-save="rowSave"
               @row-del="rowDel"
               @refresh-change="refreshChange"
               @search-reset="searchChange"
               @search-change="searchChange"
               @row-click="rowClick">
      <template slot="menuLeft">
        <el-tooltip class="item" content="查找版本规则使用范围" effect="dark" placement="top">
          <el-button v-if="permissionList.apply"
                     icon="el-icon-zoom-in"
                     plain
                     size="small"
                     type="primary"
                     @click="applyRangeSearch">查看使用范围
          </el-button>
        </el-tooltip>
      </template>
      <template slot="radio"
                slot-scope="{row}">
        <el-radio v-model="selectRow"
                  :label="row.$index">&nbsp;
        </el-radio>
      </template>
    </avue-crud>
    <versionpackage ref="applyRange" :rangeData="applyRangeData"></versionpackage>
  </basic-container>
 
</template>
 
<script>
import {getPage, add, update, remove, getAppayRange} from '../../api/omd/revisionRule';
import {mapGetters} from "vuex";
 
export default {
  name: "Version",
  data() {
    return {
      //查看使用范围
      packageSearchBox: false,
      // 点击数据
      selectRow: '',
      selectRowData: {},
      //分页数据
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 100
      },
      data: [],
      form: {},
      option: {
        height: 'auto',
        calcHeight: 20,
        headerAlign: 'center',
        align: 'center',
        border: true,
        index: true,
        searchMenuSpan: 5,
        highlightCurrentRow: true,
        stripe: true,
        viewBtn: false,
        columnBtn: false,
        column: [
          {
            label: '选择',
            prop: 'radio',
            width: 120,
            display: false
          },
          {
            label: '英文名称',
            prop: 'id',
            editDisabled: true,
            rules: [
              {
                required: true,
                message: '英文名称不能为空',
                trigger: 'blur'
              }
            ]
          },
          {
            label: "中文名称",
            prop: "name",
            search: true,
            required: true,
            rules: [
              {
                required: true,
                message: '中文名称不能为空',
                trigger: 'blur'
              }
            ]
          },
          // {
          //   label:"跳跃字符",
          //   prop: "skipCode"
          // },
          {
            label: "初始值",
            prop: "startCode",
            type: 'number',
            min: 1,
            max: 99999,
            rules: [
              {
                required: true,
                message: '初始值不能为空',
                trigger: 'blur'
              }
            ]
          },
          {
            label: "步长",
            prop: "serialStep",
            type: 'number',
            min: 1,
            max: 99999,
            rules: [
              {
                required: true,
                message: '步长不能为空',
                trigger: 'blur'
              }
            ]
          },
          // {
          //   label: "前缀",
          //   prop:"prefixCode"
          // },
          // {
          //   label: "后缀",
          //   prop: "suffixCode"
          // },
          {
            label: "描述",
            prop: "description",
            type: "textarea"
          }
        ]
      },
      applyRangeData: []
    }
  },
  computed: {
    ...mapGetters(["permission"]),
    permissionList() {
      return {
        addBtn: this.vaildData(this.permission.modeling_Version.version_add, false),
        apply: this.vaildData(this.permission.modeling_Version.version_applyopen, false),
        delBtn: this.vaildData(this.permission.modeling_Version.version_delete, false),
        editBtn: this.vaildData(this.permission.modeling_Version.version_edit, false),
      }
    }
  },
  methods: {
    // 行点击
    rowClick(row) {
      this.selectRow = row.$index;
      this.selectRowData = row;
    },
    // 查看应用范围
    applyRangeSearch() {
      if (this.selectRow === '') {
        this.$message({
          type: "warning",
          message: "请先选择属性"
        })
        return
      }
        getAppayRange(this.selectRowData.id).then(res => {
          this.applyRangeData = res.data.data;
          this.$refs.applyRange.rangeData = this.applyRangeData;
          this.$refs.applyRange.showDialog = true;
        })
 
 
      // this.packageSearchBox=true
    },
    getList() {
      this.loading = true;
      getPage(this.page.currentPage, this.page.pageSize, this.params).then(res => {
        const data = res.data.data
        this.loading = false;
        this.page.total = data.total;
        this.data = data.records;
      })
    },
    rowSave(row, done, loading) {
      add(row).then(() => {
        this.$message.success('新增成功')
        done();
        this.getList();
      }).catch(() => {
        loading()
      })
    },
    rowUpdate(row, index, done, loading) {
      console.log(row);
      const date = new Date(row.ts);
      const formattedDate = `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')} ${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}:${date.getSeconds().toString().padStart(2, '0')}.${date.getMilliseconds().toString().padStart(3, '0')}`;
      row.ts = formattedDate;
      update(row)
        .then(() => {
          this.$message.success('修改成功');
          done();
          this.getList();
        })
        .catch(() => {
          loading();
        });
    },
    rowDel(row) {
      this.$confirm('此操作将永久删除, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        console.log(row);
        return remove({oid: row.oid})
      }).then(() => {
        this.$message.success('删除成功')
        this.getList();
      })
    },
    searchChange(params, done) {
      var p = {"name_like": params.name}
      getPage(this.page.currentPage, this.page.pageSize, p).then(res => {
        const data = res.data.data
        this.loading = false;
        this.page.total = data.total;
        this.data = data.records;
      });
      if (done) {
        done();
      }
    },
    refreshChange() {
      this.getList();
      this.$message.success('刷新成功')
    }
  }
}
</script>
 
<style scoped>
 
</style>