Browse Source

分析模板

qzy 10 months ago
parent
commit
9335f97a0a
3 changed files with 476 additions and 38 deletions
  1. 53 0
      src/api/report/WORD.js
  2. 167 38
      src/views/report/RECORD/index.vue
  3. 256 0
      src/views/report/WORD/index.vue

+ 53 - 0
src/api/report/WORD.js

@@ -0,0 +1,53 @@
+import request from '@/utils/request'
+
+// 查询模板报告列表
+export function listWORD(query) {
+  return request({
+    url: '/report/WORD/list',
+    method: 'get',
+    params: query
+  })
+}
+
+// 查询模板报告所有列表
+export function listAllWORD(query) {
+  return request({
+    url: '/report/WORD/listAll',
+    method: 'get',
+    params: query
+  })
+}
+
+// 查询模板报告详细
+export function getWORD(id) {
+  return request({
+    url: '/report/WORD/getInfo/' + id,
+    method: 'get'
+  })
+}
+
+// 新增模板报告
+export function addWORD(data) {
+  return request({
+    url: '/report/WORD/add',
+    method: 'post',
+    data: data
+  })
+}
+
+// 修改模板报告
+export function updateWORD(data) {
+  return request({
+    url: '/report/WORD/edit',
+    method: 'post',
+    data: data
+  })
+}
+
+// 删除模板报告
+export function delWORD(id) {
+  return request({
+    url: '/report/WORD/remove/' + id,
+    method: 'get'
+  })
+}

+ 167 - 38
src/views/report/RECORD/index.vue

@@ -21,19 +21,7 @@
             size="mini"
             @click="handleAdd"
             v-hasPermi="['report:RECORD:add']"
-        >新增
-        </el-button>
-      </el-col>
-      <el-col :span="1.5">
-        <el-button
-            type="success"
-            plain
-            icon="el-icon-edit"
-            size="mini"
-            :disabled="single"
-            @click="handleUpdate"
-            v-hasPermi="['report:RECORD:edit']"
-        >修改
+        >导入
         </el-button>
       </el-col>
       <el-col :span="1.5">
@@ -51,7 +39,7 @@
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
-    <el-table v-loading="loading" :data="RECORDList" @selection-change="handleSelectionChange" >
+    <el-table v-loading="loading" :data="RECORDList" @selection-change="handleSelectionChange">
       <el-table-column type="selection" width="55" align="center"/>
       <el-table-column type="index" width="50" align="center" label="序号"/>
       <el-table-column label="年份" align="center" prop="reportYear">
@@ -74,15 +62,15 @@
               icon="el-icon-paperclip"
               @click="handleInfo(scope.row)"
 
-          >分析详情
+          >报告详情
           </el-button>
           <el-button
               size="mini"
               type="text"
-              icon="el-icon-edit"
-              @click="handleUpdate(scope.row)"
+              icon="el-icon-upload"
               v-hasPermi="['report:RECORD:edit']"
-          >修改
+              @click="uploadReport(scope.row)"
+          >上传报告
           </el-button>
           <el-button
               size="mini"
@@ -103,26 +91,35 @@
         :limit.sync="queryParams.pageSize"
         @pagination="getList"
     />
-    <div  v-if="detail.open">
-      <div>{{detail.title}}</div>
-      <div>一、主要指标运行情况</div>
-      <div>{?}</div>
-      <p v-html="detail.form.result"></p>
-    </div>
 
     <!-- 添加或修改辅助决策对话框 -->
-    <el-dialog :title="title" :visible.sync="open" width="700px" append-to-body id="upload-win">
+    <el-dialog :title="title" :visible.sync="open" :modal="false" width="700px" append-to-body id="upload-win">
       <el-form ref="form" :model="form" :rules="rules" label-width="120px">
+        <el-form-item prop="preface" label="报告总结">
+          <el-input v-model="form.preface" type="textarea" :rows="6" style="width: 450px"
+                    placeholder="报告总结 ${preface}"></el-input>
+        </el-form-item>
+        <el-form-item prop="gxTradeTotalMoney" label="全区外贸总值">
+          <el-input v-model="form.gxTradeTotalMoney" type="number" step="0.1" style="width: 450px"
+                    placeholder="全区外贸进出口">
+            <template slot="append">亿元</template>
+          </el-input>
+          <div>用于计算综保区外贸占全区外贸进出口百分比</div>
+        </el-form-item>
         <el-form-item label="进出口总值">
           <el-upload
               ref="upload"
+              :auto-upload="false"
               :limit="1"
+              :data="{gxTradeTotalMoney:form.gxTradeTotalMoney}"
               accept=".xlsx, .xls"
               :headers="upload.headers"
               :action="upload.url + '?updateSupport=' + upload.updateSupport"
               :disabled="upload.isUploading"
               :on-progress="handleFileUploadProgress"
+              :before-upload="beforeUpload"
               :on-success="handleFileSuccess"
+              :on-change="onChange"
               drag
           >
             <i class="el-icon-upload"></i>
@@ -145,19 +142,90 @@
         <el-button @click="cancel">取 消</el-button>
       </div>
     </el-dialog>
+    <el-dialog
+        :append-to-body="true"
+        title="提示"
+        :visible.sync="notice.visible"
+        width="30%">
+      <span>确认不填写全区外贸总值直接上传?</span>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="notice.visible = false">返回填写</el-button>
+        <el-button type="warning" @click="sureUpload">直接上传</el-button>
+      </span>
+    </el-dialog>
+    <el-dialog
+        :title="word.title"
+        :visible.sync="word.visible"
+        width="800px">
+      <div style="height: 400px;overflow-y: auto">
+        <el-timeline>
+          <el-timeline-item
+              v-for="(activity, index) in word.activities"
+              :key="index"
+              :timestamp="activity.timestamp" style="padding-top: 20px">
+            {{activity.content}}<span style="font-size: 10px;padding-left: 15px"><el-link type="primary" @click="prev(activity)">下载</el-link></span>
+          </el-timeline-item>
+        </el-timeline>
+      </div>
+      <span slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="word.visible=false">关 闭</el-button>
+      </span>
+    </el-dialog>
+    <el-dialog :title="self.title" :visible.sync="self.open" :modal="false" width="500px" append-to-body id="upload-win">
+      <div style="text-align: center;padding: 20px">
+        <el-upload
+            ref="selfUpload"
+            :limit="1"
+            accept=".doc,.docx"
+            :headers="upload.headers"
+            :data="{id:self.form.id}"
+            :action="selfUrl"
+            :on-success="handleUploadSuccess"
+            drag
+        >
+          <i class="el-icon-upload"></i>
+          <div class="el-upload__text">
+            将文件拖到此处,或
+            <em>点击上传</em>
+          </div>
+          <div class="el-upload__tip text-left" slot="tip">
+            <span>仅允许导入doc、docx格式文件。</span>
+          </div>
+        </el-upload>
+      </div>
 
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="self.open=false">关 闭</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
 <script>
 import {getRECORD, listRECORD, addRECORD, delRECORD, updateRECORD} from "@/api/report/RECORD";
+import {listAllWORD} from "@/api/report/WORD"
 import {getToken} from "@/utils/auth";
-import {Loading} from 'element-ui';
+
 
 export default {
   name: "RECORD",
   data() {
     return {
+      word:{
+        title:'',
+        visible: false,
+        activities:[]
+      },
+      notice: {
+        visible: false,
+      },
+      selfUrl: process.env.VUE_APP_BASE_API + '/report/RECORD/upload',
+      self:{
+        title:'',
+        visible: false,
+        open:false,
+        form:{}
+      },
       // 根路径
       baseURL: process.env.VUE_APP_BASE_API,
       // 遮罩层
@@ -181,6 +249,7 @@ export default {
       upload: {
         // 是否显示弹出层(用户导入)
         open: false,
+        uploadFinish: false,
         // 弹出层标题(用户导入)
         title: '',
         // 是否禁用上传
@@ -201,16 +270,20 @@ export default {
         reportMonth: null,
       },
       // 表单参数
-      form: {},
+      form: {
+        preface: null,
+        gxTradeTotalMoney: null,
+      },
       // 表单校验
       rules: {
+        gxTradeTotalMoney: []
       },
-      detail:{
-        title:'详情',
-        open:false,
-       form:{
-          result:''
-       }
+      detail: {
+        title: '详情',
+        open: false,
+        form: {
+          result: ''
+        }
       }
     };
   },
@@ -218,12 +291,28 @@ export default {
     this.getList();
   },
   methods: {
+    beforeUpload(file) {
+
+    },
+    sureUpload() {
+      this.notice.visible = false;
+      this.$refs.upload.submit();
+    },
+    onChange(file, fileList) {
+      let gxTradeTotalMoney = this.form.gxTradeTotalMoney;
+      if (!gxTradeTotalMoney && !this.upload.uploadFinish) {
+        this.notice.visible = true;
+        return;
+      }
+      this.$refs.upload.submit();
+    },
     handleFileUploadProgress(event, file, fileList) {
 
     },
     handleFileSuccess(response, file, fileList) {
       let code = response.code;
       this.$refs.upload.clearFiles();
+      this.upload.uploadFinish = true;
       if (code !== 200) {
         this.$message.error(response.msg);
         return;
@@ -233,12 +322,51 @@ export default {
       this.open = false;
       this.getList();
     },
-    handleInfo(row){
-      this.detail={
-        title:row.reportYear+'年'+row.reportMonth+'月',
+    handleUploadSuccess(response, file, fileList) {
+      let code = response.code;
+      this.$refs.selfUpload.clearFiles();
+      if (code !== 200) {
+        this.$message.error(response.msg);
+        return;
+      }
+      this.$message.success('上传成功');
+      this.self.open = false;
+      this.self.visible=false;
+    },
+    uploadReport(data){
+      this.self={
+        title: "上传【"+data.reportYear+"年"+data.reportMonth+"月】的自定义报告",
+        visible: true,
         open: true,
-        form:row
+        form: data
+      }
+    },
+    handleInfo(row) {
+      listAllWORD({recordId:row.id}).then(resp=>{
+      let list = resp.data;
+      if (list.length===1){
+        window.location.href=list[0].wordPath;
+        return;
       }
+      let activities=[];
+      list.forEach(data=>{
+        let obj={
+          timestamp:data.createTime,
+          content:data.wordName,
+          path:data.wordPath
+        }
+        activities.push(obj)
+      })
+        this.word = {
+          title: row.reportYear + '年' + row.reportMonth + '月历史报告',
+          open: true,
+          visible:true,
+          activities: activities
+        }
+      })
+    },
+    prev(data){
+      window.location.href=data.path;
     },
     /** 查询辅助决策列表 */
     getList() {
@@ -286,7 +414,8 @@ export default {
     handleAdd() {
       this.reset();
       this.open = true;
-      this.title = "添加辅助决策";
+      this.title = "导入分析数据";
+      this.upload.uploadFinish = false;
     },
     /** 修改按钮操作 */
     handleUpdate(row) {

+ 256 - 0
src/views/report/WORD/index.vue

@@ -0,0 +1,256 @@
+<template>
+  <div class="app-container">
+    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
+      <el-form-item>
+        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
+        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
+      </el-form-item>
+    </el-form>
+
+    <el-row :gutter="10" class="mb8">
+      <el-col :span="1.5">
+        <el-button
+          type="primary"
+          plain
+          icon="el-icon-plus"
+          size="mini"
+          @click="handleAdd"
+          v-hasPermi="['report:WORD:add']"
+        >新增</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="success"
+          plain
+          icon="el-icon-edit"
+          size="mini"
+          :disabled="single"
+          @click="handleUpdate"
+          v-hasPermi="['report:WORD:edit']"
+        >修改</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="danger"
+          plain
+          icon="el-icon-delete"
+          size="mini"
+          :disabled="multiple"
+          @click="handleDelete"
+          v-hasPermi="['report:WORD:remove']"
+        >删除</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="warning"
+          plain
+          icon="el-icon-download"
+          size="mini"
+          @click="handleExport"
+          v-hasPermi="['report:WORD:export']"
+        >导出</el-button>
+      </el-col>
+      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+    </el-row>
+
+    <el-table v-loading="loading" :data="WORDList" @selection-change="handleSelectionChange">
+      <el-table-column label="word名称" align="center" prop="wordName">
+
+      </el-table-column>
+      <el-table-column label="生成时间" align="center" prop="createTime">
+
+      </el-table-column>
+
+      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+        <template slot-scope="scope">
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-edit"
+            @click="handleUpdate(scope.row)"
+            v-hasPermi="['report:WORD:edit']"
+          >修改</el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-delete"
+            @click="handleDelete(scope.row)"
+            v-hasPermi="['report:WORD:remove']"
+          >删除</el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+
+    <pagination
+      v-show="total>0"
+      :total="total"
+      :page.sync="queryParams.pageNum"
+      :limit.sync="queryParams.pageSize"
+      @pagination="getList"
+    />
+
+    <!-- 添加或修改模板报告对话框 -->
+    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
+      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitForm">确 定</el-button>
+        <el-button @click="cancel">取 消</el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+  import {getWORD, listWORD} from "@/api/report/WORD";
+
+  export default {
+  name: "WORD",
+  data() {
+    return {
+      // 根路径
+      baseURL: process.env.VUE_APP_BASE_API,
+      // 遮罩层
+      loading: true,
+      // 选中数组
+      ids: [],
+      // 非单个禁用
+      single: true,
+      // 非多个禁用
+      multiple: true,
+      // 显示搜索条件
+      showSearch: true,
+      // 总条数
+      total: 0,
+      // 模板报告表格数据
+      WORDList: [],
+      // 弹出层标题
+      title: "",
+      // 是否显示弹出层
+      open: false,
+      // 查询参数
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        id: null,
+        recordId: null,
+        wordPath: null,
+        createTime: null,
+        createBy: null,
+        updateTime: null,
+        updateBy: null
+      },
+      // 表单参数
+      form: {},
+      // 表单校验
+      rules: {
+        id: [
+          { required: true, message: "主键不能为空", trigger: "blur" }
+        ],
+        recordId: [
+          { required: true, message: "报告ID不能为空", trigger: "blur" }
+        ],
+        wordPath: [
+          { required: true, message: "路径不能为空", trigger: "blur" }
+        ],
+      }
+    };
+  },
+  created() {
+    this.getList();
+  },
+  methods: {
+    /** 查询模板报告列表 */
+    getList() {
+      this.loading = true;
+      listWORD(this.queryParams).then(response => {
+        this.WORDList = response.rows;
+        this.total = response.total;
+        this.loading = false;
+      });
+    },
+    // 取消按钮
+    cancel() {
+      this.open = false;
+      this.reset();
+    },
+    // 表单重置
+    reset() {
+      this.form = {
+        id: null,
+        recordId: null,
+        wordPath: null,
+      };
+      this.resetForm("form");
+    },
+    /** 搜索按钮操作 */
+    handleQuery() {
+      this.queryParams.pageNum = 1;
+      this.getList();
+    },
+    /** 重置按钮操作 */
+    resetQuery() {
+      this.resetForm("queryForm");
+      this.handleQuery();
+    },
+    // 多选框选中数据
+    handleSelectionChange(selection) {
+      this.ids = selection.map(item => item.id)
+      this.single = selection.length!==1
+      this.multiple = !selection.length
+    },
+    /** 新增按钮操作 */
+    handleAdd() {
+      this.reset();
+      this.open = true;
+      this.title = "添加模板报告";
+    },
+    /** 修改按钮操作 */
+    handleUpdate(row) {
+      this.reset();
+      const id = row.id || this.ids
+      getWORD(id).then(response => {
+        this.form = response.data;
+        this.open = true;
+        this.title = "修改模板报告";
+      });
+    },
+    /** 提交按钮 */
+    submitForm() {
+      this.$refs["form"].validate(valid => {
+        if (valid) {
+          if (this.form.id != null) {
+            updateWORD(this.form).then(response => {
+              this.$modal.msgSuccess("修改成功");
+              this.open = false;
+              this.getList();
+            });
+          } else {
+            addWORD(this.form).then(response => {
+              this.$modal.msgSuccess("新增成功");
+              this.open = false;
+              this.getList();
+            });
+          }
+        }
+      });
+    },
+    /** 删除按钮操作 */
+    handleDelete(row) {
+      const ids = row.id || this.ids;
+      this.$modal.confirm('是否确认删除模板报告编号为"' + ids + '"的数据项?').then(function() {
+        return delWORD(ids);
+      }).then(() => {
+        this.getList();
+        this.$modal.msgSuccess("删除成功");
+      }).catch(() => {});
+    },
+    /** 导出按钮操作 */
+    handleExport() {
+      this.download('report/WORD/export', {
+        ...this.queryParams
+      }, `WORD_${new Date().getTime()}.xlsx`)
+    }
+  }
+};
+</script>