emis-frontend/src/views/emis/emisQuoteExpression/quoteExpressionPanel.vue

423 lines
13 KiB
Vue
Raw Normal View History

2024-04-22 05:35:19 +00:00
<template>
<div >
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
icon="el-icon-plus"
plain
size="mini"
@click="handleAdd"
v-hasPermi="['emis:emisQuoteExpression:add']"
>新增计算规则</el-button>
</el-col>
2024-05-11 01:28:52 +00:00
<!-- <el-col :span="1.5">
2024-04-22 05:35:19 +00:00
<el-button
plain
size="mini"
2024-05-11 01:28:52 +00:00
:disabled="single"
@click="handleCopy"
2024-04-22 05:35:19 +00:00
v-hasPermi="['emis:emisQuoteExpression:add']"
>复制计算规则</el-button>
2024-05-11 01:28:52 +00:00
</el-col> -->
2024-04-22 05:35:19 +00:00
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['emis:emisQuoteExpression:remove']"
>删除</el-button>
</el-col>
</el-row>
2024-06-23 22:45:00 +00:00
<el-table size="mini" v-loading="loading" :data="emisQuoteExpressionList" border @selection-change="handleSelectionChange">
2024-04-22 05:35:19 +00:00
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="序号" align="center" prop="quoteSequence" width="60" />
2024-05-07 04:53:25 +00:00
<el-table-column label="范围" align="center" prop="conditionExpression" width="150">
2024-04-22 05:35:19 +00:00
<template slot-scope="scope">
2024-05-07 04:53:25 +00:00
<div class="link-type" @click="handleUpdate(scope.row)">{{scope.row.startWeight}} < w <= {{scope.row.endWeight}}</div>
2024-04-22 05:35:19 +00:00
</template>
</el-table-column>
<el-table-column label="公式" align="center" prop="calculateExpression" width="100" />
2024-05-13 04:36:25 +00:00
<el-table-column label="首重费(s)" align="center" prop="initialWeight" width="100" />
2024-04-22 05:35:19 +00:00
<el-table-column label="续重单价(d)" align="center" prop="additionalWeight" width="100" />
<!-- <el-table-column label="条件表达式" align="center" prop="conditionExpression" min-width="100" /> -->
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
@click="handleUpdate(scope.row)"
>编辑</el-button>
2024-05-11 02:37:15 +00:00
<!-- <el-button
2024-04-22 05:35:19 +00:00
size="mini"
type="text"
@click="handleCopy(scope.row)"
2024-05-11 02:37:15 +00:00
>复制</el-button> -->
2024-04-22 05:35:19 +00:00
<el-button
size="mini"
type="text"
@click.native.prevent="handleDelete(scope.row,scope.$index, emisQuoteExpressionList)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<!-- @click="handleDelete(scope.row)" -->
<!-- 添加或修改费用计算表达式对话框 -->
2024-05-22 17:06:32 +00:00
<el-dialog :title="title" :visible.sync="open" width="50%" :close-on-click-modal="false" v-dialogDrag append-to-body>
2024-04-22 05:35:19 +00:00
<el-row :gutter="0">
<el-form ref="form" size="mini" :model="form" :rules="rules" label-width="80px">
<el-col :span="24">
<el-alert
title="填写说明"
type="info"
2024-05-13 04:36:25 +00:00
description="计算公式中只能包含(s,w,d数字,+,.*,/).示例:0-1公斤 首重费(s):5元,续重单价(d):每公斤2元 ,则计算公式: s+(w-1)*d"
2024-04-22 05:35:19 +00:00
show-icon
:closable="false"
style="margin-bottom: 10px;"
>
</el-alert>
</el-col>
<el-col :span="8">
2024-05-11 01:28:52 +00:00
<el-form-item label="计算范围" prop="endWeight">
2024-04-22 05:35:19 +00:00
<div style="display: inline-flex;">
2024-05-11 01:38:06 +00:00
<div><el-input v-model="form.startWeight" placeholder="" disabled></el-input></div>
2024-04-22 05:35:19 +00:00
<div style="width: 70px;font-size: 12px;text-align: center;font-weight: bold;"> <w<= </div>
<div><el-input v-model="form.endWeight" placeholder="" ></el-input></div>
</div>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="公式" prop="calculateExpression">
<el-input v-model="form.calculateExpression" placeholder="" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="序号" prop="quoteSequence">
2024-05-11 01:28:52 +00:00
<el-input v-model="form.quoteSequence" placeholder="" disabled />
2024-04-22 05:35:19 +00:00
</el-form-item>
</el-col>
<el-col :span="8">
2024-05-13 04:36:25 +00:00
<el-form-item label="首重费(s)" prop="initialWeight">
2024-04-22 05:35:19 +00:00
<el-input v-model="form.initialWeight" placeholder="" />
</el-form-item>
</el-col>
<el-col :span="8">
2024-05-07 04:53:25 +00:00
<el-form-item label="续重单价(d)" prop="additionalWeight" label-width="100px">
2024-04-22 05:35:19 +00:00
<el-input v-model="form.additionalWeight" placeholder="" />
</el-form-item>
</el-col>
</el-form>
</el-row>
<div slot="footer" class="dialog-footer" style="text-align: center;margin-bottom: 10px;">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listEmisQuoteExpression, getEmisQuoteExpression, delEmisQuoteExpression, addEmisQuoteExpression, updateEmisQuoteExpression } from "@/api/emis/emisQuoteExpression";
export default {
name: "emisQuoteExpression",
props:{
value:{
type:Array,
},
quoteId:{
type:Number
},
2024-05-10 23:12:18 +00:00
isCopy:{
type:Boolean
}
2024-04-22 05:35:19 +00:00
},
watch: {
value(newVal) {
},
quoteId(){
this.initData();
}
},
components: { },
dicts: [
],
data() {
return {
// 遮罩层
loading: false,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
// 总条数
total: 0,
// 费用计算表达式表格数据
emisQuoteExpressionList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
currentRow:{},
// 表单参数
form: {},
// 表单校验
rules: {
quoteSequence: [
{ required: true, message: "报价序号不能为空", trigger: "blur" }
],
startWeight: [
{ required: true, message: "起始重量不能为空", trigger: "blur" }
],
endWeight: [
{ required: true, message: "结束重量不能为空", trigger: "blur" }
],
// conditionExpression: [
// { required: true, message: "条件表达式不能为空", trigger: "blur" }
// ],
calculateExpression: [
{ required: true, message: "计算表达式不能为空", trigger: "blur" }
],
}
};
},
created() {
this.initData();
},
methods: {
initData() {
if(this.quoteId!=null){
// this.emisQuoteExpressionList = this.value;
this.getList();
}else{
this.emisQuoteExpressionList=[];
}
},
getList() {
let queryParams={
quoteId:this.quoteId,
}
listEmisQuoteExpression(queryParams).then(response => {
this.emisQuoteExpressionList = response.rows;
this.total = response.total;
this.loading = false;
});
},
onChage(){
this.$emit("input", this.emisQuoteExpressionList);
this.$emit("onChange",this.emisQuoteExpressionList);
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
id: null,
quoteId: this.quoteId,
quoteSequence: null,
useSiteCode: null,
useSite: null,
2024-05-11 01:28:52 +00:00
startWeight: 0,
endWeight: null,
initialWeight: 0,
additionalWeight: 0,
2024-04-22 05:35:19 +00:00
conditionExpression: null,
2024-05-11 01:28:52 +00:00
calculateExpression: null,
2024-04-22 05:35:19 +00:00
status: null,
remark: null,
};
this.resetForm("form");
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
2024-05-11 01:28:52 +00:00
this.currentRow = selection[0];
2024-04-22 05:35:19 +00:00
},
/** 新增按钮操作 */
handleAdd(row) {
this.reset();
this.open = true;
this.title = "新增公式";
const quoteSequence=this.emisQuoteExpressionList.length+1;
this.form.quoteSequence=quoteSequence;
2024-05-11 01:28:52 +00:00
if(quoteSequence>1){
// 获取上一条数据
const [lastData]= this.emisQuoteExpressionList.slice(-1);
console.log(lastData);
this.form.startWeight=lastData.endWeight;
this.form.endWeight='';
this.form.initialWeight=0;
this.form.additionalWeight=0;
if(quoteSequence==2){
2024-05-13 04:58:35 +00:00
this.form.initialWeight=lastData.calculateExpression;
2024-05-13 04:36:25 +00:00
this.form.calculateExpression='s+(w-'+lastData.endWeight+')*d';
2024-05-13 04:58:35 +00:00
}
else if(quoteSequence>2){
2024-05-13 05:00:25 +00:00
// this.form.initialWeight=lastData.initialWeight;
2024-05-13 04:36:25 +00:00
this.form.calculateExpression='w*d';
2024-05-11 01:28:52 +00:00
}
}
},
handleCopy(row){
this.reset();
this.open = true;
this.title = "复制公式";
console.log(row)
const quoteSequence=this.emisQuoteExpressionList.length+1;
if(quoteSequence>1){
// 获取上一条数据
let newData =Object.assign({}, row);
console.log(newData)
this.form=newData;
this.form.quoteSequence=quoteSequence;
// this.form.startWeight=newData.endWeight;
// this.form.endWeight='';
// this.form.initialWeight=0;
// this.form.additionalWeight=0;
// this.form.calculateExpression=newData.calculateExpression;
}
2024-04-22 05:35:19 +00:00
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
2024-05-11 01:28:52 +00:00
if(this.quoteId != null && !this.isCopy){
2024-04-22 05:35:19 +00:00
this.handleUpdateByQuoteId(row);
}else{
this.currentRow = row;
this.form = row;
}
this.open = true;
this.title = "修改公式";
},
handleUpdateByQuoteId(row){
this.loading = true;
getEmisQuoteExpression(row.id).then(response => {
this.form = response.data;
this.loading = false;
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
// 如果是已经存在的报价,直接更新
2024-05-11 01:28:52 +00:00
if(this.quoteId != null && !this.isCopy){
2024-04-22 05:35:19 +00:00
this.submitFormByQuoteId()
}else{
this.submitFormByNew();
}
this.form={};
this.open = false;
}
});
},
submitFormByQuoteId(){
if (this.form.id != null) {
updateEmisQuoteExpression(this.form).then(response => {
// this.$modal.msgSuccess("修改成功");
// this.$emit("on-changed");
this.getList();
});
} else {
addEmisQuoteExpression(this.form).then(response => {
// this.$modal.msgSuccess("添加成功");
// this.$emit("on-changed");
this.getList();
});
}
},
submitFormByNew(){
// 新增的需要带回数据
if (this.form.id == null) {
let newItem = Object.assign({}, this.form);
newItem.id=-1;
2024-05-10 07:58:05 +00:00
// console.log("000=>"+JSON.stringify(newItem));
2024-04-22 05:35:19 +00:00
this.emisQuoteExpressionList.push(newItem);
}
this.onChage();
},
/** 删除按钮操作 */
handleDelete(row,index,list) {
2024-05-11 01:28:52 +00:00
if(this.quoteId != null && !this.isCopy){
2024-04-22 05:35:19 +00:00
this.handleDeleteQuoteId(row);
}else{
this.handleDeleteByNew(row,index,list);
}
},
2024-05-11 01:28:52 +00:00
// 从数据库中删除
2024-04-22 05:35:19 +00:00
handleDeleteQuoteId(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除').then(function() {
return delEmisQuoteExpression(ids);
}).then(() => {
this.getList();
// this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
handleDeleteByNew(row,index,list){
list.splice(index, 1);
// @click.native.prevent="deleteItem(scope.$index, list)"
// let arr = []
// const quoteSequence = row.id || this.ids[0]
// this.emisQuoteExpressionList.map(item=>{
// if (item.quoteSequence == quoteSequence) {
// this.form = item;
// }
// });
}
}
};
</script>
<style scoped>
.el-divider{
margin-top: 0px;
background: 0 0;
border-top: 1px solid #E6EBF5;
}
.el-divider__text {
color: #0955ee;
cursor: pointer;
}
.el-alert__title {
color: black!important;;
}
.el-alert__description {
color: black!important;;
}
</style>