From 901be26b0491501afe8eb145392a8d8c307f0138 Mon Sep 17 00:00:00 2001
From: 唐耀东 <18861537@qq.com>
Date: 星期三, 12 十月 2022 16:37:09 +0800
Subject: [PATCH] 新增施工交付其他交付功能

---
 src/utils/down.js                                 |   74 ++++++++
 src/views/construction/constructionList/index.vue |    7 
 src/main.js                                       |    4 
 src/views/basics/template/index.vue               |   26 ++
 src/api/oa/other.js                               |   44 ++++
 src/views/construction/other/index.vue            |  345 ++++++++++++++++++++++++++++++++++++++
 6 files changed, 494 insertions(+), 6 deletions(-)

diff --git a/src/api/oa/other.js b/src/api/oa/other.js
new file mode 100644
index 0000000..ae7d2ef
--- /dev/null
+++ b/src/api/oa/other.js
@@ -0,0 +1,44 @@
+import request from '@/utils/request'
+
+// 鏌ヨ鏂藉伐浜や粯-鍏朵粬鍒楄〃
+export function listOther(query) {
+  return request({
+    url: '/oa/other/list',
+    method: 'get',
+    params: query
+  })
+}
+
+// 鏌ヨ鏂藉伐浜や粯-鍏朵粬璇︾粏
+export function getOther(id) {
+  return request({
+    url: '/oa/other/' + id,
+    method: 'get'
+  })
+}
+
+// 鏂板鏂藉伐浜や粯-鍏朵粬
+export function addOther(data) {
+  return request({
+    url: '/oa/other',
+    method: 'post',
+    data: data
+  })
+}
+
+// 淇敼鏂藉伐浜や粯-鍏朵粬
+export function updateOther(data) {
+  return request({
+    url: '/oa/other',
+    method: 'put',
+    data: data
+  })
+}
+
+// 鍒犻櫎鏂藉伐浜や粯-鍏朵粬
+export function delOther(id) {
+  return request({
+    url: '/oa/other/' + id,
+    method: 'delete'
+  })
+}
diff --git a/src/main.js b/src/main.js
index 1b818cf..6227835 100644
--- a/src/main.js
+++ b/src/main.js
@@ -37,7 +37,8 @@
 import DictData from '@/components/DictData'
 // 寮瑰嚭灞傜粍浠�
 import Dialog from '@/components/Dialog/index'
-
+//涓嬭浇闄勪欢
+import { downFile } from '@/utils/down.js'
 // 鍏ㄥ眬鏂规硶鎸傝浇
 Vue.prototype.getDicts = getDicts
 Vue.prototype.getConfigKey = getConfigKey
@@ -48,6 +49,7 @@
 Vue.prototype.selectDictLabels = selectDictLabels
 Vue.prototype.download = download
 Vue.prototype.handleTree = handleTree
+Vue.prototype.downFile = downFile
 
 // 鍏ㄥ眬缁勪欢鎸傝浇
 Vue.component('DictTag', DictTag)
diff --git a/src/utils/down.js b/src/utils/down.js
new file mode 100644
index 0000000..582af88
--- /dev/null
+++ b/src/utils/down.js
@@ -0,0 +1,74 @@
+import axios from 'axios'
+import fa from 'element-ui/src/locale/lang/fa'
+/**
+ * 涓嬭浇闄勪欢
+ */
+export function downFile(url, fileName) {
+  let type = fileType(url);
+  console.log(type);
+  axios({
+    url: url, // 鏈嶅姟鍣ㄤ笂pdf璺緞
+    method: 'get',
+    responseType: 'blob'
+  }).then(res => {
+    //console.log(res)
+    let blob = new Blob([res.data], {
+      //type绫诲瀷鍚庣杩斿洖鏉ョ殑鏁版嵁涓細鏈夛紝鏍规嵁鑷繁瀹為檯杩涜淇敼
+      // 琛ㄦ牸涓嬭浇涓� application/xlsx锛屽帇缂╁寘涓� application/zip绛夛紝
+
+      type: fileType(url),
+    });
+    if (typeof window.navigator.msSaveBlob !== "undefined") {
+      window.navigator.msSaveBlob(blob, fileName);
+    } else {
+      var blobURL = window.URL.createObjectURL(blob);
+      // 鍒涘缓闅愯棌<a>鏍囩杩涜涓嬭浇
+      var tempLink = document.createElement("a");
+      tempLink.style.display = "none";
+      tempLink.href = blobURL;
+      tempLink.setAttribute("download", fileName);
+      if (typeof tempLink.download === "undefined") {
+        tempLink.setAttribute("target", "_blank");
+      }
+      document.body.appendChild(tempLink);
+      tempLink.click();
+      document.body.removeChild(tempLink);
+      window.URL.revokeObjectURL(blobURL);
+    }
+  }).catch(err => {
+    //loading.close();
+    // eslint-disable-next-line no-undef
+    console.log(err)
+  })
+}
+export function fileType(url) {
+  let suffix = url.substring(url.lastIndexOf('.')+1)
+  let type;
+  switch (suffix) {
+    case "pdf":
+      type = "application/pdf";
+      break;
+    case "doc":
+      type = "application/msword";
+      break;
+    case "docx":
+      type = "application/msword";
+      break;
+    case "xls":
+      type = "application/vnd.ms-excel";
+      break;
+    case "xlsx":
+      type = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
+      break;
+    case "ppt":
+      type = "application/vnd.ms-powerpoint";
+      break;
+    case "pptx":
+      type = "application/vnd.ms-powerpoint";
+      break;
+    default:
+      type = "";
+      break;
+  }
+  return type;
+}
diff --git a/src/views/basics/template/index.vue b/src/views/basics/template/index.vue
index 4111efa..4ff2b62 100644
--- a/src/views/basics/template/index.vue
+++ b/src/views/basics/template/index.vue
@@ -1,5 +1,9 @@
 <template>
-  <div class="app-container">
+  <div class="app-container"
+       v-loading.fullscreen.lock="downLoading"
+       element-loading-text="涓嬭浇涓�"
+       element-loading-spinner="el-icon-loading"
+       element-loading-background="rgba(0, 0, 0, 0.8)">
         <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
           <el-form-item label="妯℃澘鍚嶇О" prop="templateName">
             <el-input
@@ -75,7 +79,10 @@
       </el-table-column>
       <el-table-column label="妯℃澘" align="left" prop="templateName">
         <template slot-scope="scope">
-          <el-link v-if="scope.row.fileUrl" type="primary" :href="scope.row.fileUrl" target="_blank">
+<!--          <el-link v-if="scope.row.fileUrl"  type="primary" :href="scope.row.fileUrl" target="_blank">-->
+<!--            {{ scope.row.templateName }}-->
+<!--          </el-link>-->
+          <el-link v-if="scope.row.fileUrl"  type="primary"  @click="uploadFile(scope.row)">
             {{ scope.row.templateName }}
           </el-link>
           <el-link v-else type="primary">{{ scope.row.templateName }}</el-link>
@@ -167,7 +174,7 @@
       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
         <el-form-item label="闄勪欢">
           <!--          <fileUpload v-model="form.fileUrl" :limit="1" :fileType="[`pdf`]"/>-->
-          <minio-upload v-model="form.fileUrl" :limit="1" :fileType="[`pdf`, 'xls', 'xlsx', 'ppt', 'pptx','doc','docx']"></minio-upload>
+          <minio-upload v-model="form.fileUrl" :limit="1" :fileType="['xls', 'xlsx', 'ppt', 'pptx','doc','docx']"></minio-upload>
         </el-form-item>
       </el-form>
       <div slot="footer" class="dialog-footer">
@@ -182,6 +189,7 @@
 import {listTemplate, getTemplate, delTemplate, addTemplate, updateTemplate} from "@/api/oa/template";
 import minioUpload from '@/components/FileUpload/minio'
 
+
 export default {
   name: "Template",
   components: {minioUpload},
@@ -191,6 +199,7 @@
       buttonLoading: false,
       // 閬僵灞�
       loading: true,
+      downLoading: false,
       // 閫変腑鏁扮粍
       ids: [],
       // 闈炲崟涓鐢�
@@ -358,7 +367,16 @@
         this.uploadFlag = true;
         this.title = "涓婁紶闄勪欢";
       });
-    }
+    },
+    uploadFile(item){
+      console.log(item)
+      if (!item) {
+        return;
+      }
+      this.downLoading = true;
+      this.downFile(item.fileUrl, item.templateName);
+      this.downLoading = false;
+    },
   }
 };
 </script>
diff --git a/src/views/construction/constructionList/index.vue b/src/views/construction/constructionList/index.vue
index c55c0ff..9ced228 100644
--- a/src/views/construction/constructionList/index.vue
+++ b/src/views/construction/constructionList/index.vue
@@ -30,6 +30,9 @@
           <el-tab-pane label="杞欢绯荤粺" name="eight">
             <system v-if="activeName === 'eight'" :schoolId="schoolId"></system>
           </el-tab-pane>
+          <el-tab-pane label="鍏朵粬" name="nine">
+            <other v-if="activeName === 'nine'" :schoolId="schoolId"></other>
+          </el-tab-pane>
         </el-tabs>
         <div class="right-view-title-icon">
           <img alt="" title="鏂藉伐鎵规" src="@/assets/images/batch-icon.png" @click="batchOpen = true" class="right-view-title-icon-item" />
@@ -58,6 +61,7 @@
 import exchange from '../exchange'
 import server from '../server'
 import system from '../system'
+import other from '../other'
 
 export default {
   name: "constructionList",
@@ -71,7 +75,8 @@
     ai,
     exchange,
     server,
-    system
+    system,
+    other
   },
   data() {
     return {
diff --git a/src/views/construction/other/index.vue b/src/views/construction/other/index.vue
new file mode 100644
index 0000000..4d3ac18
--- /dev/null
+++ b/src/views/construction/other/index.vue
@@ -0,0 +1,345 @@
+<template>
+  <div class="app-container">
+    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
+      <el-form-item label="鍚嶇О" prop="name">
+        <el-input
+          v-model="queryParams.name"
+          placeholder="璇疯緭鍏ュ悕绉�"
+          clearable
+          size="small"
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item label="閮ㄧ讲浣嶇疆" prop="buildingId">
+        <building v-model="queryParams.buildingId" :schoolId="schoolId"></building>
+      </el-form-item>
+      <el-form-item label="鏂藉伐鎵规" prop="constructionBatchId">
+        <construction-batch v-model="queryParams.constructionBatchId" :schoolId="schoolId"></construction-batch>
+      </el-form-item>
+      <template v-if="showMoreCondition">
+        <el-form-item label="鐢熶骇鍘傚晢" prop="manufacturerId">
+          <manufacturer v-model="queryParams.manufacturerId"></manufacturer>
+        </el-form-item>
+      </template>
+      <el-form-item>
+        <div class="show-more-search">
+          <ShowMore :showMoreCondition.sync="showMoreCondition"></ShowMore>
+          <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>
+        </div>
+      </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="['oa:other: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="['oa:other: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="['oa:other: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="['oa:other:export']"-->
+<!--        >瀵煎嚭</el-button>-->
+<!--      </el-col>-->
+      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+    </el-row>
+
+    <el-table v-loading="loading" :data="otherList" @selection-change="handleSelectionChange">
+      <el-table-column type="selection" width="55" align="center" />
+<!--      <el-table-column label="" align="center" prop="id" v-if="true"/>-->
+      <el-table-column label="搴忓彿" type="index" align="center" show-overflow-tooltip>
+        <template slot-scope="scope">
+          <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
+        </template>
+      </el-table-column>
+<!--      <el-table-column label="楂樻牎ID" align="center" prop="schoolId" />-->
+      <el-table-column label="鍚嶇О" min-width="300" align="center" prop="name" show-overflow-tooltip/>
+      <el-table-column label="閮ㄧ讲浣嶇疆" min-width="220" align="center" prop="buildingId_dictText" show-overflow-tooltip/>
+      <el-table-column label="鏂藉伐鎵规" align="center" prop="constructionBatchId_dictText" show-overflow-tooltip/>
+      <el-table-column label="鐢熶骇鍘傚晢" min-width="220" align="center" prop="manufacturerId_dictText" show-overflow-tooltip/>
+      <el-table-column label="鍨嬪彿" min-width="200" align="center" prop="model" show-overflow-tooltip/>
+      <el-table-column label="鎿嶄綔" align="center" fixed="right" width="220" 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="['oa:other:edit']"
+          >淇敼</el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-delete"
+            @click="handleDelete(scope.row)"
+            v-hasPermi="['oa:other: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-item label="楂樻牎ID" prop="schoolId">-->
+<!--          <el-input v-model="form.schoolId" placeholder="璇疯緭鍏ラ珮鏍D" />-->
+<!--        </el-form-item>-->
+        <el-form-item label="鍚嶇О" prop="name">
+          <el-input v-model="form.name" placeholder="璇疯緭鍏ュ悕绉�" />
+        </el-form-item>
+        <el-form-item label="閮ㄧ讲浣嶇疆" prop="buildingId">
+          <building v-if="open" v-model="form.buildingId" :schoolId="schoolId"></building>
+        </el-form-item>
+        <el-form-item label="鏂藉伐鎵规" prop="constructionBatchId">
+          <constructionBatch v-if="open" v-model="form.constructionBatchId" :schoolId="schoolId"></constructionBatch>
+        </el-form-item>
+        <el-form-item label="鐢熶骇鍘傚晢" prop="manufacturerId">
+          <manufacturer v-model="form.manufacturerId"></manufacturer>
+        </el-form-item>
+        <el-form-item label="鍨嬪彿" prop="model">
+          <el-input v-model="form.model" placeholder="璇疯緭鍏ュ瀷鍙�" />
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button :loading="buttonLoading" type="primary" @click="submitForm">纭� 瀹�</el-button>
+        <el-button @click="cancel">鍙� 娑�</el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import { listOther, getOther, delOther, addOther, updateOther } from "@/api/oa/other";
+import building from "../../components/building";
+import constructionBatch from "../../components/constructionBatch";
+import manufacturer from "../../components/manufacturer";
+import ShowMore from "@/views/components/showMore";
+export default {
+  name: "Other",
+  components:{
+    building,
+    constructionBatch,
+    manufacturer,
+    ShowMore
+  },
+  props: {
+    schoolId: {
+      type: Number,
+      default: undefined
+    }
+  },
+  data() {
+    return {
+      // 鎸夐挳loading
+      buttonLoading: false,
+      // 閬僵灞�
+      loading: true,
+      // 閫変腑鏁扮粍
+      ids: [],
+      // 闈炲崟涓鐢�
+      single: true,
+      // 闈炲涓鐢�
+      multiple: true,
+      // 鏄剧ず鎼滅储鏉′欢
+      showSearch: true,
+      // 鎬绘潯鏁�
+      total: 0,
+      // 鏂藉伐浜や粯-鍏朵粬琛ㄦ牸鏁版嵁
+      otherList: [],
+      // 寮瑰嚭灞傛爣棰�
+      title: "",
+      // 鏄惁鏄剧ず寮瑰嚭灞�
+      open: false,
+      // 鏌ヨ鍙傛暟
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        schoolId: this.schoolId,
+        name: undefined,
+        buildingId: undefined,
+        constructionBatchId: undefined,
+        manufacturerId: undefined,
+      },
+      // 琛ㄥ崟鍙傛暟
+      form: {},
+      // 琛ㄥ崟鏍¢獙
+      rules: {
+        name: [
+          { required: true, message: "鍚嶇О涓嶈兘涓虹┖", trigger: "blur" }
+        ],
+        buildingId: [
+          { required: true, message: "閮ㄧ讲浣嶇疆涓嶈兘涓虹┖", trigger: "blur" }
+        ],
+        constructionBatchId: [
+          { required: true, message: "鏂藉伐鎵规涓嶈兘涓虹┖", trigger: "blur" }
+        ],
+        manufacturerId: [
+          { required: true, message: "鐢熶骇鍘傚晢涓嶈兘涓虹┖", trigger: "blur" }
+        ],
+        model: [
+          { required: true, message: "鍨嬪彿涓嶈兘涓虹┖", trigger: "blur" }
+        ],
+      },
+      showMoreCondition: false
+    };
+  },
+  created() {
+    this.getList();
+  },
+  methods: {
+    /** 鏌ヨ鏂藉伐浜や粯-鍏朵粬鍒楄〃 */
+    getList() {
+      this.loading = true;
+      listOther(this.queryParams).then(response => {
+        this.otherList = response.rows;
+        console.log(this.otherList);
+        this.total = response.total;
+        this.loading = false;
+      });
+    },
+    // 鍙栨秷鎸夐挳
+    cancel() {
+      this.open = false;
+      this.reset();
+    },
+    // 琛ㄥ崟閲嶇疆
+    reset() {
+      this.form = {
+        id: undefined,
+        schoolId: undefined,
+        name: undefined,
+        buildingId: undefined,
+        constructionBatchId: undefined,
+        manufacturerId: undefined,
+        model: undefined,
+        createBy: undefined,
+        createTime: undefined,
+        updateBy: undefined,
+        updateTime: undefined,
+        delFlag: undefined
+      };
+      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.loading = true;
+      this.reset();
+      const id = row.id || this.ids
+      getOther(id).then(response => {
+        this.loading = false;
+        this.form = response.data;
+        this.open = true;
+        this.title = "淇敼鏂藉伐浜や粯-鍏朵粬";
+      });
+    },
+    /** 鎻愪氦鎸夐挳 */
+    submitForm() {
+      this.$refs["form"].validate(valid => {
+        if (valid) {
+          this.buttonLoading = true;
+          this.form.schoolId = this.schoolId;
+          if (this.form.id != null) {
+            updateOther(this.form).then(response => {
+              this.$modal.msgSuccess("淇敼鎴愬姛");
+              this.open = false;
+              this.getList();
+            }).finally(() => {
+              this.buttonLoading = false;
+            });
+          } else {
+            addOther(this.form).then(response => {
+              this.$modal.msgSuccess("鏂板鎴愬姛");
+              this.open = false;
+              this.getList();
+            }).finally(() => {
+              this.buttonLoading = false;
+            });
+          }
+        }
+      });
+    },
+    /** 鍒犻櫎鎸夐挳鎿嶄綔 */
+    handleDelete(row) {
+      const ids = row.id || this.ids;
+      this.$modal.confirm('鏄惁纭鍒犻櫎鏂藉伐浜や粯-鍏朵粬缂栧彿涓�"' + ids + '"鐨勬暟鎹」锛�').then(() => {
+        this.loading = true;
+        return delOther(ids);
+      }).then(() => {
+        this.loading = false;
+        this.getList();
+        this.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+      }).finally(() => {
+        this.loading = false;
+      });
+    },
+    /** 瀵煎嚭鎸夐挳鎿嶄綔 */
+    handleExport() {
+      this.download('oa/other/export', {
+        ...this.queryParams
+      }, `other_${new Date().getTime()}.xlsx`)
+    }
+  }
+};
+</script>

--
Gitblit v1.9.1