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 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) { export function postFindPermission(ids) {
return request({ return request({
url: `/api/permission/findPermission`, url: `/api/goods/permissionIds?ids=${ids}`,
method: 'post', method: 'get'
data: {
relPermissions: ids
}
}); });
} }

View File

@ -875,7 +875,7 @@ export const asyncRouter = [
redirect: '/design/usermap/home', redirect: '/design/usermap/home',
component: Layout, component: Layout,
meta: { meta: {
roles: [admin, user] roles: [admin]
}, },
children: [ children: [
{ {
@ -897,16 +897,11 @@ export const asyncRouter = [
path: 'map/draw/:mapId/:view', path: 'map/draw/:mapId/:view',
component: NewMapDraft, component: NewMapDraft,
hidden: true hidden: true
},
{ // 运行图设计
path: 'runPlan/detail/:mapId',
component: PlanMonitorDetail,
hidden: true
} }
] ]
} }
] ]
}, }
]; ];
const createRouter = () => new Router({ 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> <el-button size="small" type="primary" class="eachButton" @click="createMap">{{ $t('map.newConstruction') }}</el-button>
</div> </div>
</div> </div>
<map-operate-menu
ref="menu"
:point="point"
:edit-model="editModel"
:line-code="lineCode"
@refresh="loadInitData"
@jlmap3d="jlmap3d"
/>
</div> </div>
</template> </template>
<script> <script>
@ -36,13 +28,9 @@ import { DeviceMenu } from '@/scripts/ConstDic';
import { postBuildMapImport, listMap } from '@/api/jmap/mapdraft'; import { postBuildMapImport, listMap } from '@/api/jmap/mapdraft';
import { UrlConfig } from '@/router/index'; import { UrlConfig } from '@/router/index';
import { removeSessionStorage } from '@/utils/auth'; import { removeSessionStorage } from '@/utils/auth';
import MapOperateMenu from './mapmanage/operateMenu';
export default { export default {
name: 'UserMapList', name: 'UserMapList',
components: {
MapOperateMenu
},
props: { props: {
width: { width: {
type: Number, type: Number,
@ -110,14 +98,6 @@ export default {
mapId: elem.id, mapId: elem.id,
mapName: elem.name, mapName: elem.name,
lineCode: elem.lineCode 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 } }); this.$router.push({ path: `${UrlConfig.newDesignuser.mapDraw}/${obj.mapId}/draft`, query: { name: obj.mapName } });
break; 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) { showContextMenu(e, obj, node, vueElem) {
if (obj && obj.type == 'map') { if (obj && obj.type == 'map') {
@ -159,9 +134,6 @@ export default {
this.$store.dispatch('menuOperation/setPopMenu', { position: this.point, menu: menu }); this.$store.dispatch('menuOperation/setPopMenu', { position: this.point, menu: menu });
} }
}, },
jlmap3d() {
this.$router.push({ path: '/design/jlmap3d/edit', query: { mapid: this.editModel.id } });
},
importf() { importf() {
const loading = this.$loading({ const loading = this.$loading({
lock: true, 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> <el-button type="text" style="float: right; padding: 3px 0; margin-right: 5px;" @click="showMap">{{ $t('map.viewLayer') }}</el-button>
</div> </div>
<el-tabs v-model="enabledTab" class="mapEdit" type="card"> <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"> <el-tab-pane :label="$t('map.section')" class="tab_pane_box" name="Section">
<section-draft <section-draft
ref="Section" ref="Section"
@ -175,7 +167,6 @@
</template> </template>
<script> <script>
import LinkDraft from './link';
import SectionDraft from './section'; import SectionDraft from './section';
import SwitchDraft from './switch'; import SwitchDraft from './switch';
import SignalDraft from './signal'; import SignalDraft from './signal';
@ -201,7 +192,6 @@ export default {
name: 'MapOperate', name: 'MapOperate',
components: { components: {
CounterDraft, CounterDraft,
LinkDraft,
SectionDraft, SectionDraft,
SwitchDraft, SwitchDraft,
SignalDraft, SignalDraft,
@ -249,7 +239,7 @@ export default {
], ],
logicalLevelsSelect: [], logicalLevelsSelect: [],
physicalLevelsSelect: [], physicalLevelsSelect: [],
enabledTab: 'Link', enabledTab: 'Section',
autoSaveTask: null, autoSaveTask: null,
show: { show: {
mapEditShow: false, 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) { setOrderName(permission, good) {
if (good) { if (good) {
this.formModel.goodsName = good.name; this.formModel = { //
this.formModel.price = good.price; goodsName: good.name,
this.formModel.goodsId = good.id; price: good.price,
goodsId: good.id
};
this.permissionVo = permission; // this.permissionVo = permission; //
this.goodsVo = good; this.goodsVo = good; //
} }
}, },
buildModel() { buildModel() {
@ -363,11 +365,9 @@ export default {
this.$refs.dataform.validateForm(() => { this.$refs.dataform.validateForm(() => {
this.orderList = []; this.orderList = [];
this.goodsList.forEach(item => { this.goodsList.forEach(item => {
this.formModel.organizationId = this.buildModel();
// const param = deepAssign({}, this.formModel);
const param = { const param = {
goodItem: item.goodItem, goodItem: item.goodItem, //
permissionType: item.permissionType permissionType: item.permissionType //
}; };
this.orderList.push(param); this.orderList.push(param);
}); });
@ -380,10 +380,8 @@ export default {
return nor.permissionId; return nor.permissionId;
}); });
const param = { const param = {
// createVO: {isPackage: false, relPermissions: arr},
// orderList: this.orderList,
// canDistribute: this.formModel.canDistribute == '01'
isPackage: false, isPackage: false,
// formModel
organizationId: this.formModel.organizationId, organizationId: this.formModel.organizationId,
packageNum: this.formModel.amount, packageNum: this.formModel.amount,
amount: this.formModel.amount, amount: this.formModel.amount,
@ -397,8 +395,7 @@ export default {
bizType: this.formModel.bizType, bizType: this.formModel.bizType,
payWays: this.formModel.payWays, payWays: this.formModel.payWays,
forever: this.formModel.forever, forever: this.formModel.forever,
// list
// mapId: this.goodsList[0].mapId,
relPermissions: arr, relPermissions: arr,
orderDetailList: this.orderList orderDetailList: this.orderList
}; };
@ -431,6 +428,7 @@ export default {
// orderList: [this.formModel], // orderList: [this.formModel],
// canDistribute: this.formModel.canDistribute == '01' // canDistribute: this.formModel.canDistribute == '01'
isPackage: true, isPackage: true,
// formModel
organizationId: this.formModel.organizationId, organizationId: this.formModel.organizationId,
packageNum: this.formModel.amount, packageNum: this.formModel.amount,
startTime: this.formModel.startTime, startTime: this.formModel.startTime,
@ -443,16 +441,17 @@ export default {
totalPrice: this.formModel.totalPrice, totalPrice: this.formModel.totalPrice,
contractNo: this.formModel.contractNo, contractNo: this.formModel.contractNo,
orderType: this.formModel.orderType, orderType: this.formModel.orderType,
// goodsVo
packageName: this.goodsVo.name, packageName: this.goodsVo.name,
remarks: this.goodsVo.remarks, remarks: this.goodsVo.remarks,
price: this.goodsVo.price, price: this.goodsVo.price,
tryUse: this.goodsVo.tryUse, tryUse: this.goodsVo.tryUse,
tryUseTime: this.goodsVo.tryUseTime, tryUseTime: this.goodsVo.tryUseTime,
tryUseTimeUnit: this.goodsVo.tryUseTimeUnit, 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 // prdCode: this.permissionVo.prdCode
}; };
createPermission(param).then(res => { createPermission(param).then(res => {

View File

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