desc: 修改创建权限逻辑

This commit is contained in:
zyy 2019-12-03 17:51:39 +08:00
parent 193f9267a1
commit 94f3bce874
6 changed files with 270 additions and 172 deletions

View File

@ -124,7 +124,8 @@ export function getGoodsByPermissionId(id) {
// 创建商品
export function postsPermissionGoods(data) {
return request({
url: `/api/goods`,
// url: `/api/goods`,
url: `/api/goods/create/list`,
method: 'post',
data: data
});
@ -138,3 +139,12 @@ export function postPermissionIdsGoods(data) {
data: data
});
}
// 创建万能权限商品
export function postCreatePackage(data) {
return request({
url: `/api/goods/create/package`,
method: 'post',
data: data
});
}

View File

@ -107,7 +107,8 @@ export function cancalOrder(orderId) {
// 快速创建权限
export function createPermission(data) {
return request({
url: `/api/order/quicklyGenerateOrder`,
// url: `/api/order/quicklyGenerateOrder`,
url: `/api/distribute/createQuickly`,
method: 'post',
data: data
});

View File

@ -0,0 +1,114 @@
<template>
<el-dialog v-dialogDrag :title="this.$t('orderAuthor.oneClickGenerationPermission')" :visible.sync="dialogShow" width="500px" :before-close="handleClose">
<div>
<data-form ref="dataform" :form="form" :form-model="formModel" :rules="rules" />
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogShow = false">{{ $t('map.cancel') }}</el-button>
<el-button type="primary" :loading="loading" @click="saveAs">{{ $t('map.confirm') }}</el-button>
</span>
</el-dialog>
</template>
<script>
import { updataCommodityList } from '@/api/management/goods';
export default {
name: 'Edit',
data() {
return {
dialogShow: false,
loading: false,
formModel: {
id: '',
name: '',
price: 0
// remarks: ''
}
};
},
computed: {
form() {
return {
labelWidth: '110px',
items: [
{ prop: 'name', label: this.$t('orderAuthor.commodityName') + ':', type: 'text', required: false },
{ prop: 'price', label: this.$t('orderAuthor.price') + ':', type: 'number', required: false, min: 0.01, message: this.$t('global.yuan') }
// { prop: 'remarks', label: this.$t('orderAuthor.describtion') + ':', type: 'textarea', required: false }
]
};
},
rules() {
return {
name: [
{ required: true, message: this.$t('rules.goodsNameInput'), trigger: 'blur' }
],
price: [
{ required: true, message: this.$t('rules.totalPriceInput'), trigger: 'change' },
{
validator(rule, value, callback) {
if (Number(value) >= 0) {
if (String(value).split('.')[1] && String(value).split('.')[1].length > 2) {
callback(new Error(this.$t('rules.totalPriceInputError1')));
} else {
callback();
}
} else {
callback(new Error(this.$t('rules.totalPriceInputError2')));
}
},
trigger: 'blur'
}
]
};
}
},
methods: {
doShow(data) {
this.dialogShow = true;
console.log(data);
this.formModel = {
id: data.goods.id,
name: data.name,
price: data.price
// remarks: data.remarks
};
},
close() {
this.formModel = {
id: '',
name: '',
price: 0
// remarks: ''
};
this.dialogShow = false;
this.loading = false;
},
handleClose() {
this.close();
},
buildModel() { //
return {
id: this.formModel.id,
name: this.formModel.name,
price: this.formModel.price
// remarks: this.formModel.remarks
};
},
saveAs() {
this.$refs.dataform.validateForm(() => {
this.loading = true;
updataCommodityList(this.buildModel()).then(response => {
this.$message.success(this.$t('tip.updateSuccessfully'));
this.$emit('reloadTable', this.buildModel());
this.handleClose();
}).catch(() => {
this.$messageBox(this.$t('tip.updateFailed'));
this.handleClose();
});
});
}
}
};
</script>

View File

@ -56,7 +56,7 @@ export default {
this.display = 1;
},
// 线
permissionNextOrder(permission, good) {
permissionNextOrder(good) {
this.goodsList = [{
isPackage: true,
id: good.id,
@ -66,7 +66,6 @@ export default {
price: good.price,
list: good.list
}];
this.$refs.orderForm.setOrderName(permission, good);
this.display = 1;
},
orderNext(data) {

View File

@ -1,12 +1,7 @@
<template>
<div>
<div class="forms pack-rule">
<el-table
v-if="goodsList.length"
:data="goodsList"
border
style="width: 100%; margin-bottom: 10px;"
>
<el-table v-if="goodsList.length" :data="goodsList" border style="width: 100%; margin-bottom: 10px;">
<el-table-column prop="name" :label="$t('permission.goodsName')" />
<el-table-column prop="price" :label="$t('permission.price')" width="100" />
<el-table-column prop="remarks" label="描述" />
@ -33,7 +28,6 @@ import { addOrganization, getOrganizationList } from '@/api/management/organizat
import { getSellerList } from '@/api/management/user';
import { createPermission } from '@/api/management/order';
import PremissionList from './list';
// import { deepAssign } from '@/utils/index';
export default {
name: 'OrderForm',
@ -64,7 +58,6 @@ export default {
foreverInitData: false,
canDistribute: true,
urlInfo: {},
goodsVo: {},
orderList: [],
formModel: {
organizationId: '',
@ -138,7 +131,7 @@ export default {
return this.foreverInitData;
},
form() {
const form = {
return {
labelWidth: this.$i18n.locale == 'en' ? '200px' : '145px',
items: [
{ prop: 'organizationId', label: this.$t('orderAuthor.organizationOrEnterprise'), type: 'select', options: this.OrganizationList, allowCreate: true, onChange: this.onChange },
@ -156,7 +149,6 @@ export default {
{ prop: 'canDistribute', label: this.$t('orderAuthor.optionPrivilegeTransfer'), type: 'radio', options: this.permissionList }
]
};
return form;
},
rules() {
const _this = this;
@ -329,18 +321,6 @@ export default {
showPermission(index, row) {
this.$refs.permissionList.doShow(row.list);
},
//
setOrderName(permission, good) {
if (good) {
this.formModel = { //
goodsName: good.name,
price: good.price,
goodsId: good.id
};
this.permissionVo = permission; //
this.goodsVo = good; //
}
},
buildModel() {
// ,
let orgzId = this.formModel.organizationId;
@ -377,27 +357,24 @@ export default {
packForm() {
if (this.orderList && this.orderList.length) {
const arr = this.goodsList.map(nor => {
return nor.permissionId;
return nor.goodItem.id;
});
const param = {
isPackage: false,
// formModel
organizationId: this.formModel.organizationId,
packageNum: this.formModel.amount,
amount: this.formModel.amount,
monthAmount: this.formModel.monthAmount,
packageName: this.goodsVo.name,
totalPrice: this.formModel.totalPrice,
orderType: this.formModel.orderType,
distributeType: this.formModel.canDistribute == '01',
startTime: this.formModel.startTime,
payStatus: this.formModel.payStatus,
bizType: this.formModel.bizType,
payWays: this.formModel.payWays,
forever: this.formModel.forever,
// list
relPermissions: arr,
orderDetailList: this.orderList
canDistribute: this.formModel.canDistribute == '01',
orderCreateVO: {
amount: this.formModel.amount,
contractNo: this.formModel.contractNo,
forever: this.formModel.forever,
goodsIds: arr,
monthAmount: this.formModel.monthAmount,
orderType: this.formModel.orderType,
organizationId: this.formModel.organizationId,
payStatus: this.formModel.payStatus,
payWays: this.formModel.payWays,
price: this.formModel.price,
sellerId: this.formModel.sellerId,
startTime: this.formModel.startTime
}
};
createPermission(param).then(res => {
this.urlInfo = {
@ -416,43 +393,25 @@ export default {
createPermission() {
this.$refs.dataform.validateForm(() => {
this.formModel.organizationId = this.buildModel();
const arr = this.goodsList.map(nor => {
return nor.id;
});
const param = {
// createVO: {
// isPackage: true,
// relPermissions: this.permissionVo.relPermissions,
// name: this.permissionVo.name,
// id: this.permissionVo.id,
// remarks: this.permissionVo.remarks
// },
// goodsVO: this.goodsVo,
// orderList: [this.formModel],
// canDistribute: this.formModel.canDistribute == '01'
isPackage: true,
// formModel
organizationId: this.formModel.organizationId,
packageNum: this.formModel.amount,
startTime: this.formModel.startTime,
monthAmount: this.formModel.monthAmount,
distributeType: this.formModel.canDistribute == '01',
bizType: this.formModel.bizType,
payWays: this.formModel.payWays,
forever: this.formModel.forever,
payStatus: this.formModel.payStatus,
totalPrice: this.formModel.totalPrice,
contractNo: this.formModel.contractNo,
orderType: this.formModel.orderType,
// goodsVo
packageName: this.goodsVo.name,
remarks: this.goodsVo.remarks,
price: this.goodsVo.price,
tryUse: this.goodsVo.tryUse,
tryUseTime: this.goodsVo.tryUseTime,
tryUseTimeUnit: this.goodsVo.tryUseTimeUnit,
// ids
relPermissions: this.permissionVo.relPermissions
// mapId: this.permissionVo.mapId
// prdCode: this.permissionVo.prdCode
canDistribute: this.formModel.canDistribute == '01',
orderCreateVO: {
amount: this.formModel.amount,
contractNo: this.formModel.contractNo,
forever: this.formModel.forever,
goodsIds: arr,
monthAmount: this.formModel.monthAmount,
orderType: this.formModel.orderType,
organizationId: this.formModel.organizationId,
payStatus: this.formModel.payStatus,
payWays: this.formModel.payWays,
price: this.formModel.price,
sellerId: this.formModel.sellerId,
startTime: this.formModel.startTime
}
};
createPermission(param).then(res => {
this.urlInfo = {

View File

@ -4,12 +4,7 @@
<div class="title_nav">
<div class="map_title">{{ $t('orderAuthor.mapName') }}:</div>
<el-select v-model="addModel.mapId" :disabled="ruleList.length ? true : false" size="small">
<el-option
v-for="item in mapList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
<el-option v-for="item in mapList" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</div>
<div class="table_box">
@ -32,6 +27,7 @@
<el-table-column :label="this.$t('global.operate')" width="180">
<template slot-scope="scope">
<el-button type="text" size="small" @click="deleteForm(scope.$index, scope.row)">{{ $t('global.delete') }}</el-button>
<el-button type="text" size="small" @click="editForm(scope.$index, scope.row)">编辑</el-button>
</template>
</el-table-column>
</el-table>
@ -68,7 +64,7 @@
<el-input-number v-model="addModel.price" :min="0.01" />
<span style="padding-left: 20px; font-size: 12px; color: #a9a9a9;">{{ $t('global.yuan') }}</span>
</el-form-item>
<el-form-item v-show="addModel.type == '02'" :label="$t('orderAuthor.whetherTrial')" prop="forever">
<!-- <el-form-item v-show="addModel.type == '02'" :label="$t('orderAuthor.whetherTrial')" prop="forever">
<el-radio-group v-model="addModel.forever">
<el-radio v-for="option in $ConstSelect.Whether" :key="option.value" :label="option.value">{{ option.label }}</el-radio>
</el-radio-group>
@ -86,7 +82,7 @@
<el-form-item v-if="addModel.type == '02' && addModel.forever" :label="$t('global.duration') + ':'" prop="tryUseTime">
<el-input-number v-model="addModel.tryUseTime" :min="1" />
<span style="padding-left: 20px; font-size: 12px; color: #a9a9a9;">{{ TimeStyleDict[addModel.tryUseTimeUnit] }}</span>
</el-form-item>
</el-form-item> -->
</el-form>
<choose-permission
ref="choosePermission"
@ -103,19 +99,22 @@
<el-button type="primary" @click="permissionNext">{{ $t('orderAuthor.next') }}</el-button>
</el-button-group>
</div>
<edit ref="edit" @reloadTable="reloadTable" />
</div>
</template>
<script>
import ChoosePermission from '../../author/draft/choosePermission';
import { getPublishMapListOnline } from '@/api/jmap/map';
import { getGoodsByPermissionId, postsPermissionGoods } from '@/api/management/goods';
import { getGoodsByPermissionId, postsPermissionGoods, updataCommodityList, postCreatePackage} from '@/api/management/goods';
import { postFindPermission } from '@/api/management/order';
import Edit from './edit';
export default {
name: 'PermissionForm',
components: {
ChoosePermission
ChoosePermission,
Edit
},
data() {
return {
@ -145,6 +144,7 @@ export default {
tryUseTimeUnit: '05',
tryUseTime: 0
},
editIndex: 0,
rules: {
name: [
{ required: true, message: this.$t('rules.enterPermissionName'), trigger: 'blur' }
@ -179,52 +179,6 @@ export default {
});
}
},
changeBlur(data) { //
if (data.payPrice < 0.01) {
data.payPrice = 0.01;
}
},
postFindPermission(arr) { // ids
postFindPermission(arr).then(res => {
this.isGoods = false;
this.permissionPackageId = '';
this.permissionGoddsId = '';
if (res.data && res.data.id) {
this.isGoods = true;
this.idPackage = true;
this.permissionPackageId = res.data.id;
this.permissionGoddsId = res.data.goodsId;
this.addModel.name = res.data.name;
this.addModel.price = res.data.prdPrice || 0.01;
this.addModel.remarks = res.data.remarks;
this.addModel.tryUse = res.data.tryUse;
this.addModel.tryUseTime = res.data.tryUseTime;
this.addModel.tryUseTimeUnit = res.data.tryUseTimeUnit;
} else {
this.idPackage = false;
}
});
},
changeRadio(data) {
this.$emit('changeType', data);
if (data == '02' && this.ruleList.length) {
const arr = this.ruleList.map(item => {
return item.id;
});
this.postFindPermission(arr);
} else if (data == '01' && this.ruleList.length) {
this.ruleList.map(item => {
if (!item.price) {
getGoodsByPermissionId(item.id).then(res => {
if (res.data && (res.data instanceof Object)) {
item.price = res.data.price;
item.goods = res.data;
}
});
}
});
}
},
async loadInitData() {
//
this.TimeStyleDict = {};
@ -258,6 +212,62 @@ export default {
console.error(error, this.$t('tip.publishMap'));
}
},
changeBlur(data) { //
if (data.payPrice < 0.01) {
data.payPrice = 0.01;
}
},
postFindPermission(arr) { // ids
postFindPermission(arr).then(res => {
this.isGoods = false;
this.permissionPackageId = '';
this.permissionGoddsId = '';
if (res.data && res.data.id) {
this.isGoods = true;
this.idPackage = true;
this.permissionPackageId = res.data.permissionId;
this.permissionGoddsId = res.data.id;
this.addModel.name = res.data.name;
this.addModel.price = res.data.prdPrice || 0.01;
this.addModel.remarks = res.data.remarks;
this.addModel.tryUse = res.data.tryUse;
this.addModel.tryUseTime = res.data.tryUseTime;
this.addModel.tryUseTimeUnit = res.data.tryUseTimeUnit;
} else {
this.idPackage = false;
}
});
},
changeRadio(data) {
this.$emit('changeType', data);
if (data == '02' && this.ruleList.length) {
const arr = this.ruleList.map(item => {
return item.id;
});
this.postFindPermission(arr);
} else if (data == '01' && this.ruleList.length) {
this.ruleList.map(item => {
if (!item.price) {
getGoodsByPermissionId(item.id).then(res => {
if (res.data && (res.data instanceof Object)) {
item.price = res.data.price;
item.goods = res.data;
}
});
}
});
}
},
editForm(index, row) {
this.$refs.edit.doShow(row);
this.editIndex = index;
},
reloadTable(data) {
this.ruleList[this.editIndex].price = data.price;
this.ruleList[this.editIndex].name = data.name;
this.ruleList[this.editIndex].goods.price = data.price;
this.ruleList[this.editIndex].goods.name = data.name;
},
computedName(list, code) {
let name = '';
list.forEach(elem => {
@ -387,41 +397,46 @@ export default {
allPermissionNext(arr) { //
this.$refs.formData.validate((valid) => {
if (valid) { // 使
// postFindPermission(arr).then(res => {
this.addModel['relPermissions'] = arr; // ids
// if (res.data) {
this.addModel['id'] = this.permissionPackageId;
// }
// if (this.isGoods) { //
const good = {
id: this.permissionGoddsId,
permissionId: this.permissionPackageId,
name: this.addModel.name,
price: this.addModel.price,
remarks: this.addModel.remarks,
tryUse: this.addModel.forever,
tryUseTime: this.addModel.tryUseTime,
tryUseTimeUnit: this.addModel.tryUseTimeUnit,
list: this.ruleList
};
this.$emit('permissionNextOrder', this.addModel, good);
// }
// else {
// //
// const good = {
// id: '',
// permissionId: '',
// name: this.addModel.name,
// price: this.addModel.price,
// remarks: this.addModel.remarks,
// tryUse: this.addModel.forever,
// tryUseTime: this.addModel.tryUseTime,
// tryUseTimeUnit: this.addModel.tryUseTimeUnit,
// list: this.ruleList
// };
// this.$emit('permissionNextOrder', this.addModel, good);
// }
// }).catch((error) => { console.log(error); });
// this.addModel['relPermissions'] = arr; // ids
// this.addModel['id'] = this.permissionPackageId;
if (this.isGoods) { //
const param = {
id: this.permissionGoddsId,
name: this.addModel.name,
price: this.addModel.price,
remarks: this.addModel.remarks
};
updataCommodityList(param).then(res => {
const good = {
id: this.permissionGoddsId,
permissionId: this.permissionPackageId,
name: this.addModel.name,
price: this.addModel.price,
remarks: this.addModel.remarks,
list: this.ruleList
};
this.$emit('permissionNextOrder', good);
});
} else {
//
const param = {
name: this.addModel.name,
price: this.addModel.price,
relPermissionIds: arr,
remarks: this.addModel.remarks,
tryUse: this.addModel.forever,
tryUseTime: this.addModel.tryUseTime,
tryUseTimeUnit: this.addModel.tryUseTimeUnit
};
postCreatePackage(param).then(res => {
const good = Object.assign(res.data, { list: this.ruleList });
this.isGoods = true;
this.permissionGoddsId = res.data.id;
this.$emit('permissionNextOrder', good);
}).catch(() => {
this.$message('创建万能权限商品失败');
});
}
}
});
},