This commit is contained in:
fan 2019-11-29 17:00:31 +08:00
commit 476615957f
8 changed files with 178 additions and 733 deletions

View File

@ -129,3 +129,12 @@ export function postsPermissionGoods(data) {
data: data
});
}
// 创建万能权限商品
export function postPermissionIdsGoods(data) {
return request({
url: `/api/goods/permissionIds`,
method: 'post',
data: data
});
}

View File

@ -113,13 +113,10 @@ export function createPermission(data) {
});
}
// 校验是否存在所选择权限对应的权限包
// 万能权限查询权限包商品
export function postFindPermission(ids) {
return request({
url: `/api/permission/findPermission`,
method: 'post',
data: {
relPermissions: ids
}
url: `/api/goods/permissionIds?ids=${ids}`,
method: 'get'
});
}

View File

@ -875,7 +875,7 @@ export const asyncRouter = [
redirect: '/design/usermap/home',
component: Layout,
meta: {
roles: [admin, user]
roles: [admin]
},
children: [
{
@ -897,16 +897,11 @@ export const asyncRouter = [
path: 'map/draw/:mapId/:view',
component: NewMapDraft,
hidden: true
},
{ // 运行图设计
path: 'runPlan/detail/:mapId',
component: PlanMonitorDetail,
hidden: true
}
]
}
]
},
}
];
const createRouter = () => new Router({

View File

@ -21,14 +21,6 @@
<el-button size="small" type="primary" class="eachButton" @click="createMap">{{ $t('map.newConstruction') }}</el-button>
</div>
</div>
<map-operate-menu
ref="menu"
:point="point"
:edit-model="editModel"
:line-code="lineCode"
@refresh="loadInitData"
@jlmap3d="jlmap3d"
/>
</div>
</template>
<script>
@ -36,13 +28,9 @@ import { DeviceMenu } from '@/scripts/ConstDic';
import { postBuildMapImport, listMap } from '@/api/jmap/mapdraft';
import { UrlConfig } from '@/router/index';
import { removeSessionStorage } from '@/utils/auth';
import MapOperateMenu from './mapmanage/operateMenu';
export default {
name: 'UserMapList',
components: {
MapOperateMenu
},
props: {
width: {
type: Number,
@ -110,14 +98,6 @@ export default {
mapId: elem.id,
mapName: elem.name,
lineCode: elem.lineCode
},
{
id: '4',
name: this.$t('designPlatform.runPlanDesign'),
type: 'runPlanDesign',
mapId: elem.id,
mapName: elem.name,
lineCode: elem.lineCode
}
];
});
@ -138,12 +118,7 @@ export default {
this.$router.push({ path: `${UrlConfig.newDesignuser.mapDraw}/${obj.mapId}/draft`, query: { name: obj.mapName } });
break;
}
case 'runPlanDesign': {
this.$router.push({ path: `${UrlConfig.newDesignuser.runPlan}/${obj.mapId}?lineCode=${obj.lineCode}` });
break;
}
}
this.$refs.menu.doClose();
},
showContextMenu(e, obj, node, vueElem) {
if (obj && obj.type == 'map') {
@ -159,9 +134,6 @@ export default {
this.$store.dispatch('menuOperation/setPopMenu', { position: this.point, menu: menu });
}
},
jlmap3d() {
this.$router.push({ path: '/design/jlmap3d/edit', query: { mapid: this.editModel.id } });
},
importf() {
const loading = this.$loading({
lock: true,

View File

@ -13,14 +13,6 @@
<el-button type="text" style="float: right; padding: 3px 0; margin-right: 5px;" @click="showMap">{{ $t('map.viewLayer') }}</el-button>
</div>
<el-tabs v-model="enabledTab" class="mapEdit" type="card">
<el-tab-pane :label="$t('map.link')" class="tab_pane_box" name="Link">
<link-draft
ref="Link"
:selected="selected"
@updateMapModel="updateMapModel"
@setCenter="setCenter"
/>
</el-tab-pane>
<el-tab-pane :label="$t('map.section')" class="tab_pane_box" name="Section">
<section-draft
ref="Section"
@ -175,7 +167,6 @@
</template>
<script>
import LinkDraft from './link';
import SectionDraft from './section';
import SwitchDraft from './switch';
import SignalDraft from './signal';
@ -201,7 +192,6 @@ export default {
name: 'MapOperate',
components: {
CounterDraft,
LinkDraft,
SectionDraft,
SwitchDraft,
SignalDraft,
@ -249,7 +239,7 @@ export default {
],
logicalLevelsSelect: [],
physicalLevelsSelect: [],
enabledTab: 'Link',
enabledTab: 'Section',
autoSaveTask: null,
show: {
mapEditShow: false,

View File

@ -1,551 +0,0 @@
<template>
<el-tabs v-model="activeName" class="card">
<el-tab-pane class="view-control" :label="$t('map.property')" name="first">
<div style="height: calc(100% - 46px);">
<el-scrollbar wrap-class="scrollbar-wrapper">
<config-list ref="dataform" :form="form" :form-model="editModel" :rules="rules" />
</el-scrollbar>
</div>
<div class="button_box">
<el-button-group class="map-draft-group">
<el-button type="primary" size="small" @click="edit">{{ $t('map.updateObj') }}</el-button>
<el-button type="danger" size="small" @click="deleteObj">{{ $t('map.deleteObj') }}</el-button>
</el-button-group>
</div>
</el-tab-pane>
<el-tab-pane class="view-control" :label="$t('map.newConstruction')" name="second">
<div style="height: calc(100% - 46px);">
<el-scrollbar wrap-class="scrollbar-wrapper">
<el-form ref="make" label-width="120px" :model="addModel" size="mini">
<el-form-item :label="$t('map.linkType')">
<el-radio-group v-model="LinkType">
<el-radio
v-for="item in LinkTypeList"
:key="item.value"
:label="item.value"
border
:disabled="item.disabled"
size="mini"
>{{ item.label }}</el-radio>
</el-radio-group>
</el-form-item>
<template v-if="isNew">
<config-data ref="make1" :form="formMake1" :form-model="addModel" :rules="makeRules1" />
</template>
<template v-if="isFd">
<config-data ref="make2" :form="formMake2" :form-model="addModel" :rules="makeRules2" />
</template>
<template v-if="isSd">
<config-data ref="make3" :form="formMake3" :form-model="addModel" :rules="makeRules3" />
</template>
</el-form>
</el-scrollbar>
</div>
<div class="button_box">
<el-button-group class="map-draft-group">
<el-button v-if="isNew" type="primary" size="small" @click="isNewCreate">{{ $t('map.create') }}</el-button>
<el-button v-if="isFd" type="primary" size="small" @click="isFdCreate">{{ $t('map.create') }}</el-button>
<el-button v-if="isSd" type="primary" size="small" @click="isSdCreate">{{ $t('map.create') }}</el-button>
</el-button-group>
</div>
</el-tab-pane>
</el-tabs>
</template>
<script>
import { mapGetters } from 'vuex';
import { getUID } from '@/jmap/utils/Uid';
import { getUName } from '@/jmap/utils/Uname';
import ConfigList from './config/list';
import ConfigData from './config/data';
import { deepAssign } from '@/utils/index';
export default {
name: 'LinkDraft',
components: {
ConfigList,
ConfigData
},
props: {
selected: {
type: Object,
default: function () {
return null;
}
}
},
data() {
return {
linkLists: [],
activeName: 'first',
LinkType: '0',
LinkTypeList: [],
LinkDriectTypeList: [],
editModel: {
code: '',
type: '',
name: '',
lengthFact: 0,
leftFdCode: '',
leftSdCode: '',
rightFdCode: '',
rightSdCode: '',
lp: {
x: 0,
y: 0
},
rp: {
x: 0,
y: 0
}
},
addModel: {
code: '',
type: '01',
direct: 'R',
x: 0,
y: 0,
lengthShow: 200,
lengthFact: 0,
lfd: '',
rfd: ''
},
skins: [],
makeRules1: {
x: [
{ required: true, message: this.$t('rules.linkXCoordinate'), trigger: 'blur' }
],
y: [
{ required: true, message: this.$t('rules.linkYCoordinate'), trigger: 'blur' }
],
lengthShow: [
{ required: true, message: this.$t('rules.linkEnterLength'), trigger: 'blur' }
],
lengthFact: [
{ required: true, message: this.$t('rules.linkEnterDisplayLength'), trigger: 'blur' }
]
},
makeRules2: {
code: [
{ required: true, message: this.$t('rules.linkSelectBase'), trigger: 'change' }
],
lengthShow: [
{ required: true, message: this.$t('rules.linkEnterLength'), trigger: 'blur' }
],
lengthFact: [
{ required: true, message: this.$t('rules.linkEnterDisplayLength'), trigger: 'blur' }
]
},
makeRules3: {
lfd: [
{ required: true, message: this.$t('rules.linkEnterLeft'), trigger: 'blur' }
],
rfd: [
{ required: true, message: this.$t('rules.linkEnterRight'), trigger: 'blur' }
],
lengthFact: [
{ required: true, message: this.$t('rules.linkEnterDisplayLength'), trigger: 'blur' }
]
}
};
},
computed: {
...mapGetters('map', [
'linkList'
]),
form() {
return {
labelWidth: '130px',
items: {
code: {
name: '',
item: []
},
draw: {
name: this.$t('map.drawData'),
item: [
{ prop: 'code', label: this.$t('map.linkCode'), type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: this.linkList, change: true, deviceChange: this.deviceChange },
{ prop: 'name', label: this.$t('map.linkName'), type: 'input' },
{ prop: 'lp', label: this.$t('map.linkLp'), type: 'coordinate', width: '119px', children: [
{ prop: 'lp.x', firstLevel: 'lp', secondLevel: 'x', label: 'x:', type: 'number', labelWidth: '25px', disabled: false },
{ prop: 'lp.y', firstLevel: 'lp', secondLevel: 'y', label: 'y:', type: 'number', labelWidth: '25px', disabled: false }
] },
{ prop: 'rp', label: this.$t('map.linkRp'), type: 'coordinate', width: '119px', children: [
{ prop: 'rp.x', firstLevel: 'rp', secondLevel: 'x', label: 'x:', type: 'number', labelWidth: '25px', disabled: false },
{ prop: 'rp.y', firstLevel: 'rp', secondLevel: 'y', label: 'y:', type: 'number', labelWidth: '25px', disabled: false }
] },
{ prop: 'leftFdCode', label: this.$t('map.linkLeftFdCode'), type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: this.linkLists },
{ prop: 'leftSdCode', label: this.$t('map.linkLeftSdCode'), type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: this.linkLists },
{ prop: 'rightFdCode', label: this.$t('map.linkRightFdCode'), type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: this.linkLists },
{ prop: 'rightSdCode', label: this.$t('map.linkRightSdCode'), type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: this.linkLists }
]
},
map: {
name: this.$t('map.mapData'),
item: [
{ prop: 'lengthFact', label: this.$t('map.linkActualLength'), type: 'number', min: 0, placeholder: this.$t('tip.meter') }
]
}
}
};
},
rules() {
return {
code: [
{ required: true, message: this.$t('rules.selectEquipment'), trigger: 'change' }
],
name: [
{ required: true, message: this.$t('rules.linkSelectName'), trigger: 'blur' }
],
'lp.x': [
{ required: true, message: this.$t('rules.linkSelectName'), trigger: 'blur' }
],
'lp.y': [
{ required: true, message: this.$t('rules.linkSelectName'), trigger: 'blur' }
],
'rp.x': [
{ required: true, message: this.$t('rules.linkSelectName'), trigger: 'blur' }
],
'rp.y': [
{ required: true, message: this.$t('rules.linkSelectName'), trigger: 'blur' }
],
lengthFact: [
{ required: true, message: this.$t('rules.linkSelectName'), trigger: 'blur' }
]
};
},
formMake1() {
return {
labelWidth: '120px',
items: [
{ prop: 'lengthShow', label: this.$t('rules.lengthShow'), type: 'number', min: 0, placeholder: 'px' },
{ prop: 'lengthFact', label: this.$t('rules.lengthFact'), type: 'number', min: 0, placeholder: this.$t('tip.meter') },
{ prop: 'x', label: this.$t('rules.pointX'), type: 'number', placeholder: 'px' },
{ prop: 'y', label: this.$t('rules.pointY'), type: 'number', placeholder: 'px' }
]
};
},
formMake2() {
return {
labelWidth: '120px',
items: [
{ prop: 'code', label: this.$t('rules.basisLink'), type: 'select', optionLabel: 'name', optionValue: 'code', options: this.linkList },
{ prop: 'direct', label: this.$t('rules.direct'), type: 'radio', border: true, radioList: this.LinkDriectTypeList },
{ prop: 'lengthShow', label: this.$t('rules.lengthShow'), type: 'number', min: 0, placeholder: 'px', isHidden: this.isSd },
{ prop: 'lengthFact', label: this.$t('rules.lengthFact'), type: 'number', min: 0, placeholder: this.$t('tip.meter') }
]
};
},
formMake3() {
return {
labelWidth: '120px',
items: [
{ prop: 'lfd', label: '左侧正向Link:', type: 'select', optionLabel: 'name', optionValue: 'code', options: this.linkList },
{ prop: 'rfd', label: '右侧正向Link:', type: 'select', optionLabel: 'name', optionValue: 'code', options: this.linkList },
{ prop: 'lengthShow', label: this.$t('rules.lengthShow'), type: 'number', min: 0, placeholder: 'px', isHidden: this.isSd },
{ prop: 'lengthFact', label: this.$t('rules.lengthFact'), type: 'number', min: 0, placeholder: this.$t('tip.meter') }
]
};
},
// link
isNew() {
return this.LinkType === '0';
},
// link
isFd() {
return this.LinkType === '1';
},
// link
isSd() {
return this.LinkType === '2';
}
},
watch: {
LinkType(val) {
this.addModel.type = val == '2' ? '02' : '01';
},
selected(val, oldVal) {
this.deviceSelect(val);
},
linkList(value) {
this.linkLists = JSON.parse(JSON.stringify(this.linkList));
this.linkLists.unshift({code: '', name: '无'});
}
},
mounted() {
this.LinkTypeList = this.$ConstSelect.LinkTypeList;
this.LinkDriectTypeList = this.$ConstSelect.LinkDriectTypeList;
},
methods: {
deviceChange(code) {
this.$emit('setCenter', code);
this.deviceSelect(this.$store.getters['map/getDeviceByCode'](code));
},
deviceSelect(selected) {
this.$nextTick(() => {
this.$refs.dataform.resetFields();
this.$refs.make.resetFields();
if (selected && selected._type.toUpperCase() === 'Link'.toUpperCase()) {
this.activeName = 'first';
this.editModel = deepAssign(this.editModel, selected); //
this.addModel.code = selected.code;
}
});
},
isNewCreate() {
this.$refs['make1'].validate((valid) => {
if (valid) {
var uid = getUID('Link');
var uname = getUName(this.linkList);
const edits = [];
if (this.isNew) {
// link
const x = this.addModel.x;
const y = this.addModel.y;
var model = {
_type: 'Link',
code: uid,
name: uname,
type: this.addModel.type,
lp: {
x: x,
y: y
},
rp: {
x: x + this.addModel.lengthShow,
y: y
},
lengthFact: this.addModel.lengthFact,
color: this.addModel.color ? this.addModel.color : '#4e8de6'
};
edits.push(model);
}
this.$emit('updateMapModel', edits);
}
});
},
isFdCreate() {
this.$refs['make2'].validate((valid) => {
if (valid) {
var uid = getUID('Link');
var uname = getUName(this.linkList);
const edits = [];
var baseLink = null;
if (this.addModel) {
baseLink = deepAssign({}, this.$store.getters['map/getDeviceByCode'](this.addModel.code));
}
var leftFdCode = '';
var rightFdCode = '';
if (this.isFd) {
let lp = {};
let rp = {};
if (baseLink && baseLink._type.toUpperCase() === 'Link'.toUpperCase()) {
if (this.addModel.direct === 'L') {
lp = {
x: baseLink.lp.x - this.addModel.lengthShow,
y: baseLink.lp.y
};
rp = {
x: baseLink.lp.x,
y: baseLink.lp.y
};
rightFdCode = baseLink.code;
baseLink.leftFdCode = uid;
edits.push(baseLink);
} else {
lp = {
x: baseLink.rp.x,
y: baseLink.rp.y
};
rp = {
x: baseLink.rp.x + this.addModel.lengthShow,
y: baseLink.rp.y
};
leftFdCode = baseLink.code;
baseLink.rightFdCode = uid;
edits.push(baseLink);
}
const model = {
_type: 'Link',
code: uid,
name: uname,
type: this.addModel.type,
lp: lp,
rp: rp,
lengthFact: this.addModel.lengthFact,
leftFdCode: leftFdCode,
rightFdCode: rightFdCode
};
edits.push(model);
}
}
this.$emit('updateMapModel', edits);
}
});
},
isSdCreate() {
this.$refs['make3'].validate((valid) => {
if (valid) {
var uid = getUID('Link');
var uname = getUName(this.linkList);
const edits = [];
if (this.isSd) {
var lnode = this.findLinkData(this.addModel.lfd);
var rnode = this.findLinkData(this.addModel.rfd);
if (lnode && rnode) {
const model = {
_type: 'Link',
code: uid,
name: uname,
type: this.addModel.type,
lp: {
x: lnode.rp.x,
y: lnode.rp.y
},
rp: {
x: rnode.lp.x,
y: rnode.lp.y
},
lengthFact: this.addModel.lengthFact,
color: this.addModel.color ? this.addModel.color : '#4e8de6',
leftFdCode: lnode.code,
rightFdCode: rnode.code
};
if (rnode.lp.y === lnode.rp.y) {
lnode.rightFdCode = uid;
rnode.leftFdCode = uid;
edits.push(lnode);
edits.push(rnode);
} else {
lnode.rightSdCode = uid;
rnode.leftSdCode = uid;
edits.push(lnode);
edits.push(rnode);
}
edits.push(model);
}
}
this.$emit('updateMapModel', edits);
}
});
},
//
edit() {
this.$refs['dataform'].validate((valid) => {
if (valid) {
const data = Object.assign({_type: 'Link'}, this.editModel);
this.$emit('updateMapModel', data);
}
});
},
updateRelatedModel(node, code) {
const data = Object.assign({ _type: 'Link' }, node);
if (node.leftFdCode == code) {
data.leftFdCode = '';
return data;
}
if (node.leftSdCode == code) {
data.leftSdCode = '';
return data;
}
if (node.rightFdCode == code) {
data.rightFdCode = '';
return data;
}
if (node.rightSdCode == code) {
data.rightSdCode = '';
return data;
}
return { _type: 'Link', code: node.code };
},
deleteObj() {
const selected = this.$store.getters['map/getDeviceByCode'](this.editModel.code);
if (selected && selected._type.toUpperCase() === 'Link'.toUpperCase()) {
let node = null;
var _that = this;
const updates = [];
// link
if (selected.leftFdCode) {
node = this.findLinkData(selected.leftFdCode);
node && updates.push(this.updateRelatedModel(node, selected.code));
}
if (selected.leftSdCode) {
node = this.findLinkData(selected.leftSdCode);
node && updates.push(this.updateRelatedModel(node, selected.code));
}
if (selected.rightFdCode) {
node = this.findLinkData(selected.rightFdCode);
node && updates.push(this.updateRelatedModel(node, selected.code));
}
if (selected.rightSdCode) {
node = this.findLinkData(selected.rightSdCode);
node && updates.push(this.updateRelatedModel(node, selected.code));
}
this.$confirm(this.$t('tip.confirmDeletion'), this.$t('tip.hint'), {
confirmButtonText: this.$t('tip.confirm'),
cancelButtonText: this.$t('tip.cancel'),
type: 'warning'
}).then(() => {
updates.push(deepAssign(selected, {_dispose: true}));
_that.$emit('updateMapModel', updates);
_that.deviceSelect();
}).catch(() => {
_that.$message.info(this.$t('tip.cancelledDelete'));
});
}
},
findLinkData(code) {
let link = null;
const linkList = this.linkList;
if (linkList && linkList.length) {
for (var i = 0; i < linkList.length; i++) {
if (code === linkList[i].code) {
link = JSON.parse(JSON.stringify(linkList[i]));
return link;
}
}
}
return link;
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/mixin.scss";
.view-control{
height: 100%;
}
.card {
height: 100%;
}
.coordinate {
overflow: hidden;
.title {
text-align: right;
font-size: 14px;
color: #606266;
line-height: 40px;
padding: 0 12px 0 0;
-webkit-box-sizing: border-box;
box-sizing: border-box;
line-height: 28px;
width: 120px;
font-weight: bold;
display: block;
float: left;
margin-right: 7px;
}
}
</style>

View File

@ -332,11 +332,13 @@ export default {
//
setOrderName(permission, good) {
if (good) {
this.formModel.goodsName = good.name;
this.formModel.price = good.price;
this.formModel.goodsId = good.id;
this.formModel = { //
goodsName: good.name,
price: good.price,
goodsId: good.id
};
this.permissionVo = permission; //
this.goodsVo = good;
this.goodsVo = good; //
}
},
buildModel() {
@ -363,11 +365,9 @@ export default {
this.$refs.dataform.validateForm(() => {
this.orderList = [];
this.goodsList.forEach(item => {
this.formModel.organizationId = this.buildModel();
// const param = deepAssign({}, this.formModel);
const param = {
goodItem: item.goodItem,
permissionType: item.permissionType
goodItem: item.goodItem, //
permissionType: item.permissionType //
};
this.orderList.push(param);
});
@ -380,10 +380,8 @@ export default {
return nor.permissionId;
});
const param = {
// createVO: {isPackage: false, relPermissions: arr},
// orderList: this.orderList,
// canDistribute: this.formModel.canDistribute == '01'
isPackage: false,
// formModel
organizationId: this.formModel.organizationId,
packageNum: this.formModel.amount,
amount: this.formModel.amount,
@ -397,8 +395,7 @@ export default {
bizType: this.formModel.bizType,
payWays: this.formModel.payWays,
forever: this.formModel.forever,
// mapId: this.goodsList[0].mapId,
// list
relPermissions: arr,
orderDetailList: this.orderList
};
@ -431,6 +428,7 @@ export default {
// orderList: [this.formModel],
// canDistribute: this.formModel.canDistribute == '01'
isPackage: true,
// formModel
organizationId: this.formModel.organizationId,
packageNum: this.formModel.amount,
startTime: this.formModel.startTime,
@ -443,16 +441,17 @@ export default {
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,
relPermissions: this.permissionVo.relPermissions,
// ids
relPermissions: this.permissionVo.relPermissions
mapId: this.permissionVo.mapId
// mapId: this.permissionVo.mapId
// prdCode: this.permissionVo.prdCode
};
createPermission(param).then(res => {

View File

@ -128,6 +128,9 @@ export default {
{value: '02', label: this.$t('orderAuthor.universalPackage')}
],
isGoods: false,
idPackage: false,
permissionPackageId: '',
permissionGoddsId: '',
mapList: [],
goodsList: [], //
createGoodList: [], //
@ -158,18 +161,7 @@ export default {
const arr = list.map(item => {
return item.id;
});
postFindPermission(arr).then(res => {
this.isGoods = false;
if (res.data && res.data.id) {
this.isGoods = true;
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;
}
});
this.postFindPermission(arr);
}
}
},
@ -192,22 +184,43 @@ export default {
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;
});
postFindPermission(arr).then(res => {
this.isGoods = false;
if (res.data && res.data.id) {
this.isGoods = true;
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;
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;
}
});
}
});
}
@ -263,15 +276,17 @@ export default {
},
addRuleForm(index, row) { //
row['isPut'] = true;
getGoodsByPermissionId(row.id).then(res => {
if (res.data && (res.data instanceof Object)) {
row.price = res.data.price;
if (this.addModel.type == '01') {
if (this.addModel.type == '01') {
getGoodsByPermissionId(row.id).then(res => {
if (res.data && (res.data instanceof Object)) {
row.price = res.data.price;
row.goods = res.data;
}
this.ruleList.push(row);
}
});
});
} else if (this.addModel.type == '02') {
this.ruleList.push(row);
}
},
dialogSelect(row) {
if (this.addModel.mapId) {
@ -293,97 +308,29 @@ export default {
};
return model;
},
buildGoodModel(item) {
return {
goodItem: {
name: item.name,
permissionId: item.id,
permissionName: item.goods.name,
id: item.goods.id
},
permissionType: item.type,
permissionId: item.id,
isPackage: item.isPackage,
name: item.goods.name,
price: item.goods.price,
remarks: item.goods.remarks
};
},
async permissionNext() {
if ((this.addModel.type === '01' && this.ruleList.length) || (this.addModel.type === '02' && this.ruleList.length > 1) ) {
const arr = this.ruleList.map(item => { return item.id; });
if (this.addModel.type == '01') {
const list = []; //
const goodsList = []; //
this.ruleList.forEach(nor => {
if (nor.payPrice) {
nor.price = nor.payPrice;
goodsList.push(this.buildModel(nor));
}
if (nor.price) {
nor.payPrice = '';
list.push(nor);
}
});
if (goodsList.length) {
try {
const response = await postsPermissionGoods({goodsVOList: goodsList});
this.goodsListNew = response.data;
} catch (error) { this.goodsList = []; }
}
if (list.length == this.ruleList.length) {
this.goodsList = [];
this.ruleList.forEach(item => {
this.goodsListNew.forEach(ele => {
if (item.id == ele.permissionId) {
item.goods = ele;
}
});
const param = {
goodItem: {
name: item.name,
permissionId: item.id,
permissionName: item.goods.name,
id: item.goods.id
},
permissionType: item.type,
// mapId: item.mapId,
permissionId: item.id,
isPackage: item.isPackage,
name: item.goods.name,
price: item.goods.price,
remarks: item.goods.remarks
};
item.goods && this.goodsList.push(param);
});
if (this.goodsList.length == this.ruleList.length) {
this.$emit('permissionNext', this.goodsList);
}
} else {
this.$messageBox('基础权限没有对应商品类型, 请填写商品价格会自动创建');
}
this.basicPermissionsNext();
} else if (this.addModel.type == '02') {
this.$refs.formData.validate((valid) => {
if (valid) { // 使
postFindPermission(arr).then(res => {
this.addModel['relPermissions'] = arr;
if (res.data) {
this.addModel['id'] = res.data.id;
}
if (this.isGoods) { //
const good = {
id: res.data.goodsId,
permissionId: res.data.id,
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 = {
name: this.addModel.name,
permissionId: '',
tryUse: this.addModel.forever,
tryUseTime: this.addModel.tryUseTime,
tryUseTimeUnit: this.addModel.tryUseTimeUnit,
price: this.addModel.price,
remarks: this.addModel.remarks,
list: this.ruleList
};
this.$emit('permissionNextOrder', this.addModel, good);
}
}).catch((error) => { console.log(error); });
}
});
this.allPermissionNext(arr);
}
} else if (this.addModel.type === '02') {
this.$messageBox(this.$t('tip.createUniversalPermissionsTip'));
@ -391,6 +338,93 @@ export default {
this.$messageBox(this.$t('tip.addPackage'));
}
},
async basicPermissionsNext() { //
const list = []; //
const goodsList = []; //
let flag = true; //
this.ruleList.forEach(nor => {
if (nor.payPrice) {
nor.price = nor.payPrice;
goodsList.push(this.buildModel(nor));
}
if (nor.price) {
nor.payPrice = '';
list.push(nor);
}
});
if (goodsList.length) {
try {
const response = await postsPermissionGoods(goodsList);
flag = false;
if (response.code == 200) {
this.goodsListNew = response.data;
flag = true;
}
} catch (error) { this.goodsList = []; flag = false; }
}
if (flag) {
if (list.length == this.ruleList.length) {
this.goodsList = [];
this.ruleList.forEach(item => {
this.goodsListNew.forEach(ele => {
if (item.id == ele.permissionId) {
item.goods = ele;
}
});
const param = this.buildGoodModel(item);
item.goods && this.goodsList.push(param);
});
if (this.goodsList.length == this.ruleList.length) {
this.$emit('permissionNext', this.goodsList);
}
} else {
this.$message('基础权限没有对应商品类型, 请填写商品价格会自动创建');
}
} else {
this.$message('商品创建失败!');
}
},
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); });
}
});
},
turnback() {
this.$router.go(-1);
}