liqianyi 3 éve
szülő
commit
7b8cb2cb16

+ 7 - 0
src/api/file.js

@@ -17,3 +17,10 @@ export function downloadFile (url) {
     method: 'get'
   })
 }
+
+export function getDocDetail (docId) {
+  return request({
+    url: request.adornUrl(`/file-service/document-ctl/info/${docId}`),
+    method: 'get'
+  })
+}

+ 156 - 0
src/views/modules/doc/doc-add-or-update.vue

@@ -0,0 +1,156 @@
+<template>
+  <div>
+    <div class="my-title">{{ !id ? '上传':'编辑' }}</div>
+    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="100px">
+      <el-row>
+        <el-col :span="8">
+          <el-form-item label="文件名称" prop="fileName">
+            <el-input v-model="dataForm.fileName" placeholder="文件名称"></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" style="padding-left: 20px">
+          <el-form-item label="文件描述" prop="fileDescribe">
+            <el-input v-model="dataForm.fileDescribe" placeholder="文件描述"></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" style="padding-left: 20px">
+          <el-form-item label="文件类别" prop="fileType">
+            <el-select
+              v-model="dataForm.fileType"
+              placeholder="请选择">
+              <el-option v-for="item in optionsType"
+                         :key="item.code"
+                         :label="item.value"
+                         :value="item.code">
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-row>
+        <el-form-item label="备注说明" prop="notes">
+          <el-input type="textarea" v-model="dataForm.notes"></el-input>
+        </el-form-item>
+      </el-row>
+      <el-row>
+        <upload-component :title="'电子文件'" :accept="'*'" :file-obj-list="fileList" :limit="1" @uploadSuccess="uploadSuccess"/>
+      </el-row>
+    </el-form>
+    <span slot="footer" class="dialog-footer">
+      <el-button @click="onChose">取消</el-button>
+      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
+    </span>
+  </div>
+</template>
+
+<script>
+  import UserComponent from '../common/user-component'
+  import UploadComponent from '../common/upload-component'
+  import { getDictList } from '@/api/dict'
+  export default {
+    components: { UploadComponent, UserComponent },
+    computed: {
+      orgId: {
+        get () { return this.$store.state.user.orgId }
+      }
+    },
+    data () {
+      return {
+        visible: false,
+        id: 0,
+        dataForm: {},
+        dataRule: {
+          fileName: [{ required: true, message: '文件名称不能为空', trigger: 'blur' }],
+          fileDescribe: [{required: true, message: '文件描述不能为空', trigger: 'blur'}],
+          fileType: [{required: true, message: '请选择文件类别', trigger: 'change'}]
+        },
+        fileList: [],
+        optionsType: []
+      }
+    },
+    methods: {
+      onChose () {
+        this.$emit('onChose')
+      },
+      async init (id) {
+        this.dataForm = {}
+        this.id = id || 0
+        this.visible = true
+        this.fileList = []
+        // 获取沟通类别
+        await getDictList({type: 'doc_file_type'}).then(({data}) => {
+          if (data) {
+            this.optionsType = data
+          }
+        })
+        if (this.id) {
+          this.$http({
+            url: this.$http.adornUrl(`/file-service/document-ctl/info/${this.id}`),
+            method: 'get',
+            params: this.$http.adornParams()
+          }).then(({data}) => {
+            if (data && data.code === '200') {
+              this.dataForm = data.data
+              // 附件显示
+              if (data.data.attachList) {
+                data.data.attachList.forEach((item) => {
+                  this.fileList.push({
+                    name: item.fileName,
+                    url: item.url,
+                    id: item.url
+                  })
+                })
+              }
+            }
+          })
+        }
+      },
+      // 表单提交
+      dataFormSubmit () {
+        this.$refs['dataForm'].validate((valid) => {
+          if (valid) {
+            // 附件上传
+            let fList = this.fileList
+            if (fList.length > 0) {
+              this.dataForm.attachList = []
+              for (let i = 0; i < fList.length; i++) {
+                this.dataForm.attachList.push({
+                  fileName: fList[i].name,
+                  url: fList[i].url
+                })
+              }
+            } else {
+              this.$message.error('请上传文件')
+              return
+            }
+            this.$http({
+              url: this.$http.adornUrl(`/file-service/document-ctl/${!this.id ? 'save' : 'update'}`),
+              method: 'post',
+              data: this.$http.adornData({...this.dataForm, orgId: this.orgId})
+            }).then(({data}) => {
+              if (data && data.code === '200') {
+                this.$message({
+                  message: '操作成功',
+                  type: 'success',
+                  duration: 1500,
+                  onClose: () => {
+                    this.onChose()
+                    this.$emit('refreshDataList')
+                  }
+                })
+              } else {
+                this.$message.error(data.msg)
+              }
+            })
+          }
+        })
+      },
+      uploadSuccess (fileList) {
+        this.fileList = fileList
+      },
+      validateField (type) {
+        this.$refs.dataForm.validateField(type)
+      }
+    }
+  }
+</script>

+ 86 - 0
src/views/modules/doc/doc-detail.vue

@@ -0,0 +1,86 @@
+<template>
+  <div>
+    <div class="my-title">查看</div>
+    <div style="margin-left: 20px;margin-right: 20px">
+      <e-desc title="基本信息" column="3">
+        <e-desc-item label="文件名称">{{dataForm.fileName}}</e-desc-item>
+        <e-desc-item label="文件描述">{{dataForm.fileDescribe}}</e-desc-item>
+        <e-desc-item label="文件类别">{{dataForm.fileType}}</e-desc-item>
+
+        <e-desc-item label="备注说明" span="2">{{dataForm.notes}}</e-desc-item>
+      </e-desc>
+      <e-desc title="附件">
+        <e-desc-item span="2" label="电子文件">
+          <div v-for="(item, index) in dataForm.attachList" style="display: inline">
+            <span v-if="index > 0">,</span>
+            <a :key="item.fileName + index" type="primary" href="#" @click="previewFile(item.fileName, item.url)">{{ item.fileName }}</a>
+          </div>
+        </e-desc-item>
+      </e-desc>
+    </div>
+    <span slot="footer" class="dialog-footer">
+      <el-button @click="onChose">返回</el-button>
+    </span>
+    <!-- 文件预览 -->
+    <preview-component v-if="previewVisible" ref="preview"/>
+  </div>
+  <!-- </el-dialog> -->
+</template>
+
+<script>
+  import EDesc from '../common/e-desc'
+  import EDescItem from '../common/e-desc-item'
+  import { getDocDetail } from '@/api/file'
+  import PreviewComponent from '../common/preview-component'
+export default {
+    name: 'product-detail',
+    components: {
+      PreviewComponent,
+      EDesc,
+      EDescItem
+    },
+    data () {
+      return {
+        visible: false,
+        previewVisible: false,
+        id: 0,
+        dataForm: {}
+      }
+    },
+    methods: {
+      onChose () {
+        this.$emit('onChose')
+      },
+      async init (id) {
+        this.visible = true
+        this.id = id || 0
+        this.dataForm = {}
+        this.getDetails()
+      },
+      getDetails () {
+        getDocDetail(this.id).then(({data}) => {
+          if (data && data.code === '200') {
+            this.dataForm = data.data
+          }
+        })
+      },
+      // 预览
+      previewFile (fileName, url) {
+        this.previewVisible = true
+        this.$nextTick(() => {
+          this.$refs.preview.init(fileName, url)
+        })
+      }
+    }
+  }
+</script>
+
+<style scoped>
+.my-line{
+  border-bottom: 1px solid #c0c4cc;
+  margin-bottom: 10px;
+}
+.title{
+  padding: 10px 0 ;
+}
+</style>

+ 8 - 8
src/views/modules/doc/doc-list.vue

@@ -90,7 +90,7 @@
           label="操作">
           <template slot-scope="scope">
             <el-button v-if="isAuth('doc:ctl:info')" type="text" size="small" @click="detailHandle(scope.row.docId)">查看</el-button>
-            <el-button v-if="isAuth('doc:ctl:edit')" type="text" size="small" @click="addOrUpdateHandle(scope.row.docId)">编辑</el-button>
+            <el-button v-if="isAuth('doc:ctl:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.docId)">编辑</el-button>
           </template>
         </el-table-column>
       </el-table>
@@ -105,24 +105,24 @@
       </el-pagination>
     </template>
     <!-- 弹窗, 新增 / 修改 -->
-<!--    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"  @onChose="onChose"></add-or-update>-->
-<!--    <detail v-if="detailVisible" ref="detail"  @onChose="onChose"/>-->
+    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"  @onChose="onChose"></add-or-update>
+    <detail v-if="detailVisible" ref="detail"  @onChose="onChose"/>
     <!-- 文件预览 -->
     <preview-component v-if="previewVisible" ref="preview"/>
   </div>
 </template>
 
 <script>
-  // import AddOrUpdate from './notice-add-or-update'
-  // import Detail from './notice-detail'
+  import AddOrUpdate from './doc-add-or-update'
+  import Detail from './doc-detail'
   import { downloadUrl } from '@/api/file'
   import PreviewComponent from '../common/preview-component'
   export default {
     name: 'notice',
     components: {
-      PreviewComponent
-      // AddOrUpdate,
-      // Detail
+      PreviewComponent,
+      AddOrUpdate,
+      Detail
     },
     data () {
       return {