Jelajahi Sumber

附件类型管理功能

lizhenhao 2 tahun lalu
induk
melakukan
f96faaa2fa

+ 39 - 0
src/api/program/ProgramFileDictService.js

@@ -0,0 +1,39 @@
+import request from '@/utils/httpRequest'
+
+export default class ProgramFileDictService {
+  list (params) {
+    return request({
+      url: '/program/configuration/file/list',
+      method: 'get',
+      params: params
+    })
+  }
+  queryById (id) {
+    return request({
+      url: '/program/configuration/file/queryById',
+      method: 'get',
+      params: {id: id}
+    })
+  }
+  getAllFileType () {
+    return request({
+      url: '/program/configuration/file/getAllFileType',
+      method: 'get',
+      params: {}
+    })
+  }
+  save (inputForm) {
+    return request({
+      url: `/program/configuration/file/save`,
+      method: 'post',
+      data: inputForm
+    })
+  }
+  delete (ids) {
+    return request({
+      url: '/program/configuration/file/delete',
+      method: 'delete',
+      params: {ids: ids}
+    })
+  }
+}

+ 204 - 0
src/views/modules/program/configuration/fileDict/FileDictForm.vue

@@ -0,0 +1,204 @@
+<template>
+  <div>
+    <el-dialog
+      :title="title"
+      :close-on-click-modal="false"
+      v-dialogDrag
+      width="500px"
+      @close="close"
+      @keyup.enter.native="doSubmit"
+      :visible.sync="visible">
+      <el-form size="middle" :model="inputForm" ref="inputForm" v-loading="loading" :class="method==='view'||method==='viewChild'?'readonly':''"  :disabled="method==='view'||method==='viewChild'"
+               label-width="120px" @submit.native.prevent>
+        <el-row  :gutter="15">
+          <el-col v-if="method === 'addChild'||method === 'editChild'||method === 'viewChild'" :span="21">
+            <el-form-item label="附件类型" prop="parentId"
+                          :rules="[
+                          {required: true, message:'附件类型不能为空', trigger:'blur'}
+                 ]">
+              <el-select v-model="inputForm.parentId" style="width:100%" placeholder="请选择附件类型">
+                <el-option
+                  v-for="item in fileTypes"
+                  :key="item.id"
+                  :label="item.name"
+                  :value="item.id">
+                </el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span="21">
+            <el-form-item label="附件结构名称" prop="name"
+                          :rules="[
+                          {required: true, message:'附件结构名称不能为空', trigger:'blur'}
+                 ]">
+              <el-input v-model="inputForm.name" placeholder="请填写附件结构名称"></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="21">
+            <el-form-item label="排序" prop="sort"
+                          :rules="[
+                          {required: true, message:'排序不能为空', trigger:'blur'}
+                 ]">
+              <el-input v-model="inputForm.sort" placeholder="请填写排序"></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="21" v-if="method === 'addChild'||method === 'editChild'||method === 'viewChild'">
+            <el-form-item label="文件类型" prop="type"
+                          :rules="[
+                          {required: true, message:'文件类型不能为空', trigger:'blur'},{required: true, message:'文件类型不能为空', trigger:'change'}
+                 ]">
+              <el-select v-model="inputForm.type" collapse-tags style="width:100%" multiple placeholder="请选择文件类型">
+                <el-checkbox style="margin-left: 20px;" v-model="checked" @change='selectAll'>全选</el-checkbox>
+                <el-option
+                  v-for="item in $dictUtils.getDictList('file_type')"
+                  :key="item.label"
+                  :label="item.label"
+                  :value="item.label">
+                </el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span="21" v-if="method === 'addChild'||method === 'editChild'||method === 'viewChild'">
+            <el-form-item label="文件大小(MB)" prop="size"
+                          :rules="[
+                          {required: true, message:'文件大小不能为空', trigger:'blur'}
+                 ]">
+              <el-input v-model="inputForm.size" placeholder="请填写文件大小"></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="21">
+            <el-form-item label="备注" prop="remarks"
+                          :rules="[
+                 ]">
+              <el-input type="textarea" maxlength="200" v-model="inputForm.remarks" placeholder="请填写备注"  show-word-limit   ></el-input>
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+      <span slot="footer" class="dialog-footer">
+      <el-button size="small" @click="close()" icon="el-icon-circle-close">关闭</el-button>
+      <el-button size="small" type="primary" v-if="method != 'view'&&method != 'viewChild'" @click="doSubmit()" icon="el-icon-circle-check" v-noMoreClick>确定</el-button>
+    </span>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+  import ProgramFileDictService from '@/api/program/ProgramFileDictService'
+  export default {
+    data () {
+      return {
+        title: '',
+        method: '',
+        visible: false,
+        loading: false,
+        inputForm: {
+          name: '',
+          size: '',
+          type: [],
+          sort: '',
+          remarks: '',
+          parentId: ''
+        },
+        fileTypes: [],
+        check: false
+      }
+    },
+    programFileDictService: null,
+    created () {
+      this.programFileDictService = new ProgramFileDictService()
+    },
+    methods: {
+      init (method, id) {
+        this.method = method
+        this.getAllFileType()
+        this.inputForm = {
+          name: '',
+          size: '',
+          type: [],
+          sort: '',
+          remarks: '',
+          parentId: ''
+        }
+        if (method === 'add') {
+          this.title = `新建附件类型`
+          this.inputForm.parentId = '0'
+        } else if (method === 'edit') {
+          this.inputForm.id = id
+          this.title = '修改附件类型'
+        } else if (method === 'view') {
+          this.inputForm.id = id
+          this.title = '查看附件类型'
+        } else if (method === 'addChild') {
+          this.title = '新建附件结构'
+          this.inputForm.parentId = id
+        } else if (method === 'editChild') {
+          this.title = '修改附件结构'
+          this.inputForm.id = id
+        } else if (method === 'viewChild') {
+          this.title = '查看附件结构'
+          this.inputForm.id = id
+        }
+        this.visible = true
+        this.loading = false
+        this.$nextTick(() => {
+          this.$refs.inputForm.resetFields()
+          if (method === 'edit' || method === 'view' || method === 'editChild' || method === 'viewChild') { // 修改或者查看
+            this.loading = true
+            this.programFileDictService.queryById(this.inputForm.id).then(({data}) => {
+              this.inputForm = this.recover(this.inputForm, data)
+              this.inputForm = JSON.parse(JSON.stringify(this.inputForm))
+              this.inputForm.type = this.inputForm.type.split(',')
+              this.loading = false
+            })
+          }
+          if (method === 'addChild') {
+            this.inputForm.parentId = id
+          }
+        })
+      },
+      // 表单提交
+      doSubmit () {
+        this.$refs['inputForm'].validate((valid) => {
+          if (valid) {
+            this.loading = true
+            if (!this.commonJS.isEmpty(this.inputForm.type)) {
+              this.inputForm.type = this.inputForm.type.join(',')
+            } else {
+              this.inputForm.type = ''
+            }
+            this.programFileDictService.save(this.inputForm).then(({data}) => {
+              this.close()
+              this.$message.success(data)
+              this.$emit('refreshDataList')
+              this.loading = false
+            }).catch(() => {
+              this.loading = false
+            })
+          }
+        })
+      },
+      close () {
+        this.$refs.inputForm.resetFields()
+        this.$refs.inputForm.parentId = ''
+        this.checked = false
+        this.visible = false
+      },
+      getAllFileType () {
+        this.programFileDictService.getAllFileType().then(({data}) => {
+          this.fileTypes = data
+        })
+      },
+      selectAll () {
+        this.inputForm.type = []
+        if (this.checked) {
+          this.$dictUtils.getDictList('file_type').forEach((item) => {
+            this.inputForm.type.push(item.label)
+          })
+        } else {
+          this.inputForm.type = []
+        }
+      }
+    }
+  }
+</script>

+ 169 - 0
src/views/modules/program/configuration/fileDict/FileDictList.vue

@@ -0,0 +1,169 @@
+<template>
+  <div class="page">
+    <el-form size="small" :inline="true" class="query-form" ref="searchForm" :model="searchForm" @keyup.enter.native="refreshList()" @submit.native.prevent>
+      <!-- 搜索框-->
+      <el-form-item prop="name">
+        <el-input size="small" v-model="searchForm.name" placeholder="请输入附件类型名称" clearable></el-input>
+      </el-form-item>
+      <el-form-item>
+        <el-button type="primary" @click="refreshList()" size="small" icon="el-icon-search">查询</el-button>
+        <el-button @click="resetSearch()" size="small" icon="el-icon-refresh-right">重置</el-button>
+      </el-form-item>
+    </el-form>
+    <div class="bg-white top" style="">
+      <vxe-toolbar :refresh="{query: refreshList}" custom>
+        <template #buttons>
+          <el-button v-if="hasPermission('program:configuration:file:add')" type="primary" size="small" icon="el-icon-plus" @click="add()">新建</el-button>
+          <el-button v-if="hasPermission('program:configuration:file:del')" type="danger"   size="small" icon="el-icon-delete" @click="del()" :disabled="$refs.fileDictTable && $refs.fileDictTable.getCheckboxRecords().length === 0" plain>删除</el-button>
+        </template>
+      </vxe-toolbar>
+      <div style="height: calc(100% - 50px)">
+        <vxe-table
+          border="inner"
+          auto-resize
+          resizable
+          height="auto"
+          :loading="loading"
+          size="small"
+          ref="fileDictTable"
+          show-header-overflow
+          show-overflow
+          highlight-hover-row
+          :menu-config="{}"
+          @sort-change="sortChangeHandle"
+          :sort-config="{remote:true}"
+          :data="dataList"
+          :tree-config="{transform: true, rowField: 'id', parentField: 'parentId', expandAll: true}"
+          :checkbox-config="{}">
+          <vxe-column type="seq" width="40"></vxe-column>
+          <vxe-column type="checkbox" width="40" ></vxe-column>
+          <vxe-column width="160" title="附件结构名称" field="name" align="left" tree-node></vxe-column>
+          <vxe-column  title="类型" field="type"></vxe-column>
+          <vxe-column width="110" title="最大容量(MB)" field="size"></vxe-column>
+          <vxe-column width="70" title="序号" field="sort"></vxe-column>
+          <vxe-column title="操作" width="230px" fixed="right" align="center">
+            <template  slot-scope="scope">
+              <el-button v-if="hasPermission('program:configuration:file:edit')&&scope.row.parentId === '0'" type="text" icon="el-icon-plus" size="small" @click="addChild(scope.row.id)">新建子类型</el-button>
+              <el-button v-if="hasPermission('program:configuration:file:edit')&&scope.row.parentId === '0'" type="text" icon="el-icon-edit" size="small" @click="edit(scope.row.id)">修改</el-button>
+              <el-button v-if="hasPermission('program:configuration:file:edit')&&scope.row.parentId !== '0'" type="text" icon="el-icon-edit" size="small" @click="editChild(scope.row.id)">修改</el-button>
+              <el-button v-if="hasPermission('program:configuration:file:del')" type="text"  icon="el-icon-delete" size="small" @click="del(scope.row.id)">删除</el-button>
+            </template>
+          </vxe-column>
+        </vxe-table>
+      </div>
+    </div>
+    <FileDictForm  ref="fileDictForm" @refreshDataList="refreshList"></FileDictForm>
+  </div>
+</template>
+
+<script>
+  import ProgramFileDictService from '@/api/program/ProgramFileDictService'
+  import FileDictForm from './FileDictForm'
+  export default {
+    data () {
+      return {
+        searchForm: {
+          type: '',
+          sort: ''
+        },
+        dataList: [],
+        tablePage: {
+          total: 0,
+          currentPage: 1,
+          pageSize: 10,
+          orders: []
+        },
+        loading: false
+      }
+    },
+    programFileDictService: null,
+    created () {
+      this.programFileDictService = new ProgramFileDictService()
+    },
+    components: {
+      FileDictForm
+    },
+    mounted () {
+      this.refreshList()
+    },
+    methods: {
+      // 新增
+      add () {
+        this.$refs.fileDictForm.init('add', '')
+      },
+      addChild (id) {
+        this.$refs.fileDictForm.init('addChild', id)
+      },
+      // 修改
+      edit (id) {
+        id = id || this.$refs.fileDictTable.getCheckboxRecords().map(item => {
+          return item.id
+        })[0]
+        this.$refs.fileDictForm.init('edit', id)
+      },
+      editChild (id) {
+        id = id || this.$refs.fileDictTable.getCheckboxRecords().map(item => {
+          return item.id
+        })[0]
+        this.$refs.fileDictForm.init('editChild', id)
+      },
+      // 查看
+      view (id) {
+        this.$refs.fileDictForm.init('view', id)
+      },
+      viewChild (id) {
+        this.$refs.fileDictForm.init('viewChild', id)
+      },
+      // 获取数据列表
+      refreshList () {
+        this.loading = true
+        this.programFileDictService.list({
+          'current': this.tablePage.currentPage,
+          'size': this.tablePage.pageSize,
+          'orders': this.tablePage.orders,
+          ...this.searchForm
+        }).then(({data}) => {
+          this.dataList = data.records
+          this.tablePage.total = data.total
+          this.loading = false
+        })
+      },
+      // 当前页
+      currentChangeHandle ({ currentPage, pageSize }) {
+        this.tablePage.currentPage = currentPage
+        this.tablePage.pageSize = pageSize
+        this.refreshList()
+      },
+      // 排序
+      sortChangeHandle (column) {
+        this.tablePage.orders = []
+        if (column.order != null) {
+          this.tablePage.orders.push({column: this.$utils.toLine(column.property), asc: column.order === 'asc'})
+        }
+        this.refreshList()
+      },
+      // 删除
+      del (id) {
+        let ids = id || this.$refs.fileDictTable.getCheckboxRecords().map(item => {
+          return item.id
+        }).join(',')
+        this.$confirm(`确定删除所选项吗?`, '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+          this.loading = true
+          this.programFileDictService.delete(ids).then(({data}) => {
+            this.$message.success(data)
+            this.refreshList()
+            this.loading = false
+          })
+        })
+      },
+      resetSearch () {
+        this.$refs.searchForm.resetFields()
+        this.refreshList()
+      }
+    }
+  }
+</script>