订单创建代码调整

This commit is contained in:
joylink_cuiweidong 2019-12-09 14:51:01 +08:00
parent d8b0577c77
commit 97eeda5eeb
3 changed files with 161 additions and 36 deletions

View File

@ -232,6 +232,35 @@
</el-form-item>
</template>
<template v-else-if="checkFieldType(item, 'table')">
<div :key="item.prop" style="margin-left:150px;margin-bottom:20px">
<el-button v-if="item.buttontip" size="mini" style="margin-bottom:10px" @click="item.buttonClick">{{ item.buttontip }}
</el-button>
<el-table :data="formModel[item.prop]" border style="width:80%" class="table_item">
<el-table-column v-for="data in item.tableList" :key="data.prop" :prop="data.prop" :label="data.label">
<template slot-scope="scope">
<el-form-item v-if="data.isEdit" :prop="item.prop+'.' + scope.$index + '.'+data.prop" :required="false" :rules="data.rules[data.prop]">
<el-input-number
v-model="scope.row[data.prop]"
:min="isNaN(data.min) ? -Infinity : data.min"
:max="isNaN(data.max)? Infinity : data.max"
size="mini"
/>
</el-form-item>
<div v-else>
{{ scope.row[data.prop] }}
</div>
</template>
</el-table-column>
<el-table-column :label="item.operate" width="180">
<template slot-scope="scope">
<el-button v-for="buttonObj in item.operateButton" :key="buttonObj.name" type="text" size="small" @click="buttonObj.clickFunc(scope.row)">{{ buttonObj.name }}</el-button>
</template>
</el-table-column>
</el-table>
</div>
</template>
</template>
</el-form>
</template>
@ -286,8 +315,16 @@ export default {
}
};
</script>
<style>
<style lang="scss">
.el-input__inner.el-range-editor {
width: 100%;
}
.table_item {
.el-form-item__content{
margin-left:0px !important;
.el-input-number{
width:100% !important;
}
}
}
</style>

View File

@ -90,7 +90,7 @@ export default {
title: this.$t('orderAuthor.belongsToMap'),
prop: 'mapName',
type: 'tag',
columnValue: (row) => { return row.mapName },
columnValue: (row) => { return row.mapName; },
tagType: (row) => { return ''; }
},
{
@ -119,10 +119,22 @@ export default {
width: '250',
buttons: [
{
name: this.$t('orderAuthor.select'),
type: 'primary',
handleClick: this.handleAdd
name: this.$t('global.append'),
handleClick: this.handlePut,
type: '',
showControl: (row) => { return !row.isPut; }
},
{
name: this.$t('global.delete'),
handleClick: this.handlePop,
type: 'warning',
showControl: (row) => { return row.isPut; }
}
// {
// name: this.$t('orderAuthor.select'),
// type: 'primary',
// handleClick: this.handleAdd
// }
]
}
],
@ -163,9 +175,20 @@ export default {
}
},
handleAdd(index, row) {
this.$emit('selectGoods', row);
this.doClose();
// handleAdd(index, row) {
// this.$emit('selectGoods', row);
// // this.doClose();
// },
handlePut(index, row) {
row.isPut = true;
this.$emit('addGoods', index, row);
// this.queryList.reload();
},
handlePop(index, row) {
row.isPut = false;
this.$emit('deleteGoods', index, row);
// this.queryList.reload();
},
reloadTable() {

View File

@ -19,7 +19,8 @@
</el-button-group>
</div>
</el-scrollbar>
<add-goods ref="addGoods" @selectGoods="selectGoods" />
<add-goods ref="addGoods" @addGoods="addGoods" @deleteGoods="deleteGoods" />
<!-- @selectGoods="selectGoods" -->
</div>
</template>
@ -51,6 +52,9 @@ export default {
WhetherTypeList: [],
OrgzList: [],
PermissionTypeList: [],
isShowTable:false,
errorTip:'请输入商品数量',
errorIntTip:'数量必须为整数',
formModel: {
organizationId: '',
goodsId: '',
@ -66,7 +70,8 @@ export default {
payWays: '01',
payStatus: '02',
startTime: '',
sellerId: ''
sellerId: '',
detailCreateVOList:[]
},
DatePicker: {
shortcuts: [{
@ -150,12 +155,41 @@ export default {
labelWidth: this.$i18n.locale == 'en' ? '200px' : '145px',
items: [
{ prop: 'organizationId', label: this.$t('orderAuthor.organizationOrEnterprise'), type: 'select', required: false, disabled: this.isDisabled, options: this.OrganizationList, allowCreate: true, onChange: this.onChange },
{ prop: 'goodsName', label: this.$t('orderAuthor.commodityName'), type: 'text', required: false, disabled: true, rightWidth: true, buttontip: this.$t('orderAuthor.selectGoods'), buttonClick: this.buttonClick },
{ prop: 'price', label: this.$t('orderAuthor.itemPricing'), type: 'number', required: false, disabled: true, min: 0, message: this.$t('orderAuthor.yuan') },
// { prop: 'goodsName', label: this.$t('orderAuthor.commodityName'), type: 'text', required: false, disabled: true, rightWidth: true, buttontip: this.$t('orderAuthor.selectGoods'), buttonClick: this.buttonClick },
{ prop:'detailCreateVOList',
buttontip: this.$t('orderAuthor.selectGoods'),
buttonClick: this.buttonClick,
type:'table',
tableList:[
{prop:'goodsName', label:'商品名称' },
{prop:'goodsAmount', label:'商品数量', isEdit:true, min:0,
rules:{
goodsAmount:[
{
validator:this.validateChoose,
trigger: 'blur'
},
{
validator:this.validateChoose,
trigger: 'change'
}
]
}
},
{prop:'goodsPrice', label:'商品单价'}
],
operate:'操作',
operateButton:[
{name:'删除', clickFunc:this.removeGoods}
]
},
// { prop: 'price', label: this.$t('orderAuthor.itemPricing'), type: 'number', required: false, disabled: true, min: 0, message: this.$t('orderAuthor.yuan') },
{ prop: 'orderType', label: this.$t('orderAuthor.orderType'), type: 'select', required: false, disabled: this.isDisabled, options: this.OrderTypeList },
{ prop: 'sellerId', label: this.$t('orderAuthor.salesman'), type: 'select', required: false, show: this.isShowSeller, disabled: this.isDisabled, options: this.SellerList },
{ prop: 'contractNo', label: this.$t('orderAuthor.contractNumber'), type: 'text', required: false, show: this.isShowContractNo },
{ prop: 'amount', label: this.totalTitle, type: 'number', required: false, show: true, min: 0 },
// { prop: 'amount', label: this.totalTitle, type: 'number', required: false, show: true, min: 0 },
{ prop: 'forever', label: this.$t('orderAuthor.permanenceOrNot'), type: 'radio', required: false, options: this.$ConstSelect.Whether, disabled: this.foreverIsDisabled },
{ prop: 'startTime', label: this.$t('orderAuthor.startDate'), type: 'datetime', required: false, show: this.isShowStartDate, viewFormat: 'yyyy-MM-dd HH:mm:ss', valueFormat: 'yyyy-MM-dd HH:mm:ss', picker: this.DatePicker },
{ prop: 'monthAmount', label: this.monthsTitle, type: 'number', required: false, show: this.isShowMonths, min: 0, message: this.$t('orderAuthor.month') },
@ -265,10 +299,31 @@ export default {
buttonClick() {
this.$refs.addGoods.doShow();
},
selectGoods(data) {
this.formModel.goodsId = data.id;
this.formModel.goodsName = data.name;
this.formModel.price = data.price;
validateChoose(rule, value, callback) {
if (value || value === 0) {
if (Number.isInteger(value)) {
callback();
} else {
callback(new Error(this.errorIntTip));
}
} else {
callback(new Error(this.errorTip));
}
},
addGoods(index, row) {
const data = {
'goodsId':row.id,
'goodsName':row.name,
'goodsAmount':0,
'goodsPrice':row.price
};
this.formModel.detailCreateVOList.push(data);
},
removeGoods(data) {
this.formModel.detailCreateVOList = this.formModel.detailCreateVOList.filter(({ goodsId }) => goodsId !== data.goodsId);
},
deleteGoods(index, row) {
this.formModel.detailCreateVOList = this.formModel.detailCreateVOList.filter(({ goodsId }) => goodsId !== row.id);
},
initLoadPage() {
//
@ -314,7 +369,7 @@ export default {
this.$Dictionary.payStatus().then(list => {
this.$convertList(list, this.PayStatusTypeList, elem => {
return elem.code !== '03'; //
return elem.code !== '03' && elem.code !== '04'; //
});
});
@ -417,17 +472,12 @@ export default {
//
const model = {
organizationId: orgzId,
goodsId: this.formModel.goodsId,
organizationId: orgzId, // ok
orderType: this.formModel.orderType,
amount: this.formModel.amount,
// permissionType: this.formModel.permissionType,
forever: this.formModel.forever,
bizType: this.formModel.bizType,
price: this.formModel.price
// monthAmount: this.formModel.monthAmount,
// startTime: this.formModel.startTime,
// payWays: this.formModel.payWays,
detailCreateVOList:[]
};
// ,model
@ -441,26 +491,41 @@ export default {
if (this.isShowPayType) { model.payWays = this.formModel.payWays; }
if (this.isShowPayStatus) { model.payStatus = this.formModel.payStatus; }
if (this.isShowPayStatus) { model.payStatus = this.formModel.payStatus; } else { model.payStatus = '04'; }
if (this.isShowSeller) { model.sellerId = this.formModel.sellerId; }
// ,ID
if (this.isReNew) { model.permissionId = this.$route.params.orderId; }
return model;
let count = 0;
this.formModel.detailCreateVOList.forEach(data=>{
if (data.goodsAmount > 0) {
count++;
model.detailCreateVOList.push({'goodsId':data.goodsId, 'goodsAmount':data.goodsAmount});
}
});
if (count <= 0) {
this.$messageBox('至少有一个商品的数量大于0');
return false;
} else {
return model;
}
},
create() {
this.$refs.dataform.validateForm(() => {
this.loading = true;
createOrder(this.buildModel()).then(response => {
this.turnback();
this.loading = false;
this.$message.success(this.$t('tip.creatingSuccessful'));
}).catch(() => {
this.loading = false;
this.$messageBox(this.$t('tip.creatingFailed'));
});
if (this.buildModel()) {
this.loading = true;
createOrder(this.buildModel()).then(response => {
this.turnback();
this.loading = false;
this.$message.success(this.$t('tip.creatingSuccessful'));
}).catch(() => {
this.loading = false;
this.$messageBox(this.$t('tip.creatingFailed'));
});
}
});
},
update() {