From 0311359d2b04fc7176509b00a383dce057443001 Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期日, 08 十二月 2024 22:30:52 +0800
Subject: [PATCH] 导入合同规则
---
src/api/platform/contract.js | 12 +++
src/views/system/contract/contract/index.vue | 198 +++++++++++++++++++++++++++++++++++++------------
2 files changed, 162 insertions(+), 48 deletions(-)
diff --git a/src/api/platform/contract.js b/src/api/platform/contract.js
index 1ef129b..df9cb53 100644
--- a/src/api/platform/contract.js
+++ b/src/api/platform/contract.js
@@ -42,3 +42,15 @@
method: 'delete'
})
}
+// 瀵煎叆
+export function importRule(data) {
+ return request({
+ url: '/system/contract/updateRule',
+ method: 'post',
+ data: data,
+ headers: {
+ 'Content-Type': 'multipart/form-data'
+ },
+ timeout: 150000
+ })
+}
diff --git a/src/views/system/contract/contract/index.vue b/src/views/system/contract/contract/index.vue
index 9d9757d..a62359a 100644
--- a/src/views/system/contract/contract/index.vue
+++ b/src/views/system/contract/contract/index.vue
@@ -87,8 +87,8 @@
:before-close="handleClose"
size="40%">
<div style="margin-left: 20px;">
- <el-form :inline = "true" :model="form" class="table-expand" >
- <el-form-item label="鍚堝悓鍚嶇О" prop="name" >
+ <el-form :inline="true" :model="form" class="table-expand">
+ <el-form-item label="鍚堝悓鍚嶇О" prop="name">
<el-input v-model="form.name" style="width: 600px;"></el-input>
</el-form-item>
<el-form-item label="鍏徃鍚嶇О" prop="unitId">
@@ -170,7 +170,7 @@
</el-link
>
<div style="text-align: right; margin-top: 10px">
-<!-- <el-button type="primary" @click="handleImportRule">瀵煎叆瑙勫垯</el-button>-->
+ <el-button type="primary" @click="handleImportRule">瀵煎叆瑙勫垯</el-button>
<el-button type="primary" @click="submitForm">鎻愪氦</el-button>
</div>
</el-collapse>
@@ -184,46 +184,44 @@
width="1000px"
append-to-body
>
- <el-form ref="form" :model="upload" :rules="rules" label-width="80px">
- <div class="row-right" style="margin-left: 80px">
- <div class="margin-5">
- <el-upload
- ref="upload"
- :limit="1"
- accept=".xlsx, .xls"
- :headers="upload.headers"
- :action="upload.url"
- :disabled="upload.isUploading"
- :on-progress="handleFileUploadProgress"
- :on-success="handleFileSuccess"
- :data="upload"
- :auto-upload="false"
- drag
- style="text-align: center"
- >
- <i class="el-icon-upload"></i>
- <div class="el-upload__text">
- 灏嗘枃浠舵嫋鍒版澶勶紝鎴�<em>鐐瑰嚮涓婁紶</em>
- </div>
- <div class="el-upload__tip text-center" slot="tip">
- <span>浠呭厑璁稿鍏ls銆亁lsx鏍煎紡鏂囦欢銆�</span>
- <el-link
- type="primary"
- :underline="false"
- style="font-size: 12px; vertical-align: baseline"
- @click="importTemplate"
- >涓嬭浇妯℃澘
- </el-link
- >
- </div>
- </el-upload>
- </div>
- </div>
+ <el-form ref="importRule" :model="importRule" :rules="importRuleRules" label-width="80px">
+ <!-- <div class="row-right" style="margin-left: 80px">-->
+ <!-- <div class="margin-5">-->
+ <el-upload
+ ref="importRuleUpload"
+ :limit="1"
+ accept=".xlsx, .xls"
+ :headers="importRule.headers"
+ :action="importRule.url"
+ :disabled="importRule.isUploading"
+ :file-list="fileList"
+ :before-upload="beforeUpload"
+ drag
+ style="text-align: center"
+ >
+ <i class="el-icon-upload"></i>
+ <div class="el-upload__text">
+ 灏嗘枃浠舵嫋鍒版澶勶紝鎴�<em>鐐瑰嚮涓婁紶</em>
+ </div>
+ <div class="el-upload__tip text-center" slot="tip">
+ <span>浠呭厑璁稿鍏ls銆亁lsx鏍煎紡鏂囦欢銆�</span>
+ <el-link
+ type="primary"
+ :underline="false"
+ style="font-size: 0.7vw; vertical-align: baseline"
+ @click="importTemplate"
+ >涓嬭浇妯℃澘
+ </el-link
+ >
+ </div>
+ </el-upload>
+ <!-- </div>-->
+ <!-- </div>-->
<el-divider content-position="left">鑰冩牳缁撴灉搴旂敤瑙勫垯</el-divider>
<div class="row-warp">
<div
class="row"
- v-for="(item, index) in upload.ruleList"
+ v-for="(item, index) in importRule.ruleList"
:key="index"
>
<div class="row-left" style="flex: 0.7">
@@ -249,7 +247,7 @@
type="danger"
icon="el-icon-delete"
circle
- @click="deleteRule(index)"
+ @click="deleteImportRule(index)"
></el-button>
</el-form-item>
</div>
@@ -261,13 +259,13 @@
type="success"
icon="el-icon-plus"
circle
- @click="addRule"
+ @click="addImportRule"
></el-button>
</el-form>
<div slot="footer" class="dialog-footer">
- <el-button @click="upload.open = false">鍙� 娑�</el-button>
- <el-button type="primary" @click="submitFileForm">纭� 瀹�</el-button>
+ <el-button @click="importRule.open = false">鍙� 娑�</el-button>
+ <el-button type="primary" @click="submitImportRule">纭� 瀹�</el-button>
</div>
</el-dialog>
<!-- 鍚堝悓瀵煎叆瀵硅瘽妗� -->
@@ -416,6 +414,7 @@
import {deptSelect} from "../../../../api/system/dept";
import {getToken} from "@/utils/auth";
import {ImagePreview} from "@/components/ImagePreview";
+import {importRule} from "../../../../api/platform/contract";
export default {
name: "Contract",
@@ -426,6 +425,7 @@
name: '',
status: ''
},
+ fileList: [],
drawer: false,
direction: 'rtl',
loading: false,
@@ -461,6 +461,7 @@
url: process.env.VUE_APP_BASE_API + "/system/contract/updateRule",
ruleList: [],
},
+
dialogImageUrl: "",
dialogVisible: false,
disabled: false,
@@ -522,6 +523,17 @@
},
],
},
+ // 琛ㄥ崟鏍¢獙
+ importRuleRules: {
+ ruleList: [
+ {
+ type: "array",
+ required: true,
+ message: "鑰冩牳缁撴灉搴旂敤瑙勫垯涓嶈兘涓虹┖",
+ trigger: "submit",
+ },
+ ],
+ },
};
},
created() {
@@ -530,6 +542,11 @@
this.selectDept();
},
methods: {
+ beforeUpload(file) {
+ this.importRule.file = file
+ this.fileList = [file]
+ return false
+ },
handleClose(done) {
this.$confirm('纭鍏抽棴锛�')
.then(_ => {
@@ -544,8 +561,17 @@
description: "",
});
},
+ addImportRule() {
+ this.importRule.ruleList.push({
+ scoreCondition: "",
+ description: "",
+ });
+ },
deleteRule(index) {
this.upload.ruleList.splice(index, 1);
+ },
+ deleteImportRule(index) {
+ this.importRule.ruleList.splice(index, 1);
},
submitForm() {
this.form.startTime = this.form.timezone[0]
@@ -568,6 +594,7 @@
},
/** 瀵煎叆鎸夐挳鎿嶄綔 */
handleImportRule() {
+ this.resetImportRule();
this.importRule.title = "瑙勫垯瀵煎叆";
this.importRule.open = true;
},
@@ -578,6 +605,22 @@
// 鏂囦欢涓婁紶涓鐞�
handleFileUploadProgress(event, file, fileList) {
this.upload.isUploading = true;
+ },
+ // 鏂囦欢涓婁紶涓鐞�
+ handleRuleUploadProgress(event, file, fileList) {
+ this.importRule.isUploading = true;
+ },
+ // 鏂囦欢涓婁紶鎴愬姛澶勭悊
+ handleRuleSuccess(response, file, fileList) {
+ this.importRule.open = false;
+ this.importRule.isUploading = false;
+ this.$refs.importRule.clearFiles();
+ if (response.code != 200) {
+ this.$message.warning(response.msg);
+ } else {
+ this.$message.success(response.msg);
+ }
+ this.getList();
},
// 鏂囦欢涓婁紶鎴愬姛澶勭悊
handleFileSuccess(response, file, fileList) {
@@ -590,6 +633,27 @@
this.$message.success(response.msg);
}
this.getList();
+ },
+ // 鎻愪氦瀵煎叆瑙勫垯
+ submitImportRule() {
+ let that = this;
+ that.importRule.id = this.form.id
+ that.importRule.ruleList = JSON.stringify(this.importRule.ruleList);
+ that.loading = true;
+ that.importRule.open = false;
+ const file = this.importRule.file;
+ let formData = new FormData()
+ if(file) {
+ formData.append("file", file)
+ }
+ formData.append('id', this.form.id);
+ formData.append('ruleList', this.importRule.ruleList);
+ importRule(formData).then(res => {
+ this.$message.success("瀵煎叆鎴愬姛")
+ that.loading = false;
+ that.getRuleListById(that.importRule.id)
+ })
+ // that.resetImportRule();
},
// 鎻愪氦涓婁紶鏂囦欢
submitFileForm() {
@@ -604,6 +668,20 @@
that.reset();
});
}
+ });
+ },
+ getRuleListById(id) {
+ getRuleListByContractId(id).then((response) => {
+ this.ruleData = response.data;
+ if (this.ruleData) {
+ this.ruleName = this.ruleData.map((item) => {
+ return item.ruleName;
+ });
+ this.ruleName = [...new Set(this.ruleName)];
+ }
+ });
+ getMoneyRulesByContractId(id).then((response) => {
+ this.moneyRules = response.data;
});
},
// 鏃堕棿閫夋嫨鍙戠敓鍙樺寲
@@ -665,8 +743,7 @@
},
/** 璇︽儏鎸夐挳鎿嶄綔 */
handleDetail(item) {
- this.form = {
- }
+ this.form = {}
this.form.name = item.name
this.form.unitId = item.unitId
this.form.startTime = item.startTime
@@ -692,13 +769,38 @@
handleDownload(data) {
this.$download.resource(data);
},
+ resetImportRule() {
+ this.importRule = {
+ // 鏄惁鏄剧ず寮瑰嚭灞傦紙鍚堝悓瀵煎叆锛�
+ open: false,
+ // 寮瑰嚭灞傛爣棰橈紙鍚堝悓瀵煎叆锛�
+ title: "",
+ // 鏄惁绂佺敤涓婁紶
+ isUploading: false,
+ // 璁剧疆涓婁紶鐨勮姹傚ご閮�
+ headers: {Authorization: "Bearer " + getToken()},
+ // 涓婁紶鐨勫湴鍧�
+ url: process.env.VUE_APP_BASE_API + "/system/contract/updateRule",
+ ruleList: [],
+ };
+ this.resetForm("importRule");
+ },
reset() {
this.upload = {
+ // 鏄惁鏄剧ず寮瑰嚭灞傦紙鍚堝悓瀵煎叆锛�
open: false,
- name: undefined,
- unitId: undefined,
- timezone: undefined,
+ // 寮瑰嚭灞傛爣棰橈紙鍚堝悓瀵煎叆锛�
+ title: "",
+ // 鏄惁绂佺敤涓婁紶
+ isUploading: false,
+ // 璁剧疆涓婁紶鐨勮姹傚ご閮�
+ headers: {Authorization: "Bearer " + getToken()},
+ // 涓婁紶鐨勫湴鍧�
+ url: process.env.VUE_APP_BASE_API + "/system/contract/importData",
ruleList: [],
+ unitId: "",
+ startTime: "",
+ endTime: "",
};
this.resetForm("form");
},
--
Gitblit v1.8.0