fix:合同&商品管理完成
This commit is contained in:
parent
e50987ce21
commit
748d1c51fd
|
@ -53,3 +53,18 @@ export function getContractListsApi() {
|
|||
method: "get",
|
||||
});
|
||||
}
|
||||
// 保存合同信息
|
||||
export function postSubmitContractApi(data) {
|
||||
return request({
|
||||
url: `/admin/setting/savecontractsetting`,
|
||||
method: "post",
|
||||
data,
|
||||
});
|
||||
}
|
||||
// 下载合同信息
|
||||
export function postDownloadContractApi() {
|
||||
return request({
|
||||
url: `/admin/setting/getContractSetting`,
|
||||
method: "get",
|
||||
});
|
||||
}
|
||||
|
|
|
@ -2,33 +2,90 @@
|
|||
<div class="contract">
|
||||
<div class="lay">
|
||||
<div class="flex">
|
||||
<el-button type="primary">境内合同</el-button>
|
||||
<div class="word" v-if="contractObj.domestic">
|
||||
文件:{{ contractObj.domestic }}
|
||||
</div>
|
||||
<el-button type="success" v-if="contractObj.domestic"
|
||||
>下载境内合同</el-button
|
||||
<el-button type="text">境内合同:</el-button>
|
||||
<el-button type="primary" icon="el-icon-upload " @click="openDialog(1)">
|
||||
上传境内合同
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
v-if="contractObj.domestic"
|
||||
@click="downloadWord(1)"
|
||||
>
|
||||
下载境内合同
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<el-button type="danger">境外合同</el-button>
|
||||
<div class="word" v-if="contractObj.abroad">
|
||||
文件:{{ contractObj.abroad }}
|
||||
</div>
|
||||
<el-button type="success" v-if="contractObj.abroad"
|
||||
>下载境外合同</el-button
|
||||
<el-button type="text">境外合同:</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
icon="el-icon-s-promotion"
|
||||
@click="openDialog(2)"
|
||||
>
|
||||
上传境外合同
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
v-if="contractObj.abroad"
|
||||
@click="downloadWord(2)"
|
||||
>
|
||||
下载境外合同
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<el-dialog
|
||||
:visible.sync="dialogVisible"
|
||||
@open="onOpen"
|
||||
@close="onClose"
|
||||
:title="dialogTitle"
|
||||
>
|
||||
<el-form ref="elForm" :model="formData" size="medium" label-width="120px">
|
||||
<el-form-item label="上传" prop="trip_info" required>
|
||||
<el-upload
|
||||
ref="field105"
|
||||
action=""
|
||||
:before-upload="wordBeforeUpload"
|
||||
:http-request="handlesAvatarSuccess"
|
||||
:on-success="handleWordSuccess"
|
||||
:on-error="handleUploadError"
|
||||
:on-remove="handleRemove"
|
||||
:before-remove="beforeRemove"
|
||||
:limit="1"
|
||||
:file-list="fieldFileList"
|
||||
accept=".pdf,.docx,.xlsx"
|
||||
>
|
||||
<el-button size="small" type="primary" icon="el-icon-upload"
|
||||
>点击上传</el-button
|
||||
>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer">
|
||||
<el-button @click="close">取消</el-button>
|
||||
<el-button type="primary" @click="handelConfirm">确定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getContractListsApi } from "@/api/admin";
|
||||
import {
|
||||
getContractListsApi,
|
||||
postSubmitContractApi,
|
||||
postDownloadContractApi,
|
||||
} from "@/api/admin";
|
||||
import { getToken } from "@/utils/auth";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
contractObj: {},
|
||||
dialogVisible: false,
|
||||
dialogTitle: "",
|
||||
fieldFileList: [],
|
||||
formData: {
|
||||
domestic: "",
|
||||
abroad: "",
|
||||
},
|
||||
uploadPercent: 0,
|
||||
};
|
||||
},
|
||||
created() {
|
||||
|
@ -39,7 +96,138 @@ export default {
|
|||
const res = await getContractListsApi();
|
||||
this.contractObj = res.data;
|
||||
},
|
||||
onSubmit() {},
|
||||
async downloadWord(type) {
|
||||
const res = await postDownloadContractApi();
|
||||
if (res.error === 0) {
|
||||
let blob_url = type === 1 ? res.data.domestic : res.data.abroad;
|
||||
const extension = blob_url.substring(blob_url.lastIndexOf("."));
|
||||
let txt = (type === 1 ? "境内合同" : "境外合同") + extension;
|
||||
const url = window.URL.createObjectURL(new Blob([blob_url]));
|
||||
const link = document.createElement("a");
|
||||
link.style.display = "none";
|
||||
link.href = url;
|
||||
link.setAttribute("download", txt);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
}
|
||||
console.log(res, "下载合同");
|
||||
},
|
||||
onOpen() {},
|
||||
onClose() {
|
||||
this.$refs["elForm"].resetFields();
|
||||
this.$refs.field105.uploadFiles = []; // 删除该条数据
|
||||
this.fieldFileList = [];
|
||||
this.formData = {
|
||||
domestic: "",
|
||||
abroad: "",
|
||||
};
|
||||
},
|
||||
close() {
|
||||
console.log("1111", this.$refs.field105.uploadFiles);
|
||||
this.dialogVisible = false;
|
||||
this.$refs.field105.uploadFiles = []; // 删除该条数据
|
||||
},
|
||||
openDialog(num) {
|
||||
this.dialogTitle = num === 1 ? "境内合同" : "境外合同";
|
||||
this.dialogVisible = true;
|
||||
},
|
||||
async handelConfirm() {
|
||||
const isDomestic = this.dialogTitle === "境内合同";
|
||||
const fileField = isDomestic ? "domestic" : "abroad";
|
||||
const errorMessage = `请上传${isDomestic ? "境内" : "境外"}合同`;
|
||||
if (!this.formData[fileField]) {
|
||||
return this.$message.error(errorMessage);
|
||||
}
|
||||
|
||||
const res = await postSubmitContractApi(this.formData);
|
||||
if (res.error === 0) {
|
||||
this.$message.success("上传成功");
|
||||
this.getList();
|
||||
}
|
||||
this.close();
|
||||
console.log(res, "wwww");
|
||||
},
|
||||
async handlesAvatarSuccess(file) {
|
||||
try {
|
||||
var formdata = new FormData();
|
||||
formdata.append("file", file.file);
|
||||
const res = await this.$axios.post("/admin/upload/index", formdata, {
|
||||
headers: {
|
||||
"Content-type": "multipart/form-data",
|
||||
"X-Token": getToken(),
|
||||
},
|
||||
});
|
||||
console.log(res, "收拾收拾");
|
||||
if (res.error === 0) {
|
||||
file.onSuccess(res);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(file, "error--handlesAvatarSuccess");
|
||||
let uid = file.file.uid;
|
||||
let idx = this.$refs.field105.uploadFiles.findIndex(
|
||||
(item) => item.uid === uid
|
||||
);
|
||||
this.$refs.field105.uploadFiles.splice(idx, 1);
|
||||
this.$message.error(`上传失败`);
|
||||
}
|
||||
},
|
||||
handleWordSuccess(res, file, fileList, index) {
|
||||
console.log(res, file, fileList, "成功了");
|
||||
if (res) {
|
||||
const isDomestic = this.dialogTitle === "境内合同";
|
||||
const fileUrl = `${window.location.protocol}//${window.location.host}${res.data}`;
|
||||
isDomestic
|
||||
? (this.formData.domestic = fileUrl)
|
||||
: (this.formData.abroad = fileUrl);
|
||||
this.fieldFileList = [
|
||||
{
|
||||
name: file.name,
|
||||
uid: file.uid,
|
||||
url: fileUrl,
|
||||
},
|
||||
];
|
||||
this.$message.success("上传成功");
|
||||
}
|
||||
},
|
||||
beforeRemove(file, fileList) {
|
||||
return this.$confirm(`确定移除 ${file.name}?`);
|
||||
},
|
||||
handleRemove(file, fileList) {
|
||||
console.log(file, fileList, "handleRemove");
|
||||
this.formData.abroad = "";
|
||||
this.formData.domestic = "";
|
||||
this.fieldFileList.map((item, index) => {
|
||||
if (item.uid === file.uid) {
|
||||
this.fieldFileList.splice(index, 1);
|
||||
}
|
||||
});
|
||||
},
|
||||
handleUploadError(err, file) {
|
||||
this.$message.error(`上传失败: ${file.name}`);
|
||||
console.log(this.fieldFileList, "失败了");
|
||||
this.fieldFileList.map((item, index) => {
|
||||
if (item.uid === file.uid) {
|
||||
this.fieldFileList.splice(index, 1);
|
||||
}
|
||||
});
|
||||
},
|
||||
wordBeforeUpload(file) {
|
||||
const isRightType = [
|
||||
"application/pdf",
|
||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
].includes(file.type);
|
||||
const isRightSize = file.size / 1024 / 1024 < 2;
|
||||
|
||||
if (!isRightType) {
|
||||
this.$message.error("只允许上传 PDF、DOCX、XLSX 格式的文件");
|
||||
}
|
||||
if (!isRightSize) {
|
||||
this.$message.error("文件大小超过 2MB");
|
||||
}
|
||||
|
||||
return isRightType && isRightSize;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
width="60"
|
||||
prop="night"
|
||||
></el-table-column>
|
||||
<el-table-column
|
||||
<!-- <el-table-column
|
||||
align="type"
|
||||
label="详细行程"
|
||||
width="180"
|
||||
|
@ -105,7 +105,7 @@
|
|||
scope.row.trip_info
|
||||
}}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table-column> -->
|
||||
|
||||
<el-table-column width="180px" align="center" label="创建时间">
|
||||
<template slot-scope="scope">
|
||||
|
@ -364,9 +364,10 @@ export default {
|
|||
handleWordSuccess(res, file, fileList, index) {
|
||||
console.log(res, file, fileList, "成功了");
|
||||
if (res) {
|
||||
this.formData.trip_info = fileList
|
||||
.map((item) => item.url || item.response.url)
|
||||
.join(",");
|
||||
// this.formData.trip_info = fileList
|
||||
// .map((item) => item.url || item.response.url)
|
||||
// .join(",");
|
||||
this.formData.trip_info = `${window.location.protocol}//${window.location.host}${res.data}`;
|
||||
this.fieldFileList = [
|
||||
{
|
||||
name: file.name,
|
||||
|
|
|
@ -40,7 +40,7 @@ module.exports = {
|
|||
"/dev-api": {
|
||||
// 接口地址 以 api开头的都走下面的配置
|
||||
// target: 'https://www.szjinao.cn', // 代理目标地址为后端服务器地址 127.0.0.1 192.168.1.2
|
||||
target: 'http://192.168.0.100:8787', // 代理目标地址为后端服务器地址 127.0.0.1 192.168.1.2
|
||||
target: "http://hex.jipinq.cn", // 代理目标地址为后端服务器地址 127.0.0.1 192.168.1.2
|
||||
ws: true, // 是否支持 websocket 请求 支持
|
||||
changeOrigin: true, // 是否启用跨域
|
||||
pathRewrite: {
|
||||
|
|
Loading…
Reference in New Issue