jinlin
2024-11-02 b42429445c22164e951d514348115ee593379026
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
<template>
    <div class="mod-sys-sysOssConfig}">
      <div class="fa-card-a">
      <zt-table-wraper ref="tableObj" v-slot="{ table }" delete-url="/sys/oss/config" query-url="/sys/oss/config/page">
            <el-form :inline="true" :model="dataForm" @keyup.enter.native="table.query()">
              <zt-form-item label="模块分类" prop="busiType" style="margin-top: 2px;margin-left: 10px;line-height: 56px">
                <el-input v-model="dataForm.busiType"></el-input>
              </zt-form-item>
              <zt-form-item label="模块名称" prop="busiTypeName" style="line-height: 56px">
                <el-input v-model="dataForm.busiTypeName"></el-input>
              </zt-form-item>
              <el-form-item class="message-btn">
                <zt-button type="query" @click="table.query()"/>
                <zt-button type="add" @click="add()"/>
                <zt-button type="delete" @click="deleteByIds()"/>
              </el-form-item>
            </el-form>
            <el-table v-adaptive="{bottomOffset:70}"
                      v-loading="table.dataLoading"
                      :cell-style="cellStyle"
                      :data="table.dataList"
                      border height="650px" @selection-change="table.selectionChangeHandle">
              <el-table-column :selectable="selectable" align="center" type="selection" width="40"/>
              <el-table-column align="center" label="模块分类" prop="busiType" width="150"/>
              <el-table-column align="center" label="模块名称" prop="busiTypeName"/>
              <el-table-column align="center" label="字段分组" prop="busiFieldGroup"/>
              <el-table-column align="center" label="字段" prop="busiField"/>
              <el-table-column align="center" label="字段名称" prop="busiFieldName"/>
              <el-table-column align="center" label="可上传类型" prop="accept"/>
              <el-table-column align="center" label="可上传后缀" prop="fileTypes"/>
              <el-table-column align="center" label="大小限制(MB)" prop="fileSize"/>
              <el-table-column align="center" label="文件个数" prop="fileLimit" width="80"/>
              <zt-table-column-dict dict='bool' label="是否必填" prop="isRequired" width="80"/>
              <el-table-column align="center" label="排序" prop="sort" width="50"/>
              <el-table-column align="center" label="操作" width="200">
                <template slot-scope="scope">
                  <zt-table-button type="primary" @click="edit(scope.row,1)">查看</zt-table-button>
                  <zt-table-button v-show="isNumber(scope.row.busiType)" type="primary" @click="edit(scope.row,2)">修改
                  </zt-table-button>
                  <zt-table-button v-show="isNumber(scope.row.busiType)" type="danger" @click="deleteByIds(scope.row)">
                    删除
                  </zt-table-button>
                </template>
              </el-table-column>
            </el-table>
        <!-- 弹窗, 新增 / 修改 -->
        <add-or-update ref="AddOrUpdate" @refreshDataList="table.query"/>
      </zt-table-wraper>
      </div>
    </div>
</template>
 
<script>
import AddOrUpdate from './oss-config-add-or-update'
 
export default {
  data() {
    return {
      dataForm: {},
    }
  },
  computed: {
    isNumber: function () {
      return function (busiType) {
        let numReg = /^[-\\+]?([0-9]+\\.?)?[0-9]+$/
        let numRe = new RegExp(numReg)
        if (!numRe.test(busiType)) {
          return true
        } else {
          return false
        }
      }
    }
  },
  mounted() {
  },
  components: {
    AddOrUpdate
  },
  methods: {
    selectable(row, index) {
      let numReg = /^[-\\+]?([0-9]+\\.?)?[0-9]+$/
      let numRe = new RegExp(numReg)
      if (!numRe.test(row.busiType)) {
        return true
      } else {
        return false
      }
    },
    async deleteByIds(row) {
      let dataIds = []
      console.log(row)
      if (!row) {
        if (this.$refs.tableObj.dataSelectedList.length <= 0) {
          return this.$tip.alert(this.$t('prompt.deleteBatch'))
        }
        for (let val of this.$refs.tableObj.dataSelectedList) {
          dataIds.push(val.id)
        }
      } else {
        dataIds.push(row.id)
      }
      // alert(dataIds)
      if (await this.$tip.confirm('确定这些项目进行[删除]操作?')) {
        let res = await this.$http.delete
        (
          '/sys/oss/config/', {'data': dataIds}
        )
        if (res.success) {
          await this.$tip.success()
          this.$refs.tableObj.query()
        }
      }
    },
    edit(row, code) {
      this.$refs.AddOrUpdate.$refs.dialog.init(row, code)
    },
    add() {
      this.$refs.AddOrUpdate.$refs.dialog.init()
    },
    cellStyle({column}) {
      if (column.label === "模块分类" || column.label === '模块名称' || column.label === '字段分组' || column.label === '字段' || column.label === '字段名称') {
        return 'text-align: left !important;'
      }
    },
  }
}
</script>