田源
2023-06-09 f7e33d69713a5145d19fde5792b422826bc14107
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
<template>
  <basic-container>
    <div class="testbox">
      <div style="margin-top: 10px;display: flex;flex-wrap: wrap;width: 100%;">
        <el-button size="small" type="primary" plain @click="addvisible=true">增加
          <FormTemplateDialog
            :visible.sync="addvisible"
            :type="add"
            :templateOid="this.templateOid"
            :codeClassifyOid="this.codeClassifyOid"
            :codeRuleOid="this.codeRuleOid"
            :disabledProp="disabledProp"
          >
          </FormTemplateDialog></el-button>
        <el-button size="small" type="primary" plain @click="editvisible=true">编辑
          <FormTemplateDialog
            :visible.sync="editvisible"
            :type="edit"
            :templateOid="this.templateOids"
            :codeClassifyOid="this.codeClassifyOid"
            :codeRuleOid="this.codeRuleOid"
            :disabledProp="disabledProp"
            :rowOid="rowOid"
          ></FormTemplateDialog></el-button>
        <el-button size="small" type="primary" plain>批量导入申请</el-button>
        <el-button size="small" type="primary" plain>历史数据导入</el-button>
        <el-button size="small" type="primary" plain>批量申请编码</el-button>
        <el-button size="small" type="primary" plain>批量发布</el-button>
        <el-button size="small" type="primary" plain>查看流程历史</el-button>
        <el-button size="small" type="primary" plain>删除</el-button>
        <el-button size="small" type="primary" plain>发布</el-button>
        <el-button size="small" type="primary" plain>数据更改</el-button>
        <el-button size="small" type="primary" plain>回收</el-button>
        <el-button size="small" type="primary" plain @click="openD">导出
          <integration-transfer :visible.sync="dialogPush" :data="transferData"
                                :props="transferProps" @save="handelTransferSave"></integration-transfer>
        </el-button>
        <el-button size="small" type="primary" plain @click="findvisible=true">查询
        <advancedQuery  :visible.sync="findvisible" :options="this.options"></advancedQuery>
        </el-button>
        <el-button size="small" type="primary" plain>相似项查询</el-button>
        <el-button size="small" type="primary" plain style="margin-left: 1px;margin-top:10px">刷新</el-button>
        <el-input placeholder="请输入关键字按回车查询" style="width: 180px;margin-left: 5px;margin-top:10px" size="small"></el-input>
      </div>
      <el-row style="height: 700px;width: 100%">
        <el-table :data="tableData" style="" @cell-click="handleCellClick" max-height="700"  @selection-change="handleSelectionChange"  @sort-change="sortChange">
          <el-table-column
            type="selection"
            fixed
            width="55">
          </el-table-column>
          <el-table-column
            type="index"
            fixed
            label="序号"
            width="55">
          </el-table-column>
          <div v-for="(item,index) in this.tableHeadData" :key="index">
            <el-table-column :label="item.label" :prop="item.prop" :sortable="item.sortable" :width="item.width">
              <!-- 编辑和展示逻辑 -->
              <template slot-scope="{ row }">
                <el-input v-if="editingRow === row && editShow== item.prop" v-model="row[item.prop]" @blur="saveRow"></el-input>
                <span v-else>{{row[item.prop]}}</span>
                <el-switch
                  v-if="editShow === 'true'"
                  v-model="row[item.prop]"
                  active-color="#13ce66"
                  inactive-color="#ff4949">
                </el-switch>
              </template>
            </el-table-column>
          </div>
        </el-table>
      </el-row>
    </div>
    <div class="block" style="display: flex;justify-content: flex-end">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="page.currentPage"
        :page-sizes="page.pageSizes"
        :page-size="page.pageSizes"
        layout="total, sizes, prev, pager, next, jumper"
        :total="page.total">
      </el-pagination>
    </div>
  </basic-container>
</template>
<script>
import {MasterTable, TableData} from "@/api/GetItem";
import {listCodeAttributeByClassId} from '@/api/integration/integration.js'
import integrationTransfer from '@/views/integration/integrationTransfer'
import pinyin from "js-pinyin";
export default {
  components: {
    integrationTransfer
  },
  name: "Crud.vue",
  props:{
    page:{
      type: Object,
      default: ()=>{
        return {}
      }
    },
    codeClassifyOid:{
      type:String,
      default:""
    },
    coderuleoid:{
      type:String,
      default:""
    },
    tableDataArray:{
      type:Array,
      default:[]
    },
    total:{
      type:String,
      default:""
    },
    tableHeadDataFateher:{
      type:Array,
      default:[]
    }
  },
  data() {
    return {
      transferData:[],
      transferProps: {
        key: 'oid',
        label: 'name'
      },
      templateOid:"",
      addvisible:false,
      editvisible:false,
      findvisible:false,
      dialogPush:false,
      rowOid: '6EF696C3-CD87-0E7C-1EA1-8DE3913A95C9',
      disabledProp: ["id"],
      editingRow:null,
      editShow: "",
      editAttr:"",
      loading: false,
      data: [],
      options:{},
      option: {
        column: []
      },
      List: [],
      columnType: {
        text: "input",
        combox: "select",
        truefalse: "switch",
        number: "number",
        datetime: "datetime",
      },
      tableData:[],
      tableHeadData:[],
      tableHeadDataFateher:[],
      items:{},
      seniorQueryColumns:[]
    }
  },
  computed:{
  },
  created() {
    // this.CrudHeaderRend();
    // this.tableHeadHandle()
  },
  mounted() {
 
  },
  activated() {
    this.doLayout()
  },
  watch:{
    codeClassifyOid:{
      handler(newval,oldval){
        this.codeClassifyOid=newval;
        this.CrudHeaderRend()
      },
      deep:true
    },
    tableDataArray:{
      handler(newval,oldval){
        this.tableData=newval;
      //
      }
    },
    total:{
      handler(newval,oldval){
        this.page.total=newval;
      }
    },
    tableHeadData:{
      handler(newval,oldval){
        this.tableHeadDataFateher=newval
      }
    }
  },
  methods: {
    openD(){
      this.dialogPush=true;
      this.getListCodeByClassId()
    },
    async getListCodeByClassId() {
      this.transferData = []
      const response = await listCodeAttributeByClassId({ codeClassifyId: this.codeClassifyOid })
      if (response.status === 200) {
        const data = response.data.data
        this.transferData = data
      }
    },
    rend(){
      this.tableData=this.tableHeadData
    },
    handleSizeChange(val){
      this.page.pageSize=val
      this.$emit('pageSize',val)
      this.CrudRend()
      console.log(this.tableData)
    },
    handleCurrentChange(val){
      this.page.currentPage=val
      this.$emit('currentPage',val)
      this.CrudRend()
      console.log(val)
      console.log(this.tableData)
    },
    // 监听单元格点击事件并存储正在编辑的行
    handleCellClick(row, column) {
      this.editingRow = row;
      this.editShow = column.property;
      console.log(row)
      this.rowOid=row.oid
    },
    //删除
    enumDeleteRow(row) {
      console.log(row)
      this.tableData.splice(row, 1)
    },
    // 将正在编辑的行的状态变为 null ,即退出编辑状态
    saveRow() {
      this.editingRow = null;
    },
    doLayout() {
      this.$nextTick(() => {
        this.$refs.crud.doLayout();
      });
    },
    tableHeadHandle(){
      this.options=this.tableHeadDataFateher.tableDefineVO.seniorQueryColumns
      this.List = this.tableHeadDataFateher.tableDefineVO.cols[0];
      this.List.forEach(item => {
        let columnItem = {
          label: item.title,
          prop: item.field,
          type: this.columnType[item.type],
          sortable: item.sort,
          width: item.minWidth
        };
        this.option.column.push(columnItem);
        this.option.column=this.tableHeadData;
      })
    },
    //表格头渲染
    CrudHeaderRend() {
      if(this.codeClassifyOid != ""){
        MasterTable({
          codeClassifyOid:this.codeClassifyOid,
          functionId: 5,
        }).then(res => {
          this.options=res.data.tableDefineVO.seniorQueryColumns
          this.List = res.data.tableDefineVO.cols[0];
          this.List.forEach(item => {
            let columnItem = {
              label: item.title,
              prop: item.field,
              type: this.columnType[item.type],
              sortable: item.sort,
              width: item.minWidth
            };
            this.option.column.push(columnItem);
            this.option.column=this.tableHeadData;
            this.templateOid=res.data.tableDefineVO.oid
            this.$emit('templateOid',this.templateOid)
            console.log(this.templateOid)
          })
        })
      }
    },
    //表格数据
    CrudRend() {
       TableData({
         templateOid: this.templateOid,
         codeClassifyOid: this.codeClassifyOid,
         page: this.page.currentPage,
         limit: this.page.pageSize,
       }).then(res => {
         this.page.total = res.data.total;
         this.data = res.data.data;
         this.tableData=res.data.data;
       })
    },
    // 排序
    sortChange(val) {
      this.loading = true;
      let order = ""
      if (val.order == "ascending") {
        order = "asc";
      } else {
        order = "desc";
      }
      TableData({
        templateOid: this.templateOid,
        codeClassifyOid: this.codeClassifyOid,
        order: order,
        sort: val.prop,
        page: this.page.currentPage,
        limit: this.page.pageSize,
      }).then(res => {
        setTimeout(() => {
          this.data = res.data.data;
          this.loading = false;
        }, 100);
      })
    },
    //分页刷新
    async onLoad(val) {
      await TableData({
        templateOid: this.templateOid,
        codeClassifyOid: this.codeClassifyOid,
        page: val.currentPage,
        limit: val.pageSize,
      }).then(res => {
        this.data = res.data.data;
      })
    },
    //多选
    handleSelectionChange(row) {
      console.log(row)
    }
  }
}
</script>
 
<style lang="scss" scoped>
.testbox {
  .el-table--scrollable-x .el-table__body-wrapper {
    overflow: auto !important;
  }
 
  .el-table__fixed-right-patch {
    background-color: #f5f7fa !important;
  }
}
</style>