Commit c023df18 by 韩达

PI及合同上传、删除

parent f9dfb9b2
......@@ -16,8 +16,8 @@ export let NODE_ENVS_MSG = "/";//消息系统
switch (envs) {
case 'development':
//开发环境
NODE_ENVS = 'http://cloud.liexindev.net';
// NODE_ENVS = 'http://cloud.hd.liexinlocal.com';
// NODE_ENVS = 'http://cloud.liexindev.net';
NODE_ENVS = 'http://cloud.hd.liexinlocal.com';
NODE_ENVS_MSG = 'http://192.168.1.252:16543';
break;
case 'test':
......@@ -33,7 +33,7 @@ switch (envs) {
}
export const http = (method, url, param, loading) => {
export const http = (method, url, param, loading, responseType) => {
//axios.defaults.withCredentials = true; // 携带cookie
//loading 默认加载loading 传1 不加载
param = param && typeof param === 'object' ? param : {};
......@@ -59,6 +59,11 @@ export const http = (method, url, param, loading) => {
} else if (method === 'get' || method == 'GET') {
config.params = param;
}
if ( responseType ){
config.responseType = responseType;
}
return axios(config);
}
......
......@@ -31,24 +31,50 @@
<div class="xktitle" style="margin-bottom:10px;">合同信息</div>
<div class="operation-button row verCenter" style="margin-bottom:10px;">
<el-button type="primary" @click="downloadContract">下载猎芯合同</el-button>
<el-select v-model="lang" placeholder="中文" style="margin-left:10px;width: 5%;">
<el-option label="中文" value="1"></el-option>
<el-option label="英文" value="2"></el-option>
<el-select v-model="selectedLang" placeholder="" style="margin-left:10px;width: 5%;">
<el-option v-for="option in langOptions" :label="option.label" :value="option.value" :key="option.value"></el-option>
</el-select>
</div>
<div class="data-box th-all" style="margin-bottom:20px;" v-if="tableData">
<el-table :data="tableData" border>
<el-table-column prop="quote_sn" label="语言" min-width="30"></el-table-column>
<el-table-column prop="goods_name" label="合同编号" min-width="100"></el-table-column>
<el-table-column prop="brand_name" label="生成时间" min-width="80"></el-table-column>
<el-table-column prop="purchase_qty" label="合同附件" min-width="150"></el-table-column>
<el-table-column prop="price_without_tax" label="回传时间" width="150"></el-table-column>
<el-table-column prop="total_amount" label="上传人" width="120"></el-table-column>
<div class="data-box th-all" style="margin-bottom:20px;">
<el-table :data="contractData" border>
<el-table-column prop="languageType" label="语言" min-width="30"></el-table-column>
<el-table-column prop="contractSn" label="合同编号" min-width="100"></el-table-column>
<el-table-column prop="contractBuildTime" label="生成时间" min-width="80"></el-table-column>
<el-table-column label="合同附件" min-width="150">
<template slot-scope="scope">
<el-link v-if="scope.row.contractFileUrl!=''" :href=" scope.row.contractFileUrl " target="_blank">{{ scope.row.contractFileUrl }}</el-link>
</template>
</el-table-column>
<el-table-column prop="contractReturnDate" label="回传时间" width="150"></el-table-column>
<el-table-column prop="createName" label="上传人" width="120"></el-table-column>
<el-table-column fixed="right" label="操作" width="150" align="center">
<template slot-scope="scope">
<el-button @click="handleClick(scope.row)" type="primary" size="mini" class="yunyin-btn">上传PI</el-button>
<!-- <el-button @click="handleClick(scope.row)" type="primary" size="mini" class="yunyin-btn">上传合同</el-button>
<el-button @click="handleClick(scope.row)" type="primary" size="mini" class="yunyin-btn">删除合同</el-button> -->
<!-- 订单状态不是“完成,作废”,合同状态为有效 -->
<!-- 采购组织为“深贸电子”时,下载猎芯合同有中文,英文两种选择;列表有中文,英文两行,列表按钮分别为“上传PI,上传合同” -->
<div v-if="infos.company_id==2 && infos.status!=4 && infos.status!=-3 && scope.row.status ==1">
<el-button type="primary" v-if=" scope.row.contractFileUrl!='' " @click="delContract(scope.row)" >
<span>删除合同</span>
</el-button>
<el-upload v-else-if=" scope.row.languageType=='中文' " :headers="{ Authorization: 'Bearer ' + token }" :data="{supplier_id:supplier_id,contract_id:scope.row.contractId,type:'upload'}" :action="uploadUrl" :on-success="handleUploadSuccess" >
<el-button type="primary">上传PI</el-button>
</el-upload>
<el-upload v-else-if=" scope.row.languageType=='英文' " :headers="{ Authorization: 'Bearer ' + token }" :data="{supplier_id:supplier_id,contract_id:scope.row.contractId,type:'upload'}" :action="uploadUrl" :on-success="handleUploadSuccess" >
<el-button type="primary">上传合同</el-button>
</el-upload>
</div>
<!-- 采购组织为“猎芯科技”时,下载猎芯合同只能选择中文,列表也只有中文一行,列表按钮为“上传合同” -->
<div v-if="infos.company_id==1 && infos.status!=4 && infos.status!=-3 && scope.row.status ==1">
<el-button type="primary" v-if=" scope.row.contractFileUrl!='' " @click="delContract(scope.row)" >
<span>删除合同</span>
</el-button>
<el-upload v-else-if=" scope.row.languageType=='中文' " :headers="{ Authorization: 'Bearer ' + token }" :data="{supplier_id:supplier_id,contract_id:scope.row.contractId,type:'upload'}" :action="uploadUrl" :on-success="handleUploadSuccess" >
<el-button type="primary">上传合同</el-button>
</el-upload>
</div>
</template>
</el-table-column>
</el-table>
......@@ -75,24 +101,54 @@
</template>
<script>
import Vue from 'vue';
import Tool from '../../tool'
import Menu from "@/components/menu.vue";
import {Col, Message, Pagination, Row, Table, TableColumn, Select, Option} from 'element-ui'
import {Col, Message, Pagination, Row, Table, TableColumn, Select, Option, Link, Upload} from 'element-ui';
import axios from 'axios';
import {NODE_ENVS} from "../../ajax";
Vue.prototype.$message = Message;
Vue.use(Pagination);
Vue.use(TableColumn).use(Table).use(Row).use(Col).use(Select).use(Option);
Vue.use(TableColumn).use(Table).use(Row).use(Col).use(Select).use(Option).use(Link).use(Upload);
export default {
name: "orderTrackGoodsDetail",
data() {
return {
token: Tool.getCookie('token'),
supplier_id: 0,
infos: {},
tableData: "",
purchase_id: "",
lang: "1"
contractData: [],
langOptions: [],
selectedLang: '',
uploadUrl: NODE_ENVS + '/api/purContract/updateOrderContract',
fileData: {
token: this.token,
contract_id: 0,
oss_file_id: '',
},
};
},
created() {
this.getData(this.$route.query.purchase_id);
// 1猎芯科技,2深茂电子
if( this.infos.company_id == 1 ){
this.langOptions = [
{ label: '中文', value: 1 },
];
this.selectedLang = 1;
}else{
this.langOptions = [
{ label: '中文', value: 2 },
{ label: '英文', value: 3 },
];
this.selectedLang = 2;
}
this.supplier_id = localStorage.getItem('supplier_id');
},
watch: {
$route(to, from) {
......@@ -111,9 +167,11 @@ export default {
this.$http('post', "/api/purchase/purOrderDetail", {
id: id
}).then(res => {
console.log(res);
if (res.code === 0) {
this.infos = res.data.purchase_info;
this.tableData = res.data.purchase_item_list || [];
this.contractData = res.data.pur_contract_list || [];
} else {
this.$message({
message: res.msg,
......@@ -123,11 +181,63 @@ export default {
})
},
handleUploadSuccess(file, fileList) {
if (file.code === 0) {
this.$message({
message: '上传成功',
type: 'success',
});
window.location.reload();
} else {
this.$message({
message: file.msg,
type: 'warning'
});
}
},
//下载猎芯合同
downloadContract() {
return true;
}
// var that = this;
console.log(this.selectedLang);
this.$http('get', "/api/purContract/pdfHk", {
id: this.$route.query.purchase_id
}, true, 'blob').then(res => {
// 包装成 Blob 对象
const blob = new Blob([res.data], { type: 'application/pdf' });
// 创建 URL 对象
let pdfUrl = window.URL.createObjectURL(blob);
window.open(pdfUrl, '_blank');
})
},
// 3 删除合同
delContract(contractItem){
this.$http('post', "/api/purContract/updateOrderContract", {
contract_id:contractItem.contractId,
type:'delete',
}).then(res => {
console.log(res);
if( res.code === 0 ){
this.$message({
message: '删除成功',
type: 'success',
});
window.location.reload();
}else{
this.$message({
message: file.msg,
type: 'warning'
});
}
})
},
},
components: {
Menu
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment