Browse Source

2024-12-06

master
qiezi 1 year ago
parent
commit
edbb294bf8
  1. 281
      src/views/modules/quote/detail/primary/quoteDetailOther.vue
  2. 3
      src/views/modules/quote/detail/primary/quoteDetailTest.vue
  3. 7
      src/views/modules/quote/detail/quoteDetail.vue

281
src/views/modules/quote/detail/primary/quoteDetailOther.vue

@ -0,0 +1,281 @@
<script>
import {
queryQuoteDetailOther,
removeQuoteDetailOther, saveQuoteDetailOther,
updateQuoteDetailOther
} from "../../../../../api/quote/quoteDetailOther";
export default {
name: "quoteDetailOther",
props:{
quoteDetail:{
type: Object,
required: true
},
},
model:{
prop:"quoteDetail",
event:"update",
},
data(){
return{
queryLoading:false,
dataList:[],
other:{
itemNo:'',
otherDesc:'',
otherQty:1,
unitCost:0,
markup:0,
quoteOtherCost:0,
remark:'',
createdBy:'',
createdDate:'',
updatedBy:'',
updatedDate:'',
},
saveOther:{
},
saveVisible:false,
saveLoading:false,
otherRules:{
otherDesc: [
{ required: true, message: '请输入其他项目', trigger: ['blur','change'] }
],
otherQty: [
{ required: true, message: '请输入分摊数量', trigger: ['blur','change'] }
],
unitCost: [
{ required: true, message: '请输入分摊金额', trigger: ['blur','change'] }
],
markup: [
{ required: true, message: '请输入Mark up%', trigger: ['blur','change'] }
],
quoteOtherCost: [
{ required: true, message: '请输入单片分摊成本', trigger: ['blur','change'] }
]
},
}
},
methods:{
handleQueryQuoteDetailOther(){
let params = {
quoteDetailId: this.quoteDetail.id
}
this.dataList = [];
this.queryLoading = true
queryQuoteDetailOther(params).then(({data})=>{
if (data && data.code === 0){
this.dataList = data.rows;
}else {
this.$message.warning(data.msg)
}
this.queryLoading = false
}).catch((error)=>{
this.$message.error(error)
this.queryLoading = false
})
},
handleSave(row){
if (row){
this.saveOther = {
...row
};
}else {
this.saveOther = {...this.other};
}
this.saveVisible = true;
},
handleRemove(row){
this.$alert("确定删除该工具吗?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
let params = {
id: row.id
}
removeQuoteDetailOther(params).then(({data})=>{
if (data && data.code === 0){
this.$message.success("删除成功")
this.handleQueryQuoteDetailOther();
}else {
this.$message.warning(data.msg)
}
}).catch((error)=>{
this.$message.error(error)
})
}).catch(() => {});
},
handleSaveOrUpdate(){
this.$refs.saveOtherForm.validate((valid,obj) => {
if (valid){
if (this.saveOther.id){
this.handleUpdateOther();
}else {
this.handleSaveOther();
}
}else {
let i = 1;
for (let key in obj) {
this.$message.error(obj[key][0].message);
if (i === 1){
return
}
i++;
}
}
})
},
handleUpdateOther(){
let params ={
...this.saveOther,
updateBy:this.$store.state.user.name,
}
this.saveLoading = true
updateQuoteDetailOther(params).then(({data})=>{
this.saveLoading = false
if (data && data.code === 0){
this.$message.success(data.msg)
this.handleQueryQuoteDetailOther();
this.saveVisible = false
}else {
this.$message.warning(data.msg)
}
}).catch((error)=>{
this.saveLoading = false
this.$message.error(error)
})
},
handleSaveOther(){
let params = {
...this.saveOther,
createBy: this.$store.state.user.name,
quoteDetailId: this.quoteDetail.id,
quoteId: this.quoteDetail.quoteId,
quoteNo:this.quoteDetail.quoteNo,
site: this.quoteDetail.site,
buNo: this.quoteDetail.buNo,
versionNo:this.quoteDetail.versionNo,
quoteDetailItemNo:this.quoteDetail.itemNo,
}
if (isNaN(this.saveOther.quoteOtherCost)){
params.quoteUnitCost = 0;
}
this.saveLoading = true
saveQuoteDetailOther(params).then(({data})=>{
this.saveLoading = false
if (data && data.code === 0){
this.$message.success(data.msg)
this.handleQueryQuoteDetailOther()
this.saveVisible = false
}else {
this.$message.warning(data.msg)
}
}).catch((error)=>{
this.saveLoading = false
this.$message.error(error)
})
},
computedQuoteOtherCost(){
if (this.saveOther.itemNo === 0){
return;
}
// =/(1-mark up)/
if ((1-this.saveOther.markup/100) === 0){
this.saveOther.quoteOtherCost = 0;
return;
}
this.saveOther.quoteOtherCost = this.saveOther.unitCost / (1-this.saveOther.markup/100) / this.saveOther.otherQty;
}
},
created() {
if (this.quoteDetail && this.quoteDetail.id){
this.handleQueryQuoteDetailOther();
}
},
watch:{
'quoteDetail.id'(newVal,oldVal){
this.handleQueryQuoteDetailOther();
},
'saveOther.otherQty'(newVal, oldVal){
this.computedQuoteOtherCost();
},
'saveOther.unitCost'(newVal,oldVal){
this.computedQuoteOtherCost();
},
'saveOther.markup'(newVal,oldVal){
this.computedQuoteOtherCost();
},
}
}
</script>
<template>
<div>
<el-button type="primary" @click="handleSave(null)" :disabled="quoteDetail.status === '下达'">新增</el-button>
<el-table :data="dataList" v-loading="queryLoading" :height="420" border style="width: 100%;margin-top: 5px" >
<el-table-column label="其他项目" align="left" header-align="center" width="180" prop="otherDesc"></el-table-column>
<el-table-column label="分摊金额" align="right" header-align="center" prop="unitCost"></el-table-column>
<el-table-column label="Mark up%" align="right" header-align="center" prop="markup"></el-table-column>
<el-table-column label="需要分摊数量" align="right" header-align="center" width="120" prop="otherQty"></el-table-column>
<el-table-column label="单片分摊成本" align="right" header-align="center" prop="quoteOtherCost"></el-table-column>
<el-table-column label="备注" align="left" header-align="center" prop="remark"></el-table-column>
<el-table-column label="操作" align="center" v-if="quoteDetail.status === '草稿'">
<template slot-scope="scope" >
<a @click="handleSave(scope.row)">编辑</a>
<a v-if="scope.row.itemNo !== 0" @click="handleRemove(scope.row)">删除</a>
</template>
</el-table-column>
</el-table>
<el-dialog title="其他信息" :visible.sync="saveVisible" v-drag width="450px" append-to-body :close-on-click-modal="false">
<el-form :model="saveOther" label-position="top" :rules="otherRules" ref="saveOtherForm">
<el-row :gutter="10">
<el-col :span="24">
<el-form-item label="其他项目" prop="otherDesc" :show-message="false">
<el-input v-model="saveOther.otherDesc" :disabled="saveOther.itemNo === 0"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="分摊数量" prop="otherQty" :show-message="false">
<el-input-number style="width: 100%" :controls="false" :disabled="saveOther.itemNo === 0" :step="0" :precision="0" v-model="saveOther.otherQty"></el-input-number>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="Mark up%" prop="markup" :show-message="false">
<el-input-number style="width: 100%" :controls="false" :disabled="saveOther.itemNo === 0" :step="0" :precision="0" v-model="saveOther.markup"></el-input-number>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="10">
<el-col :span="12">
<el-form-item label="分摊金额" prop="unitCost" :show-message="false">
<el-input-number style="width: 100%" :controls="false" :disabled="saveOther.itemNo === 0" :step="0" :precision="4" v-model="saveOther.unitCost"></el-input-number>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="单片分摊成本" prop="quoteOtherCost" :show-message="false">
<el-input-number style="width: 100%" :controls="false" :disabled="saveOther.itemNo !== 0" :step="0" :precision="4" v-model="saveOther.quoteOtherCost"></el-input-number>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注" prop="remark" class="auto" :show-message="false">
<el-input type="textarea" v-model="saveOther.remark" :autosize="{minRows: 3, maxRows: 3}"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" :loading="saveLoading" @click="handleSaveOrUpdate"> </el-button>
<el-button @click="saveVisible = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
<style scoped>
</style>

3
src/views/modules/quote/detail/primary/quoteDetailTest.vue

@ -200,15 +200,12 @@ export default {
this.handleQueryQuoteDetailTest(); this.handleQueryQuoteDetailTest();
}, },
'saveTest.testQty'(newVal, oldVal){ 'saveTest.testQty'(newVal, oldVal){
console.log(1)
this.computedQuoteTestCost(); this.computedQuoteTestCost();
}, },
'saveTest.unitCost'(newVal,oldVal){ 'saveTest.unitCost'(newVal,oldVal){
console.log(2)
this.computedQuoteTestCost(); this.computedQuoteTestCost();
}, },
'saveTest.markup'(newVal,oldVal){ 'saveTest.markup'(newVal,oldVal){
console.log(3)
this.computedQuoteTestCost(); this.computedQuoteTestCost();
}, },
} }

7
src/views/modules/quote/detail/quoteDetail.vue

@ -14,10 +14,12 @@ import QuoteDetailRouting from "./primary/quoteDetailRouting.vue";
import QuoteDetailOtherCost from "./primary/quoteDetailOtherCost.vue"; import QuoteDetailOtherCost from "./primary/quoteDetailOtherCost.vue";
import DictDataSelect from "../../sys/dict-data-select.vue"; import DictDataSelect from "../../sys/dict-data-select.vue";
import QuoteDetailTest from "./primary/quoteDetailTest.vue"; import QuoteDetailTest from "./primary/quoteDetailTest.vue";
import QuoteDetailOther from "./primary/quoteDetailOther.vue";
export default { export default {
name: "quoteDetail", name: "quoteDetail",
components: { components: {
QuoteDetailOther,
QuoteDetailTest, QuoteDetailTest,
DictDataSelect, DictDataSelect,
QuoteDetailOtherCost, QuoteDetailOtherCost,
@ -755,7 +757,10 @@ export default {
<el-tab-pane label="测试" name="test"> <el-tab-pane label="测试" name="test">
<quote-detail-test v-if="saveVisible" v-model:quoteDetail="saveQuoteDetail"></quote-detail-test> <quote-detail-test v-if="saveVisible" v-model:quoteDetail="saveQuoteDetail"></quote-detail-test>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="其他成本" name="other">
<el-tab-pane label="其他" name="other">
<quote-detail-other v-if="saveVisible" v-model:quoteDetail="saveQuoteDetail"></quote-detail-other>
</el-tab-pane>
<el-tab-pane label="其他成本" name="otherCost">
<quote-detail-other-cost v-if="saveVisible" v-model:quoteDetail="saveQuoteDetail"></quote-detail-other-cost> <quote-detail-other-cost v-if="saveVisible" v-model:quoteDetail="saveQuoteDetail"></quote-detail-other-cost>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="成本&价格" name="cost"> <el-tab-pane label="成本&价格" name="cost">

Loading…
Cancel
Save