caiaa 1 년 전
부모
커밋
d1f5b5de68
3개의 변경된 파일644개의 추가작업 그리고 74개의 파일을 삭제
  1. 17 1
      mock/dict.js
  2. 259 0
      src/views/business/components/SystemDetail.vue
  3. 368 73
      src/views/business/index.vue

+ 17 - 1
mock/dict.js

@@ -1,7 +1,23 @@
 module.exports = [
   // user login
   {
-    url: '/sysDict/type/app',
+    url: '/sysDict/type/app_type',
+    type: 'get',
+    response: config => {
+      return {
+        code: 200,
+        msg: 'success',
+        data: [
+          { 'id': 1, 'value': '1', 'label': 'Type1', 'sort': 1 },
+          { 'id': 2, 'value': '2', 'label': 'Type2', 'sort': 2 },
+          { 'id': 3, 'value': '3', 'label': 'Type3', 'sort': 3 },
+          { 'id': 4, 'value': '4', 'label': 'Type4', 'sort': 4 }
+        ]
+      }
+    }
+  },
+  {
+    url: '/sysDict/type/bisiness_type',
     type: 'get',
     response: config => {
       return {

+ 259 - 0
src/views/business/components/SystemDetail.vue

@@ -0,0 +1,259 @@
+<template>
+  <div>
+    <el-dialog
+      v-loading="loading"
+      :visible.sync="visible"
+      :close-on-press-escape="true"
+      :close-on-click-modal="false"
+      :show-close="false"
+      destroy-on-close
+      custom-class="main-edit-dialog"
+      :title="title"
+    >
+      <el-form :ref="formName" :model="formData" :rules="isView ? {} : rules" label-width="100px">
+        <el-row>
+          <el-col :span="12">
+            <el-form-item prop="appType" label="Type">
+              <el-select v-if="!isView" v-model="formData.appType" placeholder="Please select">
+                <el-option v-for="item in typeData" :key="item.value" :label="item.label" :value="item.value" />
+              </el-select>
+              <span v-else>{{ formData.appType }}</span>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item prop="systemName" label="Name">
+              <el-input v-if="!isView" v-model="formData.systemName" />
+              <div v-else>{{ formData.systemName }}</div>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row>
+          <el-col :span="12">
+            <el-form-item prop="systemNumber" label="Code">
+              <el-input v-if="!isView" v-model="formData.systemNumber" />
+              <span v-else>{{ formData.systemNumber }}</span>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item prop="shortName" label="Alias">
+              <el-input v-if="!isView" v-model="formData.shortName" />
+              <span v-else>{{ formData.shortName }}</span>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row>
+          <el-col :span="12">
+            <el-form-item prop="deptName" label="Dept">
+              <el-select v-if="!isView" v-model="formData.deptName" placeholder="placeholder">
+                <el-option v-for="item in orgData" :key="item.value" :label="item.label" :value="item.value" />
+              </el-select>
+              <span v-else>{{ formData.deptName }}</span>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item prop="url" label="Url">
+              <el-input v-if="!isView" v-model="formData.url" />
+              <span v-else>{{ formData.url }}</span>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row>
+          <el-col :span="12">
+            <el-form-item prop="activeFlag" label="Active">
+              <el-select v-if="!isView" v-model="formData.activeFlag" placeholder="placeholder">
+                <el-option v-for="item in activeFlagData" :key="item.value" :label="item.label" :value="item.value" />
+              </el-select>
+              <span v-else>{{ formData.activeFlag }}</span>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item prop="policeCategory" label="Category">
+              <el-select v-if="!isView" v-model="formData.policeCategory" placeholder="placeholder">
+                <el-option v-for="item in policeCategoryData" :key="item.value" :label="item.label" :value="item.value" />
+              </el-select>
+              <span v-else>{{ formData.policeCategory }}</span>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row>
+          <el-col :span="12">
+            <el-form-item prop="icon" label="Icon" style="height: 100px;">
+              <upload-file v-if="!isView" file-type="1" :on-success="uploadSuccess" :on-error="uploadError" />
+              <el-input v-model="formData.icon" type="hidden" style="display:none" />
+              <div v-if="!isNull(formData.icon)">
+                <i class="upload-success el-icon-circle-check" />{{ fileName }}
+              </div>
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+      <div slot="footer">
+        <el-button @click="close">Cancel</el-button>
+        <el-button v-if="!isView" type="primary" @click="saveSystem">Confirm</el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+<script>
+import { isNull, isObject } from '@/utils/convert'
+
+import { pushSaveSystem } from '@/api/system'
+
+import UploadFile from '@/components/Upload/UploadFile'
+
+export default {
+  components: { UploadFile },
+  props: {
+    typeData: {
+      type: Array,
+      default() {
+        return []
+      }
+    }
+  },
+  data() {
+    return {
+      // dialog
+      visible: false,
+      isView: true,
+      type: '',
+      title: 'Edit',
+      formName: 'editForm',
+      formData: {
+        id: null,
+        appType: null,
+        systemName: '',
+        systemNumber: '',
+        shortName: null,
+        deptName: '',
+        url: '',
+        activeFlag: '',
+        policeCategory: '',
+        icon: null
+      },
+      rules: {
+        appType: [
+          { required: true, message: '请选择应用类型', trigger: 'change' }
+        ],
+        systemName: [
+          { required: true, message: '请输入应用名称', trigger: 'blur' }
+        ],
+        systemNumber: [
+          { required: true, message: '请输入应用编号', trigger: 'blur' }
+        ],
+        shortName: [
+          { required: true, message: '请输入应用简称', trigger: 'blur' }
+        ],
+        deptName: [
+          { required: true, message: '请输入应用事权单位名称', trigger: 'blur' }
+        ],
+        url: [
+          { type: 'url', required: true, message: '请输入应用访问地址', trigger: 'blur' }
+        ],
+        activeFlag: [
+          { required: true, message: '请选择应用在用标识', trigger: 'change' }
+        ],
+        icon: [
+          { required: true, message: '请上传应用图标', trigger: 'change' }
+        ]
+      },
+      fileName: '',
+      action: 'add',
+      // select:
+      orgData: [{ value: '1', label: 'Test1' }, { value: '0', label: 'Test0' }],
+      policeCategoryData: [],
+      activeFlagData: [{ value: '1', label: 'Active' }, { value: '0', label: 'Deactive' }],
+      // others
+      loading: false
+    }
+  },
+  computed: {
+    myListIds() {
+      return this.myListData.map(item => item.id)
+    }
+  },
+  methods: {
+    // Upload
+    uploadSuccess(data) {
+      this.$set(this.formData, 'icon', data.url)
+      this.fileName = data.fileName + '.' + data.extension
+    },
+    uploadError(error) {
+      this.$message.error({
+        type: 'error',
+        duration: 0,
+        showClose: true,
+        message: error.message
+      })
+    },
+    /**
+     * 加载dialog
+     */
+    open(type, data) {
+      if (type === 'ADD') {
+        this.title = 'Add'
+        this.isView = false
+        this.action = 'add'
+        if (this.type !== 'ADD') {
+          data = {}
+        }
+      } else if (type === 'EDIT') {
+        this.title = 'Edit'
+        this.isView = false
+        this.action = 'update'
+      } else {
+        this.title = 'View'
+        this.isView = true
+      }
+      this.type = type
+      if (isObject(data)) {
+        Object.keys(this.formData).forEach(key => {
+          this.formData[key] = data[key]
+        })
+      }
+      this.visible = true
+    },
+    close() {
+      this.visible = false
+    },
+    saveSystem() {
+      this.$refs[this.formName].validate((valid) => {
+        if (valid) {
+          this.loading = true
+          pushSaveSystem(this.action, this.formData).then(res => {
+            this.$refs[this.formName].resetFields()
+            this.visible = false
+            this.loading = false
+            this.$message({
+              type: 'success',
+              message: 'Save Successfully!'
+            })
+          }).catch(error => {
+            console.log(error)
+            this.loading = false
+            this.$message.error({
+              type: 'error',
+              duration: 0,
+              showClose: true,
+              message: error.message
+            })
+          })
+        }
+      })
+    },
+    isNull(obj) {
+      return isNull(obj)
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+.main-edit-dialog {
+
+  .upload-success {
+    color: #13ce66;
+    margin-right: 5px;
+  }
+}
+</style>

+ 368 - 73
src/views/business/index.vue

@@ -1,93 +1,388 @@
 <template>
-  <div>
-    <el-button type="primary" @click="showEdit">Click</el-button>
-    <el-button type="primary" @click="showEdit2">Click</el-button>
-    <el-input v-model="filterText" placeholder="Filter keyword" style="margin-bottom:30px;" />
-
-    <el-tree
-      ref="tree2"
-      :data="data2"
-      :props="defaultProps"
-      :filter-node-method="filterNode"
-      default-expand-all
-    />
-
-    <business-edit ref="businessEdit" />
-    <system-edit ref="systemEdit" />
+  <div class="business-container">
+    <el-card class="type-box">
+      <div slot="header" class="clearfix card-title">
+        <span>Test</span>
+      </div>
+      <el-radio-group v-model="formData.appType" @input="searchTable">
+        <el-radio-button label="">All</el-radio-button>
+        <el-radio-button v-for="item in typeData" :key="item.id" :label="item.value">{{ item.label }}</el-radio-button>
+      </el-radio-group>
+    </el-card>
+    <div class="business-box">
+      <div class="list-filter">
+        <el-form ref="filterForm" :model="formData" inline>
+          <el-form-item label="name">
+            <el-input v-model="formData.businessmName" class="filter-item" clearable />
+          </el-form-item>
+          <el-form-item label="name2">
+            <el-input v-model="formData.appName" class="filter-item" clearable />
+          </el-form-item>
+          <el-form-item>
+            <el-button type="primary" @click="searchTable">Search</el-button>
+          </el-form-item>
+        </el-form>
+      </div>
+      <div class="list-button">
+        <el-button type="primary" @click="showEdit('ADD')">Add</el-button>
+        <el-upload action="" class="upload-btn">
+          <el-button>Upload</el-button>
+        </el-upload>
+      </div>
+      <div v-loading="loading" class="list-box">
+        <el-scrollbar class="list-scrollbar">
+          <div class="business-item-box">
+            <div v-for="item in tableData" :key="item.id" class="business-item">
+              <div class="item-header">
+                <div class="item-type">{{ formatDictData(item.businessType) }}</div>
+                <div class="item-btn">
+                  <el-button type="text" @click="showEdit('VIEW', item)">Detail</el-button>
+                  <el-button type="text" @click="showEdit('EDIT', item)">Edit</el-button>
+                  <el-button type="text" @click="deleteItem(item.id)">Delete</el-button>
+                </div>
+              </div>
+              <div class="item-content">
+                <div class="item-content-left">
+                  <el-avatar :size="56" :src="item.icon" />
+                  <div class="item-title">
+                    <div class="item-name">{{ item.businessName }}</div>
+                    <div class="item-system">{{ item.appName }}</div>
+                  </div>
+                </div>
+                <el-button class="item-link" size="small" @click="jumpTo(item.url)">Open</el-button>
+              </div>
+              <div class="item-footer">{{ item.deptName }}</div>
+            </div>
+          </div>
+        </el-scrollbar>
+        <div v-if="total > 0" class="page">
+          <el-pagination
+            layout="total, prev, pager, next, jumper"
+            :current-page="current"
+            :total="total"
+            :page-sizes="pageSizeAll"
+            :page-size="size"
+            @size-change="handleSizeChange"
+            @current-change="handleCurrentChange"
+          />
+        </div>
+      </div>
+    </div>
+    <system-detail ref="systemDetail" :type-data="typeData" />
   </div>
 </template>
 
 <script>
-import BusinessEdit from '../home/components/BusinessEdit'
-import SystemEdit from '../home/components/SystemEdit'
+import SystemDetail from './components/SystemDetail'
+
+import { fetchDictData } from '@/api/dict'
+import { fetchAllBizList, pushdeleteItem } from '@/api/biz'
+
+import { hasValidRecords, formatDictData, isNull } from '@/utils/convert'
 
 export default {
-  components: {
-    BusinessEdit,
-    SystemEdit
-  },
+  components: { SystemDetail },
   data() {
     return {
-      filterText: '',
-      data2: [{
-        id: 1,
-        label: 'Level one 1',
-        children: [{
-          id: 4,
-          label: 'Level two 1-1',
-          children: [{
-            id: 9,
-            label: 'Level three 1-1-1'
-          }, {
-            id: 10,
-            label: 'Level three 1-1-2'
-          }]
-        }]
-      }, {
-        id: 2,
-        label: 'Level one 2',
-        children: [{
-          id: 5,
-          label: 'Level two 2-1'
-        }, {
-          id: 6,
-          label: 'Level two 2-2'
-        }]
-      }, {
-        id: 3,
-        label: 'Level one 3',
-        children: [{
-          id: 7,
-          label: 'Level two 3-1'
-        }, {
-          id: 8,
-          label: 'Level two 3-2'
-        }]
-      }],
-      defaultProps: {
-        children: 'children',
-        label: 'label'
-      }
+      // type
+      dictType: 'bisiness_type',
+      typeData: [],
+      // table
+      current: 1,
+      size: 16,
+      total: 0,
+      pageSizeAll: [10, 20, 50, 100, 200, 500],
+      tableData: [],
+      // filter
+      formData: {
+        businessType: '',
+        businessmName: '',
+        appName: ''
+      },
+      // others
+      loading: false
     }
   },
-  watch: {
-    filterText(val) {
-      this.$refs.tree2.filter(val)
-    }
+  created() {
+    this.getTypeData()
+    this.searchTable()
   },
-
   methods: {
-    filterNode(value, data) {
-      if (!value) return true
-      return data.label.indexOf(value) !== -1
+    // 改变每页显示条数
+    handleSizeChange(val) {
+      this.current = 1
+      this.size = val
+      this.getTablelist()
+    },
+    // 切换第几页
+    handleCurrentChange(val) {
+      this.current = val
+      this.getTablelist()
+    },
+    // 重置搜索项
+    resetTable(formName) {
+      this.$refs[formName].resetFields()
+      this.getTablelist()
+    },
+    // 点击搜索按钮
+    searchTable() {
+      this.current = 1
+      this.getTablelist()
+    },
+    // 获取table数据
+    getTablelist() {
+      const params = {
+        page: this.current,
+        size: this.size,
+        params: {
+          delFlag: 0,
+          businessType: this.formData.businessType,
+          businessmName: this.formData.businessmName,
+          appName: this.formData.appName
+        }
+      }
+      this.loading = true
+      fetchAllBizList(params).then(response => {
+        debugger
+        if (hasValidRecords(response)) {
+          this.tableData = response.data.records
+          this.total = response.data.total
+        } else {
+          this.tableData = []
+          this.total = 0
+        }
+        this.loading = false
+      }).catch(error => {
+        console.log(error)
+        this.loading = false
+        this.$message.error({
+          type: 'error',
+          duration: 0,
+          showClose: true,
+          message: ': ' + error.message
+        })
+      })
     },
-    showEdit() {
-      this.$refs.businessEdit.open()
+    jumpTo(link) {
+      window.open(link, '_blank')
     },
-    showEdit2() {
-      this.$refs.systemEdit.open()
+    showEdit(type, data) {
+      this.$refs.systemDetail.open(type, data)
+    },
+    deleteItem(id) {
+      this.loading = true
+      pushdeleteItem(id).then(res => {
+        this.getTablelist()
+      }).catch(error => {
+        console.log(error)
+        this.loading = false
+        this.$message.error({
+          type: 'error',
+          duration: 0,
+          showClose: true,
+          message: ': ' + error.message
+        })
+      })
+    },
+    getTypeData() {
+      fetchDictData(this.dictType).then(response => {
+        if (!isNull(response.data)) {
+          this.typeData = response.data
+        } else {
+          this.typeData = []
+        }
+      }).catch(error => {
+        console.log(error)
+        this.$message.error({
+          type: 'error',
+          duration: 0,
+          showClose: true,
+          message: '获取应用类型出错: ' + error.message
+        })
+      })
+    },
+    formatDictData(type) {
+      return formatDictData(this.typeData, type)
     }
   }
 }
 </script>
 
+<style lang="scss" scoped>
+.business-container {
+  display: flex;
+
+  .type-box {
+    width: 230px;
+    min-width: 230px;
+    margin-right: 5px;
+
+    .el-radio-group {
+      width: 100%;
+    }
+    .el-radio-button {
+      display: block;
+    }
+
+    ::v-deep {
+      .el-card__header {
+        height: 60px;
+      }
+      .el-card__body {
+        padding: 20px 0;
+      }
+
+      .el-radio-button__inner {
+        width: 100%;
+        border: 0;
+        text-align: left;
+      }
+      .el-radio-button__orig-radio:checked + .el-radio-button__inner {
+        background-color: #ebf2fd;
+        color: #0056dd;
+      }
+    }
+  }
+
+  .card-title {
+    font-size: 18px;
+    line-height: 24px;
+    color: rgba(0,0,0,0.85);
+    font-weight: bold;
+  }
+
+  .business-box {
+    padding-left: 20px;
+    background-color: #fff;
+    width: 100%;
+    height: 100%;
+
+    .upload-btn {
+      display: inline-block;
+      margin-left: 10px;
+    }
+
+    .page {
+      margin-right: 20px;
+      text-align: right;
+    }
+
+    ::v-deep {
+      .el-scrollbar__wrap{
+        overflow-x: hidden;
+      }
+
+      .el-scrollbar__bar.is-horizontal {
+        display: none;
+      }
+    }
+  }
+
+  .list-filter {
+    height: 60px;
+    width: 800px;
+    padding-top: 10px;
+  }
+
+  .list-button {
+    height: 50px;
+  }
+
+  .list-box {
+    min-width: 800px;
+    height: calc(100% - 110px);
+  }
+
+  .list-scrollbar {
+    height: calc(100% - 32px);
+  }
+
+  .business-item-box {
+    display: flex;
+    flex-wrap: wrap;
+  }
+
+  .business-item {
+    width: 380px;
+    height: 150px;
+    border: 1px solid rgba(0,0,0,0.09);
+    border-radius: 4px;
+    margin-right: 16px;
+    margin-bottom: 16px;
+    padding: 0 10px 10px 10px;
+    display: flex;
+    flex-direction: column;
+    justify-content: space-between;
+
+    .item-header {
+      height: 35px;
+    }
+
+    .item-type, .item-btn {
+      height: 100%;
+    }
+
+    .item-type {
+      display: inline-block;
+      font-size: 14px;
+      line-height: 35px;
+      color: rgba(0,0,0,0.65);
+    }
+
+    .item-btn {
+      float: right;
+    }
+
+    .item-content {
+      display: flex;
+      justify-content: space-between;
+      align-items: center;
+    }
+
+    .item-content-left {
+      display: flex;
+      align-items: center;
+    }
+
+    .item-title {
+      display: inline-block;
+      margin-left: 10px;
+
+      .item-name, .item-system {
+        width: 230px;
+        text-overflow: ellipsis;
+        overflow: hidden;
+        white-space: nowrap;
+      }
+
+      .item-name {
+        font-size: 14px;
+        font-weight: 550;
+        color: rgba(0,0,0,0.85);
+      }
+
+      .item-system {
+        font-size: 14px;
+        color: rgba(0,0,0,0.65);
+      }
+    }
+
+    .item-link {
+      float: right;
+    }
+
+    .item-footer {
+      font-size: 12px;
+      color: rgba(0,0,0,0.65);
+    }
+
+    ::v-deep {
+      .el-button--small {
+        font-size: 14px;
+      }
+    }
+  }
+
+}
+</style>
+