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) { export function postsPermissionGoods(data) {
return request({ return request({
url: `/api/goods`, // url: `/api/goods`,
url: `/api/goods/create/list`,
method: 'post', method: 'post',
data: data data: data
}); });
@ -138,3 +139,12 @@ export function postPermissionIdsGoods(data) {
data: 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) { export function createPermission(data) {
return request({ return request({
url: `/api/order/quicklyGenerateOrder`, // url: `/api/order/quicklyGenerateOrder`,
url: `/api/distribute/createQuickly`,
method: 'post', method: 'post',
data: data 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; this.display = 1;
}, },
// 线 // 线
permissionNextOrder(permission, good) { permissionNextOrder(good) {
this.goodsList = [{ this.goodsList = [{
isPackage: true, isPackage: true,
id: good.id, id: good.id,
@ -66,7 +66,6 @@ export default {
price: good.price, price: good.price,
list: good.list list: good.list
}]; }];
this.$refs.orderForm.setOrderName(permission, good);
this.display = 1; this.display = 1;
}, },
orderNext(data) { orderNext(data) {

View File

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

View File

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