Parcourir la source

1.资产模板新增创建测算表模板等页面
2.request风格修改

GouGengquan il y a 8 mois
Parent
commit
2c01bed7cf

+ 5 - 0
src/api/fileUpload.js

@@ -0,0 +1,5 @@
+import request from '@/utils/request'
+
+export function uploadAssetsCalculateTmpl(params) {
+    return request.post('/file/assets/uploadCalculateTmpl',params)
+}

+ 6 - 0
src/api/tmplAssetsCalculate.js

@@ -0,0 +1,6 @@
+import request from '@/utils/request'
+
+// 创建资产测算表模板
+export function createTmplAssetsCalculate(params) {
+    return request.post('/tmplAssetCalculate/save',params)
+}

+ 5 - 8
src/api/user.js

@@ -1,14 +1,11 @@
 import request from '@/utils/request'
 
+// 登录
 export function loginByOAInfo(params) {
-    return request({
-        url: '/auth/loginByOAInfo?oaToken=' + params,
-        method: 'post'
-    })
+    return request.post('/auth/loginByOAInfo?oaToken=' + params)
 }
+
+// 登出
 export function logout(){
-    return request({
-        url: '/auth/logout',
-        method: 'post'
-    })
+    return request.post('/auth/logout');
 }

+ 3 - 1
src/utils/request.js

@@ -55,7 +55,9 @@ service.interceptors.response.use(
           window.location.href = import.meta.env.VITE_OA_URL;
         })
       }
-      return Promise.reject(new Error(res.message || 'Error'))
+      // 不主动抛出异常,改为返回res
+      // return Promise.reject(new Error(res.message || 'Error'))
+      return res
     } else {
       return res
     }

+ 222 - 12
src/views/assets/template/createCalculate.vue

@@ -1,27 +1,228 @@
 <template>
     <div class="contrl">
-        <el-form :model="baseInfo" label-width="auto" style="margin-top: 10px;">
-            <el-divider content-position="left"><span style="color:#ff6154;">新建测算表模板</span></el-divider>
-            
-        </el-form>
+        <el-divider content-position="left"><span style="color:#ff6154;">创建测算表模板</span></el-divider>
+        <div>
+            <el-form ref="createCalculateTmpl" :model="tmplAssetCalculate" :rules="createRules" label-width="auto"
+                style="margin-top: 10px;">
+                <el-row :gutter="10">
+                    <el-col :span="12">
+                        <el-form-item label="测算表名字:" class="form-item" prop="calculateName">
+                            <el-input v-model="tmplAssetCalculate.calculateName" clearable />
+                        </el-form-item>
+                        <el-row :gutter="10">
+                            <el-col :span="24">
+                                <el-form-item label="测算类型:" class="form-item" prop="calculateType">
+                                    <el-select v-model="tmplAssetCalculate.calculateType" placeholder="选择测算类型"
+                                        @change="calculateTypeChange">
+                                        <el-option v-for="item in calculateType" :key="item.value" :label="item.label"
+                                            :value="item.value" />
+                                    </el-select>
+                                </el-form-item>
+                            </el-col>
+                        </el-row>
+                        <el-row :gutter="10">
+                            <el-col :span="24">
+                                <el-form-item label="是否有段落模板:" class="form-item" prop="hasSection">
+                                    <el-radio-group v-model="tmplAssetCalculate.hasSection">
+                                        <el-radio value="true">有</el-radio>
+                                        <el-radio value="false">无</el-radio>
+                                    </el-radio-group>
+                                </el-form-item>
+                            </el-col>
+                        </el-row>
+                        <el-row :gutter="10">
+                            <el-col :span="24">
+                                <el-form-item label="模板CODE:" class="form-item" prop="tmplCode">
+                                    <el-select v-model="tmplAssetCalculate.tmplCode" placeholder="选择模板CODE">
+                                        <el-option v-for="item in tmplCodes" :key="item.value" :label="item.label"
+                                            :value="item.value" />
+                                    </el-select>
+                                </el-form-item>
+                            </el-col>
+                        </el-row>
+                        <el-row :gutter="10">
+                            <el-col :span="24">
+                                <el-form-item label="模板文件名字:" class="form-item" prop="fileName">
+                                    <el-input v-model="tmplAssetCalculate.fileName" clearable disabled />
+                                </el-form-item>
+                            </el-col>
+                        </el-row>
+                        <el-row :gutter="10">
+                            <el-col :span="24">
+                                <el-form-item label="模板文件存储位置:" class="form-item" prop="fileUrl">
+                                    <el-input v-model="tmplAssetCalculate.fileUrl" clearable disabled />
+                                </el-form-item>
+                            </el-col>
+                        </el-row>
+                    </el-col>
+                    <el-col :span="12">
+                        <el-upload drag action="#" multiple style="width:50%;margin-left:25%;" accept=".xls,.xlsx"
+                            :limit="1" :http-request="handleUpload" :file-list="fileList" :on-exceed="handleExceed"
+                            :before-remove="beforeRemove">
+                            <el-icon class="el-icon--upload"><upload-filled /></el-icon>
+                            <div class="el-upload__text">
+                                拖拽文件 <em>或点击上传</em>
+                            </div>
+                            <template #tip>
+                                <div class="el-upload__tip">
+                                    文件大小限制在100MB及以下
+                                </div>
+                            </template>
+                        </el-upload>
+                    </el-col>
+                </el-row>
+                <el-row :gutter="10">
+                    <el-col :span="12">
+                        <el-button type="primary" style="float:right;" @click="createCalculateTmpl()">创建模板</el-button>
+                    </el-col>
+                </el-row>
+            </el-form>
+        </div>
+
     </div>
 </template>
 
-
 <script>
 
+import { uploadAssetsCalculateTmpl } from '@/api/fileUpload'
+import { createTmplAssetsCalculate } from '@/api/tmplAssetsCalculate'
+
 export default {
     name: 'assetsCreateCalculateTmpl',
-    components:{
-        
-    },
+    components: {
 
-    data(){
-        return{
-            baseInfo:{
+    },
+    data() {
+        return {
+            equipmentTmplCode: [
+                {
+                    value: 'MAIN',
+                    label: '机器设备-主模板',
+                },
+                {
+                    value: 'MAIN_DOMESTIC',
+                    label: '机器设备-主模板-国产设备信息-段落模板',
+                },
+                {
+                    value: 'MAIN_IMPORTED',
+                    label: '机器设备-主模板-进口设备信息-段落模板',
+                },
+                {
+                    value: 'MAIN_NONSTANDARD',
+                    label: '机器设备-主模板-非标设备信息-段落模板',
+                },
+                {
+                    value: 'IMPORTED_CALCULATE',
+                    label: '机器设备-进口设备测算-段落模板',
+                },
+                {
+                    value: 'IMPORTED_CALCULATE_DETAIL',
+                    label: '机器设备-进口设备测算-详细信息-段落模板',
+                },
+                {
+                    value: 'NONSTANDARD_CALCULATE',
+                    label: '机器设备-非标设备测算-段落模板',
+                },
+                {
+                    value: 'NONSTANDARD_CALCULATE_DETAIL',
+                    label: '机器设备-非标设备测算-详细信息-段落模板',
+                }
+            ],
+            tmplCodes: null,
+            calculateType: [
+                {
+                    value: '机器设备',
+                    label: '机器设备',
+                },
+                {
+                    value: '债权',
+                    label: '债权',
+                },
+            ],
+            tmplAssetCalculate: {
 
+            },
+            fileList: [],
+            createRules: {
+                calculateName: [
+                    { required: true, message: '请输入测算表名字', trigger: 'blur' }
+                ],
+                calculateType: [
+                    { required: true, message: '请选择测算类型', trigger: 'change' }
+                ],
+                hasSection: [
+                    { required: true, message: '是否有段落模板', trigger: 'change' }
+                ],
+                tmplCode: [
+                    { required: true, message: '请选择模板CODE', trigger: 'blur' }
+                ],
+                fileName: [
+                    { required: true, message: '请上传模板文件', trigger: 'blur' }
+                ],
+                fileUrl: [
+                    { required: true, message: '请上传模板文件', trigger: 'blur' }
+                ]
             }
         }
+    },
+    methods: {
+        // 上传文件
+        handleUpload(item) {
+            let fileData = new FormData();
+            fileData.append("multipartFile", item.file)
+            uploadAssetsCalculateTmpl(fileData).then(res => {
+                if (res.code == 200) {
+                    this.tmplAssetCalculate.fileName = res.data.fileName;
+                    this.tmplAssetCalculate.fileUrl = res.data.filePath;
+                } else {
+                    this.fileList = []
+                }
+            })
+        },
+        // 文件上传数量限制
+        handleExceed() {
+            ElMessage({
+                showClose: true,
+                message: "最多选择一个文件!",
+                type: 'error'
+            })
+        },
+        // 移除文件
+        beforeRemove(file, fileList) {
+            fileList = fileList.filter((o) => {
+                return o.name !== file.name
+            });
+            this.tmplAssetCalculate.fileName = null;
+            this.tmplAssetCalculate.fileUrl = null;
+        },
+        calculateTypeChange() {
+            if (this.tmplAssetCalculate.calculateType == "机器设备") {
+                this.tmplCodes = this.equipmentTmplCode;
+            }
+            if (this.tmplAssetCalculate.calculateType == "债权") {
+                this.tmplCodes = null;
+            }
+        },
+        // 创建测算表模板
+        createCalculateTmpl() {
+            this.$refs.createCalculateTmpl.validate((valid) => {
+                if (valid) {
+                    createTmplAssetsCalculate(this.tmplAssetCalculate).then(res => {
+                        if (res.code == 200) {
+                            this.$refs.createCalculateTmpl.resetFields();
+                            ElMessage({
+                                showClose: true,
+                                message: res.message,
+                                type: 'success',
+                                onClose: ()=>{
+                                    this.$router.push('/home/assets/template/mange')
+                                }
+                            })
+                        }
+                    })
+                }
+            });
+        },
     }
 }
 </script>
@@ -33,7 +234,16 @@ export default {
     border-right: 1.5px #dae1eb solid;
     padding: 20px 20px 20px 0px;
     float: left;
-
 }
 
+:deep(*) {
+    color-scheme: light;
+    --el-color-primary: #ff6154;
+    --el-color-primary-light-3: #ff7154;
+    --el-color-primary-light-5: #ff8154;
+    --el-color-primary-light-7: #ff9154;
+    --el-color-primary-light-8: #ffa999;
+    --el-color-primary-light-9: #ffa854;
+    --el-color-primary-dark-2: #ff8154;
+}
 </style>

+ 1 - 2
src/views/assets/template/mange.vue

@@ -32,11 +32,10 @@ export default {
   },
 
   created() {
-    console.log("in")
+    
   },
   methods: {
     goCreateCalculateTmpl() {
-      console.log("in")
       this.$router.push('/home/assets/template/create/calculate')
     },
     nextFolder() {