3 changed files with 287 additions and 4 deletions
-
281src/views/modules/quote/detail/primary/quoteDetailOther.vue
-
3src/views/modules/quote/detail/primary/quoteDetailTest.vue
-
7src/views/modules/quote/detail/quoteDetail.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> |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue